forked from OSchip/llvm-project
Fix crash with -emit-relocs -shared.
The code to handle the input SHT_REL/SHT_RELA sections was getting confused with the linker generated relocation sections. llvm-svn: 295322
This commit is contained in:
parent
1540b06ef8
commit
82f00ec4a2
|
|
@ -119,10 +119,14 @@ template <class ELFT> void OutputSection<ELFT>::finalize() {
|
|||
if (!Config->copyRelocs() || (Type != SHT_RELA && Type != SHT_REL))
|
||||
return;
|
||||
|
||||
InputSection<ELFT> *First = Sections[0];
|
||||
if (isa<SyntheticSection<ELFT>>(First))
|
||||
return;
|
||||
|
||||
this->Link = In<ELFT>::SymTab->OutSec->SectionIndex;
|
||||
// sh_info for SHT_REL[A] sections should contain the section header index of
|
||||
// the section to which the relocation applies.
|
||||
InputSectionBase<ELFT> *S = Sections[0]->getRelocatedSection();
|
||||
InputSectionBase<ELFT> *S = First->getRelocatedSection();
|
||||
this->Info = S->OutSec->SectionIndex;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
||||
# RUN: ld.lld --emit-relocs %t.o -o %t.so -shared
|
||||
# RUN: llvm-readobj -r %t.so | FileCheck %s
|
||||
|
||||
.data
|
||||
.quad foo
|
||||
|
||||
# CHECK: Relocations [
|
||||
# CHECK-NEXT: Section (4) .rela.dyn {
|
||||
# CHECK-NEXT: 0x1000 R_X86_64_64 foo 0x0
|
||||
# CHECK-NEXT: }
|
||||
# CHECK-NEXT: Section (8) .rela.data {
|
||||
# CHECK-NEXT: 0x1000 R_X86_64_64 foo 0x0
|
||||
# CHECK-NEXT: }
|
||||
# CHECK-NEXT: ]
|
||||
Loading…
Reference in New Issue