[lld] [llvm] [MC] Rename temporary symbols of empty name to ".L0" (PR #89693)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 23 10:36:32 PDT 2024


================
@@ -725,7 +725,13 @@ void ELFWriter::computeSymbolTable(
         HasLargeSectionIndex = true;
     }
 
+    // Temporary symbols generated for certain assembler features (.eh_frame,
+    // .debug_line) of an empty name may be referenced by relocations due to
+    // linker relaxation. Rename them to ".L0" to match the gas fake label name
+    // and allow ld/objcopy --discard-locals to discard such symbols.
     StringRef Name = Symbol.getName();
+    if (Name.empty())
+      Name = ".L0";
----------------
MaskRay wrote:

Thanks for pointing this out. I invoked `readelf -x .strtab a.o` but did not read the output carefully to notice the space.
Switched to `.L0 `

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


More information about the llvm-commits mailing list