Skip to content

Commit 6f5bcf8

Browse files
committed
fixup! Add support for FEAT_PAuth_LR to libunwind
Formatting fixes
1 parent dc4674c commit 6f5bcf8

File tree

3 files changed

+50
-45
lines changed

3 files changed

+50
-45
lines changed

libunwind/src/DwarfInstructions.hpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,19 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace, pint_t pc,
318318
// We use the hint versions of the authentication instructions below to
319319
// ensure they're assembled by the compiler even for targets with no
320320
// FEAT_PAuth/FEAT_PAuth_LR support.
321-
if(isReturnAddressSignedWithPC(addressSpace, registers, cfa, prolog)) {
322-
register unsigned long long x15 __asm("x15") = prolog.ptrAuthDiversifier;
323-
if(cieInfo.addressesSignedWithBKey) {
321+
if (isReturnAddressSignedWithPC(addressSpace, registers, cfa, prolog)) {
322+
register unsigned long long x15 __asm("x15") =
323+
prolog.ptrAuthDiversifier;
324+
if (cieInfo.addressesSignedWithBKey) {
324325
asm("hint 0x27\n\t" // pacm
325-
"hint 0xe" : "+r"(x17) : "r"(x16), "r"(x15)); // autib1716
326+
"hint 0xe"
327+
: "+r"(x17)
328+
: "r"(x16), "r"(x15)); // autib1716
326329
} else {
327330
asm("hint 0x27\n\t" // pacm
328-
"hint 0xc" : "+r"(x17) : "r"(x16), "r"(x15)); // autia1716
331+
"hint 0xc"
332+
: "+r"(x17)
333+
: "r"(x16), "r"(x15)); // autia1716
329334
}
330335
} else {
331336
if (cieInfo.addressesSignedWithBKey)

libunwind/src/DwarfParser.hpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ class CFI_Parser {
9191
int64_t cfaExpression; // CFA = expression
9292
uint32_t spExtraArgSize;
9393
RegisterLocation savedRegisters[kMaxRegisterNumber + 1];
94-
#if defined(_LIBUNWIND_TARGET_AARCH64)
95-
pint_t ptrAuthDiversifier;
96-
#endif
94+
#if defined(_LIBUNWIND_TARGET_AARCH64)
95+
pint_t ptrAuthDiversifier;
96+
#endif
9797
enum class InitializeTime { kLazy, kNormal };
9898

9999
// When saving registers, this data structure is lazily initialized.
@@ -808,15 +808,16 @@ bool CFI_Parser<A>::parseFDEInstructions(A &addressSpace,
808808
results->savedRegisters[UNW_AARCH64_RA_SIGN_STATE].value ^ 0x3;
809809
results->setRegisterValue(UNW_AARCH64_RA_SIGN_STATE, value,
810810
initialState);
811-
// When calucating the value of the PC, it is assumed that the CFI instruction
812-
// is placed before the signing instruction, however it is placed after. Because
813-
// of this, we need to take into account the CFI instruction is one instruction
814-
// call later than expected, and reduce the PC value by 4 bytes to compensate.
811+
// When calucating the value of the PC, it is assumed that the CFI
812+
// instruction is placed before the signing instruction, however it is
813+
// placed after. Because of this, we need to take into account the CFI
814+
// instruction is one instruction call later than expected, and reduce
815+
// the PC value by 4 bytes to compensate.
815816
results->ptrAuthDiversifier = fdeInfo.pcStart + codeOffset - 0x4;
816-
_LIBUNWIND_TRACE_DWARF("DW_CFA_AARCH64_negate_ra_state_with_pc(pc=0x%" PRIx64 ")\n",
817-
static_cast<uint64_t>(results->ptrAuthDiversifier));
818-
}
819-
break;
817+
_LIBUNWIND_TRACE_DWARF(
818+
"DW_CFA_AARCH64_negate_ra_state_with_pc(pc=0x%" PRIx64 ")\n",
819+
static_cast<uint64_t>(results->ptrAuthDiversifier));
820+
} break;
820821
#endif
821822

822823
#else

libunwind/src/dwarf2.h

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,43 @@
1818

1919
// DWARF unwind instructions
2020
enum {
21-
DW_CFA_nop = 0x0,
22-
DW_CFA_set_loc = 0x1,
23-
DW_CFA_advance_loc1 = 0x2,
24-
DW_CFA_advance_loc2 = 0x3,
25-
DW_CFA_advance_loc4 = 0x4,
26-
DW_CFA_offset_extended = 0x5,
27-
DW_CFA_restore_extended = 0x6,
28-
DW_CFA_undefined = 0x7,
29-
DW_CFA_same_value = 0x8,
30-
DW_CFA_register = 0x9,
31-
DW_CFA_remember_state = 0xA,
32-
DW_CFA_restore_state = 0xB,
33-
DW_CFA_def_cfa = 0xC,
34-
DW_CFA_def_cfa_register = 0xD,
35-
DW_CFA_def_cfa_offset = 0xE,
36-
DW_CFA_def_cfa_expression = 0xF,
37-
DW_CFA_expression = 0x10,
21+
DW_CFA_nop = 0x0,
22+
DW_CFA_set_loc = 0x1,
23+
DW_CFA_advance_loc1 = 0x2,
24+
DW_CFA_advance_loc2 = 0x3,
25+
DW_CFA_advance_loc4 = 0x4,
26+
DW_CFA_offset_extended = 0x5,
27+
DW_CFA_restore_extended = 0x6,
28+
DW_CFA_undefined = 0x7,
29+
DW_CFA_same_value = 0x8,
30+
DW_CFA_register = 0x9,
31+
DW_CFA_remember_state = 0xA,
32+
DW_CFA_restore_state = 0xB,
33+
DW_CFA_def_cfa = 0xC,
34+
DW_CFA_def_cfa_register = 0xD,
35+
DW_CFA_def_cfa_offset = 0xE,
36+
DW_CFA_def_cfa_expression = 0xF,
37+
DW_CFA_expression = 0x10,
3838
DW_CFA_offset_extended_sf = 0x11,
39-
DW_CFA_def_cfa_sf = 0x12,
40-
DW_CFA_def_cfa_offset_sf = 0x13,
41-
DW_CFA_val_offset = 0x14,
42-
DW_CFA_val_offset_sf = 0x15,
43-
DW_CFA_val_expression = 0x16,
44-
DW_CFA_advance_loc = 0x40, // high 2 bits are 0x1, lower 6 bits are delta
45-
DW_CFA_offset = 0x80, // high 2 bits are 0x2, lower 6 bits are register
46-
DW_CFA_restore = 0xC0, // high 2 bits are 0x3, lower 6 bits are register
39+
DW_CFA_def_cfa_sf = 0x12,
40+
DW_CFA_def_cfa_offset_sf = 0x13,
41+
DW_CFA_val_offset = 0x14,
42+
DW_CFA_val_offset_sf = 0x15,
43+
DW_CFA_val_expression = 0x16,
44+
DW_CFA_advance_loc = 0x40, // high 2 bits are 0x1, lower 6 bits are delta
45+
DW_CFA_offset = 0x80, // high 2 bits are 0x2, lower 6 bits are register
46+
DW_CFA_restore = 0xC0, // high 2 bits are 0x3, lower 6 bits are register
4747

4848
// GNU extensions
49-
DW_CFA_GNU_window_save = 0x2D,
50-
DW_CFA_GNU_args_size = 0x2E,
49+
DW_CFA_GNU_window_save = 0x2D,
50+
DW_CFA_GNU_args_size = 0x2E,
5151
DW_CFA_GNU_negative_offset_extended = 0x2F,
5252

5353
// AARCH64 extensions
5454
DW_CFA_AARCH64_negate_ra_state_with_pc = 0x2C,
55-
DW_CFA_AARCH64_negate_ra_state = 0x2D
55+
DW_CFA_AARCH64_negate_ra_state = 0x2D
5656
};
5757

58-
5958
// FSF exception handling Pointer-Encoding constants
6059
// Used in CFI augmentation by GCC
6160
enum {

0 commit comments

Comments
 (0)