[PATCH] D118796: [lld-macho][nfc] Hoist out creation of Section in parseSections()
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 2 07:50:45 PST 2022
int3 created this revision.
int3 added a reviewer: lld-macho.
Herald added a project: lld-macho.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Simplifies the code slightly.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D118796
Files:
lld/MachO/InputFiles.cpp
Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -277,17 +277,16 @@
ArrayRef<uint8_t> data = {isZeroFill(sec.flags) ? nullptr
: buf + sec.offset,
static_cast<size_t>(sec.size)};
+ sections.push_back(sec.addr);
if (sec.align >= 32) {
error("alignment " + std::to_string(sec.align) + " of section " + name +
" is too large");
- sections.push_back(sec.addr);
continue;
}
uint32_t align = 1 << sec.align;
uint32_t flags = sec.flags;
auto splitRecords = [&](int recordSize) -> void {
- sections.push_back(sec.addr);
if (data.empty())
return;
Subsections &subsections = sections.back().subsections;
@@ -321,7 +320,6 @@
isec = make<WordLiteralInputSection>(segname, name, this, data, align,
flags);
}
- sections.push_back(sec.addr);
sections.back().subsections.push_back({0, isec});
} else if (auto recordSize = getRecordSize(segname, name)) {
splitRecords(*recordSize);
@@ -350,10 +348,9 @@
// ld64 does not appear to emit contents from sections within the __LLVM
// segment. Symbols within those sections point to bitcode metadata
// instead of actual symbols. Global symbols within those sections could
- // have the same name without causing duplicate symbol errors. Push an
- // empty entry to ensure indices line up for the remaining sections.
+ // have the same name without causing duplicate symbol errors. To avoid
+ // spurious duplicate symbol errors, we do not parse these sections.
// TODO: Evaluate whether the bitcode metadata is needed.
- sections.push_back(sec.addr);
} else {
auto *isec =
make<ConcatInputSection>(segname, name, this, data, align, flags);
@@ -361,12 +358,9 @@
isec->getSegName() == segment_names::dwarf) {
// Instead of emitting DWARF sections, we emit STABS symbols to the
// object files that contain them. We filter them out early to avoid
- // parsing their relocations unnecessarily. But we must still push an
- // empty entry to ensure the indices line up for the remaining sections.
- sections.push_back(sec.addr);
+ // parsing their relocations unnecessarily.
debugSections.push_back(isec);
} else {
- sections.push_back(sec.addr);
sections.back().subsections.push_back({0, isec});
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118796.405279.patch
Type: text/x-patch
Size: 2676 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220202/c2923f03/attachment.bin>
More information about the llvm-commits
mailing list