[LinuxBIOS] v3: Miscompilation problems

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Sat Nov 24 12:28:56 CET 2007


it seems that
gcc (GCC) 4.2.1 (SUSE Linux)
can not compile our XIP code in v3 correctly unless -fno-unit-at-a-time
is set as compiler flag. While the compiler will not error out, the
generated code will NOT do what you expect.

If a shared function such as printk is called from multiple functions in
a file, only the printk calls from the most deeply nested function, or
in case there are two functions at the deepest nesting level, the printk
calls from the function executed last in sequence will be executed. The
others seem to be skipped. While I can see the calls in the generated
assembly code, their parameters/offsets are wrong except for the working

While the recent patches make our code compile again, they have
triggered another compiler bug, at least on my machine. If there is no
printk assignment in the C file (because _MAINOBJECT is not defined),
the generated assembly code is incorrect as well and printk calls will
end up somewhere in memory, hanging the machine.

How do we proceed? Blacklist compiler versions? Complain to the gcc
maintainers? Look for flags which fix the miscompilation (seems to work
for the first problem)? Hack around with ld scripts (seems to work for
the second problem)?

I have a patch for the first issue in my tree and will send it in as
soon as my net access works again well enough to update my tree to HEAD.


More information about the coreboot mailing list