[llvm] [hwasan] Add hwasan-all-globals option (PR #149621)

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 18 22:03:16 PDT 2025


================
@@ -1780,11 +1790,21 @@ void HWAddressSanitizer::instrumentGlobals() {
     if (GV.hasCommonLinkage())
       continue;
 
-    // Globals with custom sections may be used in __start_/__stop_ enumeration,
-    // which would be broken both by adding tags and potentially by the extra
-    // padding/alignment that we insert.
-    if (GV.hasSection())
-      continue;
+    if (ClAllGlobals) {
+      // Avoid adding metadata emitted for the hwasan instrumentation itself.
+      // Code which makes assumptions about memory layout of globals between
+      // __start_<section>/__end_<section> linker-generated symbols may need
+      // manual adaptation.
+      auto section = GV.getSection();
----------------
fmayer wrote:

nit: LLVM style is `Section`.

https://github.com/llvm/llvm-project/pull/149621


More information about the llvm-commits mailing list