Set the correct r_offset even when creating a R_*_NONE.
With this lld can use its own -r output when a fde is discarded. llvm-svn: 295143
This commit is contained in:
parent
4b58f577cd
commit
d50c8598fb
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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: ]
|
||||
|
||||
|
|
Loading…
Reference in New Issue