[PATCH] D25553: [ELF] - Check that .dynsym is present in DSO if SHT_GNU_versym section is.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 14 03:58:57 PDT 2016


grimar updated this revision to Diff 74654.
grimar added a comment.

- Changed testcase to use yaml2obj.
- Restored check removed by mistake.


https://reviews.llvm.org/D25553

Files:
  ELF/InputFiles.cpp
  ELF/SymbolTable.cpp
  test/ELF/invalid/verdef-no-symtab.test


Index: test/ELF/invalid/verdef-no-symtab.test
===================================================================
--- test/ELF/invalid/verdef-no-symtab.test
+++ test/ELF/invalid/verdef-no-symtab.test
@@ -0,0 +1,26 @@
+# RUN: yaml2obj %s -o %t
+# RUN: not ld.lld %t -o %tout 2>&1 | FileCheck %s
+
+## When we have SHT_GNU_versym section, it is should be associated
+## with symbol table section.
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_DYN
+  Machine:         EM_X86_64
+Sections:
+  - Name:            .versym
+    Type:            SHT_GNU_versym
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:    0x1
+    Content:         "00000000"
+
+  - Name:            .verdef
+    Type:            SHT_GNU_verdef
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:    0x1
+    Content:         "00000000"
+
+
+# CHECK: SHT_GNU_versym should be associated with symbol table
Index: ELF/SymbolTable.cpp
===================================================================
--- ELF/SymbolTable.cpp
+++ ELF/SymbolTable.cpp
@@ -76,7 +76,7 @@
   if (auto *F = dyn_cast<SharedFile<ELFT>>(File)) {
     // DSOs are uniquified not by filename but by soname.
     F->parseSoName();
-    if (!SoNames.insert(F->getSoName()).second)
+    if (HasError || !SoNames.insert(F->getSoName()).second)
       return;
     SharedFiles.push_back(F);
     F->parseRest();
Index: ELF/InputFiles.cpp
===================================================================
--- ELF/InputFiles.cpp
+++ ELF/InputFiles.cpp
@@ -536,6 +536,9 @@
     }
   }
 
+  if (this->VersymSec && !this->Symtab)
+    error("SHT_GNU_versym should be associated with symbol table");
+
   this->initStringTable();
 
   // DSOs are identified by soname, and they usually contain


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25553.74654.patch
Type: text/x-patch
Size: 1824 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161014/f8707d6a/attachment.bin>


More information about the llvm-commits mailing list