Skip to content

Commit e6625a2

Browse files
committed
[ELF] Pass Ctx &
1 parent 5d928ff commit e6625a2

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

lld/ELF/Arch/RISCV.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -758,8 +758,8 @@ static void relaxCall(Ctx &ctx, const InputSection &sec, size_t i, uint64_t loc,
758758
}
759759

760760
// Relax local-exec TLS when hi20 is zero.
761-
static void relaxTlsLe(const InputSection &sec, size_t i, uint64_t loc,
762-
Relocation &r, uint32_t &remove) {
761+
static void relaxTlsLe(Ctx &ctx, const InputSection &sec, size_t i,
762+
uint64_t loc, Relocation &r, uint32_t &remove) {
763763
uint64_t val = r.sym->getVA(ctx, r.addend);
764764
if (hi20(val) != 0)
765765
return;
@@ -852,7 +852,7 @@ static bool relax(Ctx &ctx, InputSection &sec) {
852852
case R_RISCV_TPREL_LO12_I:
853853
case R_RISCV_TPREL_LO12_S:
854854
if (relaxable(relocs, i))
855-
relaxTlsLe(sec, i, loc, r, remove);
855+
relaxTlsLe(ctx, sec, i, loc, r, remove);
856856
break;
857857
case R_RISCV_HI20:
858858
case R_RISCV_LO12_I:

lld/ELF/InputSection.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ InputSectionBase::InputSectionBase(InputFile *file, uint64_t flags,
7070

7171
// If SHF_COMPRESSED is set, parse the header. The legacy .zdebug format is no
7272
// longer supported.
73-
if (flags & SHF_COMPRESSED)
73+
if (flags & SHF_COMPRESSED) {
74+
Ctx &ctx = file->ctx;
7475
invokeELFT(parseCompressedHeader,);
76+
}
7577
}
7678

7779
// SHF_INFO_LINK and SHF_GROUP are normally resolved and not copied to the

lld/ELF/MapFile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static std::vector<Defined *> getSymbols(Ctx &ctx) {
6565
}
6666

6767
// Returns a map from sections to their symbols.
68-
static SymbolMapTy getSectionSyms(ArrayRef<Defined *> syms) {
68+
static SymbolMapTy getSectionSyms(Ctx &ctx, ArrayRef<Defined *> syms) {
6969
SymbolMapTy ret;
7070
for (Defined *dr : syms)
7171
ret[dr->section].emplace_back(dr, dr->getVA(ctx));
@@ -149,7 +149,7 @@ static void printEhFrame(Ctx &ctx, raw_ostream &os, const EhFrameSection *sec) {
149149
static void writeMapFile(Ctx &ctx, raw_fd_ostream &os) {
150150
// Collect symbol info that we want to print out.
151151
std::vector<Defined *> syms = getSymbols(ctx);
152-
SymbolMapTy sectionSyms = getSectionSyms(syms);
152+
SymbolMapTy sectionSyms = getSectionSyms(ctx, syms);
153153
DenseMap<Symbol *, std::string> symStr = getSymbolStrings(ctx, syms);
154154

155155
// Print out the header line.

lld/ELF/Symbols.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ LLVM_ATTRIBUTE_UNUSED static inline void assertSymbols() {
4444
}
4545

4646
// Returns a symbol for an error message.
47-
static std::string maybeDemangleSymbol(StringRef symName) {
48-
return elf::ctx.arg.demangle ? demangle(symName.str()) : symName.str();
47+
static std::string maybeDemangleSymbol(Ctx &ctx, StringRef symName) {
48+
return ctx.arg.demangle ? demangle(symName.str()) : symName.str();
4949
}
5050

5151
std::string lld::toString(const elf::Symbol &sym) {
5252
StringRef name = sym.getName();
53-
std::string ret = maybeDemangleSymbol(name);
53+
std::string ret = maybeDemangleSymbol(ctx, name);
5454

5555
const char *suffix = sym.getVersionSuffix();
5656
if (*suffix == '@')
@@ -617,7 +617,7 @@ void Symbol::resolve(Ctx &ctx, const LazySymbol &other) {
617617

618618
// For common objects, we want to look for global or weak definitions that
619619
// should be extracted as the canonical definition instead.
620-
if (LLVM_UNLIKELY(isCommon()) && elf::ctx.arg.fortranCommon &&
620+
if (LLVM_UNLIKELY(isCommon()) && ctx.arg.fortranCommon &&
621621
other.file->shouldExtractForCommon(getName())) {
622622
ctx.backwardReferences.erase(this);
623623
other.overwrite(*this);

0 commit comments

Comments
 (0)