forked from OSchip/llvm-project
Add missing sanitizer metadata plumbing from CFE.
clang misses attaching sanitizer metadata for external globals. Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D129492
This commit is contained in:
parent
90e5a8ac47
commit
7045519359
|
@ -4293,6 +4293,9 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty,
|
|||
getCUDARuntime().handleVarRegistration(D, *GV);
|
||||
}
|
||||
|
||||
if (D)
|
||||
SanitizerMD->reportGlobal(GV, *D);
|
||||
|
||||
LangAS ExpectedAS =
|
||||
D ? D->getType().getAddressSpace()
|
||||
: (LangOpts.OpenCL ? LangAS::opencl_global : LangAS::Default);
|
||||
|
|
|
@ -12,6 +12,7 @@ int dyn_init_global = global;
|
|||
int __attribute__((no_sanitize("address"))) attributed_global;
|
||||
int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global;
|
||||
int ignorelisted_global;
|
||||
extern int __attribute__((no_sanitize("address"))) external_global;
|
||||
|
||||
int __attribute__((section("__DATA, __common"))) sectioned_global; // KASAN - ignore globals in a section
|
||||
extern "C" {
|
||||
|
@ -21,6 +22,7 @@ int __special_global; // KASAN - ignore globals with __-prefix
|
|||
void func() {
|
||||
static int static_var = 0;
|
||||
const char *literal = "Hello, world!";
|
||||
external_global = 1;
|
||||
}
|
||||
|
||||
// GLOBS: @{{.*}}extra_global{{.*}} ={{.*}} global
|
||||
|
@ -49,6 +51,8 @@ void func() {
|
|||
// GLOBS: @{{.*}} = {{.*}}c"Hello, world!\00"
|
||||
// GLOBS-NOT: no_sanitize_address
|
||||
|
||||
// GLOBS: @{{.*}}external_global{{.*}} ={{.*}} no_sanitize_address
|
||||
|
||||
/// Without -fasynchronous-unwind-tables, ctor and dtor get the uwtable attribute.
|
||||
// CHECK-LABEL: define internal void @asan.module_ctor() #[[#ATTR:]] {
|
||||
// ASAN-NEXT: call void @__asan_init
|
||||
|
@ -83,3 +87,4 @@ void func() {
|
|||
// IGNORELIST-SRC: @{{.*}}__special_global{{.*}} ={{.*}} global {{.*}} no_sanitize_address
|
||||
// IGNORELIST-SRC: @{{.*}}static_var{{.*}} ={{.*}} global {{.*}} no_sanitize_address
|
||||
// IGNORELIST-SRC: @{{.*}} ={{.*}} c"Hello, world!\00"{{.*}} no_sanitize_address
|
||||
// IGNORELIST-SRC: @{{.*}}external_global{{.*}} ={{.*}} no_sanitize_address
|
||||
|
|
|
@ -14,15 +14,18 @@ int global;
|
|||
int __attribute__((no_sanitize("hwaddress"))) attributed_global;
|
||||
int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global;
|
||||
int ignorelisted_global;
|
||||
extern int __attribute__((no_sanitize("hwaddress"))) external_global;
|
||||
|
||||
void func() {
|
||||
static int static_var = 0;
|
||||
const char *literal = "Hello, world!";
|
||||
external_global = 1;
|
||||
}
|
||||
|
||||
// CHECK: @{{.*}}attributed_global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
|
||||
// CHECK: @{{.*}}disable_instrumentation_global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
|
||||
// CHECK: @{{.*}}ignorelisted_global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
|
||||
// CHECK: @{{.*}}external_global{{.*}} ={{.*}}, no_sanitize_hwaddress
|
||||
// CHECK: @{{.*}}extra_global{{.*}}.hwasan{{.*}} =
|
||||
// CHECK: @{{.*}}global{{.*}}.hwasan{{.*}} =
|
||||
// CHECK: @{{.*}}static_var{{.*}}.hwasan{{.*}} =
|
||||
|
@ -34,4 +37,5 @@ void func() {
|
|||
// IGNORELIST: @{{.*}}ignorelisted_globa{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
|
||||
// IGNORELIST: @{{.*}}static_var{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
|
||||
// IGNORELIST: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}}, no_sanitize_hwaddress
|
||||
// IGNORELIST: @{{.*}}external_global{{.*}} ={{.*}}, no_sanitize_hwaddress
|
||||
// IGNORELIST: @{{.*}}extra_global{{.*}}.hwasan{{.*}} =
|
||||
|
|
|
@ -11,10 +11,12 @@ int global;
|
|||
int __attribute__((no_sanitize("memtag"))) attributed_global;
|
||||
int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global;
|
||||
int ignorelisted_global;
|
||||
extern int external_global;
|
||||
|
||||
void func() {
|
||||
static int static_var = 0;
|
||||
const char *literal = "Hello, world!";
|
||||
external_global = 1;
|
||||
}
|
||||
|
||||
// CHECK: @{{.*}}extra_global{{.*}} ={{.*}} sanitize_memtag
|
||||
|
@ -29,6 +31,7 @@ void func() {
|
|||
|
||||
// CHECK: @{{.*}}static_var{{.*}} ={{.*}} sanitize_memtag
|
||||
// CHECK: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}} sanitize_memtag
|
||||
// CHECK: @{{.*}}external_global{{.*}} ={{.*}} sanitize_memtag
|
||||
|
||||
// IGNORELIST: @{{.*}}extra_global{{.*}} ={{.*}} sanitize_memtag
|
||||
|
||||
|
@ -44,3 +47,5 @@ void func() {
|
|||
// IGNORELIST-NOT: sanitize_memtag
|
||||
// IGNORELIST: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}}
|
||||
// IGNORELIST-NOT: sanitize_memtag
|
||||
// IGNORELIST: @{{.*}}external_global{{.*}} =
|
||||
// IGNORELIST-NOT: sanitize_memtag
|
||||
|
|
Loading…
Reference in New Issue