From: Indu Bhagat <indu.bhagat@oracle.com>
To: binutils@sourceware.org
Cc: Indu Bhagat <indu.bhagat@oracle.com>
Subject: [COMMITTED 07/15] gas: add new command line option --scfi=experimental
Date: Mon, 15 Jan 2024 04:07:21 -0800 [thread overview]
Message-ID: <20240115120729.29771-8-indu.bhagat@oracle.com> (raw)
In-Reply-To: <20240115120729.29771-1-indu.bhagat@oracle.com>
When the command line option --scfi=experimenta is passed to the GNU
assembler, it will synthesize DWARF call frame information (CFI) for the
input assembly.
The option --scfi=experimental will also ignore most of the existing
.cfi_* directives, if already contained in the provided input file.
Only the following CFI directives will not be ignored:
- .cfi_sections,
- .cfi_label,
- .cfi_signal_frame
To use SCFI, a target will need to:
- define TARGET_USE_SCFI and TARGET_USE_GINSN, and other necessary
definitions,
- provide means to help GAS understand the target specific instruction
semantics by creating ginsns.
The upcoming support for SCFI is inteded to be experimental, hence the
option --scfi=experimental. The --scfi= may see more options like
--scfi=[all,none] added in future, once the SCFI support in GAS is
mature and robust. The offering may also see for example, an
--scfi=inline option for dealing with inline asm may be added in the
future. In --scfi=inline option, the GNU assembler may consume (and not
ignore) the compiler generated CFI for the code surrounding the inline
asm.
Also document the option.
gas/
* as.c (show_usage): Add support for --scfi=experimental.
(parse_args): Likewise.
* as.h (enum synth_cfi_type): Define new type.
* doc/as.texi: Document the new option.
---
gas/as.c | 23 +++++++++++++++++++++--
gas/as.h | 8 ++++++++
gas/doc/as.texi | 15 +++++++++++++++
3 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/gas/as.c b/gas/as.c
index b83f0c618be..659da188da5 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -321,6 +321,11 @@ Options:\n\
generate GNU Build notes if none are present in the input\n"));
fprintf (stream, _("\
--gsframe generate SFrame stack trace information\n"));
+# if defined (TARGET_USE_SCFI) && defined (TARGET_USE_GINSN)
+ fprintf (stream, _("\
+ --scfi=experimental Synthesize DWARF CFI for hand-written asm\n\
+ (experimental support)\n"));
+# endif
#endif /* OBJ_ELF */
fprintf (stream, _("\
@@ -511,7 +516,8 @@ parse_args (int * pargc, char *** pargv)
OPTION_NOCOMPRESS_DEBUG,
OPTION_NO_PAD_SECTIONS,
OPTION_MULTIBYTE_HANDLING, /* = STD_BASE + 40 */
- OPTION_SFRAME
+ OPTION_SFRAME,
+ OPTION_SCFI
/* When you add options here, check that they do
not collide with OPTION_MD_BASE. See as.h. */
};
@@ -543,7 +549,10 @@ parse_args (int * pargc, char *** pargv)
,{"sectname-subst", no_argument, NULL, OPTION_SECTNAME_SUBST}
,{"generate-missing-build-notes", required_argument, NULL, OPTION_ELF_BUILD_NOTES}
,{"gsframe", no_argument, NULL, OPTION_SFRAME}
-#endif
+# if defined (TARGET_USE_SCFI) && defined (TARGET_USE_GINSN)
+ ,{"scfi", required_argument, NULL, OPTION_SCFI}
+# endif
+#endif /* OBJ_ELF || OBJ_MAYBE_ELF. */
,{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
,{"gdwarf-2", no_argument, NULL, OPTION_GDWARF_2}
,{"gdwarf-3", no_argument, NULL, OPTION_GDWARF_3}
@@ -982,6 +991,16 @@ This program has absolutely no warranty.\n"));
flag_execstack = 0;
break;
+# if defined (TARGET_USE_SCFI) && defined (TARGET_USE_GINSN)
+ case OPTION_SCFI:
+ if (optarg && strcasecmp (optarg, "experimental") == 0)
+ flag_synth_cfi = SYNTH_CFI_EXPERIMENTAL;
+ else
+ as_fatal (_("Invalid --scfi= option: `%s'; suggested option: experimental"),
+ optarg);
+ break;
+# endif
+
case OPTION_SIZE_CHECK:
if (strcasecmp (optarg, "error") == 0)
flag_allow_nonconst_size = false;
diff --git a/gas/as.h b/gas/as.h
index 1297e3dae41..69d7ae2cd17 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -324,6 +324,14 @@ COMMON int flag_fatal_warnings; /* --fatal-warnings */
are detected. */
COMMON unsigned char flag_always_generate_output; /* -Z */
+enum synth_cfi_type
+{
+ SYNTH_CFI_NONE = 0,
+ SYNTH_CFI_EXPERIMENTAL,
+};
+
+COMMON enum synth_cfi_type flag_synth_cfi;
+
/* This is true if the assembler should output time and space usage. */
COMMON unsigned char flag_print_statistics;
diff --git a/gas/doc/as.texi b/gas/doc/as.texi
index 7526b221a36..370f40fcbae 100644
--- a/gas/doc/as.texi
+++ b/gas/doc/as.texi
@@ -255,6 +255,7 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}.
[@b{--multibyte-handling=[allow|warn|warn-sym-only]}]
[@b{--no-pad-sections}]
[@b{-o} @var{objfile}] [@b{-R}]
+ [@b{--scfi=experimental}]
[@b{--sectname-subst}]
[@b{--size-check=[error|warning]}]
[@b{--statistics}]
@@ -932,6 +933,20 @@ Ignored. Supported for compatibility with tools that apss the same option to
both the assembler and the linker.
@ifset ELF
+@item --scfi=experimental
+This option controls whether the assembler should synthesize CFI for
+hand-written input. If the input already contains some synthesizable CFI
+directives, the assembler ignores them and emits a warning. Note that
+@code{--scfi=experimental} is not intended to be used for compiler-generated
+code, including inline assembly. This experimental support is work in
+progress. Only System V AMD64 ABI is supported.
+
+Each input function in assembly must begin with the @code{.type} directive, and
+should ideally be closed off using a @code{.size} directive. When using SCFI,
+each @code{.type} directive prompts GAS to start a new FDE (a.k.a., Function
+Descriptor Entry). This implies that with each @code{.type} directive, a
+previous block of instructions, if any, is finalised as a distinct FDE.
+
@item --sectname-subst
Honor substitution sequences in section names.
@ifclear man
--
2.41.0
next prev parent reply other threads:[~2024-01-15 12:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-15 12:07 [COMMITTED 00/15] Experimental support for synthesizing CFI for hand-written asm Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 01/15] gas: dw2gencfi: minor rejig for cfi_sections_set and all_cfi_sections Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 02/15] gas: dw2gencfi: use all_cfi_sections instead of cfi_sections Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 03/15] gas: dw2gencfi: expose a new cfi_set_last_fde API Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 04/15] gas: dw2gencfi: move some tc_* defines to the header file Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 05/15] gas: dw2gencfi: expose dot_cfi_sections for scfidw2gen Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 06/15] gas: dw2gencfi: externalize the all_cfi_sections Indu Bhagat
2024-01-15 12:07 ` Indu Bhagat [this message]
2024-01-15 12:07 ` [COMMITTED 08/15] gas: scfidw2gen: new functionality to prepare for SCFI Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 09/15] opcodes: gas: x86: define and use Rex2 as attribute not constraint Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 10/15] opcodes: x86: new marker for insns that implicitly update stack pointer Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 11/15] gas: x86: synthesize CFI for hand-written asm Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 12/15] gas: doc: update documentation for the new listing option Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 13/15] opcodes: i386-reg.tbl: Add a comment to reflect dependency on ordering Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 14/15] gas: testsuite: add an x86 testsuite for SCFI Indu Bhagat
2024-01-15 12:07 ` [COMMITTED 15/15] gas/NEWS: announce the new SCFI command line option Indu Bhagat
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=20240115120729.29771-8-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).