From a4b41dca31b67091d36cca0f538585e4dbabd0ca Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 4 Aug 2016 12:13:05 +0000 Subject: [PATCH] Remove redundant argument. But always set Script::X->OutputSections. llvm-svn: 277720 --- lld/ELF/LinkerScript.cpp | 16 ++++++---------- lld/ELF/LinkerScript.h | 11 +++++------ lld/ELF/Writer.cpp | 10 +++++----- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index d47b519..b69c02a 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -159,10 +159,7 @@ template struct SectionsSorter { template void LinkerScript::createSections( - std::vector *> *Out, OutputSectionFactory &Factory) { - OutputSections = Out; - for (auto &P : getSectionMap()) { StringRef OutputName = P.first; const InputSectionDescription *Cmd = P.second; @@ -181,7 +178,7 @@ void LinkerScript::createSections( SectionsSorter(Cmd->Sort)); for (InputSectionBase *S : Sections) - addSection(Factory, *Out, S, OutputName); + addSection(Factory, *OutputSections, S, OutputName); } // Add all other input sections, which are not listed in script. @@ -189,7 +186,7 @@ void LinkerScript::createSections( Symtab::X->getObjectFiles()) for (InputSectionBase *S : F->getSections()) if (!isDiscarded(S) && !S->OutSec) - addSection(Factory, *Out, S, getOutputSectionName(S)); + addSection(Factory, *OutputSections, S, getOutputSectionName(S)); // Remove from the output all the sections which did not meet // the optional constraints. @@ -224,9 +221,8 @@ template void LinkerScript::filter() { } } -template -void LinkerScript::assignAddresses( - ArrayRef *> Sections) { +template void LinkerScript::assignAddresses() { + ArrayRef *> Sections = *OutputSections; // Orphan sections are sections present in the input files which // are not explicitly placed into the output file by the linker script. // We place orphan sections at end of file. @@ -300,8 +296,8 @@ void LinkerScript::assignAddresses( } template -std::vector> -LinkerScript::createPhdrs(ArrayRef *> Sections) { +std::vector> LinkerScript::createPhdrs() { + ArrayRef *> Sections = *OutputSections; std::vector> Ret; for (const PhdrsCommand &Cmd : Opt.PhdrsCommands) { diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index dc61e90..642c7c7 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -137,20 +137,20 @@ template class LinkerScript { typedef typename ELFT::uint uintX_t; public: - void createSections(std::vector *> *Out, - OutputSectionFactory &Factory); + void createSections(OutputSectionFactory &Factory); - std::vector> - createPhdrs(ArrayRef *> S); + std::vector> createPhdrs(); ArrayRef getFiller(StringRef Name); bool shouldKeep(InputSectionBase *S); - void assignAddresses(ArrayRef *> S); + void assignAddresses(); int compareSections(StringRef A, StringRef B); void addScriptedSymbols(); bool hasPhdrsCommands(); uintX_t getOutputSectionSize(StringRef Name); + std::vector *> *OutputSections; + private: std::vector> getSectionMap(); @@ -167,7 +167,6 @@ private: std::vector getPhdrIndices(StringRef SectionName); size_t getPhdrIndex(StringRef PhdrName); - std::vector *> *OutputSections; uintX_t Dot; }; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 7dafdb7..dd28c68 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -233,8 +233,9 @@ template void Writer::run() { CommonInputSection Common(getCommonSymbols()); CommonInputSection::X = &Common; + Script::X->OutputSections = &OutputSections; if (ScriptConfig->HasContents) - Script::X->createSections(&OutputSections, Factory); + Script::X->createSections(Factory); else createSections(); @@ -245,12 +246,11 @@ template void Writer::run() { if (Config->Relocatable) { assignFileOffsets(); } else { - Phdrs = Script::X->hasPhdrsCommands() - ? Script::X->createPhdrs(OutputSections) - : createPhdrs(); + Phdrs = Script::X->hasPhdrsCommands() ? Script::X->createPhdrs() + : createPhdrs(); fixHeaders(); if (ScriptConfig->HasContents) { - Script::X->assignAddresses(OutputSections); + Script::X->assignAddresses(); } else { fixSectionAlignments(); assignAddresses(); -- 2.7.4