[lld] r183573 - Fix handling of files without a symbol table.

Rafael Espindola rafael.espindola at gmail.com
Fri Jun 7 14:08:20 PDT 2013


Author: rafael
Date: Fri Jun  7 16:08:19 2013
New Revision: 183573

URL: http://llvm.org/viewvc/llvm-project?rev=183573&view=rev
Log:
Fix handling of files without a symbol table.

This fixes a recent regression (r183338). Stripped elf files (like installed
crtn.o for example), are not required to have a symbol table. Handle that
correctly.

Added:
    lld/trunk/test/elf/Inputs/stripped-empty.x86_64
    lld/trunk/test/elf/stripped-empty.test
Modified:
    lld/trunk/lib/ReaderWriter/ELF/File.h

Modified: lld/trunk/lib/ReaderWriter/ELF/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/File.h?rev=183573&r1=183572&r2=183573&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/File.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/File.h Fri Jun  7 16:08:19 2013
@@ -279,7 +279,11 @@ public:
     llvm::object::symbol_iterator it(_objFile->begin_symbols());
     llvm::object::symbol_iterator ie(_objFile->end_symbols());
 
-    for (it.increment(EC); it != ie; it.increment(EC)) {
+    // Skip ELF's first dummy symbol if we have one.
+    if (it != ie)
+      it.increment(EC);
+
+    for (; it != ie; it.increment(EC)) {
       if (EC)
         return true;
 

Added: lld/trunk/test/elf/Inputs/stripped-empty.x86_64
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Inputs/stripped-empty.x86_64?rev=183573&view=auto
==============================================================================
Binary files lld/trunk/test/elf/Inputs/stripped-empty.x86_64 (added) and lld/trunk/test/elf/Inputs/stripped-empty.x86_64 Fri Jun  7 16:08:19 2013 differ

Added: lld/trunk/test/elf/stripped-empty.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/stripped-empty.test?rev=183573&view=auto
==============================================================================
--- lld/trunk/test/elf/stripped-empty.test (added)
+++ lld/trunk/test/elf/stripped-empty.test Fri Jun  7 16:08:19 2013
@@ -0,0 +1,3 @@
+RUN: lld -flavor gnu -shared -o test.so %p/Inputs/stripped-empty.x86_64
+
+test that we handle files without a symbol table.





More information about the llvm-commits mailing list