mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-18 13:34:04 +00:00
[asan] Rename the ABI versioning symbol to '__asan_version_mismatch_check' instead of abusing '__asan_init'
We currently version `__asan_init` and when the ABI version doesn't match, the linker gives a `undefined reference to '__asan_init_v5'` message. From this, it might not be obvious that it's actually a version mismatch error. This patch makes the error message much clearer by changing the name of the undefined symbol to be `__asan_version_mismatch_check_xxx` (followed by the version string). We obviously don't want the initializer to be named like that, so it's a separate symbol that is used only for the purpose of version checking. Reviewed at http://reviews.llvm.org/D11004 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243003 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dedb07fcbe
commit
00a917ca7c
@ -15,6 +15,7 @@
|
||||
#define LLVM_TRANSFORMS_UTILS_MODULEUTILS_H
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <utility> // for std::pair
|
||||
|
||||
namespace llvm {
|
||||
@ -56,7 +57,8 @@ Function *checkSanitizerInterfaceFunction(Constant *FuncOrBitcast);
|
||||
/// respectively.
|
||||
std::pair<Function *, Function *> createSanitizerCtorAndInitFunctions(
|
||||
Module &M, StringRef CtorName, StringRef InitName,
|
||||
ArrayRef<Type *> InitArgTypes, ArrayRef<Value *> InitArgs);
|
||||
ArrayRef<Type *> InitArgTypes, ArrayRef<Value *> InitArgs,
|
||||
StringRef VersionCheckName = StringRef());
|
||||
} // End llvm namespace
|
||||
|
||||
#endif // LLVM_TRANSFORMS_UTILS_MODULEUTILS_H
|
||||
|
@ -91,7 +91,9 @@ static const char *const kAsanUnregisterGlobalsName =
|
||||
"__asan_unregister_globals";
|
||||
static const char *const kAsanPoisonGlobalsName = "__asan_before_dynamic_init";
|
||||
static const char *const kAsanUnpoisonGlobalsName = "__asan_after_dynamic_init";
|
||||
static const char *const kAsanInitName = "__asan_init_v5";
|
||||
static const char *const kAsanInitName = "__asan_init";
|
||||
static const char *const kAsanVersionCheckName =
|
||||
"__asan_version_mismatch_check_v6";
|
||||
static const char *const kAsanPtrCmp = "__sanitizer_ptr_cmp";
|
||||
static const char *const kAsanPtrSub = "__sanitizer_ptr_sub";
|
||||
static const char *const kAsanHandleNoReturnName = "__asan_handle_no_return";
|
||||
@ -1468,9 +1470,9 @@ bool AddressSanitizer::doInitialization(Module &M) {
|
||||
|
||||
if (!CompileKernel) {
|
||||
std::tie(AsanCtorFunction, AsanInitFunction) =
|
||||
createSanitizerCtorAndInitFunctions(M, kAsanModuleCtorName, kAsanInitName,
|
||||
/*InitArgTypes=*/{},
|
||||
/*InitArgs=*/{});
|
||||
createSanitizerCtorAndInitFunctions(
|
||||
M, kAsanModuleCtorName, kAsanInitName,
|
||||
/*InitArgTypes=*/{}, /*InitArgs=*/{}, kAsanVersionCheckName);
|
||||
appendToGlobalCtors(M, AsanCtorFunction, kAsanCtorAndDtorPriority);
|
||||
}
|
||||
Mapping = getShadowMapping(TargetTriple, LongSize, CompileKernel);
|
||||
|
@ -107,7 +107,8 @@ Function *llvm::checkSanitizerInterfaceFunction(Constant *FuncOrBitcast) {
|
||||
|
||||
std::pair<Function *, Function *> llvm::createSanitizerCtorAndInitFunctions(
|
||||
Module &M, StringRef CtorName, StringRef InitName,
|
||||
ArrayRef<Type *> InitArgTypes, ArrayRef<Value *> InitArgs) {
|
||||
ArrayRef<Type *> InitArgTypes, ArrayRef<Value *> InitArgs,
|
||||
StringRef VersionCheckName) {
|
||||
assert(!InitName.empty() && "Expected init function name");
|
||||
assert(InitArgTypes.size() == InitArgTypes.size() &&
|
||||
"Sanitizer's init function expects different number of arguments");
|
||||
@ -122,6 +123,13 @@ std::pair<Function *, Function *> llvm::createSanitizerCtorAndInitFunctions(
|
||||
AttributeSet()));
|
||||
InitFunction->setLinkage(Function::ExternalLinkage);
|
||||
IRB.CreateCall(InitFunction, InitArgs);
|
||||
if (!VersionCheckName.empty()) {
|
||||
Function *VersionCheckFunction =
|
||||
checkSanitizerInterfaceFunction(M.getOrInsertFunction(
|
||||
VersionCheckName, FunctionType::get(IRB.getVoidTy(), {}, false),
|
||||
AttributeSet()));
|
||||
IRB.CreateCall(VersionCheckFunction, {});
|
||||
}
|
||||
return std::make_pair(Ctor, InitFunction);
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ define void @memintr_test(i8* %a, i8* %b) nounwind uwtable sanitize_address {
|
||||
; CHECK: ret void
|
||||
|
||||
; CHECK: define internal void @asan.module_ctor()
|
||||
; CHECK: call void @__asan_init_v5()
|
||||
; CHECK: call void @__asan_init()
|
||||
|
||||
; PROF
|
||||
; CHECK: ![[PROF]] = !{!"branch_weights", i32 1, i32 100000}
|
||||
|
Loading…
x
Reference in New Issue
Block a user