From b8248dacade77ea5abc49bd8c58d0b1656957492 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 22 Sep 2024 18:03:33 -0700 Subject: [PATCH] [ELF] Replace remnant config-> with ctx.arg. --- lld/ELF/Arch/MipsArchTree.cpp | 2 +- lld/ELF/CallGraphSort.cpp | 2 +- lld/ELF/Driver.cpp | 2 +- lld/ELF/InputSection.cpp | 2 +- lld/ELF/LinkerScript.cpp | 2 +- lld/ELF/SyntheticSections.cpp | 2 -- lld/ELF/Writer.cpp | 10 +++++----- lld/ELF/Writer.h | 4 ++-- 8 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lld/ELF/Arch/MipsArchTree.cpp b/lld/ELF/Arch/MipsArchTree.cpp index 959bd21a7aa6df..c958ba9032fa35 100644 --- a/lld/ELF/Arch/MipsArchTree.cpp +++ b/lld/ELF/Arch/MipsArchTree.cpp @@ -377,7 +377,7 @@ bool elf::isMipsN32Abi(const InputFile *f) { case ELF64BEKind: return isN32Abi(f); default: - llvm_unreachable("unknown Config->EKind"); + llvm_unreachable("unknown ctx.arg.ekind"); } } diff --git a/lld/ELF/CallGraphSort.cpp b/lld/ELF/CallGraphSort.cpp index 690dc1e80c9a77..e73fe12317bd76 100644 --- a/lld/ELF/CallGraphSort.cpp +++ b/lld/ELF/CallGraphSort.cpp @@ -108,7 +108,7 @@ constexpr uint64_t MAX_CLUSTER_SIZE = 1024 * 1024; using SectionPair = std::pair; -// Take the edge list in Config->CallGraphProfile, resolve symbol names to +// Take the edge list in ctx.arg.callGraphProfile, resolve symbol names to // Symbols, and generate a graph between InputSections with the provided // weights. CallGraphSort::CallGraphSort() { diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index c28314b650bef6..346f5be72d8a6f 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -2106,7 +2106,7 @@ static uint64_t getCommonPageSize(Ctx &ctx, opt::InputArgList &args) { // Parses --image-base option. static std::optional getImageBase(Ctx &ctx, opt::InputArgList &args) { - // Because we are using "Config->maxPageSize" here, this function has to be + // Because we are using `ctx.arg.maxPageSize` here, this function has to be // called after the variable is initialized. auto *arg = args.getLastArg(OPT_image_base); if (!arg) diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 12c4a622ebba8e..e9985bbae4959e 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -713,7 +713,7 @@ static int64_t getTlsTpOffset(const Symbol &s) { return s.getVA(0) - tls->p_memsz - ((-tls->p_vaddr - tls->p_memsz) & (tls->p_align - 1)); default: - llvm_unreachable("unhandled Config->EMachine"); + llvm_unreachable("unhandled ctx.arg.emachine"); } } diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index b0e1a8de790d3e..55e5f23d041f8f 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -1634,7 +1634,7 @@ SmallVector LinkerScript::createPhdrs() { // Process PHDRS and FILEHDR keywords because they are not // real output sections and cannot be added in the following loop. for (const PhdrsCommand &cmd : phdrsCommands) { - PhdrEntry *phdr = make(cmd.type, cmd.flags.value_or(PF_R)); + PhdrEntry *phdr = make(ctx, cmd.type, cmd.flags.value_or(PF_R)); if (cmd.hasFilehdr) phdr->add(ctx.out.elfHeader); diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index ecb4a02acc19fe..a736b5d340fcc5 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -2057,8 +2057,6 @@ template bool RelrSection::updateAllocSize() { size_t oldSize = relrRelocs.size(); relrRelocs.clear(); - // Same as Config->Wordsize but faster because this is a compile-time - // constant. const size_t wordsize = sizeof(typename ELFT::uint); // Number of bits to use for the relocation offsets bitmap. diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index bf08de0841220e..49a319c643b387 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -2175,8 +2175,8 @@ static uint64_t computeFlags(uint64_t flags) { template SmallVector Writer::createPhdrs(Partition &part) { SmallVector ret; - auto addHdr = [&](unsigned type, unsigned flags) -> PhdrEntry * { - ret.push_back(make(type, flags)); + auto addHdr = [&, &ctx = ctx](unsigned type, unsigned flags) -> PhdrEntry * { + ret.push_back(make(ctx, type, flags)); return ret.back(); }; @@ -2215,7 +2215,7 @@ SmallVector Writer::createPhdrs(Partition &part) { // read-only by dynamic linker after processing relocations. // Current dynamic loaders only support one PT_GNU_RELRO PHDR, give // an error message if more than one PT_GNU_RELRO PHDR is required. - PhdrEntry *relRo = make(PT_GNU_RELRO, PF_R); + PhdrEntry *relRo = make(ctx, PT_GNU_RELRO, PF_R); bool inRelroPhdr = false; OutputSection *relroEnd = nullptr; for (OutputSection *sec : ctx.outputSections) { @@ -2292,7 +2292,7 @@ SmallVector Writer::createPhdrs(Partition &part) { } // Add a TLS segment if any. - PhdrEntry *tlsHdr = make(PT_TLS, PF_R); + PhdrEntry *tlsHdr = make(ctx, PT_TLS, PF_R); for (OutputSection *sec : ctx.outputSections) if (sec->partition == partNo && sec->flags & SHF_TLS) tlsHdr->add(sec); @@ -2377,7 +2377,7 @@ void Writer::addPhdrForSection(Partition &part, unsigned shType, if (i == ctx.outputSections.end()) return; - PhdrEntry *entry = make(pType, pFlags); + PhdrEntry *entry = make(ctx, pType, pFlags); entry->add(*i); part.phdrs.push_back(entry); } diff --git a/lld/ELF/Writer.h b/lld/ELF/Writer.h index c718d27394dc47..7644b620bbffcd 100644 --- a/lld/ELF/Writer.h +++ b/lld/ELF/Writer.h @@ -23,8 +23,8 @@ template void writeResult(Ctx &ctx); // Each contains type, access flags and range of output sections that will be // placed in it. struct PhdrEntry { - PhdrEntry(unsigned type, unsigned flags) - : p_align(type == llvm::ELF::PT_LOAD ? config->maxPageSize : 0), + PhdrEntry(Ctx &ctx, unsigned type, unsigned flags) + : p_align(type == llvm::ELF::PT_LOAD ? ctx.arg.maxPageSize : 0), p_type(type), p_flags(flags) {} void add(OutputSection *sec);