diff options
author | Indu Bhagat <indu.bhagat@oracle.com> | 2022-11-15 15:06:46 -0800 |
---|---|---|
committer | Indu Bhagat <indu.bhagat@oracle.com> | 2022-11-15 15:24:06 -0800 |
commit | b52c4ee46657eb5a70095d48cbc2938d024cc3b6 (patch) | |
tree | 10fb1afba608156a25ebe9732cfe5e3fe1d85833 /gas/doc/as.texi | |
parent | b07a29781610756a9b75a931c7c13735b7555d9f (diff) | |
download | binutils-b52c4ee46657eb5a70095d48cbc2938d024cc3b6.zip binutils-b52c4ee46657eb5a70095d48cbc2938d024cc3b6.tar.gz binutils-b52c4ee46657eb5a70095d48cbc2938d024cc3b6.tar.bz2 |
gas: generate .sframe from CFI directives
Currently supported for x86_64 and aarch64 only.
[PS: Currently, the compiler has not been adapted to generate
".cfi_sections" with ".sframe" in it. The newly added command line
option of --gsframe provides an easy way to try out .sframe support
in the toolchain.]
gas interprets the CFI directives to generate DWARF-based .eh_frame
info. These internal DWARF structures are now consumed by
gen-sframe.[ch] sub-system to, in turn, create the SFrame unwind
information. These internal DWARF structures are read-only for the
purpose of SFrame unwind info generation.
SFrame unwind info generation does not impact .eh_frame unwind info
generation. Both .eh_frame and .sframe can co-exist in an ELF file,
if so desired by the user.
Recall that SFrame unwind information only contains the minimal
necessary information to generate backtraces and does not provide
information to recover all callee-saved registers. The reason being
that callee-saved registers other than FP are not needed for stack
unwinding, and hence are not included in the .sframe section.
Consequently, gen-sframe.[ch] only needs to interpret a subset of
DWARF opcodes in gas. More details follow.
[Set 1, Interpreted] The following opcodes are interpreted:
- DW_CFA_advance_loc
- DW_CFA_def_cfa
- DW_CFA_def_cfa_register
- DW_CFA_def_cfa_offset
- DW_CFA_offset
- DW_CFA_remember_state
- DW_CFA_restore_state
- DW_CFA_restore
[Set 2, Bypassed] The following opcodes are acknowledged but are not
necessary for generating SFrame unwind info:
- DW_CFA_undefined
- DW_CFA_same_value
Anything else apart from the two above-mentioned sets is skipped
altogether. This means that any function containing a CFI directive not
in Set 1 or Set 2 above, will not have any SFrame unwind information
generated for them. Holes in instructions covered by FREs of a single
FDE are not representable in the SFrame unwind format.
As few examples, following opcodes are not processed for .sframe
generation, and are skipped:
- .cfi_personality*
- .cfi_*lsda
- .cfi_escape
- .cfi_negate_ra_state
- ...
Not processing .cfi_escape, .cfi_negate_ra_state will cause SFrame
unwind information to be absent for SFrame FDEs that contain these CFI
directives, hence affecting the asynchronicity.
x86-64 and aarch64 backends need to have a few new definitions and
functions for .sframe generation. These provide gas with architecture
specific information like the SP/FP/RA register numbers and an
SFrame-specific ABI marker.
Lastly, the patch also implements an optimization for size, where
specific fragments containing SFrame FRE start address and SFrame FDE
function are fixed up. This is similar to other similar optimizations
in gas, where fragments are sized and fixed up when the associated
symbols can be resolved. This optimization is controlled by a #define
SFRAME_FRE_TYPE_SELECTION_OPT and should be easy to turn off if needed.
The optimization is on by default for both x86_64 and aarch64.
ChangeLog:
* gas/Makefile.am: Include gen-sframe.c and sframe-opt.c.
* gas/Makefile.in: Regenerated.
* gas/as.h (enum _relax_state): Add new state rs_sframe.
(sframe_estimate_size_before_relax): New function.
(sframe_relax_frag): Likewise.
(sframe_convert_frag): Likewise.
* gas/config/tc-aarch64.c (aarch64_support_sframe_p): New
definition.
(aarch64_sframe_ra_tracking_p): Likewise.
(aarch64_sframe_cfa_ra_offset): Likewise.
(aarch64_sframe_get_abi_arch): Likewise.
(md_begin): Set values of sp/fp/ra registers.
* gas/config/tc-aarch64.h (aarch64_support_sframe_p): New
declaration.
(support_sframe_p): Likewise.
(SFRAME_CFA_SP_REG): Likewise.
(SFRAME_CFA_FP_REG): Likewise.
(SFRAME_CFA_RA_REG): Likewise.
(aarch64_sframe_ra_tracking_p): Likewise.
(sframe_ra_tracking_p): Likewise.
(aarch64_sframe_cfa_ra_offset): Likewise.
(sframe_cfa_ra_offset): Likewise.
(aarch64_sframe_get_abi_arch): Likewise.
(sframe_get_abi_arch): Likewise.
* gas/config/tc-i386.c (x86_support_sframe_p): New definition.
(x86_sframe_ra_tracking_p): Likewise.
(x86_sframe_cfa_ra_offset): Likewise.
(x86_sframe_get_abi_arch): Likewise.
* gas/config/tc-i386.h (x86_support_sframe_p): New declaration.
(support_sframe_p): Likewise.
(SFRAME_CFA_SP_REG): Likewise.
(SFRAME_CFA_FP_REG): Likewise.
(x86_sframe_ra_tracking_p): Likewise.
(sframe_ra_tracking_p): Likewise.
(x86_sframe_cfa_ra_offset): Likewise.
(sframe_cfa_ra_offset): Likewise.
(x86_sframe_get_abi_arch): Likewise.
(sframe_get_abi_arch): Likewise.
* gas/config/tc-xtensa.c (unrelaxed_frag_max_size): Add case for
rs_sframe.
* gas/doc/as.texi: Add .sframe to the documentation for
.cfi_sections.
* gas/dw2gencfi.c (cfi_finish): Create a .sframe section.
* gas/dw2gencfi.h (CFI_EMIT_sframe): New definition.
* gas/write.c (cvt_frag_to_fill): Handle rs_sframe.
(relax_segment): Likewise.
* gas/gen-sframe.c: New file.
* gas/gen-sframe.h: New file.
* gas/sframe-opt.c: New file.
Diffstat (limited to 'gas/doc/as.texi')
-rw-r--r-- | gas/doc/as.texi | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/gas/doc/as.texi b/gas/doc/as.texi index 83f49c5..32300d7 100644 --- a/gas/doc/as.texi +++ b/gas/doc/as.texi @@ -4883,11 +4883,15 @@ Each expression is assembled into the next byte. @subsection @code{.cfi_sections @var{section_list}} @cindex @code{cfi_sections} directive @code{.cfi_sections} may be used to specify whether CFI directives -should emit @code{.eh_frame} section and/or @code{.debug_frame} section. -If @var{section_list} is @code{.eh_frame}, @code{.eh_frame} is emitted, -if @var{section_list} is @code{.debug_frame}, @code{.debug_frame} is emitted. -To emit both use @code{.eh_frame, .debug_frame}. The default if this -directive is not used is @code{.cfi_sections .eh_frame}. +should emit @code{.eh_frame} section, @code{.debug_frame} section and/or +@code{.sframe} section. If @var{section_list} contains @code{.eh_frame}, +@code{.eh_frame} is emitted, if @var{section_list} contains +@code{.debug_frame}, @code{.debug_frame} is emitted, and finally, if +@var{section_list} contains @code{.sframe}, @code{.sframe} is emitted. +To emit multiple sections, specify them together in a list. For example, to +emit both @code{.eh_frame} and @code{.debug_frame}, use +@code{.eh_frame, .debug_frame}. The default if this directive is not used +is @code{.cfi_sections .eh_frame}. On targets that support compact unwinding tables these can be generated by specifying @code{.eh_frame_entry} instead of @code{.eh_frame}. |