public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nelson Chu <nelson@rivosinc.com>
To: Sung-hun Kim <sfoon.kim@samsung.com>, gdb-patches@sourceware.org
Cc: binutils@sourceware.org, sungguk.na@samsung.com,
	dongkyun.s@samsung.com,  sw0312.kim@samsung.com
Subject: Re: [PATCH] RISC-V: gas: Change initial CFI operation from DW_CFA_def_cfa_register to DW_CFA_def_cfa
Date: Wed, 15 May 2024 07:19:23 +0800	[thread overview]
Message-ID: <CAPpQWtD7VpJhghiDOS+CNNXqd=h1BN3ohF5i35a1zAOXQ7RA6A@mail.gmail.com> (raw)
In-Reply-To: <20240513081149.32515-1-sfoon.kim@samsung.com>

[-- Attachment #1: Type: text/plain, Size: 1920 bytes --]

Also send this to gdb mailing list as there should be more DWARF experts
out there.

On Mon, May 13, 2024 at 4:13 PM Sung-hun Kim <sfoon.kim@samsung.com> wrote:

> The DWARF specification (especially, DWARF4 and 5 [1,2]) states that
> DW_CFA_def_cfa_register cannot be used as the first CFI operation.
> It said DW_CFA_def_cfa_register as follows:
>
>   ... This operation is valid only if the current CFA rule is defined
>   to use a register and offset.
>
> So, DW_CFA_def_cfa_register can be used after that other definition
> operation such as DW_CFA_def_cfa is called. However, the current gas
> code emits DW_CFA_def_cfa_register as an initial CFI operation for RISCV.
>
> In the libgcc, the unwinding function does not care about it, so it can
> unwind the call stack. However, on the third party library such as
> libunwindstack in Android, it causes a fatal error.
>
> This patch changes the initial CFI operation to DW_CFA_def_cfa with
> offset 0. It works as same as the previous one, but it does not have
> any limitation so it satisfies the DWARF spec. This change resolves
> the compatibility issue while preserving the original behaviour.
>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31733
>
> [1] DWARF4 specification, https://dwarfstd.org/doc/DWARF4.pdf
> [2] DWARF5 specification, https://dwarfstd.org/doc/DWARF5.pdf
>
> Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
> ---
>  gas/config/tc-riscv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
> index 1757ff6e9e2..8d749581c1d 100644
> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -5209,7 +5209,7 @@ RISC-V options:\n\
>  void
>  riscv_cfi_frame_initial_instructions (void)
>  {
> -  cfi_add_CFA_def_cfa_register (X_SP);
> +  cfi_add_CFA_def_cfa (X_SP, 0);
>  }
>
>  int
> --
> 2.25.1
>
>

  reply	other threads:[~2024-05-14 23:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20240513081154epcas1p365a9507c6e31950c50569b9ffdd63f15@epcas1p3.samsung.com>
2024-05-13  8:11 ` Sung-hun Kim
2024-05-14 23:19   ` Nelson Chu [this message]
2024-05-17 13:57   ` Andrew Burgess
2024-05-20  2:54     ` Nelson Chu

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='CAPpQWtD7VpJhghiDOS+CNNXqd=h1BN3ohF5i35a1zAOXQ7RA6A@mail.gmail.com' \
    --to=nelson@rivosinc.com \
    --cc=binutils@sourceware.org \
    --cc=dongkyun.s@samsung.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sfoon.kim@samsung.com \
    --cc=sungguk.na@samsung.com \
    --cc=sw0312.kim@samsung.com \
    /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).