public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/99282] New: Emit .cfi_sections without arguments for -fno-asynchronous-unwind-tables
@ 2021-02-26  5:49 i at maskray dot me
  2021-02-26 11:30 ` [Bug inline-asm/99282] " jakub at gcc dot gnu.org
  2021-02-26 23:17 ` i at maskray dot me
  0 siblings, 2 replies; 3+ messages in thread
From: i at maskray dot me @ 2021-02-26  5:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99282

            Bug ID: 99282
           Summary: Emit .cfi_sections without arguments for
                    -fno-asynchronous-unwind-tables
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: i at maskray dot me
  Target Milestone: ---

.cfi_* in inline asm is rare, but can be useful if the user wants precise
unwind information.

% cat a.c
int main() {
  asm("pushl 0\n.cfi_adjust_cfa_offset 4\npop %%eax\n.cfi_adjust_cfa_offset -4"
::: "eax");
}
% gcc -m32 -c -fomit-frame-pointer -fno-asynchronous-unwind-tables a.c
a.c: Assembler messages:
a.c:3: Error: CFI instruction used without previous .cfi_startproc
a.c:5: Error: CFI instruction used without previous .cfi_startproc

-fasynchronous-unwind-tables & -fno-asynchronous-unwind-tables do not have a
predefined macro, so it is difficult for the inline asm to know whether CFI
directives should be used. For ergonomics, users just want to write CFI
directives and hope they will be silently ignored in
-fno-asynchronous-unwind-tables mode. However, GNU as errors for .cfi_* without
.cfi_startproc .

I suggest that (1) GCC emits ".cfi_sections" (no argument) at the beginning,
(2) GNU as suppresses the error if no .eh_frame/.debug_frame is needed (feature
request: https://sourceware.org/bugzilla/show_bug.cgi?id=27472).

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug inline-asm/99282] Emit .cfi_sections without arguments for -fno-asynchronous-unwind-tables
  2021-02-26  5:49 [Bug c/99282] New: Emit .cfi_sections without arguments for -fno-asynchronous-unwind-tables i at maskray dot me
@ 2021-02-26 11:30 ` jakub at gcc dot gnu.org
  2021-02-26 23:17 ` i at maskray dot me
  1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-26 11:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99282

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
There is the __GCC_HAVE_DWARF2_CFI_ASM predefined macro that tells if .cfi*
directives are used or not.  And, inline asm that wishes to be usable in both
can use that.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug inline-asm/99282] Emit .cfi_sections without arguments for -fno-asynchronous-unwind-tables
  2021-02-26  5:49 [Bug c/99282] New: Emit .cfi_sections without arguments for -fno-asynchronous-unwind-tables i at maskray dot me
  2021-02-26 11:30 ` [Bug inline-asm/99282] " jakub at gcc dot gnu.org
@ 2021-02-26 23:17 ` i at maskray dot me
  1 sibling, 0 replies; 3+ messages in thread
From: i at maskray dot me @ 2021-02-26 23:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99282

--- Comment #2 from Fangrui Song <i at maskray dot me> ---
(In reply to Jakub Jelinek from comment #1)
> There is the __GCC_HAVE_DWARF2_CFI_ASM predefined macro that tells if .cfi*
> directives are used or not.  And, inline asm that wishes to be usable in
> both can use that.

Thanks. I did not know this macro. So the user writing inline asm does have a
way to know whether .cfi_* should be inserted. If you think emitting
`.cfi_sections` is unnecessary, I am fine and happy that this is closed.

(GCC already generates `.cfi_sections .debug_frame\n`, so perhaps supporting
`.cfi_sections\n` is not that costly? :) Users will newer toolchain can be a
bit happier - they don't need to do `#ifdef __GCC_HAVE_DWARF2_CFI_ASM`).

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-26 23:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-26  5:49 [Bug c/99282] New: Emit .cfi_sections without arguments for -fno-asynchronous-unwind-tables i at maskray dot me
2021-02-26 11:30 ` [Bug inline-asm/99282] " jakub at gcc dot gnu.org
2021-02-26 23:17 ` i at maskray dot me

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).