mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-19 00:59:15 +08:00
[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>
This commit is contained in:
@ -1154,15 +1154,23 @@ possible it should be in TARGET_READ_PC instead).
|
||||
invalid=False,
|
||||
)
|
||||
|
||||
Value(
|
||||
Method(
|
||||
comment="""
|
||||
On some machines, not all bits of an address word are significant.
|
||||
For example, on AArch64, the top bits of an address known as the "tag"
|
||||
are ignored by the kernel, the hardware, etc. and can be regarded as
|
||||
additional data associated with the address.
|
||||
On some architectures, not all bits of a pointer are significant.
|
||||
On AArch64, for example, the top bits of a pointer may carry a "tag", which
|
||||
can be ignored by the kernel and the hardware. The "tag" can be regarded as
|
||||
additional data associated with the pointer, but it is not part of the address.
|
||||
|
||||
Given a pointer for the architecture, this hook removes all the
|
||||
non-significant bits and sign-extends things as needed. It gets used to remove
|
||||
non-address bits from data pointers (for example, removing the AArch64 MTE tag
|
||||
bits from a pointer) and from code pointers (removing the AArch64 PAC signature
|
||||
from a pointer containing the return address).
|
||||
""",
|
||||
type="int",
|
||||
name="significant_addr_bit",
|
||||
type="CORE_ADDR",
|
||||
name="remove_non_address_bits",
|
||||
params=[("CORE_ADDR", "pointer")],
|
||||
predefault="default_remove_non_address_bits",
|
||||
invalid=False,
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user