@@ -230,14 +230,14 @@ static void writePltHeaderLong(Ctx &ctx, uint8_t *buf) {
230230
231231// True if we should use Thumb PLTs, which currently require Thumb2, and are
232232// only used if the target does not have the ARM ISA.
233- static bool useThumbPLTs () {
233+ static bool useThumbPLTs (Ctx &ctx ) {
234234 return ctx.arg .armHasThumb2ISA && !ctx.arg .armHasArmISA ;
235235}
236236
237237// The default PLT header requires the .got.plt to be within 128 Mb of the
238238// .plt in the positive direction.
239239void ARM::writePltHeader (uint8_t *buf) const {
240- if (useThumbPLTs ()) {
240+ if (useThumbPLTs (ctx )) {
241241 // The instruction sequence for thumb:
242242 //
243243 // 0: b500 push {lr}
@@ -295,7 +295,7 @@ void ARM::writePltHeader(uint8_t *buf) const {
295295}
296296
297297void ARM::addPltHeaderSymbols (InputSection &isec) const {
298- if (useThumbPLTs ()) {
298+ if (useThumbPLTs (ctx )) {
299299 addSyntheticLocal (" $t" , STT_NOTYPE, 0 , 0 , isec);
300300 addSyntheticLocal (" $d" , STT_NOTYPE, 12 , 0 , isec);
301301 } else {
@@ -320,8 +320,7 @@ static void writePltLong(uint8_t *buf, uint64_t gotPltEntryAddr,
320320// .plt in the positive direction.
321321void ARM::writePlt (uint8_t *buf, const Symbol &sym,
322322 uint64_t pltEntryAddr) const {
323-
324- if (!useThumbPLTs ()) {
323+ if (!useThumbPLTs (ctx)) {
325324 uint64_t offset = sym.getGotPltVA () - pltEntryAddr - 8 ;
326325
327326 // The PLT entry is similar to the example given in Appendix A of ELF for
@@ -373,7 +372,7 @@ void ARM::writePlt(uint8_t *buf, const Symbol &sym,
373372}
374373
375374void ARM::addPltSymbols (InputSection &isec, uint64_t off) const {
376- if (useThumbPLTs ()) {
375+ if (useThumbPLTs (ctx )) {
377376 addSyntheticLocal (" $t" , STT_NOTYPE, off, 0 , isec);
378377 } else {
379378 addSyntheticLocal (" $a" , STT_NOTYPE, off, 0 , isec);
@@ -399,7 +398,7 @@ bool ARM::needsThunk(RelExpr expr, RelType type, const InputFile *file,
399398 case R_ARM_JUMP24:
400399 // Source is ARM, all PLT entries are ARM so no interworking required.
401400 // Otherwise we need to interwork if STT_FUNC Symbol has bit 0 set (Thumb).
402- assert (!useThumbPLTs () &&
401+ assert (!useThumbPLTs (ctx ) &&
403402 " If the source is ARM, we should not need Thumb PLTs" );
404403 if (s.isFunc () && expr == R_PC && (s.getVA () & 1 ))
405404 return true ;
@@ -413,7 +412,7 @@ bool ARM::needsThunk(RelExpr expr, RelType type, const InputFile *file,
413412 case R_ARM_THM_JUMP24:
414413 // Source is Thumb, when all PLT entries are ARM interworking is required.
415414 // Otherwise we need to interwork if STT_FUNC Symbol has bit 0 clear (ARM).
416- if ((expr == R_PLT_PC && !useThumbPLTs ()) ||
415+ if ((expr == R_PLT_PC && !useThumbPLTs (ctx )) ||
417416 (s.isFunc () && (s.getVA () & 1 ) == 0 ))
418417 return true ;
419418 [[fallthrough]];
@@ -683,7 +682,7 @@ void ARM::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
683682 // PLT entries are always ARM state so we know we need to interwork.
684683 assert (rel.sym ); // R_ARM_THM_CALL is always reached via relocate().
685684 bool bit0Thumb = val & 1 ;
686- bool useThumb = bit0Thumb || useThumbPLTs ();
685+ bool useThumb = bit0Thumb || useThumbPLTs (ctx );
687686 bool isBlx = (read16 (loc + 2 ) & 0x1000 ) == 0 ;
688687 // lld 10.0 and before always used bit0Thumb when deciding to write a BLX
689688 // even when type not STT_FUNC.
@@ -1330,7 +1329,8 @@ class elf::ArmCmseSGVeneer {
13301329ArmCmseSGSection::ArmCmseSGSection (Ctx &ctx)
13311330 : SyntheticSection(llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_EXECINSTR,
13321331 llvm::ELF::SHT_PROGBITS,
1333- /* alignment=*/ 32 , " .gnu.sgstubs" ) {
1332+ /* alignment=*/ 32 , " .gnu.sgstubs" ),
1333+ ctx(ctx) {
13341334 entsize = ACLESESYM_SIZE;
13351335 // The range of addresses used in the CMSE import library should be fixed.
13361336 for (auto &[_, sym] : ctx.symtab ->cmseImportLib ) {
0 commit comments