Avoid using EhFrameHdr->Sections.

This is a necessary step for moving clearOutputSections earlier.

llvm-svn: 304009
This commit is contained in:
Rafael Espindola 2017-05-26 17:28:17 +00:00
parent d23e9267a6
commit 881cc1643a
1 changed files with 4 additions and 2 deletions

View File

@ -1785,7 +1785,9 @@ template <class ELFT> void Writer<ELFT>::writeSections() {
}
OutputSection *EhFrameHdr =
In<ELFT>::EhFrameHdr ? In<ELFT>::EhFrameHdr->OutSec : nullptr;
(In<ELFT>::EhFrameHdr && !In<ELFT>::EhFrameHdr->empty())
? In<ELFT>::EhFrameHdr->OutSec
: nullptr;
// In -r or -emit-relocs mode, write the relocation sections first as in
// ELf_Rel targets we might find out that we need to modify the relocated
@ -1811,7 +1813,7 @@ template <class ELFT> void Writer<ELFT>::writeSections() {
// The .eh_frame_hdr depends on .eh_frame section contents, therefore
// it should be written after .eh_frame is written.
if (EhFrameHdr && !EhFrameHdr->Sections.empty()) {
if (EhFrameHdr) {
OutputSectionCommand *Cmd = Script->getCmd(EhFrameHdr);
Cmd->writeTo<ELFT>(Buf + EhFrameHdr->Offset);
}