diff options
Diffstat (limited to 'lld/ELF/Writer.cpp')
-rw-r--r-- | lld/ELF/Writer.cpp | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 84e969dea78..63cd4b1334b 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -152,7 +152,7 @@ static void removeEmptyPTLoad(std::vector<PhdrEntry *> &phdrs) { }); } -static void copySectionsIntoPartitions() { +void elf::copySectionsIntoPartitions() { std::vector<InputSectionBase *> newSections; for (unsigned part = 2; part != partitions.size() + 1; ++part) { for (InputSectionBase *s : inputSections) { @@ -308,8 +308,7 @@ static OutputSection *findSection(StringRef name, unsigned partition = 1) { return nullptr; } -// Initialize Out members. -template <class ELFT> static void createSyntheticSections() { +template <class ELFT> void elf::createSyntheticSections() { // Initialize all pointers with NULL. This is needed because // you can call lld::elf::main more than once as a library. memset(&Out::first, 0, sizeof(Out)); @@ -535,24 +534,6 @@ template <class ELFT> static void createSyntheticSections() { // The main function of the writer. template <class ELFT> void Writer<ELFT>::run() { - // Make copies of any input sections that need to be copied into each - // partition. - copySectionsIntoPartitions(); - - // Create linker-synthesized sections such as .got or .plt. - // Such sections are of type input section. - createSyntheticSections<ELFT>(); - - // Some input sections that are used for exception handling need to be moved - // into synthetic sections. Do that now so that they aren't assigned to - // output sections in the usual way. - if (!config->relocatable) - combineEhSections(); - - // We want to process linker script commands. When SECTIONS command - // is given we let it create sections. - script->processSectionCommands(); - // Linker scripts controls how input sections are assigned to output sections. // Input sections that were not handled by scripts are called "orphans", and // they are assigned to output sections by the default rule. Process that. @@ -1737,8 +1718,14 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() { symtab->forEachSymbol( [](Symbol *s) { s->isPreemptible = computeIsPreemptible(*s); }); + // Change values of linker-script-defined symbols from placeholders (assigned + // by declareSymbols) to actual definitions. + script->processSymbolAssignments(); + // Scan relocations. This must be done after every symbol is declared so that - // we can correctly decide if a dynamic relocation is needed. + // we can correctly decide if a dynamic relocation is needed. This is called + // after processSymbolAssignments() because it needs to know whether a + // linker-script-defined symbol is absolute. if (!config->relocatable) { forEachRelSec(scanRelocations<ELFT>); reportUndefinedSymbols<ELFT>(); @@ -2735,6 +2722,11 @@ template <class ELFT> void Writer<ELFT>::writeBuildId() { part.buildId->writeBuildId(buildId); } +template void elf::createSyntheticSections<ELF32LE>(); +template void elf::createSyntheticSections<ELF32BE>(); +template void elf::createSyntheticSections<ELF64LE>(); +template void elf::createSyntheticSections<ELF64BE>(); + template void elf::writeResult<ELF32LE>(); template void elf::writeResult<ELF32BE>(); template void elf::writeResult<ELF64LE>(); |