Other unit-at-a-time issues (Re: HEADS UP! boot2 problems)
Matthew Dillon
dillon at apollo.backplane.com
Fri Aug 6 21:45:02 PDT 2004
:Bad things happen if unit-at-a-time optimization causes memcpy() to use a
:non-standard calling convention, since gcc -Os generates calls to memcpy()
:for struct assignments (I believe there is only one of these in boot2, in
:fsread()). Try making memcpy() non-static, using __attribute__((__used__)),
:or __attribute__((__stdcall__)) (assuming you re-enable -mrtd). Any of these
:will thwart the calling convention change.
:
:
:Tim
Well, unit-at-a-time and -mrtd don't work together, period. Bad code is
generated when complex inlining occurs (for things other then memcpy).
I tracked down the structural copies in fsread with the (default)
unit-at-a-time and WITHOUT -mrtd and they appear to generate bad
code for their memcpy calls. The unit-at-a-time memcpy expects two
arguments in registers and one on the stack, and the memcpy code
fsread() calls for the structural copy appears to be supplying
three arguments in registers and nothing on the stack.
If I make memcpy() non-static, simply by removing 'static', all the
calls to memcpy() appear to be generated properly, but boot2 still
crashes so there must be other things that unit-at-a-time is still
breaking.
It's not even funny how broken unit-at-a-time is, how the GCC folks
could turn it on by default in a release is beyond me. You know, when
I wrote DICE we had similar issues with multiple calling conventions,
but the Amiga had a function naming standard that prevented the sorts
of blowups we are seeing here... functions would be prefixed differently
depending on the calling convention used. It worked great 10+ years ago
and it would work great now. Sigh. oh well.
-Matt
Matthew Dillon
<dillon at backplane.com>
More information about the freebsd-current
mailing list