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

Reply via email to