@@ -290,7 +290,7 @@ Defined *elf::addSyntheticLocal(Ctx &ctx, StringRef name, uint8_t type,
290
290
return s;
291
291
}
292
292
293
- static size_t getHashSize () {
293
+ static size_t getHashSize (Ctx &ctx ) {
294
294
switch (ctx.arg .buildId ) {
295
295
case BuildIdKind::Fast:
296
296
return 8 ;
@@ -362,7 +362,7 @@ size_t GnuPropertySection::getSize() const {
362
362
363
363
BuildIdSection::BuildIdSection (Ctx &ctx)
364
364
: SyntheticSection(ctx, SHF_ALLOC, SHT_NOTE, 4 , " .note.gnu.build-id" ),
365
- hashSize(getHashSize()) {}
365
+ hashSize(getHashSize(ctx )) {}
366
366
367
367
void BuildIdSection::writeTo (uint8_t *buf) {
368
368
write32 (buf, 4 ); // Name size
@@ -1208,7 +1208,7 @@ bool GotPltSection::isNeeded() const {
1208
1208
return !entries.empty () || hasGotPltOffRel;
1209
1209
}
1210
1210
1211
- static StringRef getIgotPltName () {
1211
+ static StringRef getIgotPltName (Ctx &ctx ) {
1212
1212
// On ARM the IgotPltSection is part of the GotSection.
1213
1213
if (ctx.arg .emachine == EM_ARM)
1214
1214
return " .got" ;
@@ -1226,7 +1226,7 @@ static StringRef getIgotPltName() {
1226
1226
IgotPltSection::IgotPltSection (Ctx &ctx)
1227
1227
: SyntheticSection(ctx, SHF_ALLOC | SHF_WRITE,
1228
1228
ctx.arg.emachine == EM_PPC64 ? SHT_NOBITS : SHT_PROGBITS,
1229
- ctx.target->gotEntrySize, getIgotPltName()) {}
1229
+ ctx.target->gotEntrySize, getIgotPltName(ctx )) {}
1230
1230
1231
1231
void IgotPltSection::addEntry (Symbol &sym) {
1232
1232
assert (ctx.symAux .back ().pltIdx == entries.size ());
@@ -1605,7 +1605,7 @@ uint64_t DynamicReloc::getOffset() const {
1605
1605
return inputSec->getVA (offsetInSec);
1606
1606
}
1607
1607
1608
- int64_t DynamicReloc::computeAddend () const {
1608
+ int64_t DynamicReloc::computeAddend (Ctx &ctx ) const {
1609
1609
switch (kind) {
1610
1610
case AddendOnly:
1611
1611
assert (sym == nullptr );
@@ -1704,17 +1704,18 @@ void RelocationBaseSection::finalizeContents() {
1704
1704
}
1705
1705
}
1706
1706
1707
- void DynamicReloc::computeRaw (SymbolTableBaseSection *symt) {
1707
+ void DynamicReloc::computeRaw (Ctx &ctx, SymbolTableBaseSection *symt) {
1708
1708
r_offset = getOffset ();
1709
1709
r_sym = getSymIndex (symt);
1710
- addend = computeAddend ();
1710
+ addend = computeAddend (ctx );
1711
1711
kind = AddendOnly; // Catch errors
1712
1712
}
1713
1713
1714
1714
void RelocationBaseSection::computeRels () {
1715
1715
SymbolTableBaseSection *symTab = getPartition ().dynSymTab .get ();
1716
- parallelForEach (relocs,
1717
- [symTab](DynamicReloc &rel) { rel.computeRaw (symTab); });
1716
+ parallelForEach (relocs, [&ctx = ctx, symTab](DynamicReloc &rel) {
1717
+ rel.computeRaw (ctx, symTab);
1718
+ });
1718
1719
1719
1720
auto irelative = std::stable_partition (
1720
1721
relocs.begin () + numRelativeRelocs, relocs.end (),
@@ -1853,7 +1854,7 @@ bool AndroidPackedRelocationSection<ELFT>::updateAllocSize(Ctx &ctx) {
1853
1854
r.r_offset = rel.getOffset ();
1854
1855
r.setSymbolAndType (rel.getSymIndex (getPartition ().dynSymTab .get ()),
1855
1856
rel.type , false );
1856
- r.r_addend = ctx.arg .isRela ? rel.computeAddend () : 0 ;
1857
+ r.r_addend = ctx.arg .isRela ? rel.computeAddend (ctx ) : 0 ;
1857
1858
1858
1859
if (r.getType (ctx.arg .isMips64EL ) == ctx.target ->relativeRel )
1859
1860
relatives.push_back (r);
@@ -3438,6 +3439,7 @@ readPubNamesAndTypes(const LLDDwarfObj<ELFT> &obj,
3438
3439
// by uniquifying them by name.
3439
3440
static std::pair<SmallVector<GdbIndexSection::GdbSymbol, 0 >, size_t >
3440
3441
createSymbols (
3442
+ Ctx &ctx,
3441
3443
ArrayRef<SmallVector<GdbIndexSection::NameAttrEntry, 0 >> nameAttrs,
3442
3444
const SmallVector<GdbIndexSection::GdbChunk, 0 > &chunks) {
3443
3445
using GdbSymbol = GdbIndexSection::GdbSymbol;
@@ -3563,7 +3565,8 @@ std::unique_ptr<GdbIndexSection> GdbIndexSection::create(Ctx &ctx) {
3563
3565
3564
3566
auto ret = std::make_unique<GdbIndexSection>(ctx);
3565
3567
ret->chunks = std::move (chunks);
3566
- std::tie (ret->symbols , ret->size ) = createSymbols (nameAttrs, ret->chunks );
3568
+ std::tie (ret->symbols , ret->size ) =
3569
+ createSymbols (ctx, nameAttrs, ret->chunks );
3567
3570
3568
3571
// Count the areas other than the constant pool.
3569
3572
ret->size += sizeof (GdbIndexHeader) + ret->computeSymtabSize () * 8 ;
@@ -3784,9 +3787,9 @@ bool VersionTableSection::isNeeded() const {
3784
3787
(getPartition ().verDef || getPartition ().verNeed ->isNeeded ());
3785
3788
}
3786
3789
3787
- void elf::addVerneed (Symbol * ss) {
3788
- auto &file = cast<SharedFile>(*ss-> file );
3789
- if (ss-> versionId == VER_NDX_GLOBAL)
3790
+ void elf::addVerneed (Ctx &ctx, Symbol & ss) {
3791
+ auto &file = cast<SharedFile>(*ss. file );
3792
+ if (ss. versionId == VER_NDX_GLOBAL)
3790
3793
return ;
3791
3794
3792
3795
if (file.vernauxs .empty ())
@@ -3796,10 +3799,10 @@ void elf::addVerneed(Symbol *ss) {
3796
3799
// already allocated one. The verdef identifiers cover the range
3797
3800
// [1..getVerDefNum(ctx)]; this causes the vernaux identifiers to start from
3798
3801
// getVerDefNum(ctx)+1.
3799
- if (file.vernauxs [ss-> versionId ] == 0 )
3800
- file.vernauxs [ss-> versionId ] = ++SharedFile::vernauxNum + getVerDefNum (ctx);
3802
+ if (file.vernauxs [ss. versionId ] == 0 )
3803
+ file.vernauxs [ss. versionId ] = ++SharedFile::vernauxNum + getVerDefNum (ctx);
3801
3804
3802
- ss-> versionId = file.vernauxs [ss-> versionId ];
3805
+ ss. versionId = file.vernauxs [ss. versionId ];
3803
3806
}
3804
3807
3805
3808
template <class ELFT >
@@ -4659,7 +4662,7 @@ size_t MemtagGlobalDescriptors::getSize() const {
4659
4662
return createMemtagGlobalDescriptors (ctx, symbols);
4660
4663
}
4661
4664
4662
- static OutputSection *findSection (StringRef name) {
4665
+ static OutputSection *findSection (Ctx &ctx, StringRef name) {
4663
4666
for (SectionCommand *cmd : ctx.script ->sectionCommands )
4664
4667
if (auto *osd = dyn_cast<OutputDesc>(cmd))
4665
4668
if (osd->osec .name == name)
@@ -4715,7 +4718,7 @@ template <class ELFT> void elf::createSyntheticSections(Ctx &ctx) {
4715
4718
// .data.rel.ro.bss so that we match in the .data.rel.ro output section.
4716
4719
// This makes sure our relro is contiguous.
4717
4720
bool hasDataRelRo =
4718
- ctx.script ->hasSectionsCommand && findSection (" .data.rel.ro" );
4721
+ ctx.script ->hasSectionsCommand && findSection (ctx, " .data.rel.ro" );
4719
4722
ctx.in .bssRelRo = std::make_unique<BssSection>(
4720
4723
ctx, hasDataRelRo ? " .data.rel.ro.bss" : " .bss.rel.ro" , 0 , 1 );
4721
4724
add (*ctx.in .bssRelRo );
0 commit comments