[lld] r277432 - [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:49:57 PDT 2016
Author: grimar
Date: Tue Aug 2 03:49:57 2016
New Revision: 277432
URL: http://llvm.org/viewvc/llvm-project?rev=277432&view=rev
Log:
[ELF] - Fix: do not ignore relocations addends when using lld -r
Previously addends were ignored. This is PR28779.
Patch fixes the issue.
Differential revision: https://reviews.llvm.org/D23011
Modified:
lld/trunk/ELF/InputSection.cpp
lld/trunk/test/ELF/relocatable-symbols.s
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=277432&r1=277431&r2=277432&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue Aug 2 03:49:57 2016
@@ -161,9 +161,11 @@ void InputSection<ELFT>::copyRelocations
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);
}
Modified: lld/trunk/test/ELF/relocatable-symbols.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocatable-symbols.s?rev=277432&r1=277431&r2=277432&view=diff
==============================================================================
--- lld/trunk/test/ELF/relocatable-symbols.s (original)
+++ lld/trunk/test/ELF/relocatable-symbols.s Tue Aug 2 03:49:57 2016
@@ -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 {
More information about the llvm-commits
mailing list