mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-14 15:19:33 +00:00
ASan: Use createSanitizerCtor
to create ctor, and call __asan_init
Reviewers: kcc, samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8778 llvm-svn: 236777
This commit is contained in:
parent
3b3ecc12b2
commit
9c4083a84a
@ -1452,16 +1452,10 @@ bool AddressSanitizer::doInitialization(Module &M) {
|
||||
IntptrTy = Type::getIntNTy(*C, LongSize);
|
||||
TargetTriple = Triple(M.getTargetTriple());
|
||||
|
||||
AsanCtorFunction =
|
||||
Function::Create(FunctionType::get(Type::getVoidTy(*C), false),
|
||||
GlobalValue::InternalLinkage, kAsanModuleCtorName, &M);
|
||||
BasicBlock *AsanCtorBB = BasicBlock::Create(*C, "", AsanCtorFunction);
|
||||
// call __asan_init in the module ctor.
|
||||
IRBuilder<> IRB(ReturnInst::Create(*C, AsanCtorBB));
|
||||
AsanInitFunction = checkSanitizerInterfaceFunction(
|
||||
M.getOrInsertFunction(kAsanInitName, IRB.getVoidTy(), nullptr));
|
||||
AsanInitFunction->setLinkage(Function::ExternalLinkage);
|
||||
IRB.CreateCall(AsanInitFunction);
|
||||
std::tie(AsanCtorFunction, AsanInitFunction) =
|
||||
createSanitizerCtorAndInitFunctions(M, kAsanModuleCtorName, kAsanInitName,
|
||||
/*InitArgTypes=*/{},
|
||||
/*InitArgs=*/{});
|
||||
|
||||
Mapping = getShadowMapping(TargetTriple, LongSize);
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
; CHECK: @llvm.global_ctors = {{.*}}@asan.module_ctor
|
||||
|
||||
define i32 @test_load(i32* %a) sanitize_address {
|
||||
; CHECK-LABEL: @test_load
|
||||
@ -169,5 +170,8 @@ define void @memintr_test(i8* %a, i8* %b) nounwind uwtable sanitize_address {
|
||||
; CHECK: __asan_memcpy
|
||||
; CHECK: ret void
|
||||
|
||||
; CHECK: define internal void @asan.module_ctor()
|
||||
; CHECK: call void @__asan_init_v5()
|
||||
|
||||
; PROF
|
||||
; CHECK: ![[PROF]] = !{!"branch_weights", i32 1, i32 100000}
|
||||
|
Loading…
Reference in New Issue
Block a user