1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-12-23 12:03:41 +01:00

aarch64: tune down size of unw_context_t and unw_cursor_t (#71)

aarch64 defines a huge __reserved field in sigcontext.  Cut it down
to only the used FP fields.

unw_cursor_t can also be cut down a bit, while still maintaining some reserved space.
This commit is contained in:
Dave Watson 2018-04-10 10:55:45 -07:00 committed by GitHub
parent b5cbcaee13
commit 729772149f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 9 deletions

View file

@ -44,9 +44,13 @@ extern "C" {
leaving some slack for future expansion. Changing this value will leaving some slack for future expansion. Changing this value will
require recompiling all users of this library. Stack allocation is require recompiling all users of this library. Stack allocation is
relatively cheap and unwind-state copying is relatively rare, so we relatively cheap and unwind-state copying is relatively rare, so we
want to err on making it rather too big than too small. */ want to err on making it rather too big than too small.
#define UNW_TDEP_CURSOR_LEN 512 Calculation is regs used (64 + 34) * 2 + 40 (bytes of rest of
cursor) + padding
*/
#define UNW_TDEP_CURSOR_LEN 250
typedef uint64_t unw_word_t; typedef uint64_t unw_word_t;
typedef int64_t unw_sword_t; typedef int64_t unw_sword_t;
@ -169,8 +173,28 @@ typedef struct unw_tdep_save_loc
unw_tdep_save_loc_t; unw_tdep_save_loc_t;
/* On AArch64, we can directly use ucontext_t as the unwind context. */ /* On AArch64, we can directly use ucontext_t as the unwind context,
typedef ucontext_t unw_tdep_context_t; * however, the __reserved struct is quite large: tune it down to only
* the necessary used fields. */
struct unw_sigcontext
{
uint64_t fault_address;
uint64_t regs[31];
uint64_t sp;
uint64_t pc;
uint64_t pstate;
uint8_t __reserved[(34 * 8)] __attribute__((__aligned__(16)));
};
typedef struct
{
unsigned long uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
__sigset_t uc_sigmask;
struct unw_sigcontext uc_mcontext;
} unw_tdep_context_t;
#include "libunwind-common.h" #include "libunwind-common.h"
#include "libunwind-dynamic.h" #include "libunwind-dynamic.h"

View file

@ -41,7 +41,7 @@ static struct unw_addr_space local_addr_space;
unw_addr_space_t unw_local_addr_space = &local_addr_space; unw_addr_space_t unw_local_addr_space = &local_addr_space;
static inline void * static inline void *
uc_addr (ucontext_t *uc, int reg) uc_addr (unw_tdep_context_t *uc, int reg)
{ {
if (reg >= UNW_AARCH64_X0 && reg < UNW_AARCH64_V0) if (reg >= UNW_AARCH64_X0 && reg < UNW_AARCH64_V0)
return &uc->uc_mcontext.regs[reg]; return &uc->uc_mcontext.regs[reg];
@ -54,7 +54,7 @@ uc_addr (ucontext_t *uc, int reg)
# ifdef UNW_LOCAL_ONLY # ifdef UNW_LOCAL_ONLY
HIDDEN void * HIDDEN void *
tdep_uc_addr (ucontext_t *uc, int reg) tdep_uc_addr (unw_tdep_context_t *uc, int reg)
{ {
return uc_addr (uc, reg); return uc_addr (uc, reg);
} }
@ -104,7 +104,7 @@ access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, int write,
void *arg) void *arg)
{ {
unw_word_t *addr; unw_word_t *addr;
ucontext_t *uc = arg; unw_tdep_context_t *uc = arg;
if (unw_is_fpreg (reg)) if (unw_is_fpreg (reg))
goto badreg; goto badreg;
@ -133,7 +133,7 @@ static int
access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val,
int write, void *arg) int write, void *arg)
{ {
ucontext_t *uc = arg; unw_tdep_context_t *uc = arg;
unw_fpreg_t *addr; unw_fpreg_t *addr;
if (!unw_is_fpreg (reg)) if (!unw_is_fpreg (reg))

View file

@ -59,7 +59,7 @@ unw_init_local (unw_cursor_t *cursor, unw_context_t *uc)
} }
int int
unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) unw_init_local2 (unw_cursor_t *cursor, unw_tdep_context_t *uc, int flag)
{ {
if (!flag) if (!flag)
{ {