@@ -290,7 +290,7 @@ Defined *elf::addSyntheticLocal(Ctx &ctx, StringRef name, uint8_t type,
290290 return s;
291291}
292292
293- static size_t getHashSize () {
293+ static size_t getHashSize (Ctx &ctx ) {
294294 switch (ctx.arg .buildId ) {
295295 case BuildIdKind::Fast:
296296 return 8 ;
@@ -362,7 +362,7 @@ size_t GnuPropertySection::getSize() const {
362362
363363BuildIdSection::BuildIdSection (Ctx &ctx)
364364 : SyntheticSection(ctx, SHF_ALLOC, SHT_NOTE, 4 , " .note.gnu.build-id" ),
365- hashSize(getHashSize()) {}
365+ hashSize(getHashSize(ctx )) {}
366366
367367void BuildIdSection::writeTo (uint8_t *buf) {
368368 write32 (buf, 4 ); // Name size
@@ -1208,7 +1208,7 @@ bool GotPltSection::isNeeded() const {
12081208 return !entries.empty () || hasGotPltOffRel;
12091209}
12101210
1211- static StringRef getIgotPltName () {
1211+ static StringRef getIgotPltName (Ctx &ctx ) {
12121212 // On ARM the IgotPltSection is part of the GotSection.
12131213 if (ctx.arg .emachine == EM_ARM)
12141214 return " .got" ;
@@ -1226,7 +1226,7 @@ static StringRef getIgotPltName() {
12261226IgotPltSection::IgotPltSection (Ctx &ctx)
12271227 : SyntheticSection(ctx, SHF_ALLOC | SHF_WRITE,
12281228 ctx.arg.emachine == EM_PPC64 ? SHT_NOBITS : SHT_PROGBITS,
1229- ctx.target->gotEntrySize, getIgotPltName()) {}
1229+ ctx.target->gotEntrySize, getIgotPltName(ctx )) {}
12301230
12311231void IgotPltSection::addEntry (Symbol &sym) {
12321232 assert (ctx.symAux .back ().pltIdx == entries.size ());
@@ -1605,7 +1605,7 @@ uint64_t DynamicReloc::getOffset() const {
16051605 return inputSec->getVA (offsetInSec);
16061606}
16071607
1608- int64_t DynamicReloc::computeAddend () const {
1608+ int64_t DynamicReloc::computeAddend (Ctx &ctx ) const {
16091609 switch (kind) {
16101610 case AddendOnly:
16111611 assert (sym == nullptr );
@@ -1704,17 +1704,18 @@ void RelocationBaseSection::finalizeContents() {
17041704 }
17051705}
17061706
1707- void DynamicReloc::computeRaw (SymbolTableBaseSection *symt) {
1707+ void DynamicReloc::computeRaw (Ctx &ctx, SymbolTableBaseSection *symt) {
17081708 r_offset = getOffset ();
17091709 r_sym = getSymIndex (symt);
1710- addend = computeAddend ();
1710+ addend = computeAddend (ctx );
17111711 kind = AddendOnly; // Catch errors
17121712}
17131713
17141714void RelocationBaseSection::computeRels () {
17151715 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+ });
17181719
17191720 auto irelative = std::stable_partition (
17201721 relocs.begin () + numRelativeRelocs, relocs.end (),
@@ -1853,7 +1854,7 @@ bool AndroidPackedRelocationSection<ELFT>::updateAllocSize(Ctx &ctx) {
18531854 r.r_offset = rel.getOffset ();
18541855 r.setSymbolAndType (rel.getSymIndex (getPartition ().dynSymTab .get ()),
18551856 rel.type , false );
1856- r.r_addend = ctx.arg .isRela ? rel.computeAddend () : 0 ;
1857+ r.r_addend = ctx.arg .isRela ? rel.computeAddend (ctx ) : 0 ;
18571858
18581859 if (r.getType (ctx.arg .isMips64EL ) == ctx.target ->relativeRel )
18591860 relatives.push_back (r);
@@ -3438,6 +3439,7 @@ readPubNamesAndTypes(const LLDDwarfObj<ELFT> &obj,
34383439// by uniquifying them by name.
34393440static std::pair<SmallVector<GdbIndexSection::GdbSymbol, 0 >, size_t >
34403441createSymbols (
3442+ Ctx &ctx,
34413443 ArrayRef<SmallVector<GdbIndexSection::NameAttrEntry, 0 >> nameAttrs,
34423444 const SmallVector<GdbIndexSection::GdbChunk, 0 > &chunks) {
34433445 using GdbSymbol = GdbIndexSection::GdbSymbol;
@@ -3563,7 +3565,8 @@ std::unique_ptr<GdbIndexSection> GdbIndexSection::create(Ctx &ctx) {
35633565
35643566 auto ret = std::make_unique<GdbIndexSection>(ctx);
35653567 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 );
35673570
35683571 // Count the areas other than the constant pool.
35693572 ret->size += sizeof (GdbIndexHeader) + ret->computeSymtabSize () * 8 ;
@@ -3784,9 +3787,9 @@ bool VersionTableSection::isNeeded() const {
37843787 (getPartition ().verDef || getPartition ().verNeed ->isNeeded ());
37853788}
37863789
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)
37903793 return ;
37913794
37923795 if (file.vernauxs .empty ())
@@ -3796,10 +3799,10 @@ void elf::addVerneed(Symbol *ss) {
37963799 // already allocated one. The verdef identifiers cover the range
37973800 // [1..getVerDefNum(ctx)]; this causes the vernaux identifiers to start from
37983801 // 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);
38013804
3802- ss-> versionId = file.vernauxs [ss-> versionId ];
3805+ ss. versionId = file.vernauxs [ss. versionId ];
38033806}
38043807
38053808template <class ELFT >
@@ -4659,7 +4662,7 @@ size_t MemtagGlobalDescriptors::getSize() const {
46594662 return createMemtagGlobalDescriptors (ctx, symbols);
46604663}
46614664
4662- static OutputSection *findSection (StringRef name) {
4665+ static OutputSection *findSection (Ctx &ctx, StringRef name) {
46634666 for (SectionCommand *cmd : ctx.script ->sectionCommands )
46644667 if (auto *osd = dyn_cast<OutputDesc>(cmd))
46654668 if (osd->osec .name == name)
@@ -4715,7 +4718,7 @@ template <class ELFT> void elf::createSyntheticSections(Ctx &ctx) {
47154718 // .data.rel.ro.bss so that we match in the .data.rel.ro output section.
47164719 // This makes sure our relro is contiguous.
47174720 bool hasDataRelRo =
4718- ctx.script ->hasSectionsCommand && findSection (" .data.rel.ro" );
4721+ ctx.script ->hasSectionsCommand && findSection (ctx, " .data.rel.ro" );
47194722 ctx.in .bssRelRo = std::make_unique<BssSection>(
47204723 ctx, hasDataRelRo ? " .data.rel.ro.bss" : " .bss.rel.ro" , 0 , 1 );
47214724 add (*ctx.in .bssRelRo );
0 commit comments