[PATCH] D106766: [lld/mac] Move output segment rename logic into OutputSegment
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 25 07:12:46 PDT 2021
thakis created this revision.
thakis added a reviewer: lld-macho.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
thakis requested review of this revision.
No behavior change. The motivation is that segment$start$ can
create section-less segments, and this makes a corner case in
the interaction between segment$start and -rename_segment
in the upcoming segment$start patch.
https://reviews.llvm.org/D106766
Files:
lld/MachO/ConcatOutputSection.cpp
lld/MachO/OutputSegment.cpp
Index: lld/MachO/OutputSegment.cpp
===================================================================
--- lld/MachO/OutputSegment.cpp
+++ lld/MachO/OutputSegment.cpp
@@ -153,7 +153,16 @@
static DenseMap<StringRef, OutputSegment *> nameToOutputSegment;
std::vector<OutputSegment *> macho::outputSegments;
+static StringRef maybeRenameSegment(StringRef name) {
+ auto newName = config->segmentRenameMap.find(name);
+ if (newName != config->segmentRenameMap.end())
+ return newName->second;
+ return name;
+}
+
OutputSegment *macho::getOrCreateOutputSegment(StringRef name) {
+ name = maybeRenameSegment(name);
+
OutputSegment *&segRef = nameToOutputSegment[name];
if (segRef)
return segRef;
Index: lld/MachO/ConcatOutputSection.cpp
===================================================================
--- lld/MachO/ConcatOutputSection.cpp
+++ lld/MachO/ConcatOutputSection.cpp
@@ -339,7 +339,7 @@
void ConcatOutputSection::finalizeFlags(InputSection *input) {
switch (sectionType(input->getFlags())) {
default /*type-unspec'ed*/:
- // FIXME: Add additional logics here when supporting emitting obj files.
+ // FIXME: Add additional logic here when supporting emitting obj files.
break;
case S_4BYTE_LITERALS:
case S_8BYTE_LITERALS:
@@ -373,8 +373,5 @@
auto newNames = config->sectionRenameMap.find(key);
if (newNames != config->sectionRenameMap.end())
return newNames->second;
- auto newName = config->segmentRenameMap.find(key.first);
- if (newName != config->segmentRenameMap.end())
- return std::make_pair(newName->second, key.second);
return key;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106766.361500.patch
Type: text/x-patch
Size: 1618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210725/b53be3c3/attachment.bin>
More information about the llvm-commits
mailing list