gdb, gdbarch: Enable inferior calls for shadow stack support.

Inferior calls in GDB reset the current PC to the beginning of the function
that is called.  As no call instruction is executed the new return address
needs to be pushed to the shadow stack and the shadow stack pointer needs
to be updated.

This commit adds a new gdbarch method to push an address on the shadow
stack.  The method is used to adapt the function 'call_function_by_hand_dummy'
for inferior call shadow stack support.

Reviewed-By: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Approved-By: Luis Machado <luis.machado@arm.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
Christina Schimpe
2024-04-11 05:53:35 -04:00
parent a4011720d4
commit 4c2fee0658
4 changed files with 72 additions and 4 deletions

View File

@@ -2831,3 +2831,19 @@ which all assume current_inferior() is the one to read from.
predefault="default_core_parse_exec_context",
invalid=False,
)
Method(
comment="""
Some targets support special hardware-assisted control-flow protection
technologies. For example, the Intel Control-Flow Enforcement Technology
(Intel CET) on x86 provides a shadow stack and indirect branch tracking.
To enable shadow stack support for inferior calls the shadow_stack_push
gdbarch hook has to be provided.
Push NEW_ADDR to the shadow stack and update the shadow stack pointer.
""",
type="void",
name="shadow_stack_push",
params=[("CORE_ADDR", "new_addr"), ("regcache *", "regcache")],
predicate=True,
)