From owner-freebsd-current@FreeBSD.ORG Sat Aug 7 04:45:02 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 6648F16A4CE; Sat, 7 Aug 2004 04:45:02 +0000 (GMT) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4DD6043D39; Sat, 7 Aug 2004 04:45:00 +0000 (GMT) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (localhost [127.0.0.1]) i774irds027809; Fri, 6 Aug 2004 21:44:55 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.12.9p2/8.12.9/Submit) id i774irlm027808; Fri, 6 Aug 2004 21:44:53 -0700 (PDT) (envelope-from dillon) Date: Fri, 6 Aug 2004 21:44:53 -0700 (PDT) From: Matthew Dillon Message-Id: <200408070444.i774irlm027808@apollo.backplane.com> To: Tim Robbins References: <4109B4EF.605@samsco.org> <20040730152119.GA43119@freefall.freebsd.org> <200408062059.i76KxTBW026143@apollo.backplane.com> <20040807011451.GA51119@cat.robbins.dropbear.id.au> 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 04:45:02 -0000 :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