Skip to content

Commit

Permalink
[ELF] Replace remnant config-> with ctx.arg.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Sep 23, 2024
1 parent 777329d commit b8248da
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lld/ELF/Arch/MipsArchTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/CallGraphSort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/InputSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/LinkerScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions lld/ELF/SyntheticSections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions lld/ELF/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions lld/ELF/Writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit b8248da

Please sign in to comment.