Fix address sanitizer to work on MachO targets (e.g. MacOS).

This commit is contained in:
Christoffer Lerno
2025-02-28 00:11:51 +01:00
committed by Christoffer Lerno
parent 2b90500c22
commit 61c67c8f23
9 changed files with 20 additions and 5 deletions

View File

@@ -78,6 +78,7 @@ LLVMValueRef LLVMConstBswap(LLVMValueRef ConstantVal);
void LLVMBuilderSetFastMathFlags(LLVMBuilderRef Builder, FastMathOption option);
void LLVMSetDSOLocal(LLVMValueRef Global, bool value);
void LLVMSetTargetMachineUseInitArray(LLVMTargetMachineRef ref, bool use_init_array);
void LLVMSetNoSanitizeAddress(LLVMValueRef Global);
#ifdef __cplusplus
}

View File

@@ -318,6 +318,13 @@ void LLVMSetDSOLocal(LLVMValueRef Global, bool value)
llvm::unwrap<llvm::GlobalValue>(Global)->setDSOLocal(value);
}
void LLVMSetNoSanitizeAddress(LLVMValueRef Global)
{
auto global = llvm::unwrap<llvm::GlobalValue>(Global);
auto data = global->getSanitizerMetadata();
data.NoAddress = 1;
global->setSanitizerMetadata(data);
}
void LLVMBuilderSetFastMathFlags(LLVMBuilderRef Builder, FastMathOption option)
{
llvm::FastMathFlags math_flags {};