aboutsummaryrefslogtreecommitdiff
path: root/lld/ELF/SyntheticSections.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2022-01-30 13:34:27 -0800
committerFangrui Song <i@maskray.me>2022-01-30 13:34:27 -0800
commit73fd7d23046c1415b6be1bbe11c806edf3244837 (patch)
treee66b35aa6275a9daeb0d5bdd6676dafdf3bb87f3 /lld/ELF/SyntheticSections.cpp
parent744be8c5028d6190421f8879e07c8e57fd8bba9b (diff)
downloadllvm-73fd7d23046c1415b6be1bbe11c806edf3244837.zip
llvm-73fd7d23046c1415b6be1bbe11c806edf3244837.tar.gz
llvm-73fd7d23046c1415b6be1bbe11c806edf3244837.tar.bz2
[ELF] Change splitSections to objectFiles based parallelForEach. NFC
The work is more balanced.
Diffstat (limited to 'lld/ELF/SyntheticSections.cpp')
-rw-r--r--lld/ELF/SyntheticSections.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 1bcf9d1..8c0c3ab 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -83,8 +83,10 @@ static ArrayRef<uint8_t> getVersion() {
// by "readelf --string-dump .comment <file>".
// The returned object is a mergeable string section.
MergeInputSection *elf::createCommentSection() {
- return make<MergeInputSection>(SHF_MERGE | SHF_STRINGS, SHT_PROGBITS, 1,
- getVersion(), ".comment");
+ auto *sec = make<MergeInputSection>(SHF_MERGE | SHF_STRINGS, SHT_PROGBITS, 1,
+ getVersion(), ".comment");
+ sec->splitIntoPieces();
+ return sec;
}
// .MIPS.abiflags section.
@@ -3328,11 +3330,15 @@ template <class ELFT> void elf::splitSections() {
llvm::TimeTraceScope timeScope("Split sections");
// splitIntoPieces needs to be called on each MergeInputSection
// before calling finalizeContents().
- parallelForEach(inputSections, [](InputSectionBase *sec) {
- if (auto *s = dyn_cast<MergeInputSection>(sec))
- s->splitIntoPieces();
- else if (auto *eh = dyn_cast<EhInputSection>(sec))
- eh->split<ELFT>();
+ parallelForEach(objectFiles, [](ELFFileBase *file) {
+ for (InputSectionBase *sec : file->getSections()) {
+ if (!sec)
+ continue;
+ if (auto *s = dyn_cast<MergeInputSection>(sec))
+ s->splitIntoPieces();
+ else if (auto *eh = dyn_cast<EhInputSection>(sec))
+ eh->split<ELFT>();
+ }
});
}