From owner-freebsd-current@FreeBSD.ORG Sat Aug 7 01:14:55 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C3ACA16A4CE; Sat, 7 Aug 2004 01:14:55 +0000 (GMT) Received: from robbins.dropbear.id.au (233.a.003.mel.iprimus.net.au [203.134.172.233]) by mx1.FreeBSD.org (Postfix) with ESMTP id E6C8E43D2F; Sat, 7 Aug 2004 01:14:54 +0000 (GMT) (envelope-from tim@robbins.dropbear.id.au) Received: by robbins.dropbear.id.au (Postfix, from userid 1000) id 6FAF64207; Sat, 7 Aug 2004 11:14:51 +1000 (EST) Date: Sat, 7 Aug 2004 11:14:51 +1000 From: Tim Robbins To: Matthew Dillon Message-ID: <20040807011451.GA51119@cat.robbins.dropbear.id.au> References: <4109B4EF.605@samsco.org> <20040730152119.GA43119@freefall.freebsd.org> <200408062059.i76KxTBW026143@apollo.backplane.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200408062059.i76KxTBW026143@apollo.backplane.com> User-Agent: Mutt/1.4.1i cc: Alexander Kabaev cc: FreeBSD Current List Subject: Re: Other unit-at-a-time issues (Re: HEADS UP! boot2 problems) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Aug 2004 01:14:55 -0000 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