Fix a crash.
We would crash if a SHF_LINK_ORDER section pointed to a non InputSection section. Since those sections are not merged in order, SHF_LINK_ORDER is pretty meaningless and we can error on that case. llvm-svn: 304327
This commit is contained in:
parent
0064858b0e
commit
b47c6e5cbd
|
@ -181,9 +181,15 @@ uint64_t SectionBase::getOffset(const DefinedRegular &Sym) const {
|
|||
return getOffset(Sym.Value);
|
||||
}
|
||||
|
||||
InputSectionBase *InputSectionBase::getLinkOrderDep() const {
|
||||
if ((Flags & SHF_LINK_ORDER) && Link != 0)
|
||||
return File->getSections()[Link];
|
||||
InputSection *InputSectionBase::getLinkOrderDep() const {
|
||||
if ((Flags & SHF_LINK_ORDER) && Link != 0) {
|
||||
InputSectionBase *L = File->getSections()[Link];
|
||||
if (auto *IS = dyn_cast<InputSection>(L))
|
||||
return IS;
|
||||
error(
|
||||
"Merge and .eh_frame sections are not supported with SHF_LINK_ORDER " +
|
||||
toString(L));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ public:
|
|||
return getFile<ELFT>()->getObj();
|
||||
}
|
||||
|
||||
InputSectionBase *getLinkOrderDep() const;
|
||||
InputSection *getLinkOrderDep() const;
|
||||
|
||||
void uncompress();
|
||||
|
||||
|
|
|
@ -76,8 +76,8 @@ static bool compareByFilePosition(InputSection *A, InputSection *B) {
|
|||
if (A->kind() == InputSectionBase::Synthetic ||
|
||||
B->kind() == InputSectionBase::Synthetic)
|
||||
return false;
|
||||
auto *LA = cast<InputSection>(A->getLinkOrderDep());
|
||||
auto *LB = cast<InputSection>(B->getLinkOrderDep());
|
||||
InputSection *LA = A->getLinkOrderDep();
|
||||
InputSection *LB = B->getLinkOrderDep();
|
||||
OutputSection *AOut = LA->OutSec;
|
||||
OutputSection *BOut = LB->OutSec;
|
||||
if (AOut != BOut)
|
||||
|
|
|
@ -2200,7 +2200,7 @@ void ARMExidxSentinelSection::writeTo(uint8_t *Buf) {
|
|||
});
|
||||
auto L = cast<InputSectionDescription>(*ISD);
|
||||
InputSection *Highest = L->Sections[L->Sections.size() - 2];
|
||||
InputSection *LS = cast<InputSection>(Highest->getLinkOrderDep());
|
||||
InputSection *LS = Highest->getLinkOrderDep();
|
||||
uint64_t S = LS->OutSec->Addr + LS->getOffset(LS->getSize());
|
||||
uint64_t P = getVA();
|
||||
Target->relocateOne(Buf, R_ARM_PREL31, S - P);
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
# REQUIRES: x86
|
||||
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
||||
# RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s
|
||||
|
||||
# CHECK: error: Merge and .eh_frame sections are not supported with SHF_LINK_ORDER {{.*}}section-metadata-err.s.tmp.o:(.foo)
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
.quad .foo
|
||||
|
||||
.section .foo,"aM",@progbits,8
|
||||
.quad 0
|
||||
|
||||
.section bar,"ao",@progbits,.foo
|
Loading…
Reference in New Issue