diff options
| author | Fangrui Song <i@maskray.me> | 2024-10-06 18:09:52 -0700 |
|---|---|---|
| committer | Fangrui Song <i@maskray.me> | 2024-10-06 18:09:52 -0700 |
| commit | b672071ba51ef6b64651a62bcfaf78bdfdb7d3d4 (patch) | |
| tree | ceec644e07c1665e245095619a88091f700201c8 /lld/ELF/InputFiles.cpp | |
| parent | f0bd62d8709a49dd87eb75411e41e2e11e0ab59d (diff) | |
[ELF] Pass Ctx & to InputFile
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
| -rw-r--r-- | lld/ELF/InputFiles.cpp | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index d2ba5b2e4f8f..39a78a65bd7c 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -202,8 +202,8 @@ static void updateSupportedARMFeatures(Ctx &ctx, ctx.arg.armHasThumb2ISA |= thumb && *thumb >= ARMBuildAttrs::AllowThumb32; } -InputFile::InputFile(Kind k, MemoryBufferRef m) - : mb(m), groupId(ctx.driver.nextGroupId), fileKind(k) { +InputFile::InputFile(Ctx &ctx, Kind k, MemoryBufferRef m) + : ctx(ctx), mb(m), groupId(ctx.driver.nextGroupId), fileKind(k) { // All files within the same --{start,end}-group get the same group ID. // Otherwise, a new file will get a new group ID. if (!ctx.driver.isInGroup) @@ -509,8 +509,8 @@ ObjFile<ELFT>::getDILineInfo(const InputSectionBase *s, uint64_t offset) { return getDwarf()->getDILineInfo(offset, sectionIndex); } -ELFFileBase::ELFFileBase(Kind k, ELFKind ekind, MemoryBufferRef mb) - : InputFile(k, mb) { +ELFFileBase::ELFFileBase(Ctx &ctx, Kind k, ELFKind ekind, MemoryBufferRef mb) + : InputFile(ctx, k, mb) { this->ekind = ekind; } @@ -950,7 +950,8 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats, // hardware-assisted call flow control; // - AArch64 PAuth ABI core info (16 bytes). template <class ELFT> -void readGnuProperty(const InputSection &sec, ObjFile<ELFT> &f) { +static void readGnuProperty(Ctx &ctx, const InputSection &sec, + ObjFile<ELFT> &f) { using Elf_Nhdr = typename ELFT::Nhdr; using Elf_Note = typename ELFT::Note; @@ -1070,7 +1071,7 @@ InputSectionBase *ObjFile<ELFT>::createInputSection(uint32_t idx, // .note.gnu.property containing a single AND'ed bitmap, we discard an input // file's .note.gnu.property section. if (name == ".note.gnu.property") { - readGnuProperty<ELFT>(InputSection(*this, sec, name), *this); + readGnuProperty<ELFT>(ctx, InputSection(*this, sec, name), *this); return &InputSection::discarded; } @@ -1127,10 +1128,10 @@ void ObjFile<ELFT>::initializeSymbols(const object::ELFFile<ELFT> &obj) { } // Some entries have been filled by LazyObjFile. + auto *symtab = ctx.symtab.get(); for (size_t i = firstGlobal, end = eSyms.size(); i != end; ++i) if (!symbols[i]) - symbols[i] = - ctx.symtab->insert(CHECK(eSyms[i].getName(stringTable), this)); + symbols[i] = symtab->insert(CHECK(eSyms[i].getName(stringTable), this)); // Perform symbol resolution on non-local symbols. SmallVector<unsigned, 32> undefineds; @@ -1325,7 +1326,7 @@ static bool isBitcodeNonCommonDef(MemoryBufferRef mb, StringRef symName, template <class ELFT> static bool isNonCommonDef(ELFKind ekind, MemoryBufferRef mb, StringRef symName, StringRef archiveName) { - ObjFile<ELFT> *obj = make<ObjFile<ELFT>>(ekind, mb, archiveName); + ObjFile<ELFT> *obj = make<ObjFile<ELFT>>(ctx, ekind, mb, archiveName); obj->init(); StringRef stringtable = obj->getStringTable(); @@ -1357,7 +1358,7 @@ static bool isNonCommonDef(MemoryBufferRef mb, StringRef symName, unsigned SharedFile::vernauxNum; SharedFile::SharedFile(Ctx &ctx, MemoryBufferRef m, StringRef defaultSoName) - : ELFFileBase(SharedKind, getELFKind(m, ""), m), soName(defaultSoName), + : ELFFileBase(ctx, SharedKind, getELFKind(m, ""), m), soName(defaultSoName), isNeeded(!ctx.arg.asNeeded) {} // Parse the version definitions in the object file if present, and return a @@ -1697,7 +1698,7 @@ static uint8_t getOsAbi(const Triple &t) { BitcodeFile::BitcodeFile(Ctx &ctx, MemoryBufferRef mb, StringRef archiveName, uint64_t offsetInArchive, bool lazy) - : InputFile(BitcodeKind, mb) { + : InputFile(ctx, BitcodeKind, mb) { this->archiveName = archiveName; this->lazy = lazy; @@ -1859,30 +1860,30 @@ void BinaryFile::parse() { data.size(), 0, nullptr}); } -InputFile *elf::createInternalFile(StringRef name) { +InputFile *elf::createInternalFile(Ctx &ctx, StringRef name) { auto *file = - make<InputFile>(InputFile::InternalKind, MemoryBufferRef("", name)); + make<InputFile>(ctx, InputFile::InternalKind, MemoryBufferRef("", name)); // References from an internal file do not lead to --warn-backrefs // diagnostics. file->groupId = 0; return file; } -ELFFileBase *elf::createObjFile(MemoryBufferRef mb, StringRef archiveName, - bool lazy) { +ELFFileBase *elf::createObjFile(Ctx &ctx, MemoryBufferRef mb, + StringRef archiveName, bool lazy) { ELFFileBase *f; switch (getELFKind(mb, archiveName)) { case ELF32LEKind: - f = make<ObjFile<ELF32LE>>(ELF32LEKind, mb, archiveName); + f = make<ObjFile<ELF32LE>>(ctx, ELF32LEKind, mb, archiveName); break; case ELF32BEKind: - f = make<ObjFile<ELF32BE>>(ELF32BEKind, mb, archiveName); + f = make<ObjFile<ELF32BE>>(ctx, ELF32BEKind, mb, archiveName); break; case ELF64LEKind: - f = make<ObjFile<ELF64LE>>(ELF64LEKind, mb, archiveName); + f = make<ObjFile<ELF64LE>>(ctx, ELF64LEKind, mb, archiveName); break; case ELF64BEKind: - f = make<ObjFile<ELF64BE>>(ELF64BEKind, mb, archiveName); + f = make<ObjFile<ELF64BE>>(ctx, ELF64BEKind, mb, archiveName); break; default: llvm_unreachable("getELFKind"); |
