[lld] [MTE] [lld] Don't tag symbols in sections with implicit start/stop (PR #73531)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 5 21:44:07 PST 2023


================
@@ -999,6 +999,18 @@ addTaggedSymbolReferences(InputSectionBase &sec,
     // like functions or TLS symbols.
     if (sym.type != STT_OBJECT)
       continue;
+    // Global variables can be explicitly put into sections where the section
+    // name is a valid C identifier. In these cases, the linker will create
+    // implicit __start and __stop symbols for the section. Globals that are in
+    // these special sections often are done there intentionally so they can be
+    // iterated over by going from __start_<secname> -> __stop_<secname>. This
+    // doesn't work under MTE globals, because each GV would have its own unique
+    // tag. So, symbols that are destined for a special section with start/stop
+    // symbols should go untagged implicitly.
+    const Defined *defined_sym = dyn_cast<Defined>(&sym);
----------------
MaskRay wrote:

We don't use the `a_b` naming. You can just name it `d`: `const auto *d = dyn_cast<Defined>(&sym)`

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


More information about the llvm-commits mailing list