aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbarch.c
diff options
context:
space:
mode:
authorJiong Wang <jiong.wang@arm.com>2017-04-26 14:05:03 +0100
committerJiong Wang <jiong.wang@arm.com>2017-04-26 14:05:03 +0100
commitb41c5a85a734b9ca813d4a314b66ef4b4b4d1b11 (patch)
tree2203099a235d7fbec6066ef8896d4d4ebab0292b /gdb/gdbarch.c
parent23ec1e32b1ab714649a7c25e49b5d721fe3bd3db (diff)
downloadgdb-b41c5a85a734b9ca813d4a314b66ef4b4b4d1b11.zip
gdb-b41c5a85a734b9ca813d4a314b66ef4b4b4d1b11.tar.gz
gdb-b41c5a85a734b9ca813d4a314b66ef4b4b4d1b11.tar.bz2
[gdbarch] New method "execute_dwarf_cfa_vendor_op" and migrate SPARC to it
Recently a feature called "return address signing" has been added to GCC to prevent stack smash stack on AArch64. For details please refer: https://gcc.gnu.org/ml/gcc-patches/2017-01/msg00376.html GDB needs to be aware of this feature so it can restore the original return address which is critical for unwinding. On compiler side, whenever return address, i.e. LR register, is mangled or restored by hardware instruction, compiler is expected to generate a DW_CFA_AARCH64_negate_ra_state to toggle return address signing status. DW_CFA_AARCH64_negate_ra_state is using the same CFI number and therefore need to be multiplexed with DW_CFA_GNU_window_save which was designed for SPARC. A new gdbarch method "execute_dwarf_cfa_vendor_op" is introduced by this patch. It's parameters has been restricted to those only needed by SPARC and AArch64 for multiplexing DW_CFA_GNU_window_save which is a CFI operation takes none operand. Should any further DWARF CFI operation want to be multiplexed in the future, the parameter list can be extended. Below is the current function prototype. typedef int (gdbarch_execute_dwarf_cfa_vendor_op_ftype) (struct gdbarch *gdbarch, gdb_byte op, struct dwarf2_frame_state *fs); DW_CFA_GNU_window_save support for SPARC is migrated to this new gdbarch method by this patch. gdb/ * gdbarch.sh: New gdbarch method execute_dwarf_cfa_vendor_op. * gdbarch.c: Regenerated. * gdbarch.h: Regenerated. * dwarf2-frame.c (dwarf2_frame_state_alloc_regs): Made the visibility external. (execute_cfa_program): Call execute_dwarf_cfa_vendor_op for CFI between DW_CFA_lo_user and DW_CFA_high_user inclusive. (enum cfa_how_kind): Move to ... (struct dwarf2_frame_state_reg_info): Likewise. (struct dwarf2_frame_state): Likewise. * dwarf2-frame.h: ... here. (dwarf2_frame_state_alloc_regs): New declaration. * sparc-tdep.c (sparc_execute_dwarf_cfa_vendor_op): New function. (sparc32_gdbarch_init): Register execute_dwarf_cfa_vendor_op hook.
Diffstat (limited to 'gdb/gdbarch.c')
-rw-r--r--gdb/gdbarch.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 5664325..41c0866 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -275,6 +275,7 @@ struct gdbarch
int have_nonsteppable_watchpoint;
gdbarch_address_class_type_flags_ftype *address_class_type_flags;
gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name;
+ gdbarch_execute_dwarf_cfa_vendor_op_ftype *execute_dwarf_cfa_vendor_op;
gdbarch_address_class_name_to_type_flags_ftype *address_class_name_to_type_flags;
gdbarch_register_reggroup_p_ftype *register_reggroup_p;
gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument;
@@ -436,6 +437,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
gdbarch->make_symbol_special = default_make_symbol_special;
gdbarch->adjust_dwarf2_addr = default_adjust_dwarf2_addr;
gdbarch->adjust_dwarf2_line = default_adjust_dwarf2_line;
+ gdbarch->execute_dwarf_cfa_vendor_op = default_execute_dwarf_cfa_vendor_op;
gdbarch->register_reggroup_p = default_register_reggroup_p;
gdbarch->skip_permanent_breakpoint = default_skip_permanent_breakpoint;
gdbarch->displaced_step_hw_singlestep = default_displaced_step_hw_singlestep;
@@ -634,6 +636,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of have_nonsteppable_watchpoint, invalid_p == 0 */
/* Skip verify of address_class_type_flags, has predicate. */
/* Skip verify of address_class_type_flags_to_name, has predicate. */
+ /* Skip verify of execute_dwarf_cfa_vendor_op, invalid_p == 0 */
/* Skip verify of address_class_name_to_type_flags, has predicate. */
/* Skip verify of register_reggroup_p, invalid_p == 0 */
/* Skip verify of fetch_pointer_argument, has predicate. */
@@ -975,6 +978,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: elfcore_write_linux_prpsinfo = <%s>\n",
host_address_to_string (gdbarch->elfcore_write_linux_prpsinfo));
fprintf_unfiltered (file,
+ "gdbarch_dump: execute_dwarf_cfa_vendor_op = <%s>\n",
+ host_address_to_string (gdbarch->execute_dwarf_cfa_vendor_op));
+ fprintf_unfiltered (file,
"gdbarch_dump: fast_tracepoint_valid_at = <%s>\n",
host_address_to_string (gdbarch->fast_tracepoint_valid_at));
fprintf_unfiltered (file,
@@ -3523,6 +3529,23 @@ set_gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch,
gdbarch->address_class_type_flags_to_name = address_class_type_flags_to_name;
}
+bool
+gdbarch_execute_dwarf_cfa_vendor_op (struct gdbarch *gdbarch, gdb_byte op, struct dwarf2_frame_state *fs)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->execute_dwarf_cfa_vendor_op != NULL);
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_execute_dwarf_cfa_vendor_op called\n");
+ return gdbarch->execute_dwarf_cfa_vendor_op (gdbarch, op, fs);
+}
+
+void
+set_gdbarch_execute_dwarf_cfa_vendor_op (struct gdbarch *gdbarch,
+ gdbarch_execute_dwarf_cfa_vendor_op_ftype execute_dwarf_cfa_vendor_op)
+{
+ gdbarch->execute_dwarf_cfa_vendor_op = execute_dwarf_cfa_vendor_op;
+}
+
int
gdbarch_address_class_name_to_type_flags_p (struct gdbarch *gdbarch)
{