[PATCH] D75536: [LLD] Add support for --unique option
Dave Bozier via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 9 07:30:43 PDT 2020
davidb updated this revision to Diff 249094.
davidb added a comment.
- review comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75536/new/
https://reviews.llvm.org/D75536
Files:
lld/ELF/Config.h
lld/ELF/LinkerScript.cpp
lld/test/ELF/unique-orphans.s
Index: lld/test/ELF/unique-orphans.s
===================================================================
--- lld/test/ELF/unique-orphans.s
+++ lld/test/ELF/unique-orphans.s
@@ -21,6 +21,6 @@
## Test that --unique does not affect sections specified in output section descriptions.
# RUN: echo 'SECTIONS { .foo : { *(.foo) }}' > %t.script
# RUN: ld.lld %t.o -o %t2.elf -T %t.script --unique
-# RUN: llvm-readelf -S %t2.elf | FileCheck --check-prefix UNIQUE_SCRIPT %s
-# UNIQUE_SCRIPT: .foo
-# UNIQUE_SCRIPT-NOT: .foo
+# RUN: llvm-readelf -S %t2.elf | FileCheck --check-prefix SCRIPT %s
+# SCRIPT: .foo
+# SCRIPT-NOT: .foo
Index: lld/ELF/LinkerScript.cpp
===================================================================
--- lld/ELF/LinkerScript.cpp
+++ lld/ELF/LinkerScript.cpp
@@ -680,22 +680,21 @@
std::function<void(InputSectionBase *)> add;
add = [&](InputSectionBase *s) {
- if (s->isLive() && !s->parent) {
- orphanSections.push_back(s);
-
- StringRef name = getOutputSectionName(s);
-
- if (config->unique) {
- v.push_back(createSection(s, name));
- } else if (OutputSection *sec = findByName(sectionCommands, name)) {
- sec->recordSection(s);
- } else {
- if (OutputSection *os = addInputSec(map, s, name))
- v.push_back(os);
- assert(isa<MergeInputSection>(s) ||
- s->getOutputSection()->sectionIndex == UINT32_MAX);
- }
+ if (s->isLive() && !s->parent) {
+ orphanSections.push_back(s);
+
+ StringRef name = getOutputSectionName(s);
+ if (config->unique) {
+ v.push_back(createSection(s, name));
+ } else if (OutputSection *sec = findByName(sectionCommands, name)) {
+ sec->recordSection(s);
+ } else {
+ if (OutputSection *os = addInputSec(map, s, name))
+ v.push_back(os);
+ assert(isa<MergeInputSection>(s) ||
+ s->getOutputSection()->sectionIndex == UINT32_MAX);
}
+ }
if (config->relocatable)
for (InputSectionBase *depSec : s->dependentSections)
Index: lld/ELF/Config.h
===================================================================
--- lld/ELF/Config.h
+++ lld/ELF/Config.h
@@ -194,7 +194,7 @@
bool timeTraceEnabled;
bool tocOptimize;
bool undefinedVersion;
- bool unique = false;
+ bool unique;
bool useAndroidRelrTags = false;
bool warnBackrefs;
bool warnCommon;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75536.249094.patch
Type: text/x-patch
Size: 2429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200309/af2179ea/attachment.bin>
More information about the llvm-commits
mailing list