[PATCH] D22962: [ELF] - Linkerscript cleanup of LinkerScript<ELFT>::createSections()
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 29 08:07:02 PDT 2016
grimar updated this revision to Diff 66122.
https://reviews.llvm.org/D22962
Files:
ELF/LinkerScript.cpp
ELF/LinkerScript.h
Index: ELF/LinkerScript.h
===================================================================
--- ELF/LinkerScript.h
+++ ELF/LinkerScript.h
@@ -141,7 +141,7 @@
bool hasPhdrsCommands();
private:
- std::vector<std::pair<StringRef, const InputSectionDescription *>>
+ std::vector<std::pair<StringRef, std::vector<InputSectionDescription *>>>
getSectionMap();
std::vector<InputSectionBase<ELFT> *>
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -74,21 +74,19 @@
return false;
}
-// Create a vector of (<output section name>, <input section name patterns>).
-// For example, if a returned vector contains (".text" (".foo.*" ".bar.*")),
-// input sections start with ".foo." or ".bar." should be added to
-// ".text" section.
+// Create a vector of (<name>, list of <InputSectionDescription *>).
template <class ELFT>
-std::vector<std::pair<StringRef, const InputSectionDescription *>>
+std::vector<std::pair<StringRef, std::vector<InputSectionDescription *>>>
LinkerScript<ELFT>::getSectionMap() {
- std::vector<std::pair<StringRef, const InputSectionDescription *>> Ret;
-
+ std::vector<std::pair<StringRef, std::vector<InputSectionDescription *>>> Ret;
for (const std::unique_ptr<BaseCommand> &Base1 : Opt.Commands)
- if (auto *Cmd1 = dyn_cast<OutputSectionCommand>(Base1.get()))
- for (const std::unique_ptr<BaseCommand> &Base2 : Cmd1->Commands)
- if (auto *Cmd2 = dyn_cast<InputSectionDescription>(Base2.get()))
- Ret.emplace_back(Cmd1->Name, Cmd2);
-
+ if (auto *Cmd1 = dyn_cast<OutputSectionCommand>(Base1.get())) {
+ std::vector<InputSectionDescription *> Commands;
+ for (const std::unique_ptr<BaseCommand> &Cmd : Cmd1->Commands)
+ if (auto *InCmd = dyn_cast<InputSectionDescription>(Cmd.get()))
+ Commands.push_back(InCmd);
+ Ret.emplace_back(Cmd1->Name, std::move(Commands));
+ }
return Ret;
}
@@ -138,14 +136,15 @@
for (auto &P : getSectionMap()) {
StringRef OutputName = P.first;
- const InputSectionDescription *I = P.second;
- for (InputSectionBase<ELFT> *S : getInputSections(I)) {
- if (OutputName == "/DISCARD/") {
- S->Live = false;
- reportDiscarded(S);
- continue;
+ for (InputSectionDescription *InCmd : P.second) {
+ for (InputSectionBase<ELFT> *S : getInputSections(InCmd)) {
+ if (OutputName == "/DISCARD/") {
+ S->Live = false;
+ reportDiscarded(S);
+ continue;
+ }
+ Add(S, OutputName);
}
- Add(S, OutputName);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22962.66122.patch
Type: text/x-patch
Size: 2715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160729/ea21e31d/attachment.bin>
More information about the llvm-commits
mailing list