From e24457a330923dbc43a0e056deddb2d42c682e6c Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 14 Nov 2024 22:17:10 -0800 Subject: [PATCH] [ELF] Migrate away from global ctx --- lld/ELF/Arch/MipsArchTree.cpp | 8 ++-- lld/ELF/Driver.cpp | 80 +++++++++++++++++++---------------- lld/ELF/Driver.h | 2 +- lld/ELF/DriverUtils.cpp | 7 +-- lld/ELF/ScriptLexer.cpp | 2 +- lld/ELF/ScriptLexer.h | 1 + lld/ELF/ScriptParser.cpp | 12 +++--- lld/ELF/SyntheticSections.cpp | 8 ++-- lld/ELF/Target.h | 2 +- 9 files changed, 66 insertions(+), 56 deletions(-) diff --git a/lld/ELF/Arch/MipsArchTree.cpp b/lld/ELF/Arch/MipsArchTree.cpp index 239fdd100e2c..0c64a46fe85d 100644 --- a/lld/ELF/Arch/MipsArchTree.cpp +++ b/lld/ELF/Arch/MipsArchTree.cpp @@ -102,7 +102,7 @@ static uint32_t getMiscFlags(ArrayRef files) { return ret; } -static uint32_t getPicFlags(ArrayRef files) { +static uint32_t getPicFlags(Ctx &ctx, ArrayRef files) { // Check PIC/non-PIC compatibility. bool isPic = files[0].flags & (EF_MIPS_PIC | EF_MIPS_CPIC); for (const FileFlags &f : files.slice(1)) { @@ -274,7 +274,7 @@ static std::string getFullArchName(uint32_t flags) { // Output file gets EF_MIPS_ARCH_2 flag. From the other side mips3 and mips32 // are incompatible because nor mips3 is a parent for misp32, nor mips32 // is a parent for mips3. -static uint32_t getArchFlags(ArrayRef files) { +static uint32_t getArchFlags(Ctx &ctx, ArrayRef files) { uint32_t ret = files[0].flags & (EF_MIPS_ARCH | EF_MIPS_MACH); for (const FileFlags &f : files.slice(1)) { @@ -307,7 +307,7 @@ template uint32_t elf::calcMipsEFlags(Ctx &ctx) { return ctx.arg.mipsN32Abi ? EF_MIPS_ABI2 : EF_MIPS_ABI_O32; } checkFlags(ctx, v); - return getMiscFlags(v) | getPicFlags(v) | getArchFlags(v); + return getMiscFlags(v) | getPicFlags(ctx, v) | getArchFlags(ctx, v); } static int compareMipsFpAbi(uint8_t fpA, uint8_t fpB) { @@ -350,7 +350,7 @@ static StringRef getMipsFpAbiName(uint8_t fpAbi) { } } -uint8_t elf::getMipsFpAbiFlag(uint8_t oldFlag, uint8_t newFlag, +uint8_t elf::getMipsFpAbiFlag(Ctx &ctx, uint8_t oldFlag, uint8_t newFlag, StringRef fileName) { if (compareMipsFpAbi(newFlag, oldFlag) >= 0) return newFlag; diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index fed6b21ddc51..429e5fa3c9db 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -600,7 +600,7 @@ static uint8_t getZStartStopVisibility(opt::InputArgList &args) { return ret; } -static GcsPolicy getZGcs(opt::InputArgList &args) { +static GcsPolicy getZGcs(Ctx &ctx, opt::InputArgList &args) { GcsPolicy ret = GcsPolicy::Implicit; for (auto *arg : args.filtered(OPT_z)) { std::pair kv = StringRef(arg->getValue()).split('='); @@ -620,7 +620,7 @@ static GcsPolicy getZGcs(opt::InputArgList &args) { } // Report a warning for an unknown -z option. -static void checkZOptions(opt::InputArgList &args) { +static void checkZOptions(Ctx &ctx, opt::InputArgList &args) { // This function is called before getTarget(), when certain options are not // initialized yet. Claim them here. args::getZOptionValue(args, OPT_z, "max-page-size", 0); @@ -639,7 +639,7 @@ LinkerDriver::LinkerDriver(Ctx &ctx) : ctx(ctx) {} void LinkerDriver::linkerMain(ArrayRef argsArr) { ELFOptTable parser; - opt::InputArgList args = parser.parse(argsArr.slice(1)); + opt::InputArgList args = parser.parse(ctx, argsArr.slice(1)); // Interpret these flags early because error()/warn() depend on them. errorHandler().errorLimit = args::getInteger(args, OPT_error_limit, 20); @@ -689,7 +689,7 @@ void LinkerDriver::linkerMain(ArrayRef argsArr) { } readConfigs(ctx, args); - checkZOptions(args); + checkZOptions(ctx, args); // The behavior of -v or --version is a bit strange, but this is // needed for compatibility with GNU linkers. @@ -790,7 +790,7 @@ static void setUnresolvedSymbolPolicy(Ctx &ctx, opt::InputArgList &args) { diagShlib ? errorOrWarn : UnresolvedPolicy::Ignore; } -static Target2Policy getTarget2(opt::InputArgList &args) { +static Target2Policy getTarget2(Ctx &ctx, opt::InputArgList &args) { StringRef s = args.getLastArgValue(OPT_target2, "got-rel"); if (s == "rel") return Target2Policy::Rel; @@ -802,7 +802,7 @@ static Target2Policy getTarget2(opt::InputArgList &args) { return Target2Policy::GotRel; } -static bool isOutputFormatBinary(opt::InputArgList &args) { +static bool isOutputFormatBinary(Ctx &ctx, opt::InputArgList &args) { StringRef s = args.getLastArgValue(OPT_oformat, "elf"); if (s == "binary") return true; @@ -882,7 +882,8 @@ static StripPolicy getStrip(Ctx &ctx, opt::InputArgList &args) { return StripPolicy::Debug; } -static uint64_t parseSectionAddress(StringRef s, opt::InputArgList &args, +static uint64_t parseSectionAddress(Ctx &ctx, StringRef s, + opt::InputArgList &args, const opt::Arg &arg) { uint64_t va = 0; s.consume_front("0x"); @@ -891,25 +892,26 @@ static uint64_t parseSectionAddress(StringRef s, opt::InputArgList &args, return va; } -static StringMap getSectionStartMap(opt::InputArgList &args) { +static StringMap getSectionStartMap(Ctx &ctx, + opt::InputArgList &args) { StringMap ret; for (auto *arg : args.filtered(OPT_section_start)) { StringRef name; StringRef addr; std::tie(name, addr) = StringRef(arg->getValue()).split('='); - ret[name] = parseSectionAddress(addr, args, *arg); + ret[name] = parseSectionAddress(ctx, addr, args, *arg); } if (auto *arg = args.getLastArg(OPT_Ttext)) - ret[".text"] = parseSectionAddress(arg->getValue(), args, *arg); + ret[".text"] = parseSectionAddress(ctx, arg->getValue(), args, *arg); if (auto *arg = args.getLastArg(OPT_Tdata)) - ret[".data"] = parseSectionAddress(arg->getValue(), args, *arg); + ret[".data"] = parseSectionAddress(ctx, arg->getValue(), args, *arg); if (auto *arg = args.getLastArg(OPT_Tbss)) - ret[".bss"] = parseSectionAddress(arg->getValue(), args, *arg); + ret[".bss"] = parseSectionAddress(ctx, arg->getValue(), args, *arg); return ret; } -static SortSectionPolicy getSortSection(opt::InputArgList &args) { +static SortSectionPolicy getSortSection(Ctx &ctx, opt::InputArgList &args) { StringRef s = args.getLastArgValue(OPT_sort_section); if (s == "alignment") return SortSectionPolicy::Alignment; @@ -920,7 +922,8 @@ static SortSectionPolicy getSortSection(opt::InputArgList &args) { return SortSectionPolicy::Default; } -static OrphanHandlingPolicy getOrphanHandling(opt::InputArgList &args) { +static OrphanHandlingPolicy getOrphanHandling(Ctx &ctx, + opt::InputArgList &args) { StringRef s = args.getLastArgValue(OPT_orphan_handling, "place"); if (s == "warn") return OrphanHandlingPolicy::Warn; @@ -935,7 +938,7 @@ static OrphanHandlingPolicy getOrphanHandling(opt::InputArgList &args) { // synonym for "sha1" because all our hash functions including // --build-id=sha1 are actually tree hashes for performance reasons. static std::pair> -getBuildId(opt::InputArgList &args) { +getBuildId(Ctx &ctx, opt::InputArgList &args) { auto *arg = args.getLastArg(OPT_build_id); if (!arg) return {BuildIdKind::None, {}}; @@ -957,7 +960,8 @@ getBuildId(opt::InputArgList &args) { return {BuildIdKind::None, {}}; } -static std::pair getPackDynRelocs(opt::InputArgList &args) { +static std::pair getPackDynRelocs(Ctx &ctx, + opt::InputArgList &args) { StringRef s = args.getLastArgValue(OPT_pack_dyn_relocs, "none"); if (s == "android") return {true, false}; @@ -1152,7 +1156,8 @@ static void ltoValidateAllVtablesHaveTypeInfos(Ctx &ctx, } } -static CGProfileSortKind getCGProfileSortKind(opt::InputArgList &args) { +static CGProfileSortKind getCGProfileSortKind(Ctx &ctx, + opt::InputArgList &args) { StringRef s = args.getLastArgValue(OPT_call_graph_profile_sort, "cdsort"); if (s == "hfsort") return CGProfileSortKind::Hfsort; @@ -1163,7 +1168,8 @@ static CGProfileSortKind getCGProfileSortKind(opt::InputArgList &args) { return CGProfileSortKind::None; } -static DebugCompressionType getCompressionType(StringRef s, StringRef option) { +static DebugCompressionType getCompressionType(Ctx &ctx, StringRef s, + StringRef option) { DebugCompressionType type = StringSwitch(s) .Case("zlib", DebugCompressionType::Zlib) .Case("zstd", DebugCompressionType::Zstd) @@ -1184,8 +1190,8 @@ static StringRef getAliasSpelling(opt::Arg *arg) { return arg->getSpelling(); } -static std::pair getOldNewOptions(opt::InputArgList &args, - unsigned id) { +static std::pair +getOldNewOptions(Ctx &ctx, opt::InputArgList &args, unsigned id) { auto *arg = args.getLastArg(id); if (!arg) return {"", ""}; @@ -1200,8 +1206,8 @@ static std::pair getOldNewOptions(opt::InputArgList &args, // Parse options of the form "old;new[;extra]". static std::tuple -getOldNewOptionsExtra(opt::InputArgList &args, unsigned id) { - auto [oldDir, second] = getOldNewOptions(args, id); +getOldNewOptionsExtra(Ctx &ctx, opt::InputArgList &args, unsigned id) { + auto [oldDir, second] = getOldNewOptions(ctx, args, id); auto [newDir, extraDir] = second.split(';'); return {oldDir, newDir, extraDir}; } @@ -1303,13 +1309,13 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) { else if (arg->getOption().matches(OPT_Bsymbolic)) ctx.arg.bsymbolic = BsymbolicKind::All; } - ctx.arg.callGraphProfileSort = getCGProfileSortKind(args); + ctx.arg.callGraphProfileSort = getCGProfileSortKind(ctx, args); ctx.arg.checkSections = args.hasFlag(OPT_check_sections, OPT_no_check_sections, true); ctx.arg.chroot = args.getLastArgValue(OPT_chroot); if (auto *arg = args.getLastArg(OPT_compress_debug_sections)) { ctx.arg.compressDebugSections = - getCompressionType(arg->getValue(), "--compress-debug-sections"); + getCompressionType(ctx, arg->getValue(), "--compress-debug-sections"); } ctx.arg.cref = args.hasArg(OPT_cref); ctx.arg.optimizeBBJumps = @@ -1406,7 +1412,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) { ctx.arg.nmagic = args.hasFlag(OPT_nmagic, OPT_no_nmagic, false); ctx.arg.noinhibitExec = args.hasArg(OPT_noinhibit_exec); ctx.arg.nostdlib = args.hasArg(OPT_nostdlib); - ctx.arg.oFormatBinary = isOutputFormatBinary(args); + ctx.arg.oFormatBinary = isOutputFormatBinary(ctx, args); ctx.arg.omagic = args.hasFlag(OPT_omagic, OPT_no_omagic, false); ctx.arg.optRemarksFilename = args.getLastArgValue(OPT_opt_remarks_filename); ctx.arg.optStatsFilename = args.getLastArgValue(OPT_plugin_opt_stats_file); @@ -1426,7 +1432,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) { ctx.arg.optRemarksWithHotness = args.hasArg(OPT_opt_remarks_with_hotness); ctx.arg.optRemarksFormat = args.getLastArgValue(OPT_opt_remarks_format); ctx.arg.optimize = args::getInteger(args, OPT_O, 1); - ctx.arg.orphanHandling = getOrphanHandling(args); + ctx.arg.orphanHandling = getOrphanHandling(ctx, args); ctx.arg.outputFile = args.getLastArgValue(OPT_o); ctx.arg.packageMetadata = args.getLastArgValue(OPT_package_metadata); ctx.arg.pie = args.hasFlag(OPT_pie, OPT_no_pie, false); @@ -1460,11 +1466,11 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) { } ctx.arg.searchPaths = args::getStrings(args, OPT_library_path); - ctx.arg.sectionStartMap = getSectionStartMap(args); + ctx.arg.sectionStartMap = getSectionStartMap(ctx, args); ctx.arg.shared = args.hasArg(OPT_shared); ctx.arg.singleRoRx = !args.hasFlag(OPT_rosegment, OPT_no_rosegment, true); ctx.arg.soName = args.getLastArgValue(OPT_soname); - ctx.arg.sortSection = getSortSection(args); + ctx.arg.sortSection = getSortSection(ctx, args); ctx.arg.splitStackAdjustSize = args::getInteger(args, OPT_split_stack_adjust_size, 16384); ctx.arg.zSectionHeader = @@ -1472,7 +1478,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) { ctx.arg.strip = getStrip(ctx, args); // needs zSectionHeader ctx.arg.sysroot = args.getLastArgValue(OPT_sysroot); ctx.arg.target1Rel = args.hasFlag(OPT_target1_rel, OPT_target1_abs, false); - ctx.arg.target2 = getTarget2(args); + ctx.arg.target2 = getTarget2(ctx, args); ctx.arg.thinLTOCacheDir = args.getLastArgValue(OPT_thinlto_cache_dir); ctx.arg.thinLTOCachePolicy = CHECK( parseCachePruningPolicy(args.getLastArgValue(OPT_thinlto_cache_policy)), @@ -1485,10 +1491,10 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) { args.hasArg(OPT_thinlto_index_only_eq); ctx.arg.thinLTOIndexOnlyArg = args.getLastArgValue(OPT_thinlto_index_only_eq); ctx.arg.thinLTOObjectSuffixReplace = - getOldNewOptions(args, OPT_thinlto_object_suffix_replace_eq); + getOldNewOptions(ctx, args, OPT_thinlto_object_suffix_replace_eq); std::tie(ctx.arg.thinLTOPrefixReplaceOld, ctx.arg.thinLTOPrefixReplaceNew, ctx.arg.thinLTOPrefixReplaceNativeObject) = - getOldNewOptionsExtra(args, OPT_thinlto_prefix_replace_eq); + getOldNewOptionsExtra(ctx, args, OPT_thinlto_prefix_replace_eq); if (ctx.arg.thinLTOEmitIndexFiles && !ctx.arg.thinLTOIndexOnly) { if (args.hasArg(OPT_thinlto_object_suffix_replace_eq)) ErrAlways(ctx) << "--thinlto-object-suffix-replace is not supported with " @@ -1525,7 +1531,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) { ctx.arg.zCopyreloc = getZFlag(args, "copyreloc", "nocopyreloc", true); ctx.arg.zForceBti = hasZOption(args, "force-bti"); ctx.arg.zForceIbt = hasZOption(args, "force-ibt"); - ctx.arg.zGcs = getZGcs(args); + ctx.arg.zGcs = getZGcs(ctx, args); ctx.arg.zGlobal = hasZOption(args, "global"); ctx.arg.zGnustack = getZGnuStack(args); ctx.arg.zHazardplt = hasZOption(args, "hazardplt"); @@ -1627,7 +1633,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) { continue; } auto [typeStr, levelStr] = fields[1].split(':'); - auto type = getCompressionType(typeStr, arg->getSpelling()); + auto type = getCompressionType(ctx, typeStr, arg->getSpelling()); unsigned level = 0; if (fields[1].size() != typeStr.size() && !llvm::to_integer(levelStr, level)) { @@ -1781,14 +1787,14 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) { if (ctx.arg.nmagic || ctx.arg.omagic || ctx.arg.relocatable) ctx.arg.zRelro = false; - std::tie(ctx.arg.buildId, ctx.arg.buildIdVector) = getBuildId(args); + std::tie(ctx.arg.buildId, ctx.arg.buildIdVector) = getBuildId(ctx, args); if (getZFlag(args, "pack-relative-relocs", "nopack-relative-relocs", false)) { ctx.arg.relrGlibc = true; ctx.arg.relrPackDynRelocs = true; } else { std::tie(ctx.arg.androidPackDynRelocs, ctx.arg.relrPackDynRelocs) = - getPackDynRelocs(args); + getPackDynRelocs(ctx, args); } if (auto *arg = args.getLastArg(OPT_symbol_ordering_file)){ @@ -1949,7 +1955,7 @@ static void setConfigs(Ctx &ctx, opt::InputArgList &args) { } } -static bool isFormatBinary(StringRef s) { +static bool isFormatBinary(Ctx &ctx, StringRef s) { if (s == "binary") return true; if (s == "elf" || s == "default") @@ -2006,7 +2012,7 @@ void LinkerDriver::createFiles(opt::InputArgList &args) { ctx.arg.asNeeded = true; break; case OPT_format: - ctx.arg.formatBinary = isFormatBinary(arg->getValue()); + ctx.arg.formatBinary = isFormatBinary(ctx, arg->getValue()); break; case OPT_no_as_needed: ctx.arg.asNeeded = false; diff --git a/lld/ELF/Driver.h b/lld/ELF/Driver.h index 95cc437d351f..b5d41633141e 100644 --- a/lld/ELF/Driver.h +++ b/lld/ELF/Driver.h @@ -21,7 +21,7 @@ struct Ctx; class ELFOptTable : public llvm::opt::GenericOptTable { public: ELFOptTable(); - llvm::opt::InputArgList parse(ArrayRef argv); + llvm::opt::InputArgList parse(Ctx &, ArrayRef argv); }; // Create enum with OPT_xxx values for each option in Options.td diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp index 096f033a767e..d41dc2e05247 100644 --- a/lld/ELF/DriverUtils.cpp +++ b/lld/ELF/DriverUtils.cpp @@ -65,7 +65,8 @@ static void handleColorDiagnostics(opt::InputArgList &args) { ErrAlways(ctx) << "unknown option: --color-diagnostics=" << s; } -static cl::TokenizerCallback getQuotingStyle(opt::InputArgList &args) { +static cl::TokenizerCallback getQuotingStyle(Ctx &ctx, + opt::InputArgList &args) { if (auto *arg = args.getLastArg(OPT_rsp_quoting)) { StringRef s = arg->getValue(); if (s != "windows" && s != "posix") @@ -103,7 +104,7 @@ static void concatLTOPluginOptions(SmallVectorImpl &args) { } // Parses a given list of options. -opt::InputArgList ELFOptTable::parse(ArrayRef argv) { +opt::InputArgList ELFOptTable::parse(Ctx &ctx, ArrayRef argv) { // Make InputArgList from string vectors. unsigned missingIndex; unsigned missingCount; @@ -116,7 +117,7 @@ opt::InputArgList ELFOptTable::parse(ArrayRef argv) { // Expand response files (arguments in the form of @) // and then parse the argument again. - cl::ExpandResponseFiles(saver(), getQuotingStyle(args), vec); + cl::ExpandResponseFiles(saver(), getQuotingStyle(ctx, args), vec); concatLTOPluginOptions(vec); args = this->ParseArgs(vec, missingIndex, missingCount); diff --git a/lld/ELF/ScriptLexer.cpp b/lld/ELF/ScriptLexer.cpp index ae5ad7cae949..62865681127e 100644 --- a/lld/ELF/ScriptLexer.cpp +++ b/lld/ELF/ScriptLexer.cpp @@ -54,7 +54,7 @@ ScriptLexer::Buffer::Buffer(Ctx &ctx, MemoryBufferRef mb) } ScriptLexer::ScriptLexer(Ctx &ctx, MemoryBufferRef mb) - : curBuf(ctx, mb), mbs(1, mb) { + : ctx(ctx), curBuf(ctx, mb), mbs(1, mb) { activeFilenames.insert(mb.getBufferIdentifier()); } diff --git a/lld/ELF/ScriptLexer.h b/lld/ELF/ScriptLexer.h index 0f31ef17844b..d689a7e108f9 100644 --- a/lld/ELF/ScriptLexer.h +++ b/lld/ELF/ScriptLexer.h @@ -33,6 +33,7 @@ protected: Buffer() = default; Buffer(Ctx &ctx, MemoryBufferRef mb); }; + Ctx &ctx; // The current buffer and parent buffers due to INCLUDE. Buffer curBuf; SmallVector buffers; diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index d8adc56cf7d9..aa89d8c22cf2 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -972,8 +972,8 @@ void ScriptParser::readSectionAddressType(OutputSection *cmd) { } } -static Expr checkAlignment(Expr e, std::string &loc) { - return [=] { +static Expr checkAlignment(Ctx &ctx, Expr e, std::string &loc) { + return [=, &ctx] { uint64_t alignment = std::max((uint64_t)1, e().getValue()); if (!isPowerOf2_64(alignment)) { ErrAlways(ctx) << loc << ": alignment must be power of 2"; @@ -1023,9 +1023,9 @@ OutputDesc *ScriptParser::readOutputSectionDescription(StringRef outSec) { if (consume("AT")) osec->lmaExpr = readParenExpr(); if (consume("ALIGN")) - osec->alignExpr = checkAlignment(readParenExpr(), location); + osec->alignExpr = checkAlignment(ctx, readParenExpr(), location); if (consume("SUBALIGN")) - osec->subalignExpr = checkAlignment(readParenExpr(), location); + osec->subalignExpr = checkAlignment(ctx, readParenExpr(), location); // Parse constraints. if (consume("ONLY_IF_RO")) @@ -1516,13 +1516,13 @@ Expr ScriptParser::readPrimary() { expect("("); Expr e = readExpr(); if (consume(")")) { - e = checkAlignment(e, location); + e = checkAlignment(ctx, e, location); return [=, s = ctx.script] { return alignToPowerOf2(s->getDot(), e().getValue()); }; } expect(","); - Expr e2 = checkAlignment(readExpr(), location); + Expr e2 = checkAlignment(ctx, readExpr(), location); expect(")"); return [=] { ExprValue v = e(); diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index ba2dadece747..55ce1abae73a 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -150,7 +150,8 @@ MipsAbiFlagsSection::create(Ctx &ctx) { flags.ases |= s->ases; flags.flags1 |= s->flags1; flags.flags2 |= s->flags2; - flags.fp_abi = elf::getMipsFpAbiFlag(flags.fp_abi, s->fp_abi, filename); + flags.fp_abi = + elf::getMipsFpAbiFlag(ctx, flags.fp_abi, s->fp_abi, filename); }; if (create) @@ -3408,7 +3409,7 @@ readAddressAreas(DWARFContext &dwarf, InputSection *sec) { template static SmallVector -readPubNamesAndTypes(const LLDDwarfObj &obj, +readPubNamesAndTypes(Ctx &ctx, const LLDDwarfObj &obj, const SmallVectorImpl &cus) { const LLDDWARFSection &pubNames = obj.getGnuPubnamesSection(); const LLDDWARFSection &pubTypes = obj.getGnuPubtypesSection(); @@ -3564,7 +3565,8 @@ std::unique_ptr GdbIndexSection::create(Ctx &ctx) { chunks[i].sec = dobj.getInfoSection(); chunks[i].compilationUnits = readCuList(dwarf); chunks[i].addressAreas = readAddressAreas(dwarf, chunks[i].sec); - nameAttrs[i] = readPubNamesAndTypes(dobj, chunks[i].compilationUnits); + nameAttrs[i] = + readPubNamesAndTypes(ctx, dobj, chunks[i].compilationUnits); }); auto ret = std::make_unique(ctx); diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h index 250a29d61843..d4919ffc3aac 100644 --- a/lld/ELF/Target.h +++ b/lld/ELF/Target.h @@ -211,7 +211,7 @@ static inline std::string getErrorLoc(Ctx &ctx, const uint8_t *loc) { void processArmCmseSymbols(Ctx &); template uint32_t calcMipsEFlags(Ctx &); -uint8_t getMipsFpAbiFlag(uint8_t oldFlag, uint8_t newFlag, +uint8_t getMipsFpAbiFlag(Ctx &, uint8_t oldFlag, uint8_t newFlag, llvm::StringRef fileName); bool isMipsN32Abi(Ctx &, const InputFile &f); bool isMicroMips(Ctx &);