Skip to content

Commit 25cda9e

Browse files
committed
[ELF] Pass Ctx & to SyntheticSection
1 parent e018f55 commit 25cda9e

File tree

10 files changed

+240
-220
lines changed

10 files changed

+240
-220
lines changed

lld/ELF/AArch64ErrataFix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ class elf::Patch843419Section final : public SyntheticSection {
393393
};
394394

395395
Patch843419Section::Patch843419Section(Ctx &ctx, InputSection *p, uint64_t off)
396-
: SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 4,
396+
: SyntheticSection(ctx, SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 4,
397397
".text.patch"),
398398
patchee(p), patcheeOffset(off) {
399399
this->parent = p->getParent();

lld/ELF/ARMErrataFix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static bool is32bitBranch(uint32_t instr) {
136136

137137
Patch657417Section::Patch657417Section(Ctx &ctx, InputSection *p, uint64_t off,
138138
uint32_t instr, bool isARM)
139-
: SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 4,
139+
: SyntheticSection(ctx, SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 4,
140140
".text.patch"),
141141
patchee(p), patcheeOffset(off), instr(instr), isARM(isARM) {
142142
parent = p->getParent();

lld/ELF/Arch/ARM.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ class elf::ArmCmseSGVeneer {
13311331
};
13321332

13331333
ArmCmseSGSection::ArmCmseSGSection(Ctx &ctx)
1334-
: SyntheticSection(llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_EXECINSTR,
1334+
: SyntheticSection(ctx, llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_EXECINSTR,
13351335
llvm::ELF::SHT_PROGBITS,
13361336
/*alignment=*/32, ".gnu.sgstubs"),
13371337
ctx(ctx) {
@@ -1446,10 +1446,11 @@ void ArmCmseSGSection::finalizeContents(Ctx &) {
14461446
// https://developer.arm.com/documentation/ecm0359818/latest
14471447
template <typename ELFT> void elf::writeARMCmseImportLib(Ctx &ctx) {
14481448
StringTableSection *shstrtab =
1449-
make<StringTableSection>(".shstrtab", /*dynamic=*/false);
1449+
make<StringTableSection>(ctx, ".shstrtab", /*dynamic=*/false);
14501450
StringTableSection *strtab =
1451-
make<StringTableSection>(".strtab", /*dynamic=*/false);
1452-
SymbolTableBaseSection *impSymTab = make<SymbolTableSection<ELFT>>(*strtab);
1451+
make<StringTableSection>(ctx, ".strtab", /*dynamic=*/false);
1452+
SymbolTableBaseSection *impSymTab =
1453+
make<SymbolTableSection<ELFT>>(ctx, *strtab);
14531454

14541455
SmallVector<std::pair<OutputSection *, SyntheticSection *>, 0> osIsPairs;
14551456
osIsPairs.emplace_back(make<OutputSection>(strtab->name, 0, 0), strtab);

lld/ELF/Arch/RISCV.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,8 +1044,9 @@ namespace {
10441044
// extension.
10451045
class RISCVAttributesSection final : public SyntheticSection {
10461046
public:
1047-
RISCVAttributesSection()
1048-
: SyntheticSection(0, SHT_RISCV_ATTRIBUTES, 1, ".riscv.attributes") {}
1047+
RISCVAttributesSection(Ctx &ctx)
1048+
: SyntheticSection(ctx, 0, SHT_RISCV_ATTRIBUTES, 1, ".riscv.attributes") {
1049+
}
10491050

10501051
size_t getSize(Ctx &) const override { return size; }
10511052
void writeTo(Ctx &, uint8_t *buf) override;
@@ -1179,7 +1180,7 @@ mergeAttributesSection(Ctx &ctx,
11791180
unsigned firstStackAlignValue = 0, xlen = 0;
11801181
bool hasArch = false;
11811182

1182-
ctx.in.riscvAttributes = std::make_unique<RISCVAttributesSection>();
1183+
ctx.in.riscvAttributes = std::make_unique<RISCVAttributesSection>(ctx);
11831184
auto &merged = static_cast<RISCVAttributesSection &>(*ctx.in.riscvAttributes);
11841185

11851186
// Collect all tags values from attributes section.

lld/ELF/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2370,7 +2370,7 @@ static void replaceCommonSymbols(Ctx &ctx) {
23702370
if (!s)
23712371
continue;
23722372

2373-
auto *bss = make<BssSection>("COMMON", s->size, s->alignment);
2373+
auto *bss = make<BssSection>(ctx, "COMMON", s->size, s->alignment);
23742374
bss->file = s->file;
23752375
ctx.inputSections.push_back(bss);
23762376
Defined(s->file, StringRef(), s->binding, s->stOther, s->type,

lld/ELF/InputSection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ static_assert(sizeof(InputSection) <= 160, "InputSection is too big");
472472

473473
class SyntheticSection : public InputSection {
474474
public:
475-
SyntheticSection(uint64_t flags, uint32_t type, uint32_t addralign,
475+
SyntheticSection(Ctx &ctx, uint64_t flags, uint32_t type, uint32_t addralign,
476476
StringRef name)
477477
: InputSection(ctx.internalFile, flags, type, addralign, {}, name,
478478
InputSectionBase::Synthetic) {}

lld/ELF/OutputSections.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ static MergeSyntheticSection *createMergeSynthetic(Ctx &ctx, StringRef name,
178178
uint64_t flags,
179179
uint32_t addralign) {
180180
if ((flags & SHF_STRINGS) && ctx.arg.optimize >= 2)
181-
return make<MergeTailSection>(name, type, flags, addralign);
182-
return make<MergeNoTailSection>(name, type, flags, addralign);
181+
return make<MergeTailSection>(ctx, name, type, flags, addralign);
182+
return make<MergeNoTailSection>(ctx, name, type, flags, addralign);
183183
}
184184

185185
// This function scans over the InputSectionBase list sectionBases to create

lld/ELF/Relocations.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ template <class ELFT> static void addCopyRelSymbol(Ctx &ctx, SharedSymbol &ss) {
381381
// See if this symbol is in a read-only segment. If so, preserve the symbol's
382382
// memory protection by reserving space in the .bss.rel.ro section.
383383
bool isRO = isReadOnly<ELFT>(ss);
384-
BssSection *sec =
385-
make<BssSection>(isRO ? ".bss.rel.ro" : ".bss", symSize, ss.alignment);
384+
BssSection *sec = make<BssSection>(ctx, isRO ? ".bss.rel.ro" : ".bss",
385+
symSize, ss.alignment);
386386
OutputSection *osec = (isRO ? ctx.in.bssRelRo : ctx.in.bss)->getParent();
387387

388388
// At this point, sectionBases has been migrated to sections. Append sec to
@@ -2185,7 +2185,7 @@ void ThunkCreator::createInitialThunkSections(
21852185
ThunkSection *ThunkCreator::addThunkSection(OutputSection *os,
21862186
InputSectionDescription *isd,
21872187
uint64_t off) {
2188-
auto *ts = make<ThunkSection>(os, off);
2188+
auto *ts = make<ThunkSection>(ctx, os, off);
21892189
ts->partition = os->partition;
21902190
if ((ctx.arg.fixCortexA53Errata843419 || ctx.arg.fixCortexA8) &&
21912191
!isd->sections.empty()) {

0 commit comments

Comments
 (0)