From: Rafael Espindola Date: Fri, 26 May 2017 17:28:17 +0000 (+0000) Subject: Avoid using EhFrameHdr->Sections. X-Git-Tag: llvmorg-5.0.0-rc1~4159 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=881cc1643a707b06951c7424b4caacd9e3ecab66;p=platform%2Fupstream%2Fllvm.git Avoid using EhFrameHdr->Sections. This is a necessary step for moving clearOutputSections earlier. llvm-svn: 304009 --- diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index eae5337..7e0b0f1 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1785,7 +1785,9 @@ template void Writer::writeSections() { } OutputSection *EhFrameHdr = - In::EhFrameHdr ? In::EhFrameHdr->OutSec : nullptr; + (In::EhFrameHdr && !In::EhFrameHdr->empty()) + ? In::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 void Writer::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(Buf + EhFrameHdr->Offset); }