[lld] r244624 - Don't report a conflict between two local symbols.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 09:30:35 PDT 2015


Author: rafael
Date: Tue Aug 11 11:30:34 2015
New Revision: 244624

URL: http://llvm.org/viewvc/llvm-project?rev=244624&view=rev
Log:
Don't report a conflict between two local symbols.

Added:
    lld/trunk/test/elf2/Inputs/invalid-symtab-sh_info.elf
    lld/trunk/test/elf2/Inputs/local.s
    lld/trunk/test/elf2/local.s
Modified:
    lld/trunk/ELF/InputFiles.cpp
    lld/trunk/test/elf2/invalid-elf.test

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=244624&r1=244623&r2=244624&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Tue Aug 11 11:30:34 2015
@@ -59,8 +59,11 @@ template <class ELFT> void elf2::ObjectF
   StringRef StringTable = *StringTableOrErr;
 
   Elf_Sym_Range Syms = ELFObj->symbols(Symtab);
-  Syms = Elf_Sym_Range(Syms.begin() + 1, Syms.end());
   auto NumSymbols = std::distance(Syms.begin(), Syms.end());
+  uint32_t FirstNonLocal = Symtab->sh_info;
+  if (FirstNonLocal > NumSymbols)
+    error("Invalid sh_info in symbol table");
+  Syms = llvm::make_range(Syms.begin() + FirstNonLocal, Syms.end());
   SymbolBodies.reserve(NumSymbols);
   for (const Elf_Sym &Sym : Syms)
     SymbolBodies.push_back(createSymbolBody(StringTable, &Sym));

Added: lld/trunk/test/elf2/Inputs/invalid-symtab-sh_info.elf
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/Inputs/invalid-symtab-sh_info.elf?rev=244624&view=auto
==============================================================================
Binary files lld/trunk/test/elf2/Inputs/invalid-symtab-sh_info.elf (added) and lld/trunk/test/elf2/Inputs/invalid-symtab-sh_info.elf Tue Aug 11 11:30:34 2015 differ

Added: lld/trunk/test/elf2/Inputs/local.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/Inputs/local.s?rev=244624&view=auto
==============================================================================
--- lld/trunk/test/elf2/Inputs/local.s (added)
+++ lld/trunk/test/elf2/Inputs/local.s Tue Aug 11 11:30:34 2015
@@ -0,0 +1 @@
+local:

Modified: lld/trunk/test/elf2/invalid-elf.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/invalid-elf.test?rev=244624&r1=244623&r2=244624&view=diff
==============================================================================
--- lld/trunk/test/elf2/invalid-elf.test (original)
+++ lld/trunk/test/elf2/invalid-elf.test Tue Aug 11 11:30:34 2015
@@ -5,3 +5,7 @@ INVALID-DATA-ENC: Invalid data encoding
 RUN: not lld -flavor gnu2 %p/Inputs/invalid-file-class.elf -o %t2 2>&1 | \
 RUN:   FileCheck --check-prefix=INVALID-FILE-CLASS %s
 INVALID-FILE-CLASS: Invalid file class
+
+RUN: not lld -flavor gnu2 %p/Inputs/invalid-symtab-sh_info.elf -o %t2 2>&1 | \
+RUN:   FileCheck --check-prefix=INVALID-SYMTAB-SHINFO %s
+INVALID-SYMTAB-SHINFO: Invalid sh_info in symbol table

Added: lld/trunk/test/elf2/local.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/local.s?rev=244624&view=auto
==============================================================================
--- lld/trunk/test/elf2/local.s (added)
+++ lld/trunk/test/elf2/local.s Tue Aug 11 11:30:34 2015
@@ -0,0 +1,10 @@
+// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t
+// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/Inputs/local.s -o %t2
+// RUN: lld -flavor gnu2 %t %t2 -o %t3
+// REQUIRES: x86
+
+.globl _start
+_start:
+        nop
+
+local:




More information about the llvm-commits mailing list