@@ -135,10 +135,10 @@ static void updateARMVFPArgs(const ARMAttributeParser &attributes,
135
135
return ;
136
136
}
137
137
// Follow ld.bfd and error if there is a mix of calling conventions.
138
- if (config-> armVFPArgs != arg && config-> armVFPArgs != ARMVFPArgKind::Default)
138
+ if (ctx. arg . armVFPArgs != arg && ctx. arg . armVFPArgs != ARMVFPArgKind::Default)
139
139
error (toString (f) + " : incompatible Tag_ABI_VFP_args" );
140
140
else
141
- config-> armVFPArgs = arg;
141
+ ctx. arg . armVFPArgs = arg;
142
142
}
143
143
144
144
// The ARM support in lld makes some use of instructions that are not available
@@ -168,19 +168,19 @@ static void updateSupportedARMFeatures(const ARMAttributeParser &attributes) {
168
168
case ARMBuildAttrs::v6:
169
169
case ARMBuildAttrs::v6KZ:
170
170
case ARMBuildAttrs::v6K:
171
- config-> armHasBlx = true ;
171
+ ctx. arg . armHasBlx = true ;
172
172
// Architectures used in pre-Cortex processors do not support
173
173
// The J1 = 1 J2 = 1 Thumb branch range extension, with the exception
174
174
// of Architecture v6T2 (arm1156t2-s and arm1156t2f-s) that do.
175
175
break ;
176
176
default :
177
177
// All other Architectures have BLX and extended branch encoding
178
- config-> armHasBlx = true ;
179
- config-> armJ1J2BranchEncoding = true ;
178
+ ctx. arg . armHasBlx = true ;
179
+ ctx. arg . armJ1J2BranchEncoding = true ;
180
180
if (arch != ARMBuildAttrs::v6_M && arch != ARMBuildAttrs::v6S_M)
181
181
// All Architectures used in Cortex processors with the exception
182
182
// of v6-M and v6S-M have the MOVT and MOVW instructions.
183
- config-> armHasMovtMovw = true ;
183
+ ctx. arg . armHasMovtMovw = true ;
184
184
break ;
185
185
}
186
186
@@ -191,7 +191,7 @@ static void updateSupportedARMFeatures(const ARMAttributeParser &attributes) {
191
191
return ;
192
192
if (arch >= ARMBuildAttrs::CPUArch::v8_M_Base &&
193
193
profile == ARMBuildAttrs::MicroControllerProfile)
194
- config-> armCMSESupport = true ;
194
+ ctx. arg . armCMSESupport = true ;
195
195
196
196
// The thumb PLT entries require Thumb2 which can be used on multiple archs.
197
197
// For now, let's limit it to ones where ARM isn't available and we know have
@@ -200,8 +200,8 @@ static void updateSupportedARMFeatures(const ARMAttributeParser &attributes) {
200
200
attributes.getAttributeValue (ARMBuildAttrs::ARM_ISA_use);
201
201
std::optional<unsigned > thumb =
202
202
attributes.getAttributeValue (ARMBuildAttrs::THUMB_ISA_use);
203
- config-> armHasArmISA |= armISA && *armISA >= ARMBuildAttrs::Allowed;
204
- config-> armHasThumb2ISA |= thumb && *thumb >= ARMBuildAttrs::AllowThumb32;
203
+ ctx. arg . armHasArmISA |= armISA && *armISA >= ARMBuildAttrs::Allowed;
204
+ ctx. arg . armHasThumb2ISA |= thumb && *thumb >= ARMBuildAttrs::AllowThumb32;
205
205
}
206
206
207
207
InputFile::InputFile (Kind k, MemoryBufferRef m)
@@ -217,16 +217,16 @@ std::optional<MemoryBufferRef> elf::readFile(StringRef path) {
217
217
218
218
// The --chroot option changes our virtual root directory.
219
219
// This is useful when you are dealing with files created by --reproduce.
220
- if (!config-> chroot .empty () && path.starts_with (" /" ))
221
- path = saver ().save (config-> chroot + path);
220
+ if (!ctx. arg . chroot .empty () && path.starts_with (" /" ))
221
+ path = saver ().save (ctx. arg . chroot + path);
222
222
223
223
bool remapped = false ;
224
- auto it = config-> remapInputs .find (path);
225
- if (it != config-> remapInputs .end ()) {
224
+ auto it = ctx. arg . remapInputs .find (path);
225
+ if (it != ctx. arg . remapInputs .end ()) {
226
226
path = it->second ;
227
227
remapped = true ;
228
228
} else {
229
- for (const auto &[pat, toFile] : config-> remapInputsWildcards ) {
229
+ for (const auto &[pat, toFile] : ctx. arg . remapInputsWildcards ) {
230
230
if (pat.match (path)) {
231
231
path = toFile;
232
232
remapped = true ;
@@ -244,7 +244,7 @@ std::optional<MemoryBufferRef> elf::readFile(StringRef path) {
244
244
}
245
245
246
246
log (path);
247
- config-> dependencyFiles .insert (llvm::CachedHashString (path));
247
+ ctx. arg . dependencyFiles .insert (llvm::CachedHashString (path));
248
248
249
249
auto mbOrErr = MemoryBuffer::getFile (path, /* IsText=*/ false ,
250
250
/* RequiresNullTerminator=*/ false );
@@ -268,15 +268,15 @@ static bool isCompatible(InputFile *file) {
268
268
if (!file->isElf () && !isa<BitcodeFile>(file))
269
269
return true ;
270
270
271
- if (file->ekind == config-> ekind && file->emachine == config-> emachine ) {
272
- if (config-> emachine != EM_MIPS)
271
+ if (file->ekind == ctx. arg . ekind && file->emachine == ctx. arg . emachine ) {
272
+ if (ctx. arg . emachine != EM_MIPS)
273
273
return true ;
274
- if (isMipsN32Abi (file) == config-> mipsN32Abi )
274
+ if (isMipsN32Abi (file) == ctx. arg . mipsN32Abi )
275
275
return true ;
276
276
}
277
277
278
278
StringRef target =
279
- !config-> bfdname .empty () ? config-> bfdname : config-> emulation ;
279
+ !ctx. arg . bfdname .empty () ? ctx. arg . bfdname : ctx. arg . emulation ;
280
280
if (!target.empty ()) {
281
281
error (toString (file) + " is incompatible with " + target);
282
282
return false ;
@@ -311,7 +311,7 @@ template <class ELFT> static void doParseFile(InputFile *file) {
311
311
return ;
312
312
}
313
313
314
- if (config-> trace )
314
+ if (ctx. arg . trace )
315
315
message (toString (file));
316
316
317
317
if (file->kind () == InputFile::ObjKind) {
@@ -419,7 +419,7 @@ StringRef InputFile::getNameForScript() const {
419
419
// is a form of autolinking and is called `dependent libraries`. It is currently
420
420
// unique to LLVM and lld.
421
421
static void addDependentLibrary (StringRef specifier, const InputFile *f) {
422
- if (!config-> dependentLibraries )
422
+ if (!ctx. arg . dependentLibraries )
423
423
return ;
424
424
if (std::optional<std::string> s = searchLibraryBaseName (specifier))
425
425
ctx.driver .addFile (saver ().save (*s), /* withLOption=*/ true );
@@ -599,7 +599,7 @@ template <class ELFT> void ObjFile<ELFT>::parse(bool ignoreComdats) {
599
599
sections.resize (size);
600
600
for (size_t i = 0 ; i != size; ++i) {
601
601
const Elf_Shdr &sec = objSections[i];
602
- if (sec.sh_type == SHT_LLVM_DEPENDENT_LIBRARIES && !config-> relocatable ) {
602
+ if (sec.sh_type == SHT_LLVM_DEPENDENT_LIBRARIES && !ctx. arg . relocatable ) {
603
603
StringRef name = check (obj.getSectionName (sec, shstrtab));
604
604
ArrayRef<char > data = CHECK (
605
605
this ->getObj ().template getSectionContentsAsArray <char >(sec), this );
@@ -619,7 +619,7 @@ template <class ELFT> void ObjFile<ELFT>::parse(bool ignoreComdats) {
619
619
continue ;
620
620
}
621
621
622
- if (sec.sh_type == SHT_ARM_ATTRIBUTES && config-> emachine == EM_ARM) {
622
+ if (sec.sh_type == SHT_ARM_ATTRIBUTES && ctx. arg . emachine == EM_ARM) {
623
623
ARMAttributeParser attributes;
624
624
ArrayRef<uint8_t > contents =
625
625
check (this ->getObj ().getSectionContents (sec));
@@ -672,7 +672,7 @@ template <class ELFT> void ObjFile<ELFT>::parse(bool ignoreComdats) {
672
672
symtab.comdatGroups .try_emplace (CachedHashStringRef (signature), this )
673
673
.second ;
674
674
if (keepGroup) {
675
- if (!config-> resolveGroups )
675
+ if (!ctx. arg . resolveGroups )
676
676
this ->sections [i] = createInputSection (
677
677
i, sec, check (obj.getSectionName (sec, shstrtab)));
678
678
continue ;
@@ -718,7 +718,7 @@ bool ObjFile<ELFT>::shouldMerge(const Elf_Shdr &sec, StringRef name) {
718
718
// SHF_MERGE sections based both on their name and sh_entsize, but that seems
719
719
// to be more trouble than it is worth. Instead, we just use the regular (-O1)
720
720
// logic for -r.
721
- if (config-> optimize == 0 && !config-> relocatable )
721
+ if (ctx. arg . optimize == 0 && !ctx. arg . relocatable )
722
722
return false ;
723
723
724
724
// A mergeable section with size 0 is useless because they don't have
@@ -786,7 +786,7 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
786
786
// SHF_EXCLUDE'ed sections are discarded by the linker. However,
787
787
// if -r is given, we'll let the final link discard such sections.
788
788
// This is compatible with GNU.
789
- if ((sec.sh_flags & SHF_EXCLUDE) && !config-> relocatable ) {
789
+ if ((sec.sh_flags & SHF_EXCLUDE) && !ctx. arg . relocatable ) {
790
790
if (type == SHT_LLVM_CALL_GRAPH_PROFILE)
791
791
cgProfileSectionIndex = i;
792
792
if (type == SHT_LLVM_ADDRSIG) {
@@ -796,7 +796,7 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
796
796
// in the address-significance table, which refers to symbols by index.
797
797
if (sec.sh_link != 0 )
798
798
this ->addrsigSec = &sec;
799
- else if (config-> icf == ICFLevel::Safe)
799
+ else if (ctx. arg . icf == ICFLevel::Safe)
800
800
warn (toString (this ) +
801
801
" : --icf=safe conservatively ignores "
802
802
" SHT_LLVM_ADDRSIG [index " +
@@ -810,7 +810,7 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
810
810
811
811
switch (type) {
812
812
case SHT_GROUP: {
813
- if (!config-> relocatable )
813
+ if (!ctx. arg . relocatable )
814
814
sections[i] = &InputSection::discarded;
815
815
StringRef signature =
816
816
cantFail (this ->getELFSyms <ELFT>()[sec.sh_info ].getName (stringTable));
@@ -846,7 +846,7 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
846
846
// The concatenated output does not properly reflect the linking
847
847
// semantics. In addition, since we do not use the bitcode wrapper format,
848
848
// the concatenated raw bitcode would be invalid.
849
- if (config-> relocatable && !config-> fatLTOObjects ) {
849
+ if (ctx. arg . relocatable && !ctx. arg . fatLTOObjects ) {
850
850
sections[i] = &InputSection::discarded;
851
851
break ;
852
852
}
@@ -856,7 +856,7 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
856
856
createInputSection (i, sec, check (obj.getSectionName (sec, shstrtab)));
857
857
if (type == SHT_LLVM_SYMPART)
858
858
ctx.hasSympart .store (true , std::memory_order_relaxed);
859
- else if (config-> rejectMismatch &&
859
+ else if (ctx. arg . rejectMismatch &&
860
860
!isKnownSpecificSectionType (type, sec.sh_flags ))
861
861
errorOrWarn (toString (this ->sections [i]) + " : unknown section type 0x" +
862
862
Twine::utohexstr (type));
@@ -909,7 +909,7 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
909
909
// `nullptr` for the normal case. However, if -r or --emit-relocs is
910
910
// specified, we need to copy them to the output. (Some post link analysis
911
911
// tools specify --emit-relocs to obtain the information.)
912
- if (config-> copyRelocs ) {
912
+ if (ctx. arg . copyRelocs ) {
913
913
auto *isec = makeThreadLocal<InputSection>(
914
914
*this , sec, check (obj.getSectionName (sec, shstrtab)));
915
915
// If the relocated section is discarded (due to /DISCARD/ or
@@ -973,7 +973,7 @@ void readGnuProperty(const InputSection &sec, ObjFile<ELFT> &f) {
973
973
continue ;
974
974
}
975
975
976
- uint32_t featureAndType = config-> emachine == EM_AARCH64
976
+ uint32_t featureAndType = ctx. arg . emachine == EM_AARCH64
977
977
? GNU_PROPERTY_AARCH64_FEATURE_1_AND
978
978
: GNU_PROPERTY_X86_FEATURE_1_AND;
979
979
@@ -996,7 +996,7 @@ void readGnuProperty(const InputSection &sec, ObjFile<ELFT> &f) {
996
996
if (size < 4 )
997
997
reportFatal (place, " FEATURE_1_AND entry is too short" );
998
998
f.andFeatures |= read32<ELFT::Endianness>(desc.data ());
999
- } else if (config-> emachine == EM_AARCH64 &&
999
+ } else if (ctx. arg . emachine == EM_AARCH64 &&
1000
1000
type == GNU_PROPERTY_AARCH64_FEATURE_PAUTH) {
1001
1001
if (!f.aarch64PauthAbiCoreInfo .empty ()) {
1002
1002
reportFatal (data.data (),
@@ -1080,7 +1080,7 @@ InputSectionBase *ObjFile<ELFT>::createInputSection(uint32_t idx,
1080
1080
// see https://gcc.gnu.org/wiki/SplitStacks. An object file compiled
1081
1081
// for split stack will include a .note.GNU-split-stack section.
1082
1082
if (name == " .note.GNU-split-stack" ) {
1083
- if (config-> relocatable ) {
1083
+ if (ctx. arg . relocatable ) {
1084
1084
error (
1085
1085
" cannot mix split-stack and non-split-stack in a relocatable link" );
1086
1086
return &InputSection::discarded;
@@ -1109,7 +1109,7 @@ InputSectionBase *ObjFile<ELFT>::createInputSection(uint32_t idx,
1109
1109
// The linker merges EH (exception handling) frames and creates a
1110
1110
// .eh_frame_hdr section for runtime. So we handle them with a special
1111
1111
// class. For relocatable outputs, they are just passed through.
1112
- if (name == " .eh_frame" && !config-> relocatable )
1112
+ if (name == " .eh_frame" && !ctx. arg . relocatable )
1113
1113
return makeThreadLocal<EhInputSection>(*this , sec, name);
1114
1114
1115
1115
if ((sec.sh_flags & SHF_MERGE) && shouldMerge (sec, name))
@@ -1358,7 +1358,7 @@ unsigned SharedFile::vernauxNum;
1358
1358
1359
1359
SharedFile::SharedFile (MemoryBufferRef m, StringRef defaultSoName)
1360
1360
: ELFFileBase(SharedKind, getELFKind(m, " " ), m), soName(defaultSoName),
1361
- isNeeded(!config-> asNeeded) {}
1361
+ isNeeded(!ctx.arg. asNeeded) {}
1362
1362
1363
1363
// Parse the version definitions in the object file if present, and return a
1364
1364
// vector whose nth element contains a pointer to the Elf_Verdef for version
@@ -1578,7 +1578,7 @@ template <class ELFT> void SharedFile::parse() {
1578
1578
Undefined{this , name, sym.getBinding (), sym.st_other , sym.getType ()});
1579
1579
s->exportDynamic = true ;
1580
1580
if (sym.getBinding () != STB_WEAK &&
1581
- config-> unresolvedSymbolsInShlib != UnresolvedPolicy::Ignore)
1581
+ ctx. arg . unresolvedSymbolsInShlib != UnresolvedPolicy::Ignore)
1582
1582
requiredSymbols.push_back (s);
1583
1583
continue ;
1584
1584
}
@@ -1588,7 +1588,7 @@ template <class ELFT> void SharedFile::parse() {
1588
1588
// In GNU ld < 2.31 (before 3be08ea4728b56d35e136af4e6fd3086ade17764), the
1589
1589
// MIPS port puts _gp_disp symbol into DSO files and incorrectly assigns
1590
1590
// VER_NDX_LOCAL. Workaround this bug.
1591
- if (config-> emachine == EM_MIPS && name == " _gp_disp" )
1591
+ if (ctx. arg . emachine == EM_MIPS && name == " _gp_disp" )
1592
1592
continue ;
1593
1593
error (" corrupt input file: version definition index " + Twine (idx) +
1594
1594
" for symbol " + name + " is out of bounds\n >>> defined in " +
@@ -1702,7 +1702,7 @@ BitcodeFile::BitcodeFile(MemoryBufferRef mb, StringRef archiveName,
1702
1702
this ->lazy = lazy;
1703
1703
1704
1704
std::string path = mb.getBufferIdentifier ().str ();
1705
- if (config-> thinLTOIndexOnly )
1705
+ if (ctx. arg . thinLTOIndexOnly )
1706
1706
path = replaceThinLTOSuffix (mb.getBufferIdentifier ());
1707
1707
1708
1708
// ThinLTO assumes that all MemoryBufferRefs given to it have a unique
@@ -1917,7 +1917,7 @@ bool InputFile::shouldExtractForCommon(StringRef name) const {
1917
1917
}
1918
1918
1919
1919
std::string elf::replaceThinLTOSuffix (StringRef path) {
1920
- auto [suffix, repl] = config-> thinLTOObjectSuffixReplace ;
1920
+ auto [suffix, repl] = ctx. arg . thinLTOObjectSuffixReplace ;
1921
1921
if (path.consume_back (suffix))
1922
1922
return (path + repl).str ();
1923
1923
return std::string (path);
0 commit comments