summaryrefslogtreecommitdiff
path: root/gdb/arch-utils.h
diff options
context:
space:
mode:
authorLuis Machado <luis.machado@arm.com>2022-05-24 23:31:09 +0100
committerLuis Machado <luis.machado@arm.com>2022-12-16 11:18:32 +0000
commitd88cb738e6a7a7179dfaff8af78d69250c852af1 (patch)
treec34f73f06cea5177a4763afb73baf2e8a41c68f6 /gdb/arch-utils.h
parent22a8433e00fd33efcb1fa4961eb826cd97f2cd8b (diff)
downloadbinutils-gdb-d88cb738e6a7a7179dfaff8af78d69250c852af1.tar.gz
[aarch64] Fix removal of non-address bits for PAuth
PR gdb/28947 The address_significant gdbarch setting was introduced as a way to remove non-address bits from pointers, and it is specified by a constant. This constant represents the number of address bits in a pointer. Right now AArch64 is the only architecture that uses it, and 56 was a correct option so far. But if we are using Pointer Authentication (PAuth), we might use up to 2 bytes from the address space to store the required information. We could also have cases where we're using both PAuth and MTE. We could adjust the constant to 48 to cover those cases, but this doesn't cover the case where GDB needs to sign-extend kernel addresses after removal of the non-address bits. This has worked so far because bit 55 is used to select between kernel-space and user-space addresses. But trying to clear a range of bits crossing the bit 55 boundary requires the hook to be smarter. The following patch renames the gdbarch hook from significant_addr_bit to remove_non_address_bits and passes a pointer as opposed to the number of bits. The hook is now responsible for removing the required non-address bits and sign-extending the address if needed. While at it, make GDB and GDBServer share some more code for aarch64 and add a new arch-specific testcase gdb.arch/aarch64-non-address-bits.exp. Bug-url: https://sourceware.org/bugzilla/show_bug.cgi?id=28947 Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/arch-utils.h')
-rw-r--r--gdb/arch-utils.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 46018a6fbbb..76c9dcea447 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -132,6 +132,10 @@ extern const struct floatformat **
default_floatformat_for_type (struct gdbarch *gdbarch,
const char *name, int len);
+/* Default implementation of gdbarch_remove_non_address_bits. */
+CORE_ADDR default_remove_non_address_bits (struct gdbarch *gdbarch,
+ CORE_ADDR pointer);
+
/* Default implementation of gdbarch_memtag_to_string. */
extern std::string default_memtag_to_string (struct gdbarch *gdbarch,
struct value *tag);