@@ -399,24 +399,6 @@ class PPC64PDLongBranchThunk final : public PPC64LongBranchThunk {
399399 }
400400};
401401
402- // A bl instruction uses a signed 24 bit offset, with an implicit 4 byte
403- // alignment. This gives a possible 26 bits of 'reach'. If the caller and
404- // callee do not use toc and the call offset is larger than 26 bits,
405- // we need to emit a pc-rel based long-branch thunk. The target address of
406- // the callee is computed with a PC-relative offset.
407- class PPC64PCRelLongBranchThunk final : public Thunk {
408- public:
409- PPC64PCRelLongBranchThunk (Symbol &dest, int64_t addend)
410- : Thunk(dest, addend) {
411- alignment = 16 ;
412- }
413- uint32_t size () override { return 32 ; }
414- void writeTo (uint8_t *buf) override ;
415- void addSymbols (ThunkSection &isec) override ;
416- bool isCompatibleWith (const InputSection &isec,
417- const Relocation &rel) const override ;
418- };
419-
420402} // end anonymous namespace
421403
422404Defined *Thunk::addSymbol (StringRef name, uint8_t type, uint64_t value,
@@ -1061,42 +1043,6 @@ bool PPC64LongBranchThunk::isCompatibleWith(const InputSection &isec,
10611043 return rel.type == R_PPC64_REL24 || rel.type == R_PPC64_REL14;
10621044}
10631045
1064- void PPC64PCRelLongBranchThunk::writeTo (uint8_t *buf) {
1065- int64_t offset = destination.getVA () - getThunkTargetSym ()->getVA ();
1066- if (!isInt<34 >(offset))
1067- reportRangeError (buf, offset, 34 , destination,
1068- " PC-relative long branch stub offset" );
1069-
1070- int nextInstOffset;
1071- if (!config->power10Stubs ) {
1072- uint32_t off = destination.getVA (addend) - getThunkTargetSym ()->getVA () - 8 ;
1073- write32 (buf + 0 , 0x7c0802a6 ); // mflr r12
1074- write32 (buf + 4 , 0x429f0005 ); // bcl 20,31,.+4
1075- write32 (buf + 8 , 0x7d6802a6 ); // mflr r11
1076- write32 (buf + 12 , 0x7d8803a6 ); // mtlr r12
1077- write32 (buf + 16 , 0x3d8b0000 | computeHiBits (off)); // addis r12,r11,off@ha
1078- write32 (buf + 20 , 0x398c0000 | (off & 0xffff )); // addi r12,r12,off@l
1079- nextInstOffset = 24 ;
1080- } else {
1081- uint64_t paddi = PADDI_R12_NO_DISP | (((offset >> 16 ) & 0x3ffff ) << 32 ) |
1082- (offset & 0xffff );
1083- writePrefixedInstruction (buf + 0 , paddi); // paddi r12, 0, func@pcrel, 1
1084- nextInstOffset = 8 ;
1085- }
1086- write32 (buf + nextInstOffset, MTCTR_R12); // mtctr r12
1087- write32 (buf + nextInstOffset + 4 , BCTR); // bctr
1088- }
1089-
1090- void PPC64PCRelLongBranchThunk::addSymbols (ThunkSection &isec) {
1091- addSymbol (saver.save (" __long_branch_pcrel_" + destination.getName ()),
1092- STT_FUNC, 0 , isec);
1093- }
1094-
1095- bool PPC64PCRelLongBranchThunk::isCompatibleWith (const InputSection &isec,
1096- const Relocation &rel) const {
1097- return rel.type == R_PPC64_REL24_NOTOC;
1098- }
1099-
11001046Thunk::Thunk (Symbol &d, int64_t a) : destination(d), addend(a), offset(0 ) {}
11011047
11021048Thunk::~Thunk () = default ;
@@ -1223,9 +1169,7 @@ static Thunk *addThunkPPC64(RelType type, Symbol &s, int64_t a) {
12231169 return make<PPC64R2SaveStub>(s, a);
12241170
12251171 if (type == R_PPC64_REL24_NOTOC)
1226- return (s.stOther >> 5 ) > 1
1227- ? (Thunk *)make<PPC64R12SetupStub>(s)
1228- : (Thunk *)make<PPC64PCRelLongBranchThunk>(s, a);
1172+ return make<PPC64R12SetupStub>(s);
12291173
12301174 if (config->picThunk )
12311175 return make<PPC64PILongBranchThunk>(s, a);
0 commit comments