From: Indu Bhagat <indu.bhagat@oracle.com>
To: binutils@sourceware.org
Cc: Indu Bhagat <indu.bhagat@oracle.com>
Subject: [PATCH 2/5] [2/5] gas: sframe: add support for .cfi_b_key_frame
Date: Wed, 14 Dec 2022 12:07:53 -0800 [thread overview]
Message-ID: <20221214200756.1234528-3-indu.bhagat@oracle.com> (raw)
In-Reply-To: <20221214200756.1234528-1-indu.bhagat@oracle.com>
Gather the information from the DWARF FDE on whether frame's return
addresses are signed using the B key or A key. Reflect the information in
the SFrame counterpart data structure, the SFrame FDE.
ChangeLog:
* gas/gen-sframe.c (get_dw_fde_pauth_b_key_p): New definition.
(sframe_v1_set_func_info): Add new argument for pauth_key.
(sframe_set_func_info): Likewise.
(output_sframe_funcdesc): Likewise.
* gas/gen-sframe.h (struct sframe_version_ops): Add new argument
to the function pointer declaration.
* gas/sframe-opt.c (sframe_convert_frag): Handle pauth_key.
---
gas/gen-sframe.c | 26 ++++++++++++++++++++++----
gas/gen-sframe.h | 2 +-
gas/sframe-opt.c | 3 +++
3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c
index f31a66da377..5a642f9a683 100644
--- a/gas/gen-sframe.c
+++ b/gas/gen-sframe.c
@@ -106,6 +106,17 @@ get_dw_fde_end_addrS (const struct fde_entry *dw_fde)
return dw_fde->end_address;
}
+/* Get whether PAUTH B key is used. */
+static bool
+get_dw_fde_pauth_b_key_p (const struct fde_entry *dw_fde ATTRIBUTE_UNUSED)
+{
+#ifdef tc_fde_entry_extras
+ return (dw_fde->pauth_key == AARCH64_PAUTH_KEY_B);
+#else
+ return false;
+#endif
+}
+
/* SFrame Frame Row Entry (FRE) related functions. */
static void
@@ -253,10 +264,12 @@ sframe_v1_set_fre_info (unsigned int base_reg, unsigned int num_offsets,
/* SFrame (SFRAME_VERSION_1) set function info. */
static unsigned char
-sframe_v1_set_func_info (unsigned int fde_type, unsigned int fre_type)
+sframe_v1_set_func_info (unsigned int fde_type, unsigned int fre_type,
+ unsigned int pauth_key)
{
unsigned char func_info;
func_info = SFRAME_V1_FUNC_INFO (fde_type, fre_type);
+ func_info = SFRAME_V1_FUNC_INFO_UPDATE_PAUTH_KEY (pauth_key, func_info);
return func_info;
}
@@ -285,9 +298,10 @@ sframe_set_fre_info (unsigned int base_reg, unsigned int num_offsets,
/* SFrame set func info. */
ATTRIBUTE_UNUSED static unsigned char
-sframe_set_func_info (unsigned int fde_type, unsigned int fre_type)
+sframe_set_func_info (unsigned int fde_type, unsigned int fre_type,
+ unsigned int pauth_key)
{
- return sframe_ver_ops.set_func_info (fde_type, fre_type);
+ return sframe_ver_ops.set_func_info (fde_type, fre_type, pauth_key);
}
/* Get the number of SFrame FDEs for the current file. */
@@ -544,6 +558,7 @@ output_sframe_funcdesc (symbolS *start_of_fre_section,
expressionS exp;
unsigned int addr_size;
symbolS *dw_fde_start_addrS, *dw_fde_end_addrS;
+ unsigned int pauth_key;
addr_size = SFRAME_RELOC_SIZE;
dw_fde_start_addrS = get_dw_fde_start_addrS (sframe_fde->dw_fde);
@@ -575,8 +590,11 @@ output_sframe_funcdesc (symbolS *start_of_fre_section,
/* SFrame FDE function info. */
unsigned char func_info;
+ pauth_key = (get_dw_fde_pauth_b_key_p (sframe_fde->dw_fde)
+ ? SFRAME_AARCH64_PAUTH_KEY_B : SFRAME_AARCH64_PAUTH_KEY_A);
func_info = sframe_set_func_info (SFRAME_FDE_TYPE_PCINC,
- SFRAME_FRE_TYPE_ADDR4);
+ SFRAME_FRE_TYPE_ADDR4,
+ pauth_key);
#if SFRAME_FRE_TYPE_SELECTION_OPT
expressionS cexp;
create_func_info_exp (&cexp, dw_fde_end_addrS, dw_fde_start_addrS,
diff --git a/gas/gen-sframe.h b/gas/gen-sframe.h
index aa8be5df457..590bf7b505b 100644
--- a/gas/gen-sframe.h
+++ b/gas/gen-sframe.h
@@ -146,7 +146,7 @@ struct sframe_version_ops
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);
+ unsigned char (*set_func_info) (unsigned int, unsigned int, unsigned int);
};
/* Generate SFrame unwind info and prepare contents for the output.
diff --git a/gas/sframe-opt.c b/gas/sframe-opt.c
index f08a424fd88..cf7ca5c1893 100644
--- a/gas/sframe-opt.c
+++ b/gas/sframe-opt.c
@@ -95,6 +95,7 @@ sframe_convert_frag (fragS *frag)
offsetT rest_of_data;
uint8_t fde_type, fre_type;
+ uint8_t pauth_key;
expressionS *exp;
symbolS *dataS;
@@ -116,6 +117,7 @@ sframe_convert_frag (fragS *frag)
dataS = exp->X_add_symbol;
rest_of_data = (symbol_get_value_expression(dataS))->X_add_number;
fde_type = SFRAME_V1_FUNC_FDE_TYPE (rest_of_data);
+ pauth_key = SFRAME_V1_FUNC_PAUTH_KEY (rest_of_data);
gas_assert (fde_type == SFRAME_FDE_TYPE_PCINC);
/* Calculate the applicable fre_type. */
@@ -130,6 +132,7 @@ sframe_convert_frag (fragS *frag)
/* Create the new function info. */
value = SFRAME_V1_FUNC_INFO (fde_type, fre_type);
+ value = SFRAME_V1_FUNC_INFO_UPDATE_PAUTH_KEY (pauth_key, value);
frag->fr_literal[frag->fr_fix] = value;
}
--
2.37.2
next prev parent reply other threads:[~2022-12-14 20:09 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 20:07 [PATCH 0/5] SFrame: " Indu Bhagat
2022-12-14 20:07 ` [PATCH 1/5] [1/5] sframe.h: " Indu Bhagat
2022-12-14 20:07 ` Indu Bhagat [this message]
2022-12-14 20:07 ` [PATCH 3/5] [3/5] objdump/readelf: sframe: emit marker for SFrame FDE with B key Indu Bhagat
2022-12-14 20:07 ` [PATCH 4/5] [4/5] gas: sframe: testsuite: add testcase for .cfi_b_key_frame Indu Bhagat
2022-12-14 20:07 ` [PATCH 5/5] [5/5] sframe: doc: update documentation for pauth key in SFrame FDE Indu Bhagat
2022-12-19 15:36 ` [PATCH 0/5] SFrame: add support for .cfi_b_key_frame Nick Clifton
2022-12-19 17:27 ` Indu Bhagat
2022-12-19 20:23 ` [COMMITTED, V2 " Indu Bhagat
2022-12-19 20:23 ` [COMMITTED, V2 1/5] [1/5] sframe.h: " Indu Bhagat
2022-12-19 20:23 ` [COMMITTED, V2 2/5] [2/5] gas: sframe: " Indu Bhagat
2022-12-19 20:23 ` [COMMITTED, V2 3/5] [3/5] objdump/readelf: sframe: emit marker for SFrame FDE with B key Indu Bhagat
2022-12-19 20:23 ` [COMMITTED, V2 4/5] [4/5] gas: sframe: testsuite: add testcase for .cfi_b_key_frame Indu Bhagat
2022-12-19 20:23 ` [COMMITTED, V2 5/5] [5/5] sframe: doc: update documentation for pauth key in SFrame FDE Indu Bhagat
2022-12-19 21:11 ` [COMMITTED, V2 0/5] SFrame: add support for .cfi_b_key_frame Indu Bhagat
2022-12-19 21:14 ` [PATCH, " Indu Bhagat
2022-12-19 21:14 ` [PATCH, V2 1/5] [1/5] sframe.h: " Indu Bhagat
2022-12-19 21:14 ` [PATCH, V2 2/5] [2/5] gas: sframe: " Indu Bhagat
2022-12-19 21:14 ` [PATCH, V2 3/5] [3/5] objdump/readelf: sframe: emit marker for SFrame FDE with B key Indu Bhagat
2022-12-19 21:14 ` [PATCH, V2 4/5] [4/5] gas: sframe: testsuite: add testcase for .cfi_b_key_frame Indu Bhagat
2022-12-19 21:14 ` [PATCH, V2 5/5] [5/5] sframe: doc: update documentation for pauth key in SFrame FDE Indu Bhagat
2022-12-21 18:19 ` [PATCH, V2 0/5] SFrame: add support for .cfi_b_key_frame Indu Bhagat
2022-12-22 8:40 ` Nick Clifton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221214200756.1234528-3-indu.bhagat@oracle.com \
--to=indu.bhagat@oracle.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).