Skip to content

Commit 9b7a22e

Browse files
committed
[ELF] Replace config-> with ctx.arg. in LinkerScript
1 parent bb0a6f2 commit 9b7a22e

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

lld/ELF/LinkerScript.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ StringRef LinkerScript::getOutputSectionName(const InputSectionBase *s) const {
5656
if (InputSectionBase *rel = isec->getRelocatedSection()) {
5757
OutputSection *out = rel->getOutputSection();
5858
if (!out) {
59-
assert(config->relocatable && (rel->flags & SHF_LINK_ORDER));
59+
assert(ctx.arg.relocatable && (rel->flags & SHF_LINK_ORDER));
6060
return s->name;
6161
}
6262
if (s->type == SHT_CREL)
@@ -67,7 +67,7 @@ StringRef LinkerScript::getOutputSectionName(const InputSectionBase *s) const {
6767
}
6868
}
6969

70-
if (config->relocatable)
70+
if (ctx.arg.relocatable)
7171
return s->name;
7272

7373
// A BssSection created for a common symbol is identified as "COMMON" in
@@ -96,7 +96,7 @@ StringRef LinkerScript::getOutputSectionName(const InputSectionBase *s) const {
9696
// profile inaccuracy. Techniques such as hugepage remapping can make
9797
// conservative decisions at the section granularity.
9898
if (isSectionPrefix(".text", s->name)) {
99-
if (config->zKeepTextSectionPrefix)
99+
if (ctx.arg.zKeepTextSectionPrefix)
100100
for (StringRef v : {".text.hot", ".text.unknown", ".text.unlikely",
101101
".text.startup", ".text.exit", ".text.split"})
102102
if (isSectionPrefix(v.substr(5), s->name.substr(5)))
@@ -308,7 +308,7 @@ getChangedSymbolAssignment(const SymbolAssignmentMap &oldValues) {
308308
void LinkerScript::processInsertCommands() {
309309
SmallVector<OutputDesc *, 0> moves;
310310
for (const InsertCommand &cmd : insertCommands) {
311-
if (config->enableNonContiguousRegions)
311+
if (ctx.arg.enableNonContiguousRegions)
312312
error("INSERT cannot be used with --enable-non-contiguous-regions");
313313

314314
for (StringRef name : cmd.names) {
@@ -486,7 +486,7 @@ static void sortInputSections(MutableArrayRef<InputSectionBase *> vec,
486486
return;
487487

488488
if (inner == SortSectionPolicy::Default)
489-
sortSections(vec, config->sortSection);
489+
sortSections(vec, ctx.arg.sortSection);
490490
else
491491
sortSections(vec, inner);
492492
sortSections(vec, outer);
@@ -518,7 +518,7 @@ LinkerScript::computeInputSections(const InputSectionDescription *cmd,
518518
ret[i] = sections[indexes[i]];
519519
sortInputSections(
520520
MutableArrayRef<InputSectionBase *>(ret).slice(begin, end - begin),
521-
config->sortSection, SortSectionPolicy::None);
521+
ctx.arg.sortSection, SortSectionPolicy::None);
522522
};
523523

524524
for (const SectionPattern &pat : cmd->sectionPatterns) {
@@ -550,7 +550,7 @@ LinkerScript::computeInputSections(const InputSectionDescription *cmd,
550550

551551
if (sec->parent) {
552552
// Skip if not allowing multiple matches.
553-
if (!config->enableNonContiguousRegions)
553+
if (!ctx.arg.enableNonContiguousRegions)
554554
continue;
555555

556556
// Disallow spilling into /DISCARD/; special handling would be needed
@@ -734,7 +734,7 @@ void LinkerScript::processSectionCommands() {
734734

735735
// Process OVERWRITE_SECTIONS first so that it can overwrite the main script
736736
// or orphans.
737-
if (config->enableNonContiguousRegions && !overwriteSections.empty())
737+
if (ctx.arg.enableNonContiguousRegions && !overwriteSections.empty())
738738
error("OVERWRITE_SECTIONS cannot be used with "
739739
"--enable-non-contiguous-regions");
740740
DenseMap<CachedHashStringRef, OutputDesc *> map;
@@ -944,7 +944,7 @@ static OutputDesc *addInputSec(StringMap<TinyPtrVector<OutputSection *>> &map,
944944
if (sec->partition != isec->partition)
945945
continue;
946946

947-
if (config->relocatable && (isec->flags & SHF_LINK_ORDER)) {
947+
if (ctx.arg.relocatable && (isec->flags & SHF_LINK_ORDER)) {
948948
// Merging two SHF_LINK_ORDER sections with different sh_link fields will
949949
// change their semantics, so we only merge them in -r links if they will
950950
// end up being linked to the same output section. The casts are fine
@@ -978,7 +978,7 @@ void LinkerScript::addOrphanSections() {
978978
orphanSections.push_back(s);
979979

980980
StringRef name = getOutputSectionName(s);
981-
if (config->unique) {
981+
if (ctx.arg.unique) {
982982
v.push_back(createSection(s, name));
983983
} else if (OutputSection *sec = findByName(sectionCommands, name)) {
984984
sec->recordSection(s);
@@ -1004,15 +1004,15 @@ void LinkerScript::addOrphanSections() {
10041004
// In -r links, SHF_LINK_ORDER sections are added while adding their parent
10051005
// sections because we need to know the parent's output section before we
10061006
// can select an output section for the SHF_LINK_ORDER section.
1007-
if (config->relocatable && (isec->flags & SHF_LINK_ORDER))
1007+
if (ctx.arg.relocatable && (isec->flags & SHF_LINK_ORDER))
10081008
continue;
10091009

10101010
if (auto *sec = dyn_cast<InputSection>(isec))
10111011
if (InputSectionBase *rel = sec->getRelocatedSection())
10121012
if (auto *relIS = dyn_cast_or_null<InputSectionBase>(rel->parent))
10131013
add(relIS);
10141014
add(isec);
1015-
if (config->relocatable)
1015+
if (ctx.arg.relocatable)
10161016
for (InputSectionBase *depSec : isec->dependentSections)
10171017
if (depSec->flags & SHF_LINK_ORDER)
10181018
add(depSec);
@@ -1032,7 +1032,7 @@ void LinkerScript::addOrphanSections() {
10321032

10331033
void LinkerScript::diagnoseOrphanHandling() const {
10341034
llvm::TimeTraceScope timeScope("Diagnose orphan sections");
1035-
if (config->orphanHandling == OrphanHandlingPolicy::Place ||
1035+
if (ctx.arg.orphanHandling == OrphanHandlingPolicy::Place ||
10361036
!hasSectionsCommand)
10371037
return;
10381038
for (const InputSectionBase *sec : orphanSections) {
@@ -1047,19 +1047,19 @@ void LinkerScript::diagnoseOrphanHandling() const {
10471047
continue;
10481048

10491049
StringRef name = getOutputSectionName(sec);
1050-
if (config->orphanHandling == OrphanHandlingPolicy::Error)
1050+
if (ctx.arg.orphanHandling == OrphanHandlingPolicy::Error)
10511051
error(toString(sec) + " is being placed in '" + name + "'");
10521052
else
10531053
warn(toString(sec) + " is being placed in '" + name + "'");
10541054
}
10551055
}
10561056

10571057
void LinkerScript::diagnoseMissingSGSectionAddress() const {
1058-
if (!config->cmseImplib || !ctx.in.armCmseSGSection->isNeeded())
1058+
if (!ctx.arg.cmseImplib || !ctx.in.armCmseSGSection->isNeeded())
10591059
return;
10601060

10611061
OutputSection *sec = findByName(sectionCommands, ".gnu.sgstubs");
1062-
if (sec && !sec->addrExpr && !config->sectionStartMap.count(".gnu.sgstubs"))
1062+
if (sec && !sec->addrExpr && !ctx.arg.sectionStartMap.count(".gnu.sgstubs"))
10631063
error("no address assigned to the veneers output section " + sec->name);
10641064
}
10651065

@@ -1238,7 +1238,7 @@ bool LinkerScript::assignOffsets(OutputSection *sec) {
12381238
// If .relro_padding is present, round up the end to a common-page-size
12391239
// boundary to protect the last page.
12401240
if (ctx.in.relroPadding && sec == ctx.in.relroPadding->getParent())
1241-
expandOutputSection(alignToPowerOf2(dot, config->commonPageSize) - dot);
1241+
expandOutputSection(alignToPowerOf2(dot, ctx.arg.commonPageSize) - dot);
12421242

12431243
// Non-SHF_ALLOC sections do not affect the addresses of other OutputSections
12441244
// as they are not part of the process image.
@@ -1441,16 +1441,16 @@ void LinkerScript::allocateHeaders(SmallVector<PhdrEntry *, 0> &phdrs) {
14411441
llvm::any_of(phdrsCommands, [](const PhdrsCommand &cmd) {
14421442
return cmd.hasPhdrs || cmd.hasFilehdr;
14431443
});
1444-
bool paged = !config->omagic && !config->nmagic;
1444+
bool paged = !ctx.arg.omagic && !ctx.arg.nmagic;
14451445
uint64_t headerSize = getHeaderSize();
14461446

14471447
uint64_t base = 0;
14481448
// If SECTIONS is present and the linkerscript is not explicit about program
14491449
// headers, only allocate program headers if that would not add a page.
14501450
if (hasSectionsCommand && !hasExplicitHeaders)
1451-
base = alignDown(min, config->maxPageSize);
1451+
base = alignDown(min, ctx.arg.maxPageSize);
14521452
if ((paged || hasExplicitHeaders) && headerSize <= min - base) {
1453-
min = alignDown(min - headerSize, config->maxPageSize);
1453+
min = alignDown(min - headerSize, ctx.arg.maxPageSize);
14541454
ctx.out.elfHeader->addr = min;
14551455
ctx.out.programHeaders->addr = min + ctx.out.elfHeader->size;
14561456
return;
@@ -1485,7 +1485,7 @@ LinkerScript::assignAddresses() {
14851485
if (hasSectionsCommand) {
14861486
// With a linker script, assignment of addresses to headers is covered by
14871487
// allocateHeaders().
1488-
dot = config->imageBase.value_or(0);
1488+
dot = ctx.arg.imageBase.value_or(0);
14891489
} else {
14901490
// Assign addresses to headers right now.
14911491
dot = ctx.target->getImageBase();

0 commit comments

Comments
 (0)