@@ -592,7 +592,7 @@ SmallVector<EhFrameSection::FdeData, 0> EhFrameSection::getFdeData() const {
592592 return ret;
593593}
594594
595- static uint64_t readFdeAddr (uint8_t *buf, int size) {
595+ static uint64_t readFdeAddr (Ctx &ctx, uint8_t *buf, int size) {
596596 switch (size) {
597597 case DW_EH_PE_udata2:
598598 return read16 (buf);
@@ -619,7 +619,7 @@ uint64_t EhFrameSection::getFdePc(uint8_t *buf, size_t fdeOff,
619619 // stored at FDE + 8 byte. And this offset is within
620620 // the .eh_frame section.
621621 size_t off = fdeOff + 8 ;
622- uint64_t addr = readFdeAddr (buf + off, enc & 0xf );
622+ uint64_t addr = readFdeAddr (ctx, buf + off, enc & 0xf );
623623 if ((enc & 0x70 ) == DW_EH_PE_absptr)
624624 return ctx.arg .is64 ? addr : uint32_t (addr);
625625 if ((enc & 0x70 ) == DW_EH_PE_pcrel)
@@ -1478,7 +1478,7 @@ DynamicSection<ELFT>::computeContents() {
14781478 if (ctx.arg .zPacPlt )
14791479 addInt (DT_AARCH64_PAC_PLT, 0 );
14801480
1481- if (hasMemtag ()) {
1481+ if (hasMemtag (ctx )) {
14821482 addInt (DT_AARCH64_MEMTAG_MODE, ctx.arg .androidMemtagMode == NT_MEMTAG_LEVEL_ASYNC);
14831483 addInt (DT_AARCH64_MEMTAG_HEAP, ctx.arg .androidMemtagHeap );
14841484 addInt (DT_AARCH64_MEMTAG_STACK, ctx.arg .androidMemtagStack );
@@ -4359,7 +4359,7 @@ bool PPC64LongBranchTargetSection::isNeeded() const {
43594359 return !finalized || !entries.empty ();
43604360}
43614361
4362- static uint8_t getAbiVersion () {
4362+ static uint8_t getAbiVersion (Ctx &ctx ) {
43634363 // MIPS non-PIC executable gets ABI version 1.
43644364 if (ctx.arg .emachine == EM_MIPS) {
43654365 if (!ctx.arg .isPic && !ctx.arg .relocatable &&
@@ -4388,7 +4388,7 @@ template <typename ELFT> void elf::writeEhdr(uint8_t *buf, Partition &part) {
43884388 ELFT::Endianness == endianness::little ? ELFDATA2LSB : ELFDATA2MSB;
43894389 eHdr->e_ident [EI_VERSION] = EV_CURRENT;
43904390 eHdr->e_ident [EI_OSABI] = ctx.arg .osabi ;
4391- eHdr->e_ident [EI_ABIVERSION] = getAbiVersion ();
4391+ eHdr->e_ident [EI_ABIVERSION] = getAbiVersion (ctx );
43924392 eHdr->e_machine = ctx.arg .emachine ;
43934393 eHdr->e_version = EV_CURRENT;
43944394 eHdr->e_flags = ctx.arg .eflags ;
@@ -4516,7 +4516,7 @@ static bool needsInterpSection(Ctx &ctx) {
45164516 !ctx.arg .dynamicLinker .empty () && ctx.script ->needsInterpSection ();
45174517}
45184518
4519- bool elf::hasMemtag () {
4519+ bool elf::hasMemtag (Ctx &ctx ) {
45204520 return ctx.arg .emachine == EM_AARCH64 &&
45214521 ctx.arg .androidMemtagMode != ELF::NT_MEMTAG_LEVEL_NONE;
45224522}
@@ -4527,8 +4527,8 @@ bool elf::hasMemtag() {
45274527// - Dynamic entries.
45284528// This restriction could be removed in future by re-using some of the ideas
45294529// that ifuncs use in fully static executables.
4530- bool elf::canHaveMemtagGlobals () {
4531- return hasMemtag () &&
4530+ bool elf::canHaveMemtagGlobals (Ctx &ctx ) {
4531+ return hasMemtag (ctx ) &&
45324532 (ctx.arg .relocatable || ctx.arg .shared || needsInterpSection (ctx));
45334533}
45344534
@@ -4656,7 +4656,7 @@ static OutputSection *findSection(StringRef name) {
46564656 return nullptr ;
46574657}
46584658
4659- static Defined *addOptionalRegular (StringRef name, SectionBase *sec,
4659+ static Defined *addOptionalRegular (Ctx &ctx, StringRef name, SectionBase *sec,
46604660 uint64_t val, uint8_t stOther = STV_HIDDEN) {
46614661 Symbol *s = ctx.symtab ->find (name);
46624662 if (!s || s->isDefined () || s->isCommon ())
@@ -4757,10 +4757,10 @@ template <class ELFT> void elf::createSyntheticSections(Ctx &ctx) {
47574757 continue ;
47584758 part.dynamic = std::make_unique<DynamicSection<ELFT>>(ctx);
47594759
4760- if (hasMemtag ()) {
4760+ if (hasMemtag (ctx )) {
47614761 part.memtagAndroidNote = std::make_unique<MemtagAndroidNote>(ctx);
47624762 add (*part.memtagAndroidNote );
4763- if (canHaveMemtagGlobals ()) {
4763+ if (canHaveMemtagGlobals (ctx )) {
47644764 part.memtagGlobalDescriptors =
47654765 std::make_unique<MemtagGlobalDescriptors>(ctx);
47664766 add (*part.memtagGlobalDescriptors );
@@ -4840,8 +4840,8 @@ template <class ELFT> void elf::createSyntheticSections(Ctx &ctx) {
48404840 add (*ctx.in .partEnd );
48414841
48424842 ctx.in .partIndex = std::make_unique<PartitionIndexSection>(ctx);
4843- addOptionalRegular (" __part_index_begin" , ctx.in .partIndex .get (), 0 );
4844- addOptionalRegular (" __part_index_end" , ctx.in .partIndex .get (),
4843+ addOptionalRegular (ctx, " __part_index_begin" , ctx.in .partIndex .get (), 0 );
4844+ addOptionalRegular (ctx, " __part_index_end" , ctx.in .partIndex .get (),
48454845 ctx.in .partIndex ->getSize ());
48464846 add (*ctx.in .partIndex );
48474847 }
0 commit comments