diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-09-16 21:05:36 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-09-16 21:05:36 +0000 |
| commit | 7c3ff2eb584ff62a8d02ecde9dfd5bcda48d6498 (patch) | |
| tree | ffe66634ad99bea04c29fb2214c3d554d3fa6c7f /lld/ELF/LinkerScript.cpp | |
| parent | 14e9e8af359531bd5659a20f2f62a24e2c0645ca (diff) | |
| download | bcm5719-llvm-7c3ff2eb584ff62a8d02ecde9dfd5bcda48d6498.tar.gz bcm5719-llvm-7c3ff2eb584ff62a8d02ecde9dfd5bcda48d6498.zip | |
Only process commands in a ONLY_IF_RO if it matches.
This matches bfd behavior. It also makes future changes simpler as we
don't have to worry about ignoring these commands in multiple places
llvm-svn: 281775
Diffstat (limited to 'lld/ELF/LinkerScript.cpp')
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index ea38f0efef5..e6c60937161 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -208,24 +208,14 @@ LinkerScript<ELFT>::createInputSectionList(OutputSectionCommand &OutCmd) { std::vector<InputSectionBase<ELFT> *> Ret; for (const std::unique_ptr<BaseCommand> &Base : OutCmd.Commands) { - if (auto *OutCmd = dyn_cast<SymbolAssignment>(Base.get())) { - if (shouldDefine<ELFT>(OutCmd)) - addSymbol<ELFT>(OutCmd); + auto *Cmd = dyn_cast<InputSectionDescription>(Base.get()); + if (!Cmd) continue; - } - - auto *Cmd = cast<InputSectionDescription>(Base.get()); computeInputSections(Cmd); for (InputSectionData *S : Cmd->Sections) Ret.push_back(static_cast<InputSectionBase<ELFT> *>(S)); } - if (!matchConstraints<ELFT>(Ret, OutCmd.Constraint)) { - for (InputSectionBase<ELFT> *S : Ret) - S->OutSec = nullptr; - Ret.clear(); - } - return Ret; } @@ -275,7 +265,9 @@ void LinkerScript<ELFT>::addSection(OutputSectionFactory<ELFT> &Factory, template <class ELFT> void LinkerScript<ELFT>::processCommands(OutputSectionFactory<ELFT> &Factory) { - for (const std::unique_ptr<BaseCommand> &Base1 : Opt.Commands) { + for (unsigned I = 0; I < Opt.Commands.size(); ++I) { + auto Iter = Opt.Commands.begin() + I; + const std::unique_ptr<BaseCommand> &Base1 = *Iter; if (auto *Cmd = dyn_cast<SymbolAssignment>(Base1.get())) { if (shouldDefine<ELFT>(Cmd)) addRegular<ELFT>(Cmd); @@ -298,6 +290,18 @@ void LinkerScript<ELFT>::processCommands(OutputSectionFactory<ELFT> &Factory) { continue; } + if (!matchConstraints<ELFT>(V, Cmd->Constraint)) { + for (InputSectionBase<ELFT> *S : V) + S->OutSec = nullptr; + Opt.Commands.erase(Iter); + continue; + } + + for (const std::unique_ptr<BaseCommand> &Base : Cmd->Commands) + if (auto *OutCmd = dyn_cast<SymbolAssignment>(Base.get())) + if (shouldDefine<ELFT>(OutCmd)) + addSymbol<ELFT>(OutCmd); + if (V.empty()) continue; @@ -410,8 +414,7 @@ findSections(OutputSectionCommand &Cmd, const std::vector<OutputSectionBase<ELFT> *> &Sections) { std::vector<OutputSectionBase<ELFT> *> Ret; for (OutputSectionBase<ELFT> *Sec : Sections) - if (Sec->getName() == Cmd.Name && - checkConstraint(Sec->getFlags(), Cmd.Constraint)) + if (Sec->getName() == Cmd.Name) Ret.push_back(Sec); return Ret; } |

