.eh_frame bloat issue - solution found

Denys Vlasenko vda.linux at googlemail.com
Tue Sep 4 09:48:54 UTC 2012


On Mon, Sep 3, 2012 at 6:47 PM, Rich Felker <dalias at aerifal.cx> wrote:
> By default, modern GCC generates DWARF2 debug/unwind tables in the
> .eh_frame section of the object files/binaries. This adds significant
> bloat (as much as 15%) to the size of the busybox binary, including
> the portion mapped/loaded into memory at runtime (possibly a big issue
> for NOMMU targets), and the section is not strippable with the strip
> command due to being part of the loaded program text.
>
> I've since done some further checking - both testing and asking the
> GCC developers about it - and it seems the solution is to add to the
> CFLAGS -fno-unwind-tables and -fno-asynchronous-unwind-tables. If
> debugging is disabled, this will prevent GCC from outputting DWARF2
> tables entirely. But since busybox builds with -g by default, the
> interesting case is what happens then. I originally thought these
> options would break debugging, but they don't; instead, they tell GCC
> to output the DWARF2 tables in the .debug_frame section instead of
> the newish .eh_frame section (used for exception handling). With these
> options added, busybox_unstripped is still fully debuggable, and the
> final busybox binary loses the 15% bloat factor from the DWARF2
> tables.

Thanks. I added this:

--- a/Makefile.flags
+++ b/Makefile.flags
@@ -53,6 +53,9 @@ CFLAGS += $(call cc-option,-fno-builtin-strlen
-finline-limit=0 -fomit-frame-poi
 CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
 CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
 CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1
-falign-labels=1 -falign-loops=1,)
+# Defeat .eh_frame bloat (gcc 4.6.3 x86-32 defconfig: 20% smaller
busybox binary):
+CFLAGS += $(call cc-option,-fno-unwind-tables,)
+CFLAGS += $(call cc-option,-fno-asynchronous-unwind-tables,)


More information about the busybox mailing list