On Wed, Feb 17, 2021 at 9:22 PM Fangrui Song <i@xxxxxxxxxx> wrote: > g++ -fno-exceptions -fno-asynchronous-unwind-tables -S a.cc => no > .cfi_* directive > g++ -fno-exceptions -fno-asynchronous-unwind-tables -g -S a.cc => > there are .cfi_* directive > The intent is that -g produces .debug_frame sections, because the compiler is supposed to, and we can't know in advance whether the debugger will want them. EH produces .eh_frame sections. If we need to produce an eh_frame section, then we don't bother to produce a debug_frame section because they are basically the same, except that eh_frame has extra alignment padding to make it friendlier to non-dwarf2 systems, and gdb can use either section. The .cfi_* directives are used for both the debug_frame and eh_frame sections. When using -g with exceptions off, you should see a .cfi_sections .debug_frame directive which tells the assembler to produce a debug_frame section. If no .cfi_sections directive the assembler will produce a eh_frame section by default. If a toolchain produces debug info by default, you can turn it off with -g0, preferably at the end of the command in case there is a -g option somewhere earlier in the command. Exact behavior will depend on gcc version and target, since cfi_sections was added about 10 years ago, and some targets enable debug and/or exceptions by default, and some targets don't use dwarf2 exceptions. Jim