Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MihKc-0005xU-Uh for mharc-grub-devel@gnu.org; Wed, 02 Sep 2009 00:20:26 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MihKb-0005wy-TF for grub-devel@gnu.org; Wed, 02 Sep 2009 00:20:25 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MihKX-0005rM-2W for grub-devel@gnu.org; Wed, 02 Sep 2009 00:20:25 -0400 Received: from [199.232.76.173] (port=36422 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MihKW-0005r2-Uy for grub-devel@gnu.org; Wed, 02 Sep 2009 00:20:20 -0400 Received: from mail-pz0-f191.google.com ([209.85.222.191]:40724) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MihKW-000560-Ir for grub-devel@gnu.org; Wed, 02 Sep 2009 00:20:20 -0400 Received: by pzk29 with SMTP id 29so495240pzk.1 for ; Tue, 01 Sep 2009 21:20:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=aqLPp9jvZbxH264wRaGND5JpzVjntS7hvUAsu4CHwv4=; b=S6WItKcGDwZKtyLJHTx0cCrT8zQ9NlWLAHTy124sny+L3EHcauXYJytc+RL1wvq/l4 yNXKOdlYFt3bxGVLUbxkAZr3nL5LD2GfI6QujgnfCxBxb74MOh5sh/mc96mQDY09M1wl 1KAfJeTz579zbQBIMcv3P8mCKhWF4q5D3csNM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=g80cCtpyEcQqzUzwfhH/1cRSzfT3WglLbc/beCu9WHey4Eo4VCpZLzf0+0vhXm/hwo UR5nBcpxTgDNl540qLIRS4cYbOHP/5VouEmfcFwRLF5JRYo9kFWB0ZZ+w6i1G5maEzg3 teP2qAlDxLB76emN+bkJeGcjeyWTq3nDUbrp4= MIME-Version: 1.0 Received: by 10.140.188.15 with SMTP id l15mr2148469rvf.42.1251865219537; Tue, 01 Sep 2009 21:20:19 -0700 (PDT) In-Reply-To: References: Date: Wed, 2 Sep 2009 12:20:19 +0800 Message-ID: From: Bean To: The development of GRUB 2 Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [RFC] Eliminate NESTED_ATTR_FUNC X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2009 04:20:26 -0000 On Tue, Sep 1, 2009 at 11:43 PM, Bean wrote: > I make an assembly dump of the code generated by gcc-4.2. Apparently, > the "FIX" is achieved by ignoring the regparm attribute at all. > __attribute__ ((__regparm__ (3))) doesn't have any effect any more, it > always pass the parameters on the stack. This defeats the original > purpose of -mregparm=3, which passes parameters using register and > therefore reduce module size. In fact, if we are going to use stack, > we could just remove -mregparm=3 option, this works for all version of > gcc. Hi, Oh, I was wrong previously, gcc does respect __attribute__ ((__regparm__ (3))) flag (I forget to add -Os so it still uses stack to store value). And the bug is still there ! Try this test program: #include void foo (int a, int b, void (*hook) (int aa, int bb, int cc)) { b += a; hook (a, b, a + b); } void qq (int a) { auto void q1 (int aa, int bb, int cc); void q1 (int aa, int bb, int cc) { printf ("%d %d %d\n", a, aa + bb, cc); } foo (a, a + 1, q1); } int main() { qq (10); } Compile with: gcc -m32 -mregparm=3 -Os test.c ./a.out 10 31 -6674368 gcc is 4.3.4 from debian. --- Bean gitgrub home: http://github.com/grub/grub/ my fork page: http://github.com/bean123/grub/