@@ -102,7 +102,7 @@ static ELFKind getELFKind(MemoryBufferRef mb, StringRef archiveName) {
102
102
// For ARM only, to set the EF_ARM_ABI_FLOAT_SOFT or EF_ARM_ABI_FLOAT_HARD
103
103
// flag in the ELF Header we need to look at Tag_ABI_VFP_args to find out how
104
104
// the input objects have been compiled.
105
- static void updateARMVFPArgs (const ARMAttributeParser &attributes,
105
+ static void updateARMVFPArgs (Ctx &ctx, const ARMAttributeParser &attributes,
106
106
const InputFile *f) {
107
107
std::optional<unsigned > attr =
108
108
attributes.getAttributeValue (ARMBuildAttrs::ABI_VFP_args);
@@ -150,7 +150,8 @@ static void updateARMVFPArgs(const ARMAttributeParser &attributes,
150
150
// at compile time. We follow the convention that if at least one input object
151
151
// is compiled with an architecture that supports these features then lld is
152
152
// permitted to use them.
153
- static void updateSupportedARMFeatures (const ARMAttributeParser &attributes) {
153
+ static void updateSupportedARMFeatures (Ctx &ctx,
154
+ const ARMAttributeParser &attributes) {
154
155
std::optional<unsigned > attr =
155
156
attributes.getAttributeValue (ARMBuildAttrs::CPU_arch);
156
157
if (!attr)
@@ -264,7 +265,7 @@ std::optional<MemoryBufferRef> elf::readFile(StringRef path) {
264
265
// All input object files must be for the same architecture
265
266
// (e.g. it does not make sense to link x86 object files with
266
267
// MIPS object files.) This function checks for that error.
267
- static bool isCompatible (InputFile *file) {
268
+ static bool isCompatible (Ctx &ctx, InputFile *file) {
268
269
if (!file->isElf () && !isa<BitcodeFile>(file))
269
270
return true ;
270
271
@@ -297,7 +298,7 @@ static bool isCompatible(InputFile *file) {
297
298
}
298
299
299
300
template <class ELFT > static void doParseFile (Ctx &ctx, InputFile *file) {
300
- if (!isCompatible (file))
301
+ if (!isCompatible (ctx, file))
301
302
return ;
302
303
303
304
// Lazy object file
@@ -418,7 +419,8 @@ StringRef InputFile::getNameForScript() const {
418
419
// the various ways that a library can be specified to LLD. This ELF extension
419
420
// is a form of autolinking and is called `dependent libraries`. It is currently
420
421
// unique to LLVM and lld.
421
- static void addDependentLibrary (StringRef specifier, const InputFile *f) {
422
+ static void addDependentLibrary (Ctx &ctx, StringRef specifier,
423
+ const InputFile *f) {
422
424
if (!ctx.arg .dependentLibraries )
423
425
return ;
424
426
if (std::optional<std::string> s = searchLibraryBaseName (specifier))
@@ -611,7 +613,7 @@ template <class ELFT> void ObjFile<ELFT>::parse(bool ignoreComdats) {
611
613
} else {
612
614
for (const char *d = data.begin (), *e = data.end (); d < e;) {
613
615
StringRef s (d);
614
- addDependentLibrary (s, this );
616
+ addDependentLibrary (ctx, s, this );
615
617
d += s.size () + 1 ;
616
618
}
617
619
}
@@ -631,8 +633,8 @@ template <class ELFT> void ObjFile<ELFT>::parse(bool ignoreComdats) {
631
633
InputSection isec (*this , sec, name);
632
634
warn (toString (&isec) + " : " + llvm::toString (std::move (e)));
633
635
} else {
634
- updateSupportedARMFeatures (attributes);
635
- updateARMVFPArgs (attributes, this );
636
+ updateSupportedARMFeatures (ctx, attributes);
637
+ updateARMVFPArgs (ctx, attributes, this );
636
638
637
639
// FIXME: Retain the first attribute section we see. The eglibc ARM
638
640
// dynamic loaders require the presence of an attribute section for
@@ -1704,7 +1706,7 @@ BitcodeFile::BitcodeFile(MemoryBufferRef mb, StringRef archiveName,
1704
1706
1705
1707
std::string path = mb.getBufferIdentifier ().str ();
1706
1708
if (ctx.arg .thinLTOIndexOnly )
1707
- path = replaceThinLTOSuffix (mb.getBufferIdentifier ());
1709
+ path = replaceThinLTOSuffix (ctx, mb.getBufferIdentifier ());
1708
1710
1709
1711
// ThinLTO assumes that all MemoryBufferRefs given to it have a unique
1710
1712
// name. If two archives define two members with the same name, this
@@ -1738,9 +1740,10 @@ static uint8_t mapVisibility(GlobalValue::VisibilityTypes gvVisibility) {
1738
1740
llvm_unreachable (" unknown visibility" );
1739
1741
}
1740
1742
1741
- static void
1742
- createBitcodeSymbol (Symbol *&sym, const std::vector<bool > &keptComdats,
1743
- const lto::InputFile::Symbol &objSym, BitcodeFile &f) {
1743
+ static void createBitcodeSymbol (Ctx &ctx, Symbol *&sym,
1744
+ const std::vector<bool > &keptComdats,
1745
+ const lto::InputFile::Symbol &objSym,
1746
+ BitcodeFile &f) {
1744
1747
uint8_t binding = objSym.isWeak () ? STB_WEAK : STB_GLOBAL;
1745
1748
uint8_t type = objSym.isTLS () ? STT_TLS : STT_NOTYPE;
1746
1749
uint8_t visibility = mapVisibility (objSym.getVisibility ());
@@ -1791,13 +1794,13 @@ void BitcodeFile::parse() {
1791
1794
// ObjFile<ELFT>::initializeSymbols.
1792
1795
for (auto [i, irSym] : llvm::enumerate (obj->symbols ()))
1793
1796
if (!irSym.isUndefined ())
1794
- createBitcodeSymbol (symbols[i], keptComdats, irSym, *this );
1797
+ createBitcodeSymbol (ctx, symbols[i], keptComdats, irSym, *this );
1795
1798
for (auto [i, irSym] : llvm::enumerate (obj->symbols ()))
1796
1799
if (irSym.isUndefined ())
1797
- createBitcodeSymbol (symbols[i], keptComdats, irSym, *this );
1800
+ createBitcodeSymbol (ctx, symbols[i], keptComdats, irSym, *this );
1798
1801
1799
1802
for (auto l : obj->getDependentLibraries ())
1800
- addDependentLibrary (l, this );
1803
+ addDependentLibrary (ctx, l, this );
1801
1804
}
1802
1805
1803
1806
void BitcodeFile::parseLazy () {
@@ -1917,7 +1920,7 @@ bool InputFile::shouldExtractForCommon(StringRef name) const {
1917
1920
return isNonCommonDef (mb, name, archiveName);
1918
1921
}
1919
1922
1920
- std::string elf::replaceThinLTOSuffix (StringRef path) {
1923
+ std::string elf::replaceThinLTOSuffix (Ctx &ctx, StringRef path) {
1921
1924
auto [suffix, repl] = ctx.arg .thinLTOObjectSuffixReplace ;
1922
1925
if (path.consume_back (suffix))
1923
1926
return (path + repl).str ();
0 commit comments