@@ -167,7 +167,7 @@ template <class ELFT>
167
167
void MipsOptionsSection<ELFT>::writeTo(Ctx &ctx, uint8_t *buf) {
168
168
auto *options = reinterpret_cast <Elf_Mips_Options *>(buf);
169
169
options->kind = ODK_REGINFO;
170
- options->size = getSize ();
170
+ options->size = getSize (ctx );
171
171
172
172
if (!ctx.arg .relocatable )
173
173
reginfo.ri_gp_value = ctx.in .mipsGot ->getGp ();
@@ -322,7 +322,7 @@ GnuPropertySection::GnuPropertySection()
322
322
323
323
void GnuPropertySection::writeTo (Ctx &ctx, uint8_t *buf) {
324
324
write32 (buf, 4 ); // Name size
325
- write32 (buf + 4 , getSize () - 16 ); // Content size
325
+ write32 (buf + 4 , getSize (ctx ) - 16 ); // Content size
326
326
write32 (buf + 8 , NT_GNU_PROPERTY_TYPE_0); // Type
327
327
memcpy (buf + 12 , " GNU" , 4 ); // Name string
328
328
@@ -348,7 +348,7 @@ void GnuPropertySection::writeTo(Ctx &ctx, uint8_t *buf) {
348
348
}
349
349
}
350
350
351
- size_t GnuPropertySection::getSize () const {
351
+ size_t GnuPropertySection::getSize (Ctx &ctx ) const {
352
352
uint32_t contentSize = 0 ;
353
353
if (ctx.arg .andFeatures != 0 )
354
354
contentSize += ctx.arg .is64 ? 16 : 12 ;
@@ -1183,7 +1183,7 @@ void GotPltSection::addEntry(Symbol &sym) {
1183
1183
entries.push_back (&sym);
1184
1184
}
1185
1185
1186
- size_t GotPltSection::getSize () const {
1186
+ size_t GotPltSection::getSize (Ctx &ctx ) const {
1187
1187
return (ctx.target ->gotPltHeaderEntriesNum + entries.size ()) *
1188
1188
ctx.target ->gotEntrySize ;
1189
1189
}
@@ -1228,7 +1228,7 @@ void IgotPltSection::addEntry(Symbol &sym) {
1228
1228
entries.push_back (&sym);
1229
1229
}
1230
1230
1231
- size_t IgotPltSection::getSize () const {
1231
+ size_t IgotPltSection::getSize (Ctx &ctx ) const {
1232
1232
return entries.size () * ctx.target ->gotEntrySize ;
1233
1233
}
1234
1234
@@ -1303,17 +1303,17 @@ DynamicSection<ELFT>::DynamicSection()
1303
1303
//
1304
1304
// DT_RELASZ is the total size of the included sections.
1305
1305
static uint64_t addRelaSz (const RelocationBaseSection &relaDyn) {
1306
- size_t size = relaDyn.getSize ();
1306
+ size_t size = relaDyn.getSize (ctx );
1307
1307
if (ctx.in .relaPlt ->getParent () == relaDyn.getParent ())
1308
- size += ctx.in .relaPlt ->getSize ();
1308
+ size += ctx.in .relaPlt ->getSize (ctx );
1309
1309
return size;
1310
1310
}
1311
1311
1312
1312
// A Linker script may assign the RELA relocation sections to the same
1313
1313
// output section. When this occurs we cannot just use the OutputSection
1314
1314
// Size. Moreover the [DT_JMPREL, DT_JMPREL + DT_PLTRELSZ) is permitted to
1315
1315
// overlap with the [DT_RELA, DT_RELA + DT_RELASZ).
1316
- static uint64_t addPltRelSz () { return ctx.in .relaPlt ->getSize (); }
1316
+ static uint64_t addPltRelSz () { return ctx.in .relaPlt ->getSize (ctx ); }
1317
1317
1318
1318
// Add remaining entries to complete .dynamic contents.
1319
1319
template <class ELFT >
@@ -1482,15 +1482,15 @@ DynamicSection<ELFT>::computeContents() {
1482
1482
addInSec (DT_AARCH64_MEMTAG_GLOBALS,
1483
1483
*ctx.mainPart ->memtagGlobalDescriptors );
1484
1484
addInt (DT_AARCH64_MEMTAG_GLOBALSSZ,
1485
- ctx.mainPart ->memtagGlobalDescriptors ->getSize ());
1485
+ ctx.mainPart ->memtagGlobalDescriptors ->getSize (ctx ));
1486
1486
}
1487
1487
}
1488
1488
}
1489
1489
1490
1490
addInSec (DT_SYMTAB, *part.dynSymTab );
1491
1491
addInt (DT_SYMENT, sizeof (Elf_Sym));
1492
1492
addInSec (DT_STRTAB, *part.dynStrTab );
1493
- addInt (DT_STRSZ, part.dynStrTab ->getSize ());
1493
+ addInt (DT_STRSZ, part.dynStrTab ->getSize (ctx ));
1494
1494
if (!ctx.arg .zText )
1495
1495
addInt (DT_TEXTREL, 0 );
1496
1496
if (part.gnuHashTab && part.gnuHashTab ->getParent ())
@@ -2361,7 +2361,7 @@ void SymtabShndxSection::finalizeContents(Ctx &) {
2361
2361
getParent ()->link = ctx.in .symTab ->getParent ()->sectionIndex ;
2362
2362
}
2363
2363
2364
- size_t SymtabShndxSection::getSize () const {
2364
+ size_t SymtabShndxSection::getSize (Ctx &ctx ) const {
2365
2365
return ctx.in .symTab ->getNumSymbols () * 4 ;
2366
2366
}
2367
2367
@@ -2583,7 +2583,7 @@ void PltSection::addEntry(Symbol &sym) {
2583
2583
entries.push_back (&sym);
2584
2584
}
2585
2585
2586
- size_t PltSection::getSize () const {
2586
+ size_t PltSection::getSize (Ctx &ctx ) const {
2587
2587
return headerSize + entries.size () * ctx.target ->pltEntrySize ;
2588
2588
}
2589
2589
@@ -2620,7 +2620,7 @@ void IpltSection::writeTo(Ctx &ctx, uint8_t *buf) {
2620
2620
}
2621
2621
}
2622
2622
2623
- size_t IpltSection::getSize () const {
2623
+ size_t IpltSection::getSize (Ctx &ctx ) const {
2624
2624
return entries.size () * ctx.target ->ipltEntrySize ;
2625
2625
}
2626
2626
@@ -2648,7 +2648,7 @@ void PPC32GlinkSection::writeTo(Ctx &ctx, uint8_t *buf) {
2648
2648
writePPC32GlinkSection (buf, entries.size ());
2649
2649
}
2650
2650
2651
- size_t PPC32GlinkSection::getSize () const {
2651
+ size_t PPC32GlinkSection::getSize (Ctx &ctx ) const {
2652
2652
return headerSize + entries.size () * ctx.target ->pltEntrySize + footerSize;
2653
2653
}
2654
2654
@@ -2717,7 +2717,7 @@ void IBTPltSection::writeTo(Ctx &ctx, uint8_t *buf) {
2717
2717
ctx.target ->writeIBTPlt (buf, ctx.in .plt ->getNumEntries ());
2718
2718
}
2719
2719
2720
- size_t IBTPltSection::getSize () const {
2720
+ size_t IBTPltSection::getSize (Ctx &ctx ) const {
2721
2721
// 16 is the header size of .plt.
2722
2722
return 16 + ctx.in .plt ->getNumEntries () * ctx.target ->pltEntrySize ;
2723
2723
}
@@ -3662,7 +3662,7 @@ void EhFrameHeader::write() {
3662
3662
}
3663
3663
}
3664
3664
3665
- size_t EhFrameHeader::getSize () const {
3665
+ size_t EhFrameHeader::getSize (Ctx &ctx ) const {
3666
3666
// .eh_frame_hdr has a 12 bytes header followed by an array of FDEs.
3667
3667
return 12 + getPartition ().ehFrame ->numFdes * 8 ;
3668
3668
}
@@ -3728,7 +3728,7 @@ void VersionDefinitionSection::writeTo(Ctx &ctx, uint8_t *buf) {
3728
3728
write32 (buf + 16 , 0 ); // vd_next
3729
3729
}
3730
3730
3731
- size_t VersionDefinitionSection::getSize () const {
3731
+ size_t VersionDefinitionSection::getSize (Ctx &ctx ) const {
3732
3732
return EntrySize * getVerDefNum ();
3733
3733
}
3734
3734
@@ -3745,7 +3745,7 @@ void VersionTableSection::finalizeContents(Ctx &) {
3745
3745
getParent ()->link = getPartition ().dynSymTab ->getParent ()->sectionIndex ;
3746
3746
}
3747
3747
3748
- size_t VersionTableSection::getSize () const {
3748
+ size_t VersionTableSection::getSize (Ctx &ctx ) const {
3749
3749
return (getPartition ().dynSymTab ->getSymbols ().size () + 1 ) * 2 ;
3750
3750
}
3751
3751
@@ -3852,7 +3852,7 @@ void VersionNeedSection<ELFT>::writeTo(Ctx &ctx, uint8_t *buf) {
3852
3852
verneed[-1 ].vn_next = 0 ;
3853
3853
}
3854
3854
3855
- template <class ELFT > size_t VersionNeedSection<ELFT>::getSize() const {
3855
+ template <class ELFT > size_t VersionNeedSection<ELFT>::getSize(Ctx &ctx ) const {
3856
3856
return verneeds.size () * sizeof (Elf_Verneed) +
3857
3857
SharedFile::vernauxNum * sizeof (Elf_Vernaux);
3858
3858
}
@@ -3873,9 +3873,9 @@ MergeTailSection::MergeTailSection(StringRef name, uint32_t type,
3873
3873
: MergeSyntheticSection(name, type, flags, alignment),
3874
3874
builder(StringTableBuilder::RAW, llvm::Align(alignment)) {}
3875
3875
3876
- size_t MergeTailSection::getSize () const { return builder.getSize (); }
3876
+ size_t MergeTailSection::getSize (Ctx & ) const { return builder.getSize (); }
3877
3877
3878
- void MergeTailSection::writeTo (Ctx &ctx , uint8_t *buf) { builder.write (buf); }
3878
+ void MergeTailSection::writeTo (Ctx &, uint8_t *buf) { builder.write (buf); }
3879
3879
3880
3880
void MergeTailSection::finalizeContents (Ctx &) {
3881
3881
// Add all string pieces to the string table builder to create section
@@ -4228,7 +4228,7 @@ ThunkSection::ThunkSection(OutputSection *os, uint64_t off)
4228
4228
this ->outSecOff = off;
4229
4229
}
4230
4230
4231
- size_t ThunkSection::getSize () const {
4231
+ size_t ThunkSection::getSize (Ctx & ) const {
4232
4232
if (roundUpSizeForErrata)
4233
4233
return alignTo (size, 4096 );
4234
4234
return size;
@@ -4318,7 +4318,7 @@ PPC64LongBranchTargetSection::addEntry(const Symbol *sym, int64_t addend) {
4318
4318
return res.first ->second ;
4319
4319
}
4320
4320
4321
- size_t PPC64LongBranchTargetSection::getSize () const {
4321
+ size_t PPC64LongBranchTargetSection::getSize (Ctx &ctx ) const {
4322
4322
return entries.size () * 8 ;
4323
4323
}
4324
4324
@@ -4415,7 +4415,7 @@ PartitionElfHeaderSection<ELFT>::PartitionElfHeaderSection()
4415
4415
: SyntheticSection(SHF_ALLOC, SHT_LLVM_PART_EHDR, 1 , " " ) {}
4416
4416
4417
4417
template <typename ELFT>
4418
- size_t PartitionElfHeaderSection<ELFT>::getSize() const {
4418
+ size_t PartitionElfHeaderSection<ELFT>::getSize(Ctx &ctx ) const {
4419
4419
return sizeof (typename ELFT::Ehdr);
4420
4420
}
4421
4421
@@ -4433,7 +4433,7 @@ PartitionProgramHeadersSection<ELFT>::PartitionProgramHeadersSection()
4433
4433
: SyntheticSection(SHF_ALLOC, SHT_LLVM_PART_PHDR, 1 , " .phdrs" ) {}
4434
4434
4435
4435
template <typename ELFT>
4436
- size_t PartitionProgramHeadersSection<ELFT>::getSize() const {
4436
+ size_t PartitionProgramHeadersSection<ELFT>::getSize(Ctx &ctx ) const {
4437
4437
return sizeof (typename ELFT::Phdr) * getPartition ().phdrs .size ();
4438
4438
}
4439
4439
@@ -4445,7 +4445,7 @@ void PartitionProgramHeadersSection<ELFT>::writeTo(Ctx &ctx, uint8_t *buf) {
4445
4445
PartitionIndexSection::PartitionIndexSection ()
4446
4446
: SyntheticSection(SHF_ALLOC, SHT_PROGBITS, 4 , " .rodata" ) {}
4447
4447
4448
- size_t PartitionIndexSection::getSize () const {
4448
+ size_t PartitionIndexSection::getSize (Ctx &ctx ) const {
4449
4449
return 12 * (ctx.partitions .size () - 1 );
4450
4450
}
4451
4451
@@ -4548,7 +4548,7 @@ void MemtagAndroidNote::writeTo(Ctx &ctx, uint8_t *buf) {
4548
4548
write32 (buf, value); // note value
4549
4549
}
4550
4550
4551
- size_t MemtagAndroidNote::getSize () const {
4551
+ size_t MemtagAndroidNote::getSize (Ctx &ctx ) const {
4552
4552
return sizeof (llvm::ELF::Elf64_Nhdr) +
4553
4553
/* namesz=*/ alignTo (sizeof (kMemtagAndroidNoteName ), 4 ) +
4554
4554
/* descsz=*/ sizeof (uint32_t );
@@ -4563,7 +4563,7 @@ void PackageMetadataNote::writeTo(Ctx &ctx, uint8_t *buf) {
4563
4563
ctx.arg .packageMetadata .size ());
4564
4564
}
4565
4565
4566
- size_t PackageMetadataNote::getSize () const {
4566
+ size_t PackageMetadataNote::getSize (Ctx &ctx ) const {
4567
4567
return sizeof (llvm::ELF::Elf64_Nhdr) + 4 +
4568
4568
alignTo (ctx.arg .packageMetadata .size () + 1 , 4 );
4569
4569
}
@@ -4623,19 +4623,19 @@ createMemtagGlobalDescriptors(const SmallVector<const Symbol *, 0> &symbols,
4623
4623
}
4624
4624
4625
4625
bool MemtagGlobalDescriptors::updateAllocSize () {
4626
- size_t oldSize = getSize ();
4626
+ size_t oldSize = getSize (ctx );
4627
4627
std::stable_sort (symbols.begin (), symbols.end (),
4628
4628
[](const Symbol *s1, const Symbol *s2) {
4629
4629
return s1->getVA () < s2->getVA ();
4630
4630
});
4631
- return oldSize != getSize ();
4631
+ return oldSize != getSize (ctx );
4632
4632
}
4633
4633
4634
4634
void MemtagGlobalDescriptors::writeTo (Ctx &ctx, uint8_t *buf) {
4635
4635
createMemtagGlobalDescriptors (symbols, buf);
4636
4636
}
4637
4637
4638
- size_t MemtagGlobalDescriptors::getSize () const {
4638
+ size_t MemtagGlobalDescriptors::getSize (Ctx &ctx ) const {
4639
4639
return createMemtagGlobalDescriptors (symbols);
4640
4640
}
4641
4641
@@ -4831,7 +4831,7 @@ template <class ELFT> void elf::createSyntheticSections(Ctx &ctx) {
4831
4831
ctx.in .partIndex = std::make_unique<PartitionIndexSection>();
4832
4832
addOptionalRegular (" __part_index_begin" , ctx.in .partIndex .get (), 0 );
4833
4833
addOptionalRegular (" __part_index_end" , ctx.in .partIndex .get (),
4834
- ctx.in .partIndex ->getSize ());
4834
+ ctx.in .partIndex ->getSize (ctx ));
4835
4835
add (*ctx.in .partIndex );
4836
4836
}
4837
4837
0 commit comments