GAS ".cfi_*" directives emitted for 64 bit but not 32 bit

Ian Lance Taylor iant@google.com
Thu Nov 4 19:02:00 GMT 2010


Jeremy Hall <jeremy.m0jnx@gmail.com> writes:

> GCC 4.5.1 (-Os) on Fedora 14.
>
> .cfi_startproc / .cfi_endproc etc directlives in the .s file.
>
> Compiling a C program I see these are included for 64 bit, and they
> increase the executable size by about 10%.
>
> Firstly, is there an option for GCC to not emit these?  I can do a two
> stage compile and remove them from the intermediate .s file with sed -
> which works fine, but I'd rather do it properly!

-fno-asynchronous-unwind-tables should do it.  You may also need
-fno-unwind-tables.

> Secondly, why are they output in 64 bit mode but not in 32 bit mode?
> (all other things being equal).

Because by default the 64-bit code does not use a frame pointer, and
that means that it is hard to unwind the stack, e.g., in the debugger.
The unwind tables permit the debugger to reliably unwind the stack, and
similarly for the backtrace libc function.  They are also used for
exception handling also since you are using C that presumably does not
matter to you.

> Why are these needed in C which doesn't have exceptions?  Is it for
> GDB or valgrind?  For my purposes I am happy to rebuild for debugging.

In that case you don't need them.

Ian



More information about the Gcc-help mailing list