@@ -56,7 +56,7 @@ StringRef LinkerScript::getOutputSectionName(const InputSectionBase *s) const {
56
56
if (InputSectionBase *rel = isec->getRelocatedSection ()) {
57
57
OutputSection *out = rel->getOutputSection ();
58
58
if (!out) {
59
- assert (config-> relocatable && (rel->flags & SHF_LINK_ORDER));
59
+ assert (ctx. arg . relocatable && (rel->flags & SHF_LINK_ORDER));
60
60
return s->name ;
61
61
}
62
62
if (s->type == SHT_CREL)
@@ -67,7 +67,7 @@ StringRef LinkerScript::getOutputSectionName(const InputSectionBase *s) const {
67
67
}
68
68
}
69
69
70
- if (config-> relocatable )
70
+ if (ctx. arg . relocatable )
71
71
return s->name ;
72
72
73
73
// A BssSection created for a common symbol is identified as "COMMON" in
@@ -96,7 +96,7 @@ StringRef LinkerScript::getOutputSectionName(const InputSectionBase *s) const {
96
96
// profile inaccuracy. Techniques such as hugepage remapping can make
97
97
// conservative decisions at the section granularity.
98
98
if (isSectionPrefix (" .text" , s->name )) {
99
- if (config-> zKeepTextSectionPrefix )
99
+ if (ctx. arg . zKeepTextSectionPrefix )
100
100
for (StringRef v : {" .text.hot" , " .text.unknown" , " .text.unlikely" ,
101
101
" .text.startup" , " .text.exit" , " .text.split" })
102
102
if (isSectionPrefix (v.substr (5 ), s->name .substr (5 )))
@@ -308,7 +308,7 @@ getChangedSymbolAssignment(const SymbolAssignmentMap &oldValues) {
308
308
void LinkerScript::processInsertCommands () {
309
309
SmallVector<OutputDesc *, 0 > moves;
310
310
for (const InsertCommand &cmd : insertCommands) {
311
- if (config-> enableNonContiguousRegions )
311
+ if (ctx. arg . enableNonContiguousRegions )
312
312
error (" INSERT cannot be used with --enable-non-contiguous-regions" );
313
313
314
314
for (StringRef name : cmd.names ) {
@@ -486,7 +486,7 @@ static void sortInputSections(MutableArrayRef<InputSectionBase *> vec,
486
486
return ;
487
487
488
488
if (inner == SortSectionPolicy::Default)
489
- sortSections (vec, config-> sortSection );
489
+ sortSections (vec, ctx. arg . sortSection );
490
490
else
491
491
sortSections (vec, inner);
492
492
sortSections (vec, outer);
@@ -518,7 +518,7 @@ LinkerScript::computeInputSections(const InputSectionDescription *cmd,
518
518
ret[i] = sections[indexes[i]];
519
519
sortInputSections (
520
520
MutableArrayRef<InputSectionBase *>(ret).slice (begin, end - begin),
521
- config-> sortSection , SortSectionPolicy::None);
521
+ ctx. arg . sortSection , SortSectionPolicy::None);
522
522
};
523
523
524
524
for (const SectionPattern &pat : cmd->sectionPatterns ) {
@@ -550,7 +550,7 @@ LinkerScript::computeInputSections(const InputSectionDescription *cmd,
550
550
551
551
if (sec->parent ) {
552
552
// Skip if not allowing multiple matches.
553
- if (!config-> enableNonContiguousRegions )
553
+ if (!ctx. arg . enableNonContiguousRegions )
554
554
continue ;
555
555
556
556
// Disallow spilling into /DISCARD/; special handling would be needed
@@ -734,7 +734,7 @@ void LinkerScript::processSectionCommands() {
734
734
735
735
// Process OVERWRITE_SECTIONS first so that it can overwrite the main script
736
736
// or orphans.
737
- if (config-> enableNonContiguousRegions && !overwriteSections.empty ())
737
+ if (ctx. arg . enableNonContiguousRegions && !overwriteSections.empty ())
738
738
error (" OVERWRITE_SECTIONS cannot be used with "
739
739
" --enable-non-contiguous-regions" );
740
740
DenseMap<CachedHashStringRef, OutputDesc *> map;
@@ -944,7 +944,7 @@ static OutputDesc *addInputSec(StringMap<TinyPtrVector<OutputSection *>> &map,
944
944
if (sec->partition != isec->partition )
945
945
continue ;
946
946
947
- if (config-> relocatable && (isec->flags & SHF_LINK_ORDER)) {
947
+ if (ctx. arg . relocatable && (isec->flags & SHF_LINK_ORDER)) {
948
948
// Merging two SHF_LINK_ORDER sections with different sh_link fields will
949
949
// change their semantics, so we only merge them in -r links if they will
950
950
// end up being linked to the same output section. The casts are fine
@@ -978,7 +978,7 @@ void LinkerScript::addOrphanSections() {
978
978
orphanSections.push_back (s);
979
979
980
980
StringRef name = getOutputSectionName (s);
981
- if (config-> unique ) {
981
+ if (ctx. arg . unique ) {
982
982
v.push_back (createSection (s, name));
983
983
} else if (OutputSection *sec = findByName (sectionCommands, name)) {
984
984
sec->recordSection (s);
@@ -1004,15 +1004,15 @@ void LinkerScript::addOrphanSections() {
1004
1004
// In -r links, SHF_LINK_ORDER sections are added while adding their parent
1005
1005
// sections because we need to know the parent's output section before we
1006
1006
// 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))
1008
1008
continue ;
1009
1009
1010
1010
if (auto *sec = dyn_cast<InputSection>(isec))
1011
1011
if (InputSectionBase *rel = sec->getRelocatedSection ())
1012
1012
if (auto *relIS = dyn_cast_or_null<InputSectionBase>(rel->parent ))
1013
1013
add (relIS);
1014
1014
add (isec);
1015
- if (config-> relocatable )
1015
+ if (ctx. arg . relocatable )
1016
1016
for (InputSectionBase *depSec : isec->dependentSections )
1017
1017
if (depSec->flags & SHF_LINK_ORDER)
1018
1018
add (depSec);
@@ -1032,7 +1032,7 @@ void LinkerScript::addOrphanSections() {
1032
1032
1033
1033
void LinkerScript::diagnoseOrphanHandling () const {
1034
1034
llvm::TimeTraceScope timeScope (" Diagnose orphan sections" );
1035
- if (config-> orphanHandling == OrphanHandlingPolicy::Place ||
1035
+ if (ctx. arg . orphanHandling == OrphanHandlingPolicy::Place ||
1036
1036
!hasSectionsCommand)
1037
1037
return ;
1038
1038
for (const InputSectionBase *sec : orphanSections) {
@@ -1047,19 +1047,19 @@ void LinkerScript::diagnoseOrphanHandling() const {
1047
1047
continue ;
1048
1048
1049
1049
StringRef name = getOutputSectionName (sec);
1050
- if (config-> orphanHandling == OrphanHandlingPolicy::Error)
1050
+ if (ctx. arg . orphanHandling == OrphanHandlingPolicy::Error)
1051
1051
error (toString (sec) + " is being placed in '" + name + " '" );
1052
1052
else
1053
1053
warn (toString (sec) + " is being placed in '" + name + " '" );
1054
1054
}
1055
1055
}
1056
1056
1057
1057
void LinkerScript::diagnoseMissingSGSectionAddress () const {
1058
- if (!config-> cmseImplib || !ctx.in .armCmseSGSection ->isNeeded ())
1058
+ if (!ctx. arg . cmseImplib || !ctx.in .armCmseSGSection ->isNeeded ())
1059
1059
return ;
1060
1060
1061
1061
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" ))
1063
1063
error (" no address assigned to the veneers output section " + sec->name );
1064
1064
}
1065
1065
@@ -1238,7 +1238,7 @@ bool LinkerScript::assignOffsets(OutputSection *sec) {
1238
1238
// If .relro_padding is present, round up the end to a common-page-size
1239
1239
// boundary to protect the last page.
1240
1240
if (ctx.in .relroPadding && sec == ctx.in .relroPadding ->getParent ())
1241
- expandOutputSection (alignToPowerOf2 (dot, config-> commonPageSize ) - dot);
1241
+ expandOutputSection (alignToPowerOf2 (dot, ctx. arg . commonPageSize ) - dot);
1242
1242
1243
1243
// Non-SHF_ALLOC sections do not affect the addresses of other OutputSections
1244
1244
// as they are not part of the process image.
@@ -1441,16 +1441,16 @@ void LinkerScript::allocateHeaders(SmallVector<PhdrEntry *, 0> &phdrs) {
1441
1441
llvm::any_of (phdrsCommands, [](const PhdrsCommand &cmd) {
1442
1442
return cmd.hasPhdrs || cmd.hasFilehdr ;
1443
1443
});
1444
- bool paged = !config-> omagic && !config-> nmagic ;
1444
+ bool paged = !ctx. arg . omagic && !ctx. arg . nmagic ;
1445
1445
uint64_t headerSize = getHeaderSize ();
1446
1446
1447
1447
uint64_t base = 0 ;
1448
1448
// If SECTIONS is present and the linkerscript is not explicit about program
1449
1449
// headers, only allocate program headers if that would not add a page.
1450
1450
if (hasSectionsCommand && !hasExplicitHeaders)
1451
- base = alignDown (min, config-> maxPageSize );
1451
+ base = alignDown (min, ctx. arg . maxPageSize );
1452
1452
if ((paged || hasExplicitHeaders) && headerSize <= min - base) {
1453
- min = alignDown (min - headerSize, config-> maxPageSize );
1453
+ min = alignDown (min - headerSize, ctx. arg . maxPageSize );
1454
1454
ctx.out .elfHeader ->addr = min;
1455
1455
ctx.out .programHeaders ->addr = min + ctx.out .elfHeader ->size ;
1456
1456
return ;
@@ -1485,7 +1485,7 @@ LinkerScript::assignAddresses() {
1485
1485
if (hasSectionsCommand) {
1486
1486
// With a linker script, assignment of addresses to headers is covered by
1487
1487
// allocateHeaders().
1488
- dot = config-> imageBase .value_or (0 );
1488
+ dot = ctx. arg . imageBase .value_or (0 );
1489
1489
} else {
1490
1490
// Assign addresses to headers right now.
1491
1491
dot = ctx.target ->getImageBase ();
0 commit comments