[PATCH] D129492: Add missing sanitizer metadata plumbing from CFE.
Mitch Phillips via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 11 08:28:17 PDT 2022
hctim created this revision.
hctim added a reviewer: eugenis.
Herald added a project: All.
hctim requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
clang misses attaching sanitizer metadata for external globals.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D129492
Files:
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/memtag-globals.cpp
Index: clang/test/CodeGen/memtag-globals.cpp
===================================================================
--- clang/test/CodeGen/memtag-globals.cpp
+++ clang/test/CodeGen/memtag-globals.cpp
@@ -11,10 +11,12 @@
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 @@
// 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 @@
// IGNORELIST-NOT: sanitize_memtag
// IGNORELIST: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}}
// IGNORELIST-NOT: sanitize_memtag
+// IGNORELIST: @{{.*}}external_global{{.*}} =
+// IGNORELIST-NOT: sanitize_memtag
Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4286,6 +4286,9 @@
getCUDARuntime().handleVarRegistration(D, *GV);
}
+ if (D)
+ SanitizerMD->reportGlobal(GV, *D);
+
LangAS ExpectedAS =
D ? D->getType().getAddressSpace()
: (LangOpts.OpenCL ? LangAS::opencl_global : LangAS::Default);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129492.443652.patch
Type: text/x-patch
Size: 1589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220711/f6829e71/attachment.bin>
More information about the cfe-commits
mailing list