[PATCH] D13564: [ELF2] Make sure symbol-less relocations make it to the target's handler
hfinkel@anl.gov via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 8 10:13:26 PDT 2015
hfinkel created this revision.
hfinkel added reviewers: ruiu, rafael.
hfinkel added a subscriber: llvm-commits.
hfinkel added a project: lld.
Some relocations don't actually require a symbol. For example, PPC64 as a TOC relocation (R_PPC64_TOC) which just bases its value on the location of the TOC base, and so there does not seem to be any corresponding symbol. Make sure the target's handler can see such relocations.
http://reviews.llvm.org/D13564
Files:
ELF/InputSection.cpp
test/elf2/basic64be.s
Index: test/elf2/basic64be.s
===================================================================
--- test/elf2/basic64be.s
+++ test/elf2/basic64be.s
@@ -109,7 +109,10 @@
# CHECK-NEXT: AddressAlignment: 1
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: SectionData (
-# CHECK-NEXT: 0000: 00000000 10010000 00000000 00000000 |................|
+# FIXME: The TOC pointer here is not calculated correctly because this input
+# has no .got section (it has no .toc or .tocbss either, so we should use the
+# .plt address to form the TOC base value).
+# CHECK-NEXT: 0000: 00000000 10010000 FFFFFFFF FFFF8000 |................|
# CHECK-NEXT: 0010: 00000000 00000000 |........|
# CHECK-NEXT: )
# CHECK-NEXT: }
Index: ELF/InputSection.cpp
===================================================================
--- ELF/InputSection.cpp
+++ ELF/InputSection.cpp
@@ -43,9 +43,14 @@
const Elf_Shdr *SymTab = File.getSymbolTable();
if (SymIndex < SymTab->sh_info) {
const Elf_Sym *Sym = File.getObj().getRelocationSymbol(&RI, SymTab);
- if (!Sym)
- continue;
- SymVA = getLocalSymVA(Sym, File);
+ if (!Sym) {
+ // Some targets have special relocations that don't correspond to
+ // particular symbols (for example, R_PPC64_TOC). SymVA is unused for
+ // these.
+ SymVA = 0;
+ } else {
+ SymVA = getLocalSymVA(Sym, File);
+ }
} else {
SymbolBody &Body = *File.getSymbolBody(SymIndex);
SymVA = getSymVA<ELFT>(Body);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13564.36872.patch
Type: text/x-patch
Size: 1552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151008/f2232426/attachment-0001.bin>
More information about the llvm-commits
mailing list