[PATCH] D84001: [ELF] Allow mixed SHF_LINK_ORDER & non-SHF_LINK_ORDER sections and sort within InputSectionDescription
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 17 04:15:15 PDT 2020
grimar added inline comments.
================
Comment at: lld/ELF/Writer.cpp:1609
+ InputSection *lb = b->flags & SHF_LINK_ORDER ? b->getLinkOrderDep() : nullptr;
// SHF_LINK_ORDER sections with non-zero sh_link are ordered before others.
if (!la || !lb)
----------------
This comment needs updating.
================
Comment at: lld/ELF/Writer.cpp:1659
}
}
----------------
Consider reordering to reduce nesting and to remove `clear()` calls:
```
// Link order may be distributed across several InputSectionDescriptions.
// Sorting is performed separately.
for (BaseCommand *base : sec->sectionCommands) {
auto *isd = dyn_cast<InputSectionDescription>(base);
if (!isd)
continue;
bool hasLinkOrder = false;
std::vector<InputSection **> scriptSections;
std::vector<InputSection *> sections;
for (InputSection *&isec : isd->sections) {
if (isec->flags & SHF_LINK_ORDER) {
InputSection *link = isec->getLinkOrderDep();
if (link && !link->getParent())
error(toString(isec) + ": sh_link points to discarded section " +
toString(link));
hasLinkOrder = true;
}
scriptSections.push_back(&isec);
sections.push_back(isec);
}
if (!hasLinkOrder || errorCount())
continue;
llvm::stable_sort(sections, compareByFilePosition);
for (int i = 0, n = sections.size(); i < n; ++i)
*scriptSections[i] = sections[i];
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84001/new/
https://reviews.llvm.org/D84001
More information about the llvm-commits
mailing list