[PATCH 9/9] gas/riscv: Produce version 3 DWARF CIE by default
Palmer Dabbelt via binutils
binutils@sourceware.org
Fri Nov 22 22:33:00 GMT 2019
On Fri, 22 Nov 2019 04:10:33 PST (-0800), andrew.burgess@embecosm.com wrote:
> The flag controlling the default DWARF CIE version to produce now
> starts with the value -1. This can be modified with the command line
> flag as before, but after command line flag processing, in
> md_after_parse_args targets can, if the global still has the value -1,
> override this value. This gives a target specific default.
>
> If a CIE version is not select either by command line flag, or a
> target specific default, then some new code in dwarf2_init now select
> a global default. This remains as version 1 to match previous
> behaviour.
>
> This RISC-V has a target specific default of version provided, this
> make the return column uleb128, which means we can use all DWARF
> registers include CSRs.
>
> I chose to switch to version 3 rather than version 4 as this is most
> similar to the global default (version 1). Switching to version 4
> adds additional columns to the CIE header.
>
> gas/ChangeLog:
>
> * as.c (flag_dwarf_cie_version): Change initial value to -1, and
> update comment.
> * config/tc-riscv.c (riscv_after_parse_args): Set
> flag_dwarf_cie_version if it has not already been set.
> * dwarf2dbg.c (dwarf2_init): Initialise flag_dwarf_cie_version if
> needed.
> * testsuite/gas/riscv/default-cie-version.d: New file.
> * testsuite/gas/riscv/default-cie-version.s: New file.
>
> Change-Id: Ibbfe8f0979fba480bf0a359978b09d2b3055555e
> ---
> gas/ChangeLog | 11 +++++++++++
> gas/as.c | 10 ++++++----
> gas/config/tc-riscv.c | 6 ++++++
> gas/dwarf2dbg.c | 11 +++++++++++
> gas/testsuite/gas/riscv/default-cie-version.d | 15 +++++++++++++++
> gas/testsuite/gas/riscv/default-cie-version.s | 2 ++
> 6 files changed, 51 insertions(+), 4 deletions(-)
> create mode 100644 gas/testsuite/gas/riscv/default-cie-version.d
> create mode 100644 gas/testsuite/gas/riscv/default-cie-version.s
>
> diff --git a/gas/as.c b/gas/as.c
> index cc84725a421..d8501645fe8 100644
> --- a/gas/as.c
> +++ b/gas/as.c
> @@ -95,10 +95,12 @@ int debug_memory = 0;
> /* Enable verbose mode. */
> int verbose = 0;
>
> -/* Which version of DWARF CIE to produce. The default could be overridden
> - by a target during its initialisation, or by the --gdwarf-cie-version
> - command line flag. */
> -int flag_dwarf_cie_version = 1;
> +/* Which version of DWARF CIE to produce. This default value of -1
> + indicates that this value has not been set yet, a default value is
> + provided in DWARF2_INIT. A different value can also be supplied by the
I don't see DWARF2_INIT, just dwarf2_init.
> + command line flag --gdwarf-cie-version, or by a target in
> + MD_AFTER_PARSE_ARGS. */
> +int flag_dwarf_cie_version = -1;
>
> #if defined OBJ_ELF || defined OBJ_MAYBE_ELF
> int flag_use_elf_stt_common = DEFAULT_GENERATE_ELF_STT_COMMON;
> diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
> index dcd8405a2c1..055d80c3444 100644
> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -2341,6 +2341,12 @@ riscv_after_parse_args (void)
>
> /* Insert float_abi into the EF_RISCV_FLOAT_ABI field of elf_flags. */
> elf_flags |= float_abi * (EF_RISCV_FLOAT_ABI & ~(EF_RISCV_FLOAT_ABI << 1));
> +
> + /* If the CIE to be produced has not been overridden on the command line,
> + then produce version 3 by default. This allows us to use the full
> + range of registers in a .cfi_return_column directive. */
> + if (flag_dwarf_cie_version == -1)
> + flag_dwarf_cie_version = 3;
> }
>
> long
> diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
> index 90b47b02fc0..ac7cbd8037c 100644
> --- a/gas/dwarf2dbg.c
> +++ b/gas/dwarf2dbg.c
> @@ -2194,6 +2194,17 @@ void
> dwarf2_init (void)
> {
> last_seg_ptr = &all_segs;
> +
> + /* Select the default CIE version to produce here. The global
> + starts with a value of -1 and will be modified to a valid value
> + either by the user providing a command line option, or some
> + targets will select their own default in md_after_parse_args. If
> + we get here and the global still contains -1 then it is up to us
> + to pick a sane default. The default we choose is 1, this is the
> + CIE version gas has produced for a long time, and there seems no
> + reason to change it yet. */
> + if (flag_dwarf_cie_version == -1)
> + flag_dwarf_cie_version = 1;
> }
>
>
> diff --git a/gas/testsuite/gas/riscv/default-cie-version.d b/gas/testsuite/gas/riscv/default-cie-version.d
> new file mode 100644
> index 00000000000..035f2587ff1
> --- /dev/null
> +++ b/gas/testsuite/gas/riscv/default-cie-version.d
> @@ -0,0 +1,15 @@
> +#objdump: --dwarf=frames
> +#as:
> +#...
> +.*: file format elf.*-.*riscv
> +
> +Contents of the .* section:
> +
> +00000000 0+[0-9a-f]+ 0+000 CIE
> + Version: 3
> + Augmentation: .*
> + Code alignment factor: .*
> + Data alignment factor: .*
> + Return address column: .*
> + Augmentation data: .*
> +#...
> \ No newline at end of file
> diff --git a/gas/testsuite/gas/riscv/default-cie-version.s b/gas/testsuite/gas/riscv/default-cie-version.s
> new file mode 100644
> index 00000000000..659b3b9d99b
> --- /dev/null
> +++ b/gas/testsuite/gas/riscv/default-cie-version.s
> @@ -0,0 +1,2 @@
> + .cfi_startproc
> + .cfi_endproc
Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com>
More information about the Binutils
mailing list