aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorIndu Bhagat <indu.bhagat@oracle.com>2022-12-16 22:01:51 -0800
committerIndu Bhagat <indu.bhagat@oracle.com>2022-12-16 22:01:51 -0800
commit28f69152b99fd3a774e9bb9e66496cb1d7fd03b9 (patch)
tree656e578c608e7b7a7b4d4f6a8ca18cb034988fe5 /gas
parent4604c7294166199f89a0122ee35095d7e0cd2d07 (diff)
downloadgdb-28f69152b99fd3a774e9bb9e66496cb1d7fd03b9.zip
gdb-28f69152b99fd3a774e9bb9e66496cb1d7fd03b9.tar.gz
gdb-28f69152b99fd3a774e9bb9e66496cb1d7fd03b9.tar.bz2
gas: sframe: add support for .cfi_negate_ra_state
DW_CFA_AARCH64_negate_ra_state in aarch64 is multiplexed with DW_CFA_GNU_window_save in the DWARF format. Remove the common-empty-4 testcase because the generated SFrame section will not be be empty anymore. A relevant test will be added in a later commit. ChangeLog: * gas/gen-sframe.c (sframe_v1_set_fre_info): Add new argument for mangled_ra_p. (sframe_set_fre_info): Likewise. (output_sframe_row_entry): Handle mangled_ra_p. (sframe_row_entry_new): Reset mangled_ra_p. (sframe_row_entry_initialize): Initialize mangled_ra_p. (sframe_xlate_do_gnu_window_save): New definition. (sframe_do_cfi_insn): Handle DW_CFA_GNU_window_save. * gas/gen-sframe.h (struct sframe_row_entry): New member. (struct sframe_version_ops): Add a new argument for mangled_ra_p. * gas/testsuite/gas/cfi-sframe/cfi-sframe.exp: Remove test. * gas/testsuite/gas/cfi-sframe/common-empty-4.d: Removed. * gas/testsuite/gas/cfi-sframe/common-empty-4.s: Removed.
Diffstat (limited to 'gas')
-rw-r--r--gas/gen-sframe.c42
-rw-r--r--gas/gen-sframe.h6
-rw-r--r--gas/testsuite/gas/cfi-sframe/cfi-sframe.exp1
-rw-r--r--gas/testsuite/gas/cfi-sframe/common-empty-4.d14
-rw-r--r--gas/testsuite/gas/cfi-sframe/common-empty-4.s17
5 files changed, 39 insertions, 41 deletions
diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c
index 075720f..9baf20b 100644
--- a/gas/gen-sframe.c
+++ b/gas/gen-sframe.c
@@ -243,10 +243,11 @@ static struct sframe_version_ops sframe_ver_ops;
static unsigned char
sframe_v1_set_fre_info (unsigned int base_reg, unsigned int num_offsets,
- unsigned int offset_size)
+ unsigned int offset_size, bool mangled_ra_p)
{
unsigned char fre_info;
fre_info = SFRAME_V1_FRE_INFO (base_reg, num_offsets, offset_size);
+ fre_info = SFRAME_V1_FRE_INFO_UPDATE_MANGLED_RA_P (mangled_ra_p, fre_info);
return fre_info;
}
@@ -275,10 +276,10 @@ sframe_set_version (uint32_t sframe_version __attribute__((unused)))
static unsigned char
sframe_set_fre_info (unsigned int base_reg, unsigned int num_offsets,
- unsigned int offset_size)
+ unsigned int offset_size, bool mangled_ra_p)
{
return sframe_ver_ops.set_fre_info (base_reg, num_offsets,
- offset_size);
+ offset_size, mangled_ra_p);
}
/* SFrame set func info. */
@@ -507,7 +508,7 @@ output_sframe_row_entry (symbolS *fde_start_addr,
fre_num_offsets = get_fre_num_offsets (sframe_fre);
fre_offset_size = sframe_get_fre_offset_size (sframe_fre);
fre_info = sframe_set_fre_info (fre_base_reg, fre_num_offsets,
- fre_offset_size);
+ fre_offset_size, sframe_fre->mangled_ra_p);
out_one (fre_info);
idx = sframe_fre_offset_func_map_index (fre_offset_size);
@@ -845,6 +846,9 @@ sframe_row_entry_new (void)
for the supported arches. */
fre->cfa_base_reg = -1;
fre->merge_candidate = true;
+ /* Reset the mangled RA status bit to zero by default. We will initialize it in
+ sframe_row_entry_initialize () with the sticky bit if set. */
+ fre->mangled_ra_p = false;
return fre;
}
@@ -890,6 +894,9 @@ sframe_row_entry_initialize (struct sframe_row_entry *cur_fre,
cur_fre->bp_offset = prev_fre->bp_offset;
cur_fre->ra_loc = prev_fre->ra_loc;
cur_fre->ra_offset = prev_fre->ra_offset;
+ /* Treat RA mangling as a sticky bit. It retains its value until another
+ .cfi_negate_ra_state is seen. */
+ cur_fre->mangled_ra_p = prev_fre->mangled_ra_p;
}
/* Translate DW_CFA_advance_loc into SFrame context.
@@ -1150,6 +1157,23 @@ sframe_xlate_do_restore (struct sframe_xlate_ctx *xlate_ctx,
return SFRAME_XLATE_OK;
}
+/* Translate DW_CFA_GNU_window_save into SFrame context.
+ Return SFRAME_XLATE_OK if success. */
+
+static int
+sframe_xlate_do_gnu_window_save (struct sframe_xlate_ctx *xlate_ctx,
+ struct cfi_insn_data *cfi_insn ATTRIBUTE_UNUSED)
+{
+ struct sframe_row_entry *cur_fre = xlate_ctx->cur_fre;
+
+ gas_assert (cur_fre);
+ /* Toggle the mangled RA status bit. */
+ cur_fre->mangled_ra_p = !cur_fre->mangled_ra_p;
+ cur_fre->merge_candidate = false;
+
+ return SFRAME_XLATE_OK;
+}
+
/* Process CFI_INSN and update the translation context with the FRE
information.
@@ -1195,6 +1219,11 @@ sframe_do_cfi_insn (struct sframe_xlate_ctx *xlate_ctx,
case DW_CFA_restore:
err = sframe_xlate_do_restore (xlate_ctx, cfi_insn);
break;
+ /* DW_CFA_AARCH64_negate_ra_state is multiplexed with
+ DW_CFA_GNU_window_save. */
+ case DW_CFA_GNU_window_save:
+ err = sframe_xlate_do_gnu_window_save (xlate_ctx, cfi_insn);
+ break;
case DW_CFA_undefined:
case DW_CFA_same_value:
break;
@@ -1207,10 +1236,7 @@ sframe_do_cfi_insn (struct sframe_xlate_ctx *xlate_ctx,
- ...
Following skipped operations do, however, impact the asynchronicity:
- - CFI_escape,
- - DW_CFA_GNU_window_save,
- - DW_CFA_AARCH64_negate_ra_state (multiplexed with
- DW_CFA_GNU_window_save) */
+ - CFI_escape */
err = SFRAME_XLATE_ERR_NOTREPRESENTED;
// printf (_("SFrame Unsupported or unknown Dwarf CFI number: %#x\n"), op);
diff --git a/gas/gen-sframe.h b/gas/gen-sframe.h
index 93af499..5d5702a 100644
--- a/gas/gen-sframe.h
+++ b/gas/gen-sframe.h
@@ -50,6 +50,9 @@ struct sframe_row_entry
on it. */
bool merge_candidate;
+ /* Whether the return address is mangled with pauth code. */
+ bool mangled_ra_p;
+
/* Track CFA base (architectural) register ID. */
unsigned int cfa_base_reg;
/* Offset from the CFA base register for recovering CFA. */
@@ -140,7 +143,8 @@ struct sframe_version_ops
{
unsigned char format_version; /* SFrame format version. */
/* set SFrame FRE info. */
- unsigned char (*set_fre_info) (unsigned int, unsigned int, unsigned int);
+ unsigned char (*set_fre_info) (unsigned int, unsigned int, unsigned int,
+ bool);
/* set SFrame Func info. */
unsigned char (*set_func_info) (unsigned int, unsigned int);
};
diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp b/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp
index eb6da61..8129e86 100644
--- a/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp
+++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp
@@ -82,7 +82,6 @@ if { ([istarget "x86_64-*-*"] || [istarget "aarch64*-*-*"]) \
run_dump_test "common-empty-1"
run_dump_test "common-empty-2"
run_dump_test "common-empty-3"
- run_dump_test "common-empty-4"
}
# x86-64 specific tests
diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-4.d b/gas/testsuite/gas/cfi-sframe/common-empty-4.d
deleted file mode 100644
index f7a6062..0000000
--- a/gas/testsuite/gas/cfi-sframe/common-empty-4.d
+++ /dev/null
@@ -1,14 +0,0 @@
-#as: --gsframe
-#objdump: --sframe=.sframe
-#name: SFrame supports only default return column
-#...
-Contents of the SFrame section .sframe:
-
- Header :
-
- Version: SFRAME_VERSION_1
- Flags: NONE
- Num FDEs: 0
- Num FREs: 0
-
-#pass
diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-4.s b/gas/testsuite/gas/cfi-sframe/common-empty-4.s
deleted file mode 100644
index f97ca2f..0000000
--- a/gas/testsuite/gas/cfi-sframe/common-empty-4.s
+++ /dev/null
@@ -1,17 +0,0 @@
-## ARMv8.3 addded support a new security feature named Pointer Authentication. The
-## main idea behind this is to use the unused bits in the pointer values.
-## Each pointer is patched with a PAC before writing to memory, and is verified
-## before using it.
-## When the pointers are mangled, the unwinder needs to know so it can mask off
-## the PAC from the pointer value to recover the return address, and
-## conversely, skip doing so if the pointers are not mangled.
-##
-## .cfi_negate_ra_state CFI directive is used to convey this information.
-##
-## SFrame does not have any means to represent this information at this time.
- .cfi_startproc
- .long 0
- .cfi_def_cfa_offset 16
- .cfi_negate_ra_state
- .long 0
- .cfi_endproc