Date: Sun, 23 Nov 1997 00:44:38 +1100 (EST) From: Andrew Cagney <cagney@tpgi.com.au> To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: gnu/5126: <Synopsis of the problem (one line)> Message-ID: <199711221344.AAA25765@b1.tpgi.com.au> Resent-Message-ID: <199711221350.FAA06333@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 5126 >Category: gnu >Synopsis: <Synopsis of the problem (one line)> >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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199711221344.AAA25765>