Skip to content

Commit a9e6f90

Browse files
authored
[libunwind][PAuthLR] Remove PC offset when using FEAT_PAuthLR (#164224)
When originally introduced to libunwind as part of #112171, FEAT_PAuthLR had its Call Frame Instruction's (CFI's) in a different location to other Signing Authentication methods. To incorporate this in libunwind, a 4 byte offset was introduced to work with this. However, this design was reversed in #121551 so the CFI's are emitted in the same location as other methods. When making this change, the offset in libunwind was not removed, so libunwind's PC value would be incorrect. As the 4 byte offset is no longer needed, that adjustment can be removed. results->ptrAuthDiversifier will still be set.
1 parent da15b8f commit a9e6f90

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

libunwind/src/DwarfParser.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -842,12 +842,10 @@ bool CFI_Parser<A>::parseFDEInstructions(A &addressSpace,
842842
results->savedRegisters[UNW_AARCH64_RA_SIGN_STATE].value ^ 0x3;
843843
results->setRegisterValue(UNW_AARCH64_RA_SIGN_STATE, value,
844844
initialState);
845-
// When calculating the value of the PC, it is assumed that the CFI
846-
// instruction is placed before the signing instruction, however it is
847-
// placed after. Because of this, we need to take into account the CFI
848-
// instruction is one instruction call later than expected, and reduce
849-
// the PC value by 4 bytes to compensate.
850-
results->ptrAuthDiversifier = fdeInfo.pcStart + codeOffset - 0x4;
845+
// When using Feat_PAuthLR, the PC value needs to be captured so that
846+
// during unwinding, the correct PC value is used for re-authentication.
847+
// It is assumed that the CFI is placed before the signing instruction.
848+
results->ptrAuthDiversifier = fdeInfo.pcStart + codeOffset;
851849
_LIBUNWIND_TRACE_DWARF(
852850
"DW_CFA_AARCH64_negate_ra_state_with_pc(pc=0x%" PRIx64 ")\n",
853851
static_cast<uint64_t>(results->ptrAuthDiversifier));

0 commit comments

Comments
 (0)