@@ -999,9 +999,11 @@ class AArch64BtiPac final : public AArch64 {
999
999
1000
1000
private:
1001
1001
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;
1005
1007
};
1006
1008
} // namespace
1007
1009
@@ -1016,13 +1018,18 @@ AArch64BtiPac::AArch64BtiPac(Ctx &ctx) : AArch64(ctx) {
1016
1018
// relocations.
1017
1019
// The PAC PLT entries require dynamic loader support and this isn't known
1018
1020
// from properties in the objects, so we use the command line flag.
1019
- pacEntry = ctx.arg .zPacPlt ;
1020
1021
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
+ }
1024
1031
1025
- if (btiHeader || pacEntry ) {
1032
+ if (btiHeader || (pacEntryKind != PEK_NoAuth) ) {
1026
1033
pltEntrySize = 24 ;
1027
1034
ipltEntrySize = 24 ;
1028
1035
}
@@ -1106,9 +1113,10 @@ void AArch64BtiPac::writePlt(uint8_t *buf, const Symbol &sym,
1106
1113
relocateNoSym (buf + 4 , R_AARCH64_LDST64_ABS_LO12_NC, gotPltEntryAddr);
1107
1114
relocateNoSym (buf + 8 , R_AARCH64_ADD_ABS_LO12_NC, gotPltEntryAddr);
1108
1115
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));
1112
1120
else
1113
1121
memcpy (buf + sizeof (addrInst), stdBr, sizeof (stdBr));
1114
1122
if (!hasBti)
0 commit comments