[PATCH] D47952: ASan: Always call the version mismatch symbol before __asan_init

Filipe Cabecinhas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 8 10:00:45 PDT 2018


filcab created this revision.
filcab added reviewers: kcc, rnk.
Herald added a reviewer: javed.absar.

This enables us to handle different ASan versions with the same runtime.

Previous version bumps were due to the following reasons (check
asan_init_version.h):

Struct layout changes: v2, v4, v7
Function existence/arguments changes: v5, v6, v8
Miscellaneous additional data structures changes: v3

It is possible to support these kinds of changes *if* we know which
version we're dealing with.

Our plan is to internally ship a library with more than one
__asan_version_mismatch_check_v*, and have those functions setup
function pointers to deal appropriately with the structures added by the
compiler. We will not allow more than one version per executable run
(all modules), though, as that would add too much complexity for little
gain.


Repository:
  rL LLVM

https://reviews.llvm.org/D47952

Files:
  lib/Transforms/Utils/ModuleUtils.cpp
  test/DebugInfo/AArch64/asan-stack-vars.ll
  test/Instrumentation/AddressSanitizer/basic-myriad.ll
  test/Instrumentation/AddressSanitizer/basic.ll


Index: test/Instrumentation/AddressSanitizer/basic.ll
===================================================================
--- test/Instrumentation/AddressSanitizer/basic.ll
+++ test/Instrumentation/AddressSanitizer/basic.ll
@@ -223,6 +223,7 @@
 }
 
 ; CHECK: define internal void @asan.module_ctor()
+; CHECK: call void @__asan_version_mismatch_check_v
 ; CHECK: call void @__asan_init()
 
 ; PROF
Index: test/Instrumentation/AddressSanitizer/basic-myriad.ll
===================================================================
--- test/Instrumentation/AddressSanitizer/basic-myriad.ll
+++ test/Instrumentation/AddressSanitizer/basic-myriad.ll
@@ -81,4 +81,5 @@
 }
 
 ; CHECK: define internal void @asan.module_ctor()
+; CHECK: call void @__asan_version_mismatch_check_v
 ; CHECK: call void @__asan_init()
Index: test/DebugInfo/AArch64/asan-stack-vars.ll
===================================================================
--- test/DebugInfo/AArch64/asan-stack-vars.ll
+++ test/DebugInfo/AArch64/asan-stack-vars.ll
@@ -239,8 +239,8 @@
 declare i8* @objc_autoreleaseReturnValue(i8* returned)
 
 define internal void @asan.module_ctor() {
-  call void @__asan_init()
   call void @__asan_version_mismatch_check_v8()
+  call void @__asan_init()
   ret void
 }
 
Index: lib/Transforms/Utils/ModuleUtils.cpp
===================================================================
--- lib/Transforms/Utils/ModuleUtils.cpp
+++ lib/Transforms/Utils/ModuleUtils.cpp
@@ -163,14 +163,14 @@
       GlobalValue::InternalLinkage, CtorName, &M);
   BasicBlock *CtorBB = BasicBlock::Create(M.getContext(), "", Ctor);
   IRBuilder<> IRB(ReturnInst::Create(M.getContext(), CtorBB));
-  IRB.CreateCall(InitFunction, InitArgs);
   if (!VersionCheckName.empty()) {
     Function *VersionCheckFunction =
         checkSanitizerInterfaceFunction(M.getOrInsertFunction(
             VersionCheckName, FunctionType::get(IRB.getVoidTy(), {}, false),
             AttributeList()));
     IRB.CreateCall(VersionCheckFunction, {});
   }
+  IRB.CreateCall(InitFunction, InitArgs);
   return std::make_pair(Ctor, InitFunction);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47952.150533.patch
Type: text/x-patch
Size: 2097 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180608/9f3761da/attachment.bin>


More information about the llvm-commits mailing list