Other unit-at-a-time issues (Re: HEADS UP! boot2 problems)
Tim Robbins
tjr at freebsd.org
Fri Aug 6 18:14:55 PDT 2004
On Fri, Aug 06, 2004 at 01:59:29PM -0700, Matthew Dillon wrote:
> I tracked down one problem with the unit-at-a-time code.... it's not
> compatible with -mrtd. Bad code is produced, specifically a missing
> pop in a call.
>
> After removing -mrtd the DFly boot code progressed a bit farther before
> crashing, but unfortunately it still crashed. -fno-unit-at-a-time is
> still required to produce a good 'boot2' boot block even when -mrtd is
> removed.
>
> I was able to determine that the issue is solely with boot2... the
> /boot/loader built with the (default) unit-at-a-time feature appear
> to work just fine.
>
> I have not tracked down the additional bad assembly being produced,
> but it is not an impossible task. The boot2 objdump is not
> actually all that big, but the functions are reordered and I didn't
> want to spend all day tracking down the remaining bugs.
>
> --
>
> I would appreciate it if someone in FreeBSD land would submit this bug
> to the GCC folks.
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
More information about the freebsd-current
mailing list