From fba2ae7b2c43d3e706849c8098930683cbd0e322 Mon Sep 17 00:00:00 2001 From: "Deng, Yimin (NSB - CN/Shanghai)" Date: Wed, 18 Apr 2018 03:12:45 +0000 Subject: [PATCH] mipsN32: A modification suggestion to support mips N32 --- include/libunwind-mips.h | 2 +- include/tdep-mips/libunwind_i.h | 8 ++++++++ src/mips/Gcreate_addr_space.c | 8 ++++++++ src/mips/Gregs.c | 3 ++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/libunwind-mips.h b/include/libunwind-mips.h index 97c95e24..ced34b20 100644 --- a/include/libunwind-mips.h +++ b/include/libunwind-mips.h @@ -98,7 +98,7 @@ typedef enum UNW_MIPS_R30, UNW_MIPS_R31, - UNW_MIPS_PC = 34, + UNW_MIPS_PC = 64, /* FIXME: Other registers! */ diff --git a/include/tdep-mips/libunwind_i.h b/include/tdep-mips/libunwind_i.h index 3fe40c0c..0c0fd3cf 100644 --- a/include/tdep-mips/libunwind_i.h +++ b/include/tdep-mips/libunwind_i.h @@ -247,6 +247,14 @@ dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) 0, c->as_arg); else if (c->as->abi == UNW_MIPS_ABI_O32) return read_s32 (c, DWARF_GET_LOC (loc), val); + else if (c->as->abi == UNW_MIPS_ABI_N32) { + if (tdep_big_endian(c->as)) + return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc) + 4, val, + 0, c->as_arg); + else + return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, + 0, c->as_arg); + } else return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, 0, c->as_arg); diff --git a/src/mips/Gcreate_addr_space.c b/src/mips/Gcreate_addr_space.c index 493d03db..c2408b95 100644 --- a/src/mips/Gcreate_addr_space.c +++ b/src/mips/Gcreate_addr_space.c @@ -58,7 +58,15 @@ unw_create_addr_space (unw_accessors_t *a, int byte_order) as->big_endian = (byte_order == __BIG_ENDIAN); /* FIXME! There is no way to specify the ABI. */ +#if _MIPS_SIM == _ABIO32 as->abi = UNW_MIPS_ABI_O32; +#elif _MIPS_SIM == _ABIN32 + as->abi = UNW_MIPS_ABI_N32; +#elif _MIPS_SIM == _ABI64 + as->abi = UNW_MIPS_ABI_N64; +#else +# error Unsupported ABI +#endif as->addr_size = 4; return as; diff --git a/src/mips/Gregs.c b/src/mips/Gregs.c index 95194022..e967324d 100644 --- a/src/mips/Gregs.c +++ b/src/mips/Gregs.c @@ -63,7 +63,7 @@ tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, case UNW_MIPS_R26: case UNW_MIPS_R27: case UNW_MIPS_R28: - case UNW_MIPS_R29: + case UNW_MIPS_R30: case UNW_MIPS_R31: loc = c->dwarf.loc[reg - UNW_MIPS_R0]; @@ -75,6 +75,7 @@ tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, loc = c->dwarf.loc[reg]; break; + case UNW_MIPS_R29: case UNW_MIPS_CFA: if (write) return -UNW_EREADONLYREG;