[ELF] Fix crash when .eh_frame(_hdr) is discarded
lld crashes when .eh_frame or .eh_frame_hdr section is discarded in linker script and there is no PHDRS directive. Differential revision: https://reviews.llvm.org/D30885 llvm-svn: 297712
This commit is contained in:
parent
2968547997
commit
30c1b436ad
|
@ -1355,7 +1355,8 @@ template <class ELFT> std::vector<PhdrEntry> Writer<ELFT>::createPhdrs() {
|
|||
Ret.push_back(std::move(RelRo));
|
||||
|
||||
// PT_GNU_EH_FRAME is a special section pointing on .eh_frame_hdr.
|
||||
if (!In<ELFT>::EhFrame->empty() && In<ELFT>::EhFrameHdr)
|
||||
if (!In<ELFT>::EhFrame->empty() && In<ELFT>::EhFrameHdr &&
|
||||
In<ELFT>::EhFrame->OutSec && In<ELFT>::EhFrameHdr->OutSec)
|
||||
AddHdr(PT_GNU_EH_FRAME, In<ELFT>::EhFrameHdr->OutSec->getPhdrFlags())
|
||||
->add(In<ELFT>::EhFrameHdr->OutSec);
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
||||
# RUN: echo "SECTIONS { /DISCARD/ : { *(.eh_frame*) *(.eh_frame_hdr*) } }" > %t.script
|
||||
# RUN: ld.lld -o %t1 --eh-frame-hdr --script %t.script %t
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
nop
|
||||
|
||||
.section .dah,"ax",@progbits
|
||||
.cfi_startproc
|
||||
nop
|
||||
.cfi_endproc
|
Loading…
Reference in New Issue