Index: lld/trunk/ELF/Writer.cpp =================================================================== --- lld/trunk/ELF/Writer.cpp +++ lld/trunk/ELF/Writer.cpp @@ -880,24 +880,16 @@ template void Writer::forEachRelSec(std::function Fn) { - for (InputSectionBase *IS : InputSections) { - if (!IS->Live) - continue; - // Scan all relocations. Each relocation goes through a series - // of tests to determine if it needs special treatment, such as - // creating GOT, PLT, copy relocations, etc. - // Note that relocations for non-alloc sections are directly - // processed by InputSection::relocateNonAlloc. - if (!(IS->Flags & SHF_ALLOC)) - continue; - if (isa(IS) || isa(IS)) + // Scan all relocations. Each relocation goes through a series + // of tests to determine if it needs special treatment, such as + // creating GOT, PLT, copy relocations, etc. + // Note that relocations for non-alloc sections are directly + // processed by InputSection::relocateNonAlloc. + for (InputSectionBase *IS : InputSections) + if (IS->Live && isa(IS) && (IS->Flags & SHF_ALLOC)) Fn(*IS); - } - - if (!Config->Relocatable) { - for (EhInputSection *ES : In::EhFrame->Sections) - Fn(*ES); - } + for (EhInputSection *ES : In::EhFrame->Sections) + Fn(*ES); } template void Writer::createSections() { @@ -1280,7 +1272,8 @@ // Scan relocations. This must be done after every symbol is declared so that // we can correctly decide if a dynamic relocation is needed. - forEachRelSec(scanRelocations); + if (!Config->Relocatable) + forEachRelSec(scanRelocations); if (InX::Plt && !InX::Plt->empty()) InX::Plt->addSymbols();