diff options
author | Fangrui Song <i@maskray.me> | 2024-11-16 22:34:12 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2024-11-16 22:34:13 -0800 |
commit | 2991a4e2097ab3f32d37fdceab08c658836e312c (patch) | |
tree | 7bf051059609d96ea3b9405be68384db17a4c378 | |
parent | 8f238f662c8237b88392f8a94469cd50d86636d6 (diff) | |
download | llvm-2991a4e2097ab3f32d37fdceab08c658836e312c.zip llvm-2991a4e2097ab3f32d37fdceab08c658836e312c.tar.gz llvm-2991a4e2097ab3f32d37fdceab08c658836e312c.tar.bz2 |
[ELF] Replace functions bAlloc/saver/uniqueSaver with member access
-rw-r--r-- | lld/ELF/AArch64ErrataFix.cpp | 4 | ||||
-rw-r--r-- | lld/ELF/ARMErrataFix.cpp | 4 | ||||
-rw-r--r-- | lld/ELF/Arch/LoongArch.cpp | 2 | ||||
-rw-r--r-- | lld/ELF/Arch/PPC64.cpp | 2 | ||||
-rw-r--r-- | lld/ELF/Arch/RISCV.cpp | 4 | ||||
-rw-r--r-- | lld/ELF/Config.h | 6 | ||||
-rw-r--r-- | lld/ELF/Driver.cpp | 9 | ||||
-rw-r--r-- | lld/ELF/DriverUtils.cpp | 4 | ||||
-rw-r--r-- | lld/ELF/InputFiles.cpp | 17 | ||||
-rw-r--r-- | lld/ELF/InputSection.cpp | 2 | ||||
-rw-r--r-- | lld/ELF/LTO.cpp | 6 | ||||
-rw-r--r-- | lld/ELF/LinkerScript.cpp | 2 | ||||
-rw-r--r-- | lld/ELF/MarkLive.cpp | 4 | ||||
-rw-r--r-- | lld/ELF/OutputSections.cpp | 4 | ||||
-rw-r--r-- | lld/ELF/ScriptParser.cpp | 6 | ||||
-rw-r--r-- | lld/ELF/SyntheticSections.cpp | 4 | ||||
-rw-r--r-- | lld/ELF/Thunks.cpp | 65 | ||||
-rw-r--r-- | lld/ELF/Writer.cpp | 2 |
18 files changed, 69 insertions, 78 deletions
diff --git a/lld/ELF/AArch64ErrataFix.cpp b/lld/ELF/AArch64ErrataFix.cpp index 038d4e0..7c65b8ae 100644 --- a/lld/ELF/AArch64ErrataFix.cpp +++ b/lld/ELF/AArch64ErrataFix.cpp @@ -398,9 +398,9 @@ Patch843419Section::Patch843419Section(Ctx &ctx, InputSection *p, uint64_t off) patchee(p), patcheeOffset(off) { this->parent = p->getParent(); patchSym = addSyntheticLocal( - ctx, saver(ctx).save("__CortexA53843419_" + utohexstr(getLDSTAddr())), + ctx, ctx.saver.save("__CortexA53843419_" + utohexstr(getLDSTAddr())), STT_FUNC, 0, getSize(), *this); - addSyntheticLocal(ctx, saver(ctx).save("$x"), STT_NOTYPE, 0, 0, *this); + addSyntheticLocal(ctx, ctx.saver.save("$x"), STT_NOTYPE, 0, 0, *this); } uint64_t Patch843419Section::getLDSTAddr() const { diff --git a/lld/ELF/ARMErrataFix.cpp b/lld/ELF/ARMErrataFix.cpp index 15bfbaa..4257e49 100644 --- a/lld/ELF/ARMErrataFix.cpp +++ b/lld/ELF/ARMErrataFix.cpp @@ -141,9 +141,9 @@ Patch657417Section::Patch657417Section(Ctx &ctx, InputSection *p, uint64_t off, patchee(p), patcheeOffset(off), instr(instr), isARM(isARM) { parent = p->getParent(); patchSym = addSyntheticLocal( - ctx, saver(ctx).save("__CortexA8657417_" + utohexstr(getBranchAddr())), + ctx, ctx.saver.save("__CortexA8657417_" + utohexstr(getBranchAddr())), STT_FUNC, isARM ? 0 : 1, getSize(), *this); - addSyntheticLocal(ctx, saver(ctx).save(isARM ? "$a" : "$t"), STT_NOTYPE, 0, 0, + addSyntheticLocal(ctx, ctx.saver.save(isARM ? "$a" : "$t"), STT_NOTYPE, 0, 0, *this); } diff --git a/lld/ELF/Arch/LoongArch.cpp b/lld/ELF/Arch/LoongArch.cpp index 7a66058..0eb56de 100644 --- a/lld/ELF/Arch/LoongArch.cpp +++ b/lld/ELF/Arch/LoongArch.cpp @@ -851,7 +851,7 @@ void LoongArch::finalizeRelax(int passes) const { MutableArrayRef<Relocation> rels = sec->relocs(); ArrayRef<uint8_t> old = sec->content(); size_t newSize = old.size() - aux.relocDeltas[rels.size() - 1]; - uint8_t *p = bAlloc(ctx).Allocate<uint8_t>(newSize); + uint8_t *p = ctx.bAlloc.Allocate<uint8_t>(newSize); uint64_t offset = 0; int64_t delta = 0; sec->content_ = p; diff --git a/lld/ELF/Arch/PPC64.cpp b/lld/ELF/Arch/PPC64.cpp index cb0a94e..4dc9f93 100644 --- a/lld/ELF/Arch/PPC64.cpp +++ b/lld/ELF/Arch/PPC64.cpp @@ -271,7 +271,7 @@ static void writeSequence(Ctx &ctx, const char *prefix, int from, char name[16]; int first; const size_t size = 32 - from + tail.size(); - MutableArrayRef<uint32_t> buf(bAlloc(ctx).Allocate<uint32_t>(size), size); + MutableArrayRef<uint32_t> buf(ctx.bAlloc.Allocate<uint32_t>(size), size); uint32_t *ptr = buf.data(); for (int r = from; r < 32; ++r) { format("%s%d", prefix, r).snprint(name, sizeof(name)); diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp index 1f83ffa..5368ced 100644 --- a/lld/ELF/Arch/RISCV.cpp +++ b/lld/ELF/Arch/RISCV.cpp @@ -947,7 +947,7 @@ void RISCV::finalizeRelax(int passes) const { ArrayRef<uint8_t> old = sec->content(); size_t newSize = old.size() - aux.relocDeltas[rels.size() - 1]; size_t writesIdx = 0; - uint8_t *p = bAlloc(ctx).Allocate<uint8_t>(newSize); + uint8_t *p = ctx.bAlloc.Allocate<uint8_t>(newSize); uint64_t offset = 0; int64_t delta = 0; sec->content_ = p; @@ -1257,7 +1257,7 @@ mergeAttributesSection(Ctx &ctx, if (hasArch && xlen != 0) { if (auto result = RISCVISAInfo::createFromExtMap(xlen, exts)) { merged.strAttr.try_emplace(RISCVAttrs::ARCH, - saver(ctx).save((*result)->toString())); + ctx.saver.save((*result)->toString())); } else { Err(ctx) << result.takeError(); } diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index 431d675..8da1ead 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -686,12 +686,6 @@ static inline ArrayRef<VersionDefinition> namedVersionDefs(Ctx &ctx) { return llvm::ArrayRef(ctx.arg.versionDefinitions).slice(2); } -inline llvm::BumpPtrAllocator &bAlloc(Ctx &ctx) { return ctx.bAlloc; } -inline llvm::StringSaver &saver(Ctx &ctx) { return ctx.saver; } -inline llvm::UniqueStringSaver &uniqueSaver(Ctx &ctx) { - return ctx.uniqueSaver; -} - struct ELFSyncStream : SyncStream { Ctx &ctx; ELFSyncStream(Ctx &ctx, DiagLevel level) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 927fa9d..6e20d9a 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -330,7 +330,7 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) { // Add a given library by searching it from input search paths. void LinkerDriver::addLibrary(StringRef name) { if (std::optional<std::string> path = searchLibrary(ctx, name)) - addFile(saver(ctx).save(*path), /*withLOption=*/true); + addFile(ctx.saver.save(*path), /*withLOption=*/true); else ctx.e.error("unable to find library -l" + name, ErrorTag::LibNotFound, {name}); @@ -1619,8 +1619,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) { // Parse LTO options. if (auto *arg = args.getLastArg(OPT_plugin_opt_mcpu_eq)) - parseClangOption(ctx, - saver(ctx).save("-mcpu=" + StringRef(arg->getValue())), + parseClangOption(ctx, ctx.saver.save("-mcpu=" + StringRef(arg->getValue())), arg->getSpelling()); for (opt::Arg *arg : args.filtered(OPT_plugin_opt_eq_minus)) @@ -2567,7 +2566,7 @@ static std::vector<WrappedSymbol> addWrappedSymbols(Ctx &ctx, opt::InputArgList &args) { std::vector<WrappedSymbol> v; DenseSet<StringRef> seen; - auto &ss = saver(ctx); + auto &ss = ctx.saver; for (auto *arg : args.filtered(OPT_wrap)) { StringRef name = arg->getValue(); if (!seen.insert(name).second) @@ -2582,7 +2581,7 @@ static std::vector<WrappedSymbol> addWrappedSymbols(Ctx &ctx, // If __real_ is referenced, pull in the symbol if it is lazy. Do this after // processing __wrap_ as that may have referenced __real_. - StringRef realName = saver(ctx).save("__real_" + name); + StringRef realName = ctx.saver.save("__real_" + name); if (Symbol *real = ctx.symtab->find(realName)) { ctx.symtab->addUnusedUndefined(name, sym->binding); // Update sym's binding, which will replace real's later in diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp index 97ede74..0278c07 100644 --- a/lld/ELF/DriverUtils.cpp +++ b/lld/ELF/DriverUtils.cpp @@ -95,7 +95,7 @@ static void concatLTOPluginOptions(Ctx &ctx, for (size_t i = 0, e = args.size(); i != e; ++i) { StringRef s = args[i]; if ((s == "-plugin-opt" || s == "--plugin-opt") && i + 1 != e) { - v.push_back(saver(ctx).save(s + "=" + args[i + 1]).data()); + v.push_back(ctx.saver.save(s + "=" + args[i + 1]).data()); ++i; } else { v.push_back(args[i]); @@ -118,7 +118,7 @@ opt::InputArgList ELFOptTable::parse(Ctx &ctx, ArrayRef<const char *> argv) { // Expand response files (arguments in the form of @<filename>) // and then parse the argument again. - cl::ExpandResponseFiles(saver(ctx), getQuotingStyle(ctx, args), vec); + cl::ExpandResponseFiles(ctx.saver, getQuotingStyle(ctx, args), vec); concatLTOPluginOptions(ctx, vec); args = this->ParseArgs(vec, missingIndex, missingCount); diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 5f0c848..2249127 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -222,7 +222,7 @@ std::optional<MemoryBufferRef> elf::readFile(Ctx &ctx, StringRef path) { // The --chroot option changes our virtual root directory. // This is useful when you are dealing with files created by --reproduce. if (!ctx.arg.chroot.empty() && path.starts_with("/")) - path = saver(ctx).save(ctx.arg.chroot + path); + path = ctx.saver.save(ctx.arg.chroot + path); bool remapped = false; auto it = ctx.arg.remapInputs.find(path); @@ -427,9 +427,9 @@ static void addDependentLibrary(Ctx &ctx, StringRef specifier, if (!ctx.arg.dependentLibraries) return; if (std::optional<std::string> s = searchLibraryBaseName(ctx, specifier)) - ctx.driver.addFile(saver(ctx).save(*s), /*withLOption=*/true); + ctx.driver.addFile(ctx.saver.save(*s), /*withLOption=*/true); else if (std::optional<std::string> s = findFromSearchPaths(ctx, specifier)) - ctx.driver.addFile(saver(ctx).save(*s), /*withLOption=*/true); + ctx.driver.addFile(ctx.saver.save(*s), /*withLOption=*/true); else if (fs::exists(specifier)) ctx.driver.addFile(specifier, /*withLOption=*/false); else @@ -1512,7 +1512,7 @@ template <class ELFT> void SharedFile::parse() { } // DSOs are uniquified not by filename but by soname. - StringSaver &ss = saver(ctx); + StringSaver &ss = ctx.saver; DenseMap<CachedHashStringRef, SharedFile *>::iterator it; bool wasInserted; std::tie(it, wasInserted) = @@ -1720,7 +1720,7 @@ BitcodeFile::BitcodeFile(Ctx &ctx, MemoryBufferRef mb, StringRef archiveName, // into consideration at LTO time (which very likely causes undefined // symbols later in the link stage). So we append file offset to make // filename unique. - StringSaver &ss = saver(ctx); + StringSaver &ss = ctx.saver; StringRef name = archiveName.empty() ? ss.save(path) : ss.save(archiveName + "(" + path::filename(path) + @@ -1761,7 +1761,7 @@ static void createBitcodeSymbol(Ctx &ctx, Symbol *&sym, // Update objSym.Name to reference (via StringRef) the string saver's copy; // this way LTO can reference the same string saver's copy rather than // keeping copies of its own. - objSym.Name = uniqueSaver(ctx).save(objSym.getName()); + objSym.Name = ctx.uniqueSaver.save(objSym.getName()); sym = ctx.symtab->insert(objSym.getName()); } @@ -1814,14 +1814,13 @@ void BitcodeFile::parse() { void BitcodeFile::parseLazy() { numSymbols = obj->symbols().size(); symbols = std::make_unique<Symbol *[]>(numSymbols); - auto &ss = uniqueSaver(ctx); for (auto [i, irSym] : llvm::enumerate(obj->symbols())) { // Symbols can be duplicated in bitcode files because of '#include' and // linkonce_odr. Use uniqueSaver to save symbol names for de-duplication. // Update objSym.Name to reference (via StringRef) the string saver's copy; // this way LTO can reference the same string saver's copy rather than // keeping copies of its own. - irSym.Name = ss.save(irSym.getName()); + irSym.Name = ctx.uniqueSaver.save(irSym.getName()); if (!irSym.isUndefined()) { auto *sym = ctx.symtab->insert(irSym.getName()); sym->resolve(ctx, LazySymbol{*this}); @@ -1858,7 +1857,7 @@ void BinaryFile::parse() { if (!isAlnum(c)) c = '_'; - llvm::StringSaver &ss = saver(ctx); + llvm::StringSaver &ss = ctx.saver; ctx.symtab->addAndCheckDuplicate( ctx, Defined{ctx, this, ss.save(s + "_start"), STB_GLOBAL, STV_DEFAULT, STT_OBJECT, 0, 0, section}); diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index f297075..90d3fae 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -130,7 +130,7 @@ void InputSectionBase::decompress() const { { static std::mutex mu; std::lock_guard<std::mutex> lock(mu); - uncompressedBuf = bAlloc(ctx).Allocate<uint8_t>(size); + uncompressedBuf = ctx.bAlloc.Allocate<uint8_t>(size); } invokeELFT(decompressAux, ctx, *this, uncompressedBuf, size); diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp index 7379f97..4f57463 100644 --- a/lld/ELF/LTO.cpp +++ b/lld/ELF/LTO.cpp @@ -397,8 +397,8 @@ std::vector<InputFile *> BitcodeCompiler::compile() { StringRef ltoObjName; if (bitcodeFilePath == "ld-temp.o") { ltoObjName = - saver(ctx).save(Twine(ctx.arg.outputFile) + ".lto" + - (i == 0 ? Twine("") : Twine('.') + Twine(i)) + ext); + ctx.saver.save(Twine(ctx.arg.outputFile) + ".lto" + + (i == 0 ? Twine("") : Twine('.') + Twine(i)) + ext); } else { StringRef directory = sys::path::parent_path(bitcodeFilePath); // For an archive member, which has an identifier like "d/a.a(coll.o at @@ -412,7 +412,7 @@ std::vector<InputFile *> BitcodeCompiler::compile() { sys::path::append(path, directory, outputFileBaseName + ".lto." + baseName + ext); sys::path::remove_dots(path, true); - ltoObjName = saver(ctx).save(path.str()); + ltoObjName = ctx.saver.save(path.str()); } if (savePrelink || ctx.arg.ltoEmitAsm) saveBuffer(buf[i].second, ltoObjName); diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 0298294..d3a9302 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -59,7 +59,7 @@ StringRef LinkerScript::getOutputSectionName(const InputSectionBase *s) const { assert(ctx.arg.relocatable && (rel->flags & SHF_LINK_ORDER)); return s->name; } - StringSaver &ss = saver(ctx); + StringSaver &ss = ctx.saver; if (s->type == SHT_CREL) return ss.save(".crel" + out->name); if (s->type == SHT_RELA) diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp index df81d443..08d9ece 100644 --- a/lld/ELF/MarkLive.cpp +++ b/lld/ELF/MarkLive.cpp @@ -301,8 +301,8 @@ template <class ELFT> void MarkLive<ELFT>::run() { // As a workaround for glibc libc.a before 2.34 // (https://sourceware.org/PR27492), retain __libc_atexit and similar // sections regardless of zStartStopGC. - cNamedSections[saver(ctx).save("__start_" + sec->name)].push_back(sec); - cNamedSections[saver(ctx).save("__stop_" + sec->name)].push_back(sec); + cNamedSections[ctx.saver.save("__start_" + sec->name)].push_back(sec); + cNamedSections[ctx.saver.save("__stop_" + sec->name)].push_back(sec); } } diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index ccc8bb1..094524f 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -118,9 +118,9 @@ void OutputSection::commitSection(InputSection *isec) { type = SHT_CREL; if (type == SHT_REL) { if (name.consume_front(".rel")) - name = saver(ctx).save(".crel" + name); + name = ctx.saver.save(".crel" + name); } else if (name.consume_front(".rela")) { - name = saver(ctx).save(".crel" + name); + name = ctx.saver.save(".crel" + name); } } else { if (typeIsSet || !canMergeToProgbits(ctx, type) || diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index f7e3a5e..f53515c 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -317,7 +317,7 @@ void ScriptParser::addFile(StringRef s) { SmallString<128> pathData; StringRef path = (ctx.arg.sysroot + s).toStringRef(pathData); if (sys::fs::exists(path)) - ctx.driver.addFile(saver(ctx).save(path), /*withLOption=*/false); + ctx.driver.addFile(ctx.saver.save(path), /*withLOption=*/false); else setError("cannot find " + s + " inside " + ctx.arg.sysroot); return; @@ -331,7 +331,7 @@ void ScriptParser::addFile(StringRef s) { if (ctx.arg.sysroot.empty()) ctx.driver.addFile(s.substr(1), /*withLOption=*/false); else - ctx.driver.addFile(saver(ctx).save(ctx.arg.sysroot + "/" + s.substr(1)), + ctx.driver.addFile(ctx.saver.save(ctx.arg.sysroot + "/" + s.substr(1)), /*withLOption=*/false); } else if (s.starts_with("-l")) { // Case 3: search in the list of library paths. @@ -354,7 +354,7 @@ void ScriptParser::addFile(StringRef s) { } else { // Finally, search in the list of library paths. if (std::optional<std::string> path = findFromSearchPaths(ctx, s)) - ctx.driver.addFile(saver(ctx).save(*path), /*withLOption=*/true); + ctx.driver.addFile(ctx.saver.save(*path), /*withLOption=*/true); else setError("unable to find " + s); } diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 0dad0f7..3b97111 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -77,7 +77,7 @@ static ArrayRef<uint8_t> getVersion(Ctx &ctx) { // This is only for testing. StringRef s = getenv("LLD_VERSION"); if (s.empty()) - s = saver(ctx).save(Twine("Linker: ") + getLLDVersion()); + s = ctx.saver.save(Twine("Linker: ") + getLLDVersion()); // +1 to include the terminating '\0'. return {(const uint8_t *)s.data(), s.size() + 1}; @@ -270,7 +270,7 @@ MipsReginfoSection<ELFT>::create(Ctx &ctx) { InputSection *elf::createInterpSection(Ctx &ctx) { // StringSaver guarantees that the returned string ends with '\0'. - StringRef s = saver(ctx).save(ctx.arg.dynamicLinker); + StringRef s = ctx.saver.save(ctx.arg.dynamicLinker); ArrayRef<uint8_t> contents = {(const uint8_t *)s.data(), s.size() + 1}; return make<InputSection>(ctx.internalFile, SHF_ALLOC, SHT_PROGBITS, 1, diff --git a/lld/ELF/Thunks.cpp b/lld/ELF/Thunks.cpp index 7c5bd05..c962545 100644 --- a/lld/ELF/Thunks.cpp +++ b/lld/ELF/Thunks.cpp @@ -599,7 +599,7 @@ void AArch64ABSLongThunk::writeLong(uint8_t *buf) { } void AArch64ABSLongThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__AArch64AbsLongThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__AArch64AbsLongThunk_" + destination.getName()), STT_FUNC, 0, isec); addSymbol("$x", STT_NOTYPE, 0, isec); if (!getMayUseShortThunk()) @@ -631,13 +631,13 @@ void AArch64ADRPThunk::writeLong(uint8_t *buf) { } void AArch64ADRPThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__AArch64ADRPThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__AArch64ADRPThunk_" + destination.getName()), STT_FUNC, 0, isec); addSymbol("$x", STT_NOTYPE, 0, isec); } void AArch64BTILandingPadThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__AArch64BTIThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__AArch64BTIThunk_" + destination.getName()), STT_FUNC, 0, isec); addSymbol("$x", STT_NOTYPE, 0, isec); } @@ -776,7 +776,7 @@ void ARMV7ABSLongThunk::writeLong(uint8_t *buf) { } void ARMV7ABSLongThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__ARMv7ABSLongThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__ARMv7ABSLongThunk_" + destination.getName()), STT_FUNC, 0, isec); addSymbol("$a", STT_NOTYPE, 0, isec); } @@ -793,7 +793,7 @@ void ThumbV7ABSLongThunk::writeLong(uint8_t *buf) { } void ThumbV7ABSLongThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__Thumbv7ABSLongThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__Thumbv7ABSLongThunk_" + destination.getName()), STT_FUNC, 1, isec); addSymbol("$t", STT_NOTYPE, 0, isec); } @@ -813,7 +813,7 @@ void ARMV7PILongThunk::writeLong(uint8_t *buf) { } void ARMV7PILongThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__ARMV7PILongThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__ARMV7PILongThunk_" + destination.getName()), STT_FUNC, 0, isec); addSymbol("$a", STT_NOTYPE, 0, isec); } @@ -833,7 +833,7 @@ void ThumbV7PILongThunk::writeLong(uint8_t *buf) { } void ThumbV7PILongThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__ThumbV7PILongThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__ThumbV7PILongThunk_" + destination.getName()), STT_FUNC, 1, isec); addSymbol("$t", STT_NOTYPE, 0, isec); } @@ -853,7 +853,7 @@ void ThumbV6MABSLongThunk::writeLong(uint8_t *buf) { } void ThumbV6MABSLongThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__Thumbv6MABSLongThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__Thumbv6MABSLongThunk_" + destination.getName()), STT_FUNC, 1, isec); addSymbol("$t", STT_NOTYPE, 0, isec); if (!getMayUseShortThunk()) @@ -884,9 +884,8 @@ void ThumbV6MABSXOLongThunk::writeLong(uint8_t *buf) { } void ThumbV6MABSXOLongThunk::addSymbols(ThunkSection &isec) { - addSymbol( - saver(ctx).save("__Thumbv6MABSXOLongThunk_" + destination.getName()), - STT_FUNC, 1, isec); + addSymbol(ctx.saver.save("__Thumbv6MABSXOLongThunk_" + destination.getName()), + STT_FUNC, 1, isec); addSymbol("$t", STT_NOTYPE, 0, isec); } @@ -910,7 +909,7 @@ void ThumbV6MPILongThunk::writeLong(uint8_t *buf) { } void ThumbV6MPILongThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__Thumbv6MPILongThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__Thumbv6MPILongThunk_" + destination.getName()), STT_FUNC, 1, isec); addSymbol("$t", STT_NOTYPE, 0, isec); if (!getMayUseShortThunk()) @@ -925,7 +924,7 @@ void ARMV5LongLdrPcThunk::writeLong(uint8_t *buf) { } void ARMV5LongLdrPcThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__ARMv5LongLdrPcThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__ARMv5LongLdrPcThunk_" + destination.getName()), STT_FUNC, 0, isec); addSymbol("$a", STT_NOTYPE, 0, isec); if (!getMayUseShortThunk()) @@ -941,7 +940,7 @@ void ARMV4ABSLongBXThunk::writeLong(uint8_t *buf) { } void ARMV4ABSLongBXThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__ARMv4ABSLongBXThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__ARMv4ABSLongBXThunk_" + destination.getName()), STT_FUNC, 0, isec); addSymbol("$a", STT_NOTYPE, 0, isec); if (!getMayUseShortThunk()) @@ -959,7 +958,7 @@ void ThumbV4ABSLongBXThunk::writeLong(uint8_t *buf) { } void ThumbV4ABSLongBXThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__Thumbv4ABSLongBXThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__Thumbv4ABSLongBXThunk_" + destination.getName()), STT_FUNC, 1, isec); addSymbol("$t", STT_NOTYPE, 0, isec); addSymbol("$a", STT_NOTYPE, 4, isec); @@ -979,7 +978,7 @@ void ThumbV4ABSLongThunk::writeLong(uint8_t *buf) { } void ThumbV4ABSLongThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__Thumbv4ABSLongThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__Thumbv4ABSLongThunk_" + destination.getName()), STT_FUNC, 1, isec); addSymbol("$t", STT_NOTYPE, 0, isec); addSymbol("$a", STT_NOTYPE, 4, isec); @@ -998,7 +997,7 @@ void ARMV4PILongBXThunk::writeLong(uint8_t *buf) { } void ARMV4PILongBXThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__ARMv4PILongBXThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__ARMv4PILongBXThunk_" + destination.getName()), STT_FUNC, 0, isec); addSymbol("$a", STT_NOTYPE, 0, isec); if (!getMayUseShortThunk()) @@ -1015,7 +1014,7 @@ void ARMV4PILongThunk::writeLong(uint8_t *buf) { } void ARMV4PILongThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__ARMv4PILongThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__ARMv4PILongThunk_" + destination.getName()), STT_FUNC, 0, isec); addSymbol("$a", STT_NOTYPE, 0, isec); if (!getMayUseShortThunk()) @@ -1035,7 +1034,7 @@ void ThumbV4PILongBXThunk::writeLong(uint8_t *buf) { } void ThumbV4PILongBXThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__Thumbv4PILongBXThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__Thumbv4PILongBXThunk_" + destination.getName()), STT_FUNC, 1, isec); addSymbol("$t", STT_NOTYPE, 0, isec); addSymbol("$a", STT_NOTYPE, 4, isec); @@ -1057,7 +1056,7 @@ void ThumbV4PILongThunk::writeLong(uint8_t *buf) { } void ThumbV4PILongThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__Thumbv4PILongThunk_" + destination.getName()), + addSymbol(ctx.saver.save("__Thumbv4PILongThunk_" + destination.getName()), STT_FUNC, 1, isec); addSymbol("$t", STT_NOTYPE, 0, isec); addSymbol("$a", STT_NOTYPE, 4, isec); @@ -1072,7 +1071,7 @@ void AVRThunk::writeTo(uint8_t *buf) { } void AVRThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__AVRThunk_" + destination.getName()), STT_FUNC, 0, + addSymbol(ctx.saver.save("__AVRThunk_" + destination.getName()), STT_FUNC, 0, isec); } @@ -1088,8 +1087,8 @@ void MipsThunk::writeTo(uint8_t *buf) { } void MipsThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__LA25Thunk_" + destination.getName()), STT_FUNC, - 0, isec); + addSymbol(ctx.saver.save("__LA25Thunk_" + destination.getName()), STT_FUNC, 0, + isec); } InputSection *MipsThunk::getTargetInputSection() const { @@ -1112,7 +1111,7 @@ void MicroMipsThunk::writeTo(uint8_t *buf) { void MicroMipsThunk::addSymbols(ThunkSection &isec) { Defined *d = - addSymbol(saver(ctx).save("__microLA25Thunk_" + destination.getName()), + addSymbol(ctx.saver.save("__microLA25Thunk_" + destination.getName()), STT_FUNC, 0, isec); d->stOther |= STO_MIPS_MICROMIPS; } @@ -1137,7 +1136,7 @@ void MicroMipsR6Thunk::writeTo(uint8_t *buf) { void MicroMipsR6Thunk::addSymbols(ThunkSection &isec) { Defined *d = - addSymbol(saver(ctx).save("__microLA25Thunk_" + destination.getName()), + addSymbol(ctx.saver.save("__microLA25Thunk_" + destination.getName()), STT_FUNC, 0, isec); d->stOther |= STO_MIPS_MICROMIPS; } @@ -1198,7 +1197,7 @@ void PPC32PltCallStub::addSymbols(ThunkSection &isec) { else os << ".plt_pic32."; os << destination.getName(); - addSymbol(saver(ctx).save(buf), STT_FUNC, 0, isec); + addSymbol(ctx.saver.save(buf), STT_FUNC, 0, isec); } bool PPC32PltCallStub::isCompatibleWith(const InputSection &isec, @@ -1207,8 +1206,8 @@ bool PPC32PltCallStub::isCompatibleWith(const InputSection &isec, } void PPC32LongThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__LongThunk_" + destination.getName()), STT_FUNC, - 0, isec); + addSymbol(ctx.saver.save("__LongThunk_" + destination.getName()), STT_FUNC, 0, + isec); } void PPC32LongThunk::writeTo(uint8_t *buf) { @@ -1251,7 +1250,7 @@ void PPC64PltCallStub::writeTo(uint8_t *buf) { } void PPC64PltCallStub::addSymbols(ThunkSection &isec) { - Defined *s = addSymbol(saver(ctx).save("__plt_" + destination.getName()), + Defined *s = addSymbol(ctx.saver.save("__plt_" + destination.getName()), STT_FUNC, 0, isec); s->setNeedsTocRestore(true); s->file = destination.file; @@ -1295,7 +1294,7 @@ void PPC64R2SaveStub::writeTo(uint8_t *buf) { } void PPC64R2SaveStub::addSymbols(ThunkSection &isec) { - Defined *s = addSymbol(saver(ctx).save("__toc_save_" + destination.getName()), + Defined *s = addSymbol(ctx.saver.save("__toc_save_" + destination.getName()), STT_FUNC, 0, isec); s->setNeedsTocRestore(true); } @@ -1339,8 +1338,8 @@ void PPC64R12SetupStub::writeTo(uint8_t *buf) { } void PPC64R12SetupStub::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save((gotPlt ? "__plt_pcrel_" : "__gep_setup_") + - destination.getName()), + addSymbol(ctx.saver.save((gotPlt ? "__plt_pcrel_" : "__gep_setup_") + + destination.getName()), STT_FUNC, 0, isec); } @@ -1357,7 +1356,7 @@ void PPC64LongBranchThunk::writeTo(uint8_t *buf) { } void PPC64LongBranchThunk::addSymbols(ThunkSection &isec) { - addSymbol(saver(ctx).save("__long_branch_" + destination.getName()), STT_FUNC, + addSymbol(ctx.saver.save("__long_branch_" + destination.getName()), STT_FUNC, 0, isec); } diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 0ec0da2..69a2222 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -2153,7 +2153,7 @@ void Writer<ELFT>::addStartStopSymbols(OutputSection &osec) { StringRef s = osec.name; if (!isValidCIdentifier(s)) return; - StringSaver &ss = saver(ctx); + StringSaver &ss = ctx.saver; Defined *startSym = addOptionalRegular(ctx, ss.save("__start_" + s), &osec, 0, ctx.arg.zStartStopVisibility); Defined *stopSym = addOptionalRegular(ctx, ss.save("__stop_" + s), &osec, -1, |