gcc miscompiles its sources (boehm-gc)

Martin Kahlert martin.kahlert@infineon.com
Thu Oct 18 01:31:00 GMT 2001


Hi!
gcc-3.1 (yesterday's CVS) has an optimization bug, which prevents static linking on Linux for 
executables produced by gcj (see http://gcc.gnu.org/ml/java/2001-10/msg00077.html )
In boehm-gc/mark_rts.c I changed the first if statement inside the function
GC_exclude_static_roots to look like this:
void GC_exclude_static_roots(start, finish)
GC_PTR start;
GC_PTR finish;
{
 struct exclusion * next;
 size_t next_index, i;
 if (0 == GC_excl_table_entries) {
	next = 0;
 } else {
	next = GC_next_exclusion(start);
 printf("GC_excl_table = %p next = %p, diff = %i\n",
 GC_excl_table, next, next - GC_excl_table);
 }
 ...
The assembly code produced by 
gcc -O -S -I include mark_rts.c reads like that:
.globl GC_exclude_static_roots
	.type	GC_exclude_static_roots,@function
GC_exclude_static_roots:
	pushl	%ebp
	movl	%esp, %ebp
	pushl	%edi
	pushl	%esi
	pushl	%ebx
	subl	28,ドル %esp
	movl	12(%ebp), %edi
	movl	0,ドル %ebx
	cmpl	0,ドル GC_excl_table_entries
	je	.L227
	movl	8(%ebp), %eax
	movl	%eax, (%esp) # %eax = start
	call	GC_next_exclusion # next = GC_next_exclusion(%eax);
	movl	%eax, %ebx # %ebx = next
	movl	stdout, %eax 
	movl	%eax, (%esp) # (%esp) = stdout
	movl	$.LC6, 4(%esp) # 4(%esp) = "GC_excl_table = %p next = %p, diff = %i\n"
	movl	$GC_arrays+42608, 8(%esp) # 8(%esp) = GC_excl_table (= $GC_arrays+42608)
	movl	%ebx, 12(%esp) # 12(%esp) = next ( = %ebx )
	movl	%ebx, %eax # %eax = next ( = %ebx )
	subl	$GC_arrays-42608, %eax # %eax -= $GC_arrays-42608 which should instead be GC_excl_table = $GC_arrays+42608
	sarl	3,ドル %eax # %eax /= 8 ( = sizeof(struct exclusion))
	movl	%eax, 16(%esp) # 16(%esp) = diff ( = %eax )
	call	fprintf
 ....
So the error is the generation of
subl $GC_arrays-42608, %eax
instead of
subl $GC_arrays+42608, %eax
Now i am at the end with my knowledge.
Someone with deeper understanding has to look into that.
It would be nice, if this bug would be removed soon, so i could check, if
static linking works at all using gcj.
$ gcc -v
Reading specs from /sw/gcc-3.1/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc-3.1/configure --prefix=/sw/gcc-3.1 --enable-languages=c++,f77,java --enable-threads=posix
Thread model: posix
gcc version 3.1 20011017 (experimental)
Thanks a lot,
Martin.
-- 
The early bird catches the worm. If you want something else for 
breakfast, get up later.


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /