[U-Boot] gcc, ARM, -fdata-sections -fmerge-constants and strings

Tom Rini trini at ti.com
Mon Aug 20 18:55:08 CEST 2012


Hey all,

As I just mentioned in another thread, gcc bug #54303 [1] causes us
problems.  -fmerge-constants is an optimization enabled in most levels.
On some platforms such as x86_64, when used with -fdata-sections it
means that each set of "strings" in a function will result in a
per-function .rodata.strN.N section.  Later when a function isn't used
these sections can also be garbage collected.  However, on ARM this
isn't what happens.  All strings for an object file are collected into a
single .rodata.strN.N section.  Further, these sections are combined
again when we link our library.  This means that we can only garbage
collect strings for a given library when none of them are used.  This is
OK in some cases as we luck out and don't need any of the functions with
printf/puts.  In other cases, such as if we move the SPL framework to
common/ all of the strings we need will be retained.  This pushes us
over the size limit in some cases, along with being a flat-out bug.

As this is a bug, and something that is handled correctly on other
platforms my hope is that fixing the problem won't be hard for someone
that knows the toolchain and eventually we can set a minimum requirement
on a gcc without this bug.  A work-around for this would be to disable
-fmerge-constants but this results in a larger SPL binary, but not so
large as when we collected nothing.  It is larger than being careful
about where we place source files, so I would only suggest this as a
work-around once we have a fixed gcc available.

[1]
 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54303

-- 
Tom


More information about the U-Boot mailing list