[lld] r293177 - Fix -r when the input has a relocation with no symbol.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 26 06:09:19 PST 2017
Author: rafael
Date: Thu Jan 26 08:09:18 2017
New Revision: 293177
URL: http://llvm.org/viewvc/llvm-project?rev=293177&view=rev
Log:
Fix -r when the input has a relocation with no symbol.
Should fix a few freebsd packages with dtrace.
Added:
lld/trunk/test/ELF/Inputs/dtrace-r.o
lld/trunk/test/ELF/dtrace-r.test
Modified:
lld/trunk/ELF/SyntheticSections.cpp
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=293177&r1=293176&r2=293177&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Thu Jan 26 08:09:18 2017
@@ -1122,6 +1122,8 @@ template <class ELFT>
size_t SymbolTableSection<ELFT>::getSymbolIndex(SymbolBody *Body) {
auto I = llvm::find_if(
Symbols, [&](const SymbolTableEntry &E) { return E.Symbol == Body; });
+ if (I == Symbols.end())
+ return 0;
return I - Symbols.begin() + 1;
}
Added: lld/trunk/test/ELF/Inputs/dtrace-r.o
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/dtrace-r.o?rev=293177&view=auto
==============================================================================
Binary files lld/trunk/test/ELF/Inputs/dtrace-r.o (added) and lld/trunk/test/ELF/Inputs/dtrace-r.o Thu Jan 26 08:09:18 2017 differ
Added: lld/trunk/test/ELF/dtrace-r.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/dtrace-r.test?rev=293177&view=auto
==============================================================================
--- lld/trunk/test/ELF/dtrace-r.test (added)
+++ lld/trunk/test/ELF/dtrace-r.test Thu Jan 26 08:09:18 2017
@@ -0,0 +1,8 @@
+RUN: ld.lld -r -o %t.o %p/Inputs/dtrace-r.o
+RUN: llvm-readobj -r %t.o | FileCheck %s
+
+CHECK: Relocations [
+CHECK-NEXT: Section ({{.*}}) .rela.text {
+CHECK-NEXT: 0x0 R_X86_64_NONE - 0x0
+CHECK-NEXT: }
+CHECK-NEXT: ]
More information about the llvm-commits
mailing list