Re: Other unit-at-a-time issues (Re: HEADS UP! boot2 problems)

From: Matthew Dillon <dillon_at_apollo.backplane.com>
Date: Fri, 6 Aug 2004 21:44:53 -0700 (PDT)
: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>
Received on Sat Aug 07 2004 - 02:45:02 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:05 UTC