@@ -310,7 +310,7 @@ void ARM::addPltHeaderSymbols(InputSection &isec) const {
310310
311311// Long form PLT entries that do not have any restrictions on the displacement
312312// of the .plt from the .got.plt.
313- static void writePltLong (uint8_t *buf, uint64_t gotPltEntryAddr,
313+ static void writePltLong (Ctx &ctx, uint8_t *buf, uint64_t gotPltEntryAddr,
314314 uint64_t pltEntryAddr) {
315315 write32 (ctx, buf + 0 , 0xe59fc004 ); // ldr ip, L2
316316 write32 (ctx, buf + 4 , 0xe08cc00f ); // L1: add ip, ip, pc
@@ -339,7 +339,7 @@ void ARM::writePlt(uint8_t *buf, const Symbol &sym,
339339 };
340340 if (!llvm::isUInt<27 >(offset)) {
341341 // We cannot encode the Offset, use the long form.
342- writePltLong (buf, sym.getGotPltVA (ctx), pltEntryAddr);
342+ writePltLong (ctx, buf, sym.getGotPltVA (ctx), pltEntryAddr);
343343 return ;
344344 }
345345 write32 (ctx, buf + 0 , pltData[0 ] | ((offset >> 20 ) & 0xff ));
@@ -562,8 +562,8 @@ void ARM::encodeAluGroup(uint8_t *loc, const Relocation &rel, uint64_t val,
562562 (read32 (ctx, loc) & 0xff3ff000 ) | opcode | rot | (imm & 0xff ));
563563}
564564
565- static void encodeLdrGroup (uint8_t *loc, const Relocation &rel, uint64_t val ,
566- int group) {
565+ static void encodeLdrGroup (Ctx &ctx, uint8_t *loc, const Relocation &rel,
566+ uint64_t val, int group) {
567567 // R_ARM_LDR_PC_Gn is S + A - P, we have ((S + A) | T) - P, if S is a
568568 // function then addr is 0 (modulo 2) and Pa is 0 (modulo 4) so we can clear
569569 // bottom bit to recover S + A - P.
@@ -580,8 +580,8 @@ static void encodeLdrGroup(uint8_t *loc, const Relocation &rel, uint64_t val,
580580 write32 (ctx, loc, (read32 (ctx, loc) & 0xff7ff000 ) | opcode | imm);
581581}
582582
583- static void encodeLdrsGroup (uint8_t *loc, const Relocation &rel, uint64_t val ,
584- int group) {
583+ static void encodeLdrsGroup (Ctx &ctx, uint8_t *loc, const Relocation &rel,
584+ uint64_t val, int group) {
585585 // R_ARM_LDRS_PC_Gn is S + A - P, we have ((S + A) | T) - P, if S is a
586586 // function then addr is 0 (modulo 2) and Pa is 0 (modulo 4) so we can clear
587587 // bottom bit to recover S + A - P.
@@ -804,22 +804,22 @@ void ARM::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
804804 encodeAluGroup (loc, rel, val, 2 , true );
805805 break ;
806806 case R_ARM_LDR_PC_G0:
807- encodeLdrGroup (loc, rel, val, 0 );
807+ encodeLdrGroup (ctx, loc, rel, val, 0 );
808808 break ;
809809 case R_ARM_LDR_PC_G1:
810- encodeLdrGroup (loc, rel, val, 1 );
810+ encodeLdrGroup (ctx, loc, rel, val, 1 );
811811 break ;
812812 case R_ARM_LDR_PC_G2:
813- encodeLdrGroup (loc, rel, val, 2 );
813+ encodeLdrGroup (ctx, loc, rel, val, 2 );
814814 break ;
815815 case R_ARM_LDRS_PC_G0:
816- encodeLdrsGroup (loc, rel, val, 0 );
816+ encodeLdrsGroup (ctx, loc, rel, val, 0 );
817817 break ;
818818 case R_ARM_LDRS_PC_G1:
819- encodeLdrsGroup (loc, rel, val, 1 );
819+ encodeLdrsGroup (ctx, loc, rel, val, 1 );
820820 break ;
821821 case R_ARM_LDRS_PC_G2:
822- encodeLdrsGroup (loc, rel, val, 2 );
822+ encodeLdrsGroup (ctx, loc, rel, val, 2 );
823823 break ;
824824 case R_ARM_THM_ALU_PREL_11_0: {
825825 // ADR encoding T2 (sub), T3 (add) i:imm3:imm8
@@ -1096,11 +1096,11 @@ static void toLittleEndianInstructions(uint8_t *buf, uint64_t start,
10961096 CodeState curState = static_cast <CodeState>(width);
10971097 if (curState == CodeState::Arm)
10981098 for (uint64_t i = start; i < end; i += width)
1099- write32le (buf + i, read32 (ctx, buf + i));
1099+ write32le (buf + i, read32be ( buf + i));
11001100
11011101 if (curState == CodeState::Thumb)
11021102 for (uint64_t i = start; i < end; i += width)
1103- write16le (buf + i, read16 (ctx, buf + i));
1103+ write16le (buf + i, read16be ( buf + i));
11041104}
11051105
11061106// Arm BE8 big endian format requires instructions to be little endian, with
0 commit comments