Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
lld/ELF/MarkLive.cpp
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | static void forEachSuccessor(InputSection<ELFT> &Sec, | ||||
std::function<void(ResolvedReloc<ELFT>)> Fn) { | std::function<void(ResolvedReloc<ELFT>)> Fn) { | ||||
if (Sec.AreRelocsRela) { | if (Sec.AreRelocsRela) { | ||||
for (const typename ELFT::Rela &Rel : Sec.relas()) | for (const typename ELFT::Rela &Rel : Sec.relas()) | ||||
Fn(resolveReloc(Sec, Rel)); | Fn(resolveReloc(Sec, Rel)); | ||||
} else { | } else { | ||||
for (const typename ELFT::Rel &Rel : Sec.rels()) | for (const typename ELFT::Rel &Rel : Sec.rels()) | ||||
Fn(resolveReloc(Sec, Rel)); | Fn(resolveReloc(Sec, Rel)); | ||||
} | } | ||||
if (Sec.DependentSection) | for (InputSectionBase<ELFT> *D : Sec.DependentSections) | ||||
Fn({Sec.DependentSection, 0}); | Fn({D, 0}); | ||||
} | } | ||||
// The .eh_frame section is an unfortunate special case. | // The .eh_frame section is an unfortunate special case. | ||||
// The section is divided in CIEs and FDEs and the relocations it can have are | // The section is divided in CIEs and FDEs and the relocations it can have are | ||||
// * CIEs can refer to a personality function. | // * CIEs can refer to a personality function. | ||||
// * FDEs can refer to a LSDA | // * FDEs can refer to a LSDA | ||||
// * FDEs refer to the function they contain information about | // * FDEs refer to the function they contain information about | ||||
// The last kind of relocation cannot keep the referred section alive, or they | // The last kind of relocation cannot keep the referred section alive, or they | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | template <class ELFT> void elf::markLive() { | ||||
// file can interrupt other ELF file's symbols at runtime. | // file can interrupt other ELF file's symbols at runtime. | ||||
for (const Symbol *S : Symtab<ELFT>::X->getSymbols()) | for (const Symbol *S : Symtab<ELFT>::X->getSymbols()) | ||||
if (S->includeInDynsym()) | if (S->includeInDynsym()) | ||||
MarkSymbol(S->body()); | MarkSymbol(S->body()); | ||||
// Preserve special sections and those which are specified in linker | // Preserve special sections and those which are specified in linker | ||||
// script KEEP command. | // script KEEP command. | ||||
for (InputSectionBase<ELFT> *Sec : Symtab<ELFT>::X->Sections) { | for (InputSectionBase<ELFT> *Sec : Symtab<ELFT>::X->Sections) { | ||||
if (Sec->Flags & SHF_LINK_ORDER) { | |||||
forEachSuccessor<ELFT>( | |||||
cast<InputSection<ELFT>>(*Sec), [=](ResolvedReloc<ELFT> R) { | |||||
cast<InputSection<ELFT>>(R.Sec)->DependentSections.push_back(Sec); | |||||
eugenis: This does not have to be an InputSection.
I see it crashing on .rodata.str1.1 which is a… | |||||
}); | |||||
continue; | |||||
} | |||||
ruiuUnsubmitted Not Done ReplyInline ActionsWhy do you need this code? It seems you initializes DependentSections in InputFiles. ruiu: Why do you need this code? It seems you initializes DependentSections in InputFiles. | |||||
// .eh_frame is always marked as live now, but also it can reference to | // .eh_frame is always marked as live now, but also it can reference to | ||||
// sections that contain personality. We preserve all non-text sections | // sections that contain personality. We preserve all non-text sections | ||||
// referred by .eh_frame here. | // referred by .eh_frame here. | ||||
if (auto *EH = dyn_cast_or_null<EhInputSection<ELFT>>(Sec)) | if (auto *EH = dyn_cast_or_null<EhInputSection<ELFT>>(Sec)) | ||||
scanEhFrameSection<ELFT>(*EH, Enqueue); | scanEhFrameSection<ELFT>(*EH, Enqueue); | ||||
if (isReserved(Sec) || Script<ELFT>::X->shouldKeep(Sec)) | if (isReserved(Sec) || Script<ELFT>::X->shouldKeep(Sec)) | ||||
Enqueue({Sec, 0}); | Enqueue({Sec, 0}); | ||||
} | } | ||||
// Mark all reachable sections. | // Mark all reachable sections. | ||||
while (!Q.empty()) | while (!Q.empty()) { | ||||
forEachSuccessor<ELFT>(*Q.pop_back_val(), Enqueue); | InputSection<ELFT> &Sec = *Q.pop_back_val(); | ||||
forEachSuccessor<ELFT>(Sec, Enqueue); | |||||
} | |||||
} | } | ||||
template void elf::markLive<ELF32LE>(); | template void elf::markLive<ELF32LE>(); | ||||
template void elf::markLive<ELF32BE>(); | template void elf::markLive<ELF32BE>(); | ||||
template void elf::markLive<ELF64LE>(); | template void elf::markLive<ELF64LE>(); | ||||
template void elf::markLive<ELF64BE>(); | template void elf::markLive<ELF64BE>(); |
This does not have to be an InputSection.
I see it crashing on .rodata.str1.1 which is a MergeInputSection.