@@ -202,8 +202,8 @@ static void updateSupportedARMFeatures(Ctx &ctx,
202202 ctx.arg .armHasThumb2ISA |= thumb && *thumb >= ARMBuildAttrs::AllowThumb32;
203203}
204204
205- InputFile::InputFile (Kind k, MemoryBufferRef m)
206- : mb(m), groupId(ctx.driver.nextGroupId), fileKind(k) {
205+ InputFile::InputFile (Ctx &ctx, Kind k, MemoryBufferRef m)
206+ : ctx(ctx), mb(m), groupId(ctx.driver.nextGroupId), fileKind(k) {
207207 // All files within the same --{start,end}-group get the same group ID.
208208 // Otherwise, a new file will get a new group ID.
209209 if (!ctx.driver .isInGroup )
@@ -509,8 +509,8 @@ ObjFile<ELFT>::getDILineInfo(const InputSectionBase *s, uint64_t offset) {
509509 return getDwarf ()->getDILineInfo (offset, sectionIndex);
510510}
511511
512- ELFFileBase::ELFFileBase (Kind k, ELFKind ekind, MemoryBufferRef mb)
513- : InputFile(k, mb) {
512+ ELFFileBase::ELFFileBase (Ctx &ctx, Kind k, ELFKind ekind, MemoryBufferRef mb)
513+ : InputFile(ctx, k, mb) {
514514 this ->ekind = ekind;
515515}
516516
@@ -950,7 +950,8 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
950950// hardware-assisted call flow control;
951951// - AArch64 PAuth ABI core info (16 bytes).
952952template <class ELFT >
953- void readGnuProperty (const InputSection &sec, ObjFile<ELFT> &f) {
953+ static void readGnuProperty (Ctx &ctx, const InputSection &sec,
954+ ObjFile<ELFT> &f) {
954955 using Elf_Nhdr = typename ELFT::Nhdr;
955956 using Elf_Note = typename ELFT::Note;
956957
@@ -1070,7 +1071,7 @@ InputSectionBase *ObjFile<ELFT>::createInputSection(uint32_t idx,
10701071 // .note.gnu.property containing a single AND'ed bitmap, we discard an input
10711072 // file's .note.gnu.property section.
10721073 if (name == " .note.gnu.property" ) {
1073- readGnuProperty<ELFT>(InputSection (*this , sec, name), *this );
1074+ readGnuProperty<ELFT>(ctx, InputSection (*this , sec, name), *this );
10741075 return &InputSection::discarded;
10751076 }
10761077
@@ -1127,10 +1128,10 @@ void ObjFile<ELFT>::initializeSymbols(const object::ELFFile<ELFT> &obj) {
11271128 }
11281129
11291130 // Some entries have been filled by LazyObjFile.
1131+ auto *symtab = ctx.symtab .get ();
11301132 for (size_t i = firstGlobal, end = eSyms.size (); i != end; ++i)
11311133 if (!symbols[i])
1132- symbols[i] =
1133- ctx.symtab ->insert (CHECK (eSyms[i].getName (stringTable), this ));
1134+ symbols[i] = symtab->insert (CHECK (eSyms[i].getName (stringTable), this ));
11341135
11351136 // Perform symbol resolution on non-local symbols.
11361137 SmallVector<unsigned , 32 > undefineds;
@@ -1325,7 +1326,7 @@ static bool isBitcodeNonCommonDef(MemoryBufferRef mb, StringRef symName,
13251326template <class ELFT >
13261327static bool isNonCommonDef (ELFKind ekind, MemoryBufferRef mb, StringRef symName,
13271328 StringRef archiveName) {
1328- ObjFile<ELFT> *obj = make<ObjFile<ELFT>>(ekind, mb, archiveName);
1329+ ObjFile<ELFT> *obj = make<ObjFile<ELFT>>(ctx, ekind, mb, archiveName);
13291330 obj->init ();
13301331 StringRef stringtable = obj->getStringTable ();
13311332
@@ -1357,7 +1358,7 @@ static bool isNonCommonDef(MemoryBufferRef mb, StringRef symName,
13571358unsigned SharedFile::vernauxNum;
13581359
13591360SharedFile::SharedFile (Ctx &ctx, MemoryBufferRef m, StringRef defaultSoName)
1360- : ELFFileBase(SharedKind, getELFKind(m, " " ), m), soName(defaultSoName),
1361+ : ELFFileBase(ctx, SharedKind, getELFKind(m, " " ), m), soName(defaultSoName),
13611362 isNeeded(!ctx.arg.asNeeded) {}
13621363
13631364// Parse the version definitions in the object file if present, and return a
@@ -1697,7 +1698,7 @@ static uint8_t getOsAbi(const Triple &t) {
16971698
16981699BitcodeFile::BitcodeFile (Ctx &ctx, MemoryBufferRef mb, StringRef archiveName,
16991700 uint64_t offsetInArchive, bool lazy)
1700- : InputFile(BitcodeKind, mb) {
1701+ : InputFile(ctx, BitcodeKind, mb) {
17011702 this ->archiveName = archiveName;
17021703 this ->lazy = lazy;
17031704
@@ -1859,30 +1860,30 @@ void BinaryFile::parse() {
18591860 data.size (), 0 , nullptr });
18601861}
18611862
1862- InputFile *elf::createInternalFile (StringRef name) {
1863+ InputFile *elf::createInternalFile (Ctx &ctx, StringRef name) {
18631864 auto *file =
1864- make<InputFile>(InputFile::InternalKind, MemoryBufferRef (" " , name));
1865+ make<InputFile>(ctx, InputFile::InternalKind, MemoryBufferRef (" " , name));
18651866 // References from an internal file do not lead to --warn-backrefs
18661867 // diagnostics.
18671868 file->groupId = 0 ;
18681869 return file;
18691870}
18701871
1871- ELFFileBase *elf::createObjFile (MemoryBufferRef mb, StringRef archiveName ,
1872- bool lazy) {
1872+ ELFFileBase *elf::createObjFile (Ctx &ctx, MemoryBufferRef mb ,
1873+ StringRef archiveName, bool lazy) {
18731874 ELFFileBase *f;
18741875 switch (getELFKind (mb, archiveName)) {
18751876 case ELF32LEKind:
1876- f = make<ObjFile<ELF32LE>>(ELF32LEKind, mb, archiveName);
1877+ f = make<ObjFile<ELF32LE>>(ctx, ELF32LEKind, mb, archiveName);
18771878 break ;
18781879 case ELF32BEKind:
1879- f = make<ObjFile<ELF32BE>>(ELF32BEKind, mb, archiveName);
1880+ f = make<ObjFile<ELF32BE>>(ctx, ELF32BEKind, mb, archiveName);
18801881 break ;
18811882 case ELF64LEKind:
1882- f = make<ObjFile<ELF64LE>>(ELF64LEKind, mb, archiveName);
1883+ f = make<ObjFile<ELF64LE>>(ctx, ELF64LEKind, mb, archiveName);
18831884 break ;
18841885 case ELF64BEKind:
1885- f = make<ObjFile<ELF64BE>>(ELF64BEKind, mb, archiveName);
1886+ f = make<ObjFile<ELF64BE>>(ctx, ELF64BEKind, mb, archiveName);
18861887 break ;
18871888 default :
18881889 llvm_unreachable (" getELFKind" );
0 commit comments