This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

A very "strange" bug in gcc 2.96


There is the ia32 asm ouput from gcc 2.96 with -O2. Please notice that

	jmp	foo

is generated, instead of

        call foo
        leave
        ret

It is ok if foo () is a static function. But for extern, they are
not the same. The GNU linker supports shared libraries even without
-fPIC. With "jmp foo", it doesn't work anymore. If it is intentional,
we should declare PIC is required for building shared libraries.
Personally, I don't like compiler does this behind my back. It took
me several days to figure out why things stopped working.

Thanks.

H.J.
---x.c--
int foo ()
{
  return 8;
}

int bar ()
{
  return foo ();
}
---x.s--
	.file	"x.c"
	.version	"01.01"
gcc2_compiled.:
.text
	.align 16
.globl foo
	.type	 foo,@function
foo:
	pushl	%ebp
	movl	$8, %eax
	movl	%esp, %ebp
	popl	%ebp
	ret
.Lfe1:
	.size	 foo,.Lfe1-foo
	.align 16
.globl bar
	.type	 bar,@function
bar:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$8, %esp
	movl	%ebp, %esp
	popl	%ebp
	jmp	foo
.Lfe2:
	.size	 bar,.Lfe2-bar
	.ident	"GCC: (GNU) 2.96 20000517 (experimental)"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]