[lld] r372735 - [ELF] Delete SectionBase::assigned
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 24 04:48:46 PDT 2019
Author: maskray
Date: Tue Sep 24 04:48:46 2019
New Revision: 372735
URL: http://llvm.org/viewvc/llvm-project?rev=372735&view=rev
Log:
[ELF] Delete SectionBase::assigned
D67504 removed uses of `assigned` from OutputSection::addSection, which
makes `assigned` purely used in processSectionCommands() and its
callees. By replacing its references with `parent`, we can remove
`assigned`.
Reviewed By: grimar
Differential Revision: https://reviews.llvm.org/D67531
Modified:
lld/trunk/ELF/InputSection.h
lld/trunk/ELF/LinkerScript.cpp
Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=372735&r1=372734&r2=372735&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Tue Sep 24 04:48:46 2019
@@ -54,22 +54,9 @@ public:
unsigned sectionKind : 3;
- // The next three bit fields are only used by InputSectionBase, but we
+ // The next two bit fields are only used by InputSectionBase, but we
// put them here so the struct packs better.
- // True if this section has already been placed to a linker script
- // output section. This is needed because, in a linker script, you
- // can refer to the same section more than once. For example, in
- // the following linker script,
- //
- // .foo : { *(.text) }
- // .bar : { *(.text) }
- //
- // .foo takes all .text sections, and .bar becomes empty. To achieve
- // this, we need to memorize whether a section has been placed or
- // not for each input section.
- unsigned assigned : 1;
-
unsigned bss : 1;
// Set for sections that should not be folded by ICF.
@@ -108,9 +95,9 @@ protected:
SectionBase(Kind sectionKind, StringRef name, uint64_t flags,
uint64_t entsize, uint64_t alignment, uint32_t type,
uint32_t info, uint32_t link)
- : name(name), repl(this), sectionKind(sectionKind), assigned(false),
- bss(false), keepUnique(false), partition(0), alignment(alignment),
- flags(flags), entsize(entsize), type(type), link(link), info(info) {}
+ : name(name), repl(this), sectionKind(sectionKind), bss(false),
+ keepUnique(false), partition(0), alignment(alignment), flags(flags),
+ entsize(entsize), type(type), link(link), info(info) {}
};
// This corresponds to a section of an input file.
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=372735&r1=372734&r2=372735&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Sep 24 04:48:46 2019
@@ -414,7 +414,7 @@ LinkerScript::computeInputSections(const
size_t sizeBefore = ret.size();
for (InputSectionBase *sec : inputSections) {
- if (!sec->isLive() || sec->assigned)
+ if (!sec->isLive() || sec->parent)
continue;
// For -emit-relocs we have to ignore entries like
@@ -433,7 +433,6 @@ LinkerScript::computeInputSections(const
continue;
ret.push_back(sec);
- sec->assigned = true;
}
sortInputSections(
@@ -455,6 +454,7 @@ void LinkerScript::discard(InputSectionB
mainPart->hashTab = nullptr;
s->markDead();
+ s->parent = nullptr;
for (InputSection *ds : s->dependentSections)
discard(ds);
}
@@ -466,6 +466,8 @@ LinkerScript::createInputSectionList(Out
for (BaseCommand *base : outCmd.sectionCommands) {
if (auto *cmd = dyn_cast<InputSectionDescription>(base)) {
cmd->sectionBases = computeInputSections(cmd);
+ for (InputSectionBase *s : cmd->sectionBases)
+ s->parent = &outCmd;
ret.insert(ret.end(), cmd->sectionBases.begin(), cmd->sectionBases.end());
}
}
@@ -497,7 +499,7 @@ void LinkerScript::processSectionCommand
// way to "make it as if it wasn't present" is to make it empty.
if (!matchConstraints(v, sec->constraint)) {
for (InputSectionBase *s : v)
- s->assigned = false;
+ s->parent = nullptr;
sec->sectionCommands.clear();
continue;
}
@@ -512,8 +514,6 @@ void LinkerScript::processSectionCommand
}
sec->sectionIndex = i++;
- for (InputSectionBase *s : v)
- s->parent = sec;
}
}
}
More information about the llvm-commits
mailing list