diff options
-rw-r--r-- | lld/ELF/InputSection.cpp | 13 | ||||
-rw-r--r-- | lld/test/ELF/relocatable-eh-frame.s | 6 |
2 files changed, 12 insertions, 7 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 7b273ac5c9f..742943e9125 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -236,6 +236,13 @@ void InputSection<ELFT>::copyRelocations(uint8_t *Buf, ArrayRef<RelTy> Rels) { if (Config->Rela) P->r_addend = getAddend<ELFT>(Rel); + // Output section VA is zero for -r, so r_offset is an offset within the + // section, but for --emit-relocs it is an virtual address. + P->r_offset = RelocatedSection->OutSec->Addr + + RelocatedSection->getOffset(Rel.r_offset); + P->setSymbolAndType(In<ELFT>::SymTab->getSymbolIndex(&Body), Type, + Config->Mips64EL); + if (Body.Type == STT_SECTION) { // We combine multiple section symbols into only one per // section. This means we have to update the addend. That is @@ -263,12 +270,6 @@ void InputSection<ELFT>::copyRelocations(uint8_t *Buf, ArrayRef<RelTy> Rels) { } } - // Output section VA is zero for -r, so r_offset is an offset within the - // section, but for --emit-relocs it is an virtual address. - P->r_offset = RelocatedSection->OutSec->Addr + - RelocatedSection->getOffset(Rel.r_offset); - P->setSymbolAndType(In<ELFT>::SymTab->getSymbolIndex(&Body), Type, - Config->Mips64EL); } } diff --git a/lld/test/ELF/relocatable-eh-frame.s b/lld/test/ELF/relocatable-eh-frame.s index 6a9c6c74cb4..c2e5ec63f86 100644 --- a/lld/test/ELF/relocatable-eh-frame.s +++ b/lld/test/ELF/relocatable-eh-frame.s @@ -2,11 +2,15 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o # RUN: ld.lld -r %t.o %t.o -o %t # RUN: llvm-readobj -r %t | FileCheck %s +# RUN: ld.lld %t -o %t.so -shared +# RUN: llvm-objdump -h %t.so | FileCheck --check-prefix=DSO %s + +# DSO: .eh_frame 00000030 # CHECK: Relocations [ # CHECK-NEXT: Section ({{.*}}) .rela.eh_frame { # CHECK-NEXT: 0x20 R_X86_64_PC32 .foo 0x0 -# CHECK-NEXT: 0x0 R_X86_64_NONE - 0x0 +# CHECK-NEXT: 0x50 R_X86_64_NONE - 0x0 # CHECK-NEXT: } # CHECK-NEXT: ] |