Skip to content

Commit fc1375a

Browse files
committed
Sigh, actually make sure it builds, also address warnings
1 parent 49a0111 commit fc1375a

File tree

6 files changed

+28
-33
lines changed

6 files changed

+28
-33
lines changed

libunwind/src/DwarfInstructions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DwarfInstructions {
3333
typedef typename A::pint_t pint_t;
3434
typedef typename A::sint_t sint_t;
3535

36-
static int stepWithDwarf(A &addressSpace, typename R::link_reg_t &pc,
36+
static int stepWithDwarf(A &addressSpace, const typename R::link_reg_t &pc,
3737
pint_t fdeStart, R &registers, bool &isSignalFrame,
3838
bool stage2);
3939

libunwind/src/DwarfParser.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,14 @@ const char *CFI_Parser<A>::parseCIE(A &addressSpace, pint_t cie,
409409
const auto oldDiscriminator = resultAddr;
410410
#else
411411
const auto oldDiscriminator = ptrauth_blend_discriminator(
412-
(void*)resultAddr, __ptrauth_unwind_pacret_personality_disc);
412+
(void *)resultAddr, __ptrauth_unwind_pacret_personality_disc);
413413
#endif
414414
const auto discriminator = ptrauth_blend_discriminator(
415-
&cieInfo->personality, __ptrauth_unwind_cie_info_personality_disc);
415+
&cieInfo->personality,
416+
__ptrauth_unwind_cie_info_personality_disc);
416417
void *signedPtr = ptrauth_auth_and_resign(
417-
(void *)personality, ptrauth_key_function_pointer, resultAddr,
418-
ptrauth_key_function_pointer, discriminator);
418+
(void *)personality, ptrauth_key_function_pointer,
419+
oldDiscriminator, ptrauth_key_function_pointer, discriminator);
419420
personality = (pint_t)signedPtr;
420421
}
421422
#endif

libunwind/src/Registers.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
#include "config.h"
1919
#include "libunwind.h"
20-
#include "shadow_stack_unwind.h"
2120
#include "libunwind_ext.h"
21+
#include "shadow_stack_unwind.h"
2222

2323
namespace libunwind {
2424

@@ -1839,8 +1839,8 @@ class _LIBUNWIND_HIDDEN Registers_arm64 {
18391839
public:
18401840
Registers_arm64();
18411841
Registers_arm64(const void *registers);
1842-
Registers_arm64(const Registers_arm64&);
1843-
Registers_arm64& operator=(const Registers_arm64&);
1842+
Registers_arm64(const Registers_arm64 &);
1843+
Registers_arm64 &operator=(const Registers_arm64 &);
18441844

18451845
typedef uint64_t reg_t;
18461846
typedef uint64_t __ptrauth_unwind_registers_arm64_link_reg link_reg_t;
@@ -1863,7 +1863,7 @@ class _LIBUNWIND_HIDDEN Registers_arm64 {
18631863

18641864
uint64_t getSP() const { return _registers.__sp; }
18651865
void setSP(uint64_t value) { _registers.__sp = value; }
1866-
uint64_t getIP() const {
1866+
uint64_t getIP() const {
18671867
uint64_t value = _registers.__pc;
18681868
#if __has_feature(ptrauth_calls)
18691869
// Note the value of the PC was signed to its address in the register state
@@ -1956,11 +1956,12 @@ inline Registers_arm64::Registers_arm64(const void *registers) {
19561956
#endif
19571957
}
19581958

1959-
inline Registers_arm64::Registers_arm64(const Registers_arm64& other) {
1959+
inline Registers_arm64::Registers_arm64(const Registers_arm64 &other) {
19601960
*this = other;
19611961
}
19621962

1963-
inline Registers_arm64& Registers_arm64::operator=(const Registers_arm64& other) {
1963+
inline Registers_arm64 &
1964+
Registers_arm64::operator=(const Registers_arm64 &other) {
19641965
memcpy(&_registers, &other._registers, sizeof(_registers));
19651966
memcpy(_vectorHalfRegisters, &other._vectorHalfRegisters,
19661967
sizeof(_vectorHalfRegisters));

libunwind/src/UnwindCursor.hpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,13 +1367,13 @@ UnwindCursor<A, R>::UnwindCursor(unw_context_t *context, A &as)
13671367
"UnwindCursor<> does not fit in unw_cursor_t");
13681368
static_assert((alignof(UnwindCursor<A, R>) <= alignof(unw_cursor_t)),
13691369
"UnwindCursor<> requires more alignment than unw_cursor_t");
1370-
memset(&_info, 0, sizeof(_info));
1370+
memset(static_cast<void *>(&_info), 0, sizeof(_info));
13711371
}
13721372

13731373
template <typename A, typename R>
13741374
UnwindCursor<A, R>::UnwindCursor(A &as, void *)
13751375
: _addressSpace(as), _unwindInfoMissing(false), _isSignalFrame(false) {
1376-
memset(&_info, 0, sizeof(_info));
1376+
memset(static_cast<void *>(&_info), 0, sizeof(_info));
13771377
// FIXME
13781378
// fill in _registers from thread arg
13791379
}
@@ -1998,13 +1998,11 @@ bool UnwindCursor<A, R>::getInfoFromCompactEncodingSection(
19981998
#if __has_feature(ptrauth_calls)
19991999
// The GOT for the personality function was signed address authenticated.
20002000
// Resign it as a regular function pointer.
2001-
const auto discriminator =
2002-
ptrauth_blend_discriminator(&_info.handler,
2003-
__ptrauth_unwind_upi_handler_disc);
2004-
void *signedPtr =
2005-
ptrauth_auth_and_resign((void *)personality, ptrauth_key_function_pointer,
2006-
personalityPointer, ptrauth_key_function_pointer,
2007-
discriminator);
2001+
const auto discriminator = ptrauth_blend_discriminator(
2002+
&_info.handler, __ptrauth_unwind_upi_handler_disc);
2003+
void *signedPtr = ptrauth_auth_and_resign(
2004+
(void *)personality, ptrauth_key_function_pointer, personalityPointer,
2005+
ptrauth_key_function_pointer, discriminator);
20082006
personality = (__typeof(personality))signedPtr;
20092007
#endif
20102008
if (log)
@@ -3229,7 +3227,7 @@ template <typename A, typename R> int UnwindCursor<A, R>::step(bool stage2) {
32293227
template <typename A, typename R>
32303228
void UnwindCursor<A, R>::getInfo(unw_proc_info_t *info) {
32313229
if (_unwindInfoMissing)
3232-
memset(info, 0, sizeof(*info));
3230+
memset(static_cast<void *>(info), 0, sizeof(*info));
32333231
else
32343232
*info = _info;
32353233
}

libunwind/src/UnwindLevel1.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@
9696
static _Unwind_Personality_Fn get_handler_function(unw_proc_info_t *frameInfo) {
9797
union {
9898
void *opaque_handler;
99-
_Unwind_Personality_Fn __ptrauth_unwind_upi_handler *
100-
handler;
99+
_Unwind_Personality_Fn __ptrauth_unwind_upi_handler *handler;
101100
} u;
102101
u.opaque_handler = (void *)&frameInfo->handler;
103102
return *u.handler;
@@ -608,7 +607,7 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {
608607
unw_word_t result;
609608
__unw_get_reg(cursor, UNW_REG_IP, &result);
610609

611-
#if __has_feature(ptrauth_calls)
610+
#if defined(__ARM64E__)
612611
// If we are in an arm64e frame, then the PC should have been signed with the
613612
// sp
614613
{

libunwind/src/libunwind.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "libunwind_ext.h"
1616

1717
#include <stdlib.h>
18-
#include <sys/types.h>
1918

2019
// Define the __has_feature extension for compilers that do not support it so
2120
// that we can later check for the presence of ASan in a compiler-neutral way.
@@ -137,15 +136,12 @@ _LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
137136
union {
138137
unw_word_t opaque_value;
139138
unw_word_t
140-
__unwind_ptrauth_restricted_intptr(ptrauth_key_return_address, 1, 0)
141-
authenticated_value;
139+
__unwind_ptrauth_restricted_intptr(ptrauth_key_return_address, 1,
140+
0) authenticated_value;
142141
} u;
143142
u.opaque_value = (uint64_t)ptrauth_auth_and_resign(
144-
(void *)value,
145-
ptrauth_key_return_address,
146-
getSP(),
147-
ptrauth_key_return_address,
148-
&u.opaque_value);
143+
(void *)value, ptrauth_key_return_address, sp,
144+
ptrauth_key_return_address, &u.opaque_value);
149145

150146
if (u.authenticated_value < info.start_ip ||
151147
u.authenticated_value > info.end_ip)
@@ -157,7 +153,7 @@ _LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
157153
if (ptrauth_auth_and_resign((void *)pc, ptrauth_key_return_address, sp,
158154
ptrauth_key_return_address,
159155
sp) != (void *)pc) {
160-
_LIBUNWIND_LOG("Bad unwind through arm64e (0x%llX, 0x%llX)->0x%llX\n",
156+
_LIBUNWIND_LOG("Bad unwind through arm64e (0x%zX, 0x%zX)->0x%zX\n",
161157
pc, sp,
162158
(pint_t)ptrauth_auth_data(
163159
(void *)pc, ptrauth_key_return_address, sp));

0 commit comments

Comments
 (0)