@@ -999,9 +999,11 @@ class AArch64BtiPac final : public AArch64 {
999999
10001000private:
10011001 bool btiHeader; // bti instruction needed in PLT Header and Entry
1002- bool pacEntry; // Authenticated branch needed in PLT Entry
1003- bool pacUseHint =
1004- true ; // Use hint space instructions for authenticated branch in PLT entry
1002+ enum {
1003+ PEK_NoAuth,
1004+ PEK_AuthHint, // use autia1716 instr for authenticated branch in PLT entry
1005+ PEK_Auth, // use braa instr for authenticated branch in PLT entry
1006+ } pacEntryKind;
10051007};
10061008} // namespace
10071009
@@ -1016,13 +1018,18 @@ AArch64BtiPac::AArch64BtiPac(Ctx &ctx) : AArch64(ctx) {
10161018 // relocations.
10171019 // The PAC PLT entries require dynamic loader support and this isn't known
10181020 // from properties in the objects, so we use the command line flag.
1019- pacEntry = ctx.arg .zPacPlt ;
10201021
1021- if (llvm::any_of (ctx.aarch64PauthAbiCoreInfo ,
1022- [](uint8_t c) { return c != 0 ; }))
1023- pacUseHint = false ;
1022+ if (ctx.arg .zPacPlt ) {
1023+ if (llvm::any_of (ctx.aarch64PauthAbiCoreInfo ,
1024+ [](uint8_t c) { return c != 0 ; }))
1025+ pacEntryKind = PEK_Auth;
1026+ else
1027+ pacEntryKind = PEK_AuthHint;
1028+ } else {
1029+ pacEntryKind = PEK_NoAuth;
1030+ }
10241031
1025- if (btiHeader || pacEntry ) {
1032+ if (btiHeader || (pacEntryKind != PEK_NoAuth) ) {
10261033 pltEntrySize = 24 ;
10271034 ipltEntrySize = 24 ;
10281035 }
@@ -1106,9 +1113,10 @@ void AArch64BtiPac::writePlt(uint8_t *buf, const Symbol &sym,
11061113 relocateNoSym (buf + 4 , R_AARCH64_LDST64_ABS_LO12_NC, gotPltEntryAddr);
11071114 relocateNoSym (buf + 8 , R_AARCH64_ADD_ABS_LO12_NC, gotPltEntryAddr);
11081115
1109- if (pacEntry)
1110- memcpy (buf + sizeof (addrInst), (pacUseHint ? pacHintBr : pacBr),
1111- sizeof (pacUseHint ? pacHintBr : pacBr));
1116+ if (pacEntryKind != PEK_NoAuth)
1117+ memcpy (buf + sizeof (addrInst),
1118+ pacEntryKind == PEK_AuthHint ? pacHintBr : pacBr,
1119+ sizeof (pacEntryKind == PEK_AuthHint ? pacHintBr : pacBr));
11121120 else
11131121 memcpy (buf + sizeof (addrInst), stdBr, sizeof (stdBr));
11141122 if (!hasBti)
0 commit comments