From owner-freebsd-bugs Sat Nov 22 05:50:06 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id FAA06349 for bugs-outgoing; Sat, 22 Nov 1997 05:50:06 -0800 (PST) (envelope-from owner-freebsd-bugs) Received: (from gnats@localhost) by hub.freebsd.org (8.8.7/8.8.7) id FAA06333; Sat, 22 Nov 1997 05:50:03 -0800 (PST) (envelope-from gnats) Resent-Date: Sat, 22 Nov 1997 05:50:03 -0800 (PST) Resent-Message-Id: <199711221350.FAA06333@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, cagney@tpgi.com.au Received: from random.tpgi.com.au (random.tpgi.com.au [203.12.160.7]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id FAA06102 for ; Sat, 22 Nov 1997 05:44:22 -0800 (PST) (envelope-from cagney@tpgi.com.au) Received: (from smtpd@localhost) by random.tpgi.com.au (8.8.4/8.8.6) id AAA13100 for ; Sun, 23 Nov 1997 00:44:19 +1100 (EST) Received: from oberon.tpgi.com.au(203.12.160.2), claiming to be "oberon.com.au" via SMTP by random.tpgi.com.au, id smtpdAAAa003Cd; Sun Nov 23 00:44:12 1997 Received: from b1.tpgi.com.au by oberon.com.au (SMI-8.6/SMI-SVR4) id AAA07042; Sun, 23 Nov 1997 00:44:06 +1100 Received: (from cagney@localhost) by b1.tpgi.com.au (8.8.7/8.7.3) id AAA25765; Sun, 23 Nov 1997 00:44:38 +1100 (EST) Message-Id: <199711221344.AAA25765@b1.tpgi.com.au> Date: Sun, 23 Nov 1997 00:44:38 +1100 (EST) From: Andrew Cagney Reply-To: cagney@tpgi.com.au To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: gnu/5126: Sender: owner-freebsd-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Number: 5126 >Category: gnu >Synopsis: >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Nov 22 05:50:02 PST 1997 >Last-Modified: >Originator: Andrew Cagney >Organization: >Release: FreeBSD 2.2.5-RELEASE i386 >Environment: `Virgin 2.2.5' (I've reverted back to 2.1.7 :-) >Description: For the program below, when compiled with G++ (-gpic) , produces the incorrect assembler: .type _d__Fv,@function _d__Fv: pushl %ebp movl %esp,%ebp pushl %ebx call L5 L5: popl %ebx addl $_GLOBAL_OFFSET_TABLE_+[.-L5],%ebx movl _DefaultHash__Fv@GOT(%ebx),%edx movl %edx,%eax jmp L3 .align 2,0x90 jmp L4 .align 2,0x90 jmp L3 .align 2,0x90 L4: L3: movl -4(%ebp),%ebx leave ret Notice that it has generated a ``@GOT'' instead of ``@GOTOFF'' for the reference to the static function DefaultHash (which has been both declared and defined). If the declaration is removed, the correct code is generated. If GCC is used, the correct code is generated. >How-To-Repeat: $ cat test.cc static void DefaultHash(void); static void DefaultHash(void) { } void * d (void) { return DefaultHash; } $ gcc -c -fpic test.cc /tmp/cc005218.s: Assembler messages: /tmp/cc005218.s:45: Warning: GOT relocation burb: `_DefaultHash__Fv' should be global $ cp test.cc test.c $ gcc -c -fpic test.c $ tail +2 test.cc > t.cc $ cat t.cc static void DefaultHash(void) { } void * d (void) { return DefaultHash; } $ gcc -c -fpic t.cc >Fix: Re-arrange code so that the static declaration isn't needed. >Audit-Trail: >Unformatted: