summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-06-07 21:08:19 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-06-07 21:08:19 +0000
commita0af48fc93f9b2dfcbad78d59b87b9b2edab00da (patch)
tree7e901b9476668cc82bbcfcc26992b23b1a88cb71
parent999dacc55b96643a9942c5e69d63381ff569ca33 (diff)
downloadbcm5719-llvm-a0af48fc93f9b2dfcbad78d59b87b9b2edab00da.tar.gz
bcm5719-llvm-a0af48fc93f9b2dfcbad78d59b87b9b2edab00da.zip
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. llvm-svn: 183573
-rw-r--r--lld/lib/ReaderWriter/ELF/File.h6
-rw-r--r--lld/test/elf/Inputs/stripped-empty.x86_64bin0 -> 416 bytes
-rw-r--r--lld/test/elf/stripped-empty.test3
3 files changed, 8 insertions, 1 deletions
diff --git a/lld/lib/ReaderWriter/ELF/File.h b/lld/lib/ReaderWriter/ELF/File.h
index 720e67eb129..c732bef18a9 100644
--- a/lld/lib/ReaderWriter/ELF/File.h
+++ b/lld/lib/ReaderWriter/ELF/File.h
@@ -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;
diff --git a/lld/test/elf/Inputs/stripped-empty.x86_64 b/lld/test/elf/Inputs/stripped-empty.x86_64
new file mode 100644
index 00000000000..7368ba280d7
--- /dev/null
+++ b/lld/test/elf/Inputs/stripped-empty.x86_64
Binary files differ
diff --git a/lld/test/elf/stripped-empty.test b/lld/test/elf/stripped-empty.test
new file mode 100644
index 00000000000..1794161291c
--- /dev/null
+++ b/lld/test/elf/stripped-empty.test
@@ -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.
OpenPOWER on IntegriCloud