bad generation of stabs under i386-coff with -O2 -finline-functions

Marc Espie Marc.Espie@liafa.jussieu.fr
Tue Oct 13 05:05:00 GMT 1998


While trying to build egcs under OpenBSD, I've run into a problem, which
I think may occur under every machine which use stabs for constructing
CTOR lists (e.g., coff, and no use_collect2), or possibly, the i386 code
generation is involved as well...

Consider the following code:
// a.C
static struct object
	{
	object()
		{
		exit(0);
		}
	} o;

// b.C
int main()
	{
	abort();
	}

If compiled and linked with -O2, it works; with -O2 -finline-functions it
fails. A save-temps gives the following assembly files:
; a.s, -O2
	.file	"a.cc"
gcc2_compiled.:
___gnu_compiled_cplusplus:
.lcomm _o,4
.text
	.align 2,0x90
.globl __GLOBAL_$I$a.C
	.type	 __GLOBAL_$I$a.C,@function
__GLOBAL_$I$a.C:
	pushl %ebp
	movl %esp,%ebp
	pushl $0
	call _exit
Lfe1:
	.size	 __GLOBAL_$I$a.C,Lfe1-__GLOBAL_$I$a.C
.stabs "___CTOR_LIST__",22,0,0,__GLOBAL_$I$a.C

; a.s, -O2 -finline-functions
	.file	"a.cc"
gcc2_compiled.:
___gnu_compiled_cplusplus:
.lcomm _o,4
.stabs "___CTOR_LIST__",22,0,0,__GLOBAL_$I$a.C
.text
	.align 2,0x90
.globl __GLOBAL_$I$a.C
	.type	 __GLOBAL_$I$a.C,@function
__GLOBAL_$I$a.C:
	pushl %ebp
	movl %esp,%ebp
	pushl $0
	call _exit
Lfe1:
	.size	 __GLOBAL_$I$a.C,Lfe1-__GLOBAL_$I$a.C

I don't really what's supposed to be going on, maybe gnu-as and gnu-ld are
supposed to be able to handle the difference. This shows up under native
gcc 2.8.1, egcs-1.1b, and the 0510 snapshot.

I'd like to know whether this really is a bug, e.g., how that code handles
under NetBSD or FreeBSD...
-- 
	Marc Espie		
|anime, sf, juggling, unicycle, acrobatics, comics...
|AmigaOS, OpenBSD, C++, perl, Icon, PostScript...
| `real programmers don't die, they just get out of beta'



More information about the Gcc-bugs mailing list