[ELF] Replace remnant config-> with ctx.arg.

This commit is contained in:
Fangrui Song
2024-09-22 18:03:33 -07:00
parent 777329d32f
commit b8248dacad
8 changed files with 12 additions and 14 deletions

View File

@@ -377,7 +377,7 @@ bool elf::isMipsN32Abi(const InputFile *f) {
case ELF64BEKind:
return isN32Abi<ELF64BE>(f);
default:
llvm_unreachable("unknown Config->EKind");
llvm_unreachable("unknown ctx.arg.ekind");
}
}

View File

@@ -108,7 +108,7 @@ constexpr uint64_t MAX_CLUSTER_SIZE = 1024 * 1024;
using SectionPair =
std::pair<const InputSectionBase *, const InputSectionBase *>;
// 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() {

View File

@@ -2106,7 +2106,7 @@ static uint64_t getCommonPageSize(Ctx &ctx, opt::InputArgList &args) {
// Parses --image-base option.
static std::optional<uint64_t> 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)

View File

@@ -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");
}
}

View File

@@ -1634,7 +1634,7 @@ SmallVector<PhdrEntry *, 0> 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<PhdrEntry>(cmd.type, cmd.flags.value_or(PF_R));
PhdrEntry *phdr = make<PhdrEntry>(ctx, cmd.type, cmd.flags.value_or(PF_R));
if (cmd.hasFilehdr)
phdr->add(ctx.out.elfHeader);

View File

@@ -2057,8 +2057,6 @@ template <class ELFT> bool RelrSection<ELFT>::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.

View File

@@ -2175,8 +2175,8 @@ static uint64_t computeFlags(uint64_t flags) {
template <class ELFT>
SmallVector<PhdrEntry *, 0> Writer<ELFT>::createPhdrs(Partition &part) {
SmallVector<PhdrEntry *, 0> ret;
auto addHdr = [&](unsigned type, unsigned flags) -> PhdrEntry * {
ret.push_back(make<PhdrEntry>(type, flags));
auto addHdr = [&, &ctx = ctx](unsigned type, unsigned flags) -> PhdrEntry * {
ret.push_back(make<PhdrEntry>(ctx, type, flags));
return ret.back();
};
@@ -2215,7 +2215,7 @@ SmallVector<PhdrEntry *, 0> Writer<ELFT>::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<PhdrEntry>(PT_GNU_RELRO, PF_R);
PhdrEntry *relRo = make<PhdrEntry>(ctx, PT_GNU_RELRO, PF_R);
bool inRelroPhdr = false;
OutputSection *relroEnd = nullptr;
for (OutputSection *sec : ctx.outputSections) {
@@ -2292,7 +2292,7 @@ SmallVector<PhdrEntry *, 0> Writer<ELFT>::createPhdrs(Partition &part) {
}
// Add a TLS segment if any.
PhdrEntry *tlsHdr = make<PhdrEntry>(PT_TLS, PF_R);
PhdrEntry *tlsHdr = make<PhdrEntry>(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<ELFT>::addPhdrForSection(Partition &part, unsigned shType,
if (i == ctx.outputSections.end())
return;
PhdrEntry *entry = make<PhdrEntry>(pType, pFlags);
PhdrEntry *entry = make<PhdrEntry>(ctx, pType, pFlags);
entry->add(*i);
part.phdrs.push_back(entry);
}

View File

@@ -23,8 +23,8 @@ template <class ELFT> 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);