[PATCH] D23011: [ELF] - Fix: do not ignore relocations addends when using lld -r
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 2 01:57:36 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277432: [ELF] - Fix: do not ignore relocations addends when using lld -r (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D23011?vs=66310&id=66441#toc
Repository:
rL LLVM
https://reviews.llvm.org/D23011
Files:
lld/trunk/ELF/InputSection.cpp
lld/trunk/test/ELF/relocatable-symbols.s
Index: lld/trunk/test/ELF/relocatable-symbols.s
===================================================================
--- lld/trunk/test/ELF/relocatable-symbols.s
+++ lld/trunk/test/ELF/relocatable-symbols.s
@@ -2,6 +2,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld -r %t -o %tout
# RUN: llvm-objdump -d %tout | FileCheck -check-prefix=DISASM %s
+# RUN: llvm-readobj -r %t | FileCheck -check-prefix=RELOC %s
# RUN: llvm-readobj -symbols -r %tout | FileCheck -check-prefix=SYMBOL %s
# DISASM: _start:
@@ -28,20 +29,37 @@
# DISASM-NEXT: 1: 90 nop
# DISASM-NEXT: 2: 90 nop
+# RELOC: Relocations [
+# RELOC-NEXT: Section ({{.*}}) .rela.text {
+# RELOC-NEXT: 0x1 R_X86_64_PC32 __start_foo 0xFFFFFFFFFFFFFFFC
+# RELOC-NEXT: 0x6 R_X86_64_PC32 __stop_foo 0xFFFFFFFFFFFFFFFC
+# RELOC-NEXT: 0xB R_X86_64_PC32 __start_bar 0xFFFFFFFFFFFFFFFC
+# RELOC-NEXT: 0x10 R_X86_64_PC32 __stop_bar 0xFFFFFFFFFFFFFFFC
+# RELOC-NEXT: 0x15 R_X86_64_PC32 __start_doo 0xFFFFFFFFFFFFFFFC
+# RELOC-NEXT: 0x1A R_X86_64_PC32 __stop_doo 0xFFFFFFFFFFFFFFFC
+# RELOC-NEXT: 0x1F R_X86_64_PC32 __preinit_array_start 0xFFFFFFFFFFFFFFFC
+# RELOC-NEXT: 0x24 R_X86_64_PC32 __preinit_array_end 0xFFFFFFFFFFFFFFFC
+# RELOC-NEXT: 0x29 R_X86_64_PC32 __init_array_start 0xFFFFFFFFFFFFFFFC
+# RELOC-NEXT: 0x2E R_X86_64_PC32 __init_array_end 0xFFFFFFFFFFFFFFFC
+# RELOC-NEXT: 0x33 R_X86_64_PC32 __fini_array_start 0xFFFFFFFFFFFFFFFC
+# RELOC-NEXT: 0x38 R_X86_64_PC32 __fini_array_end 0xFFFFFFFFFFFFFFFC
+# RELOC-NEXT: }
+# RELOC-NEXT: ]
+
# SYMBOL: Relocations [
# SYMBOL-NEXT: Section ({{.*}}) .rela.text {
-# SYMBOL-NEXT: 0x1 R_X86_64_PC32 __start_foo 0x0
-# SYMBOL-NEXT: 0x6 R_X86_64_PC32 __stop_foo 0x0
-# SYMBOL-NEXT: 0xB R_X86_64_PC32 __start_bar 0x0
-# SYMBOL-NEXT: 0x10 R_X86_64_PC32 __stop_bar 0x0
-# SYMBOL-NEXT: 0x15 R_X86_64_PC32 __start_doo 0x0
-# SYMBOL-NEXT: 0x1A R_X86_64_PC32 __stop_doo 0x0
-# SYMBOL-NEXT: 0x1F R_X86_64_PC32 __preinit_array_start 0x0
-# SYMBOL-NEXT: 0x24 R_X86_64_PC32 __preinit_array_end 0x0
-# SYMBOL-NEXT: 0x29 R_X86_64_PC32 __init_array_start 0x0
-# SYMBOL-NEXT: 0x2E R_X86_64_PC32 __init_array_end 0x0
-# SYMBOL-NEXT: 0x33 R_X86_64_PC32 __fini_array_start 0x0
-# SYMBOL-NEXT: 0x38 R_X86_64_PC32 __fini_array_end 0x0
+# SYMBOL-NEXT: 0x1 R_X86_64_PC32 __start_foo 0xFFFFFFFFFFFFFFFC
+# SYMBOL-NEXT: 0x6 R_X86_64_PC32 __stop_foo 0xFFFFFFFFFFFFFFFC
+# SYMBOL-NEXT: 0xB R_X86_64_PC32 __start_bar 0xFFFFFFFFFFFFFFFC
+# SYMBOL-NEXT: 0x10 R_X86_64_PC32 __stop_bar 0xFFFFFFFFFFFFFFFC
+# SYMBOL-NEXT: 0x15 R_X86_64_PC32 __start_doo 0xFFFFFFFFFFFFFFFC
+# SYMBOL-NEXT: 0x1A R_X86_64_PC32 __stop_doo 0xFFFFFFFFFFFFFFFC
+# SYMBOL-NEXT: 0x1F R_X86_64_PC32 __preinit_array_start 0xFFFFFFFFFFFFFFFC
+# SYMBOL-NEXT: 0x24 R_X86_64_PC32 __preinit_array_end 0xFFFFFFFFFFFFFFFC
+# SYMBOL-NEXT: 0x29 R_X86_64_PC32 __init_array_start 0xFFFFFFFFFFFFFFFC
+# SYMBOL-NEXT: 0x2E R_X86_64_PC32 __init_array_end 0xFFFFFFFFFFFFFFFC
+# SYMBOL-NEXT: 0x33 R_X86_64_PC32 __fini_array_start 0xFFFFFFFFFFFFFFFC
+# SYMBOL-NEXT: 0x38 R_X86_64_PC32 __fini_array_end 0xFFFFFFFFFFFFFFFC
# SYMBOL-NEXT: }
# SYMBOL-NEXT: ]
# SYMBOL: Symbol {
Index: lld/trunk/ELF/InputSection.cpp
===================================================================
--- lld/trunk/ELF/InputSection.cpp
+++ lld/trunk/ELF/InputSection.cpp
@@ -161,9 +161,11 @@
uint32_t Type = Rel.getType(Config->Mips64EL);
SymbolBody &Body = this->File->getRelocTargetSym(Rel);
- RelTy *P = reinterpret_cast<RelTy *>(Buf);
+ Elf_Rela *P = reinterpret_cast<Elf_Rela *>(Buf);
Buf += sizeof(RelTy);
+ if (Config->Rela)
+ P->r_addend = getAddend<ELFT>(Rel);
P->r_offset = RelocatedSection->getOffset(Rel.r_offset);
P->setSymbolAndType(Body.DynsymIndex, Type, Config->Mips64EL);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23011.66441.patch
Type: text/x-patch
Size: 3958 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160802/ffec7e45/attachment.bin>
More information about the llvm-commits
mailing list