[PATCH] D101698: [ELF] Don't suggest alternative spelling of an empty nameFix PR50111

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 3 09:05:14 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGf9c8ebdc30c2: [ELF] Don't suggest alternative spelling of an empty name (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101698/new/

https://reviews.llvm.org/D101698

Files:
  lld/ELF/Relocations.cpp
  lld/test/ELF/undef-not-suggest.test


Index: lld/test/ELF/undef-not-suggest.test
===================================================================
--- lld/test/ELF/undef-not-suggest.test
+++ lld/test/ELF/undef-not-suggest.test
@@ -52,3 +52,31 @@
     Section: .text.foo
   - Name:    for
     Section: .data
+
+## Check we don't suggest an empty name symbol (e.g. STT_SECTION).
+
+# RUN: yaml2obj --docnum=2 %s -o %t2.o
+# RUN: not ld.lld %t2.o -o /dev/null 2>&1 | FileCheck %s
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name:  .text
+    Type:  SHT_PROGBITS
+    Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+  - Name: .rela.text
+    Type:  SHT_RELA
+    Info: .text
+    Relocations:
+      - Type:   R_X86_64_64
+        Symbol: f
+Symbols:
+  - Name:    ""
+    Type:    STT_SECTION
+    Section: .text
+  - Name:    f
+    Binding: STB_GLOBAL
Index: lld/ELF/Relocations.cpp
===================================================================
--- lld/ELF/Relocations.cpp
+++ lld/ELF/Relocations.cpp
@@ -763,7 +763,7 @@
 
     // Build a map of local defined symbols.
     for (const Symbol *s : sym.file->getSymbols())
-      if (s->isLocal() && s->isDefined())
+      if (s->isLocal() && s->isDefined() && !s->getName().empty())
         map.try_emplace(s->getName(), s);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101698.342414.patch
Type: text/x-patch
Size: 1326 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210503/34504ef7/attachment.bin>


More information about the llvm-commits mailing list