This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


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

0501 snap, mcore-sim execution failures


Building egcs-20000501, gdb-4.95.0, binutils-000421, newlib-1.8.2
configured for --host=i586-pc-linux-gnu --target=mcore-mcore-elf
yields failures for all executions running mcore-sim tests.

Testing with a mainline that only calls exit, I think what is happening
is that _init is calling __do_global_ctors_aux which modifies the stack
pointer r0, but doesn't restore it. When _init attempts to return, it
loads 0x0 from the stack frame instead of the saved return pointer.
This means _init returns to itself, continues calling __do_global_ctors_aux
until something causes at trap.
Building crtend.o without optimization looks like it yields a
__do_global_ctors_aux that restores the stack pointer appropriately. 


./xgcc -v --save-temps -B/usr/local/mcore-mcore-elf/bin/ -B./ -isystem \
    /usr/local/mcore-mcore-elf/include \
    -DCROSS_COMPILE -DIN_GCC -DDONT_HAVE_STDIO -DDONT_HAVE_SETJMP \
    -Dinhibit_libc -g -W -Wall -Wtraditional -isystem ./include \
    -I. -I../../egcs-20000501/gcc -I../../egcs-20000501/gcc/config \
    -I../../egcs-20000501/gcc/../include \
    -O2  -g0 \
    -finhibit-size-directive -fno-inline-functions -fno-exceptions   \
    -c ../../egcs-20000501/gcc/crtstuff.c -DCRT_END -o crtend.o
Reading specs from ./specs
gcc version 2.96 20000501 (experimental)
 ./cpp -lang-c -v -I. -I../../egcs-20000501/gcc -I../../egcs-20000501/gcc/config -I../../egcs-20000501/gcc/../include -iprefix ./../lib/gcc-lib/mcore-mcore-elf/2.96/ -isystem ./include -isystem /usr/local/mcore-mcore-elf/bin/include -D__GNUC__=2 -D__GNUC_MINOR__=96 -D__GNUC_PATCHLEVEL__=0 -D__mcore__ -D__MCORE__=1 -D__declspec(x)=__attribute__((x)) -D__ELF__ -D__mcore__ -D__MCORE__=1 -D__declspec(x)=__attribute__((x)) -D__ELF__ -D__CHAR_UNSIGNED__ -D__OPTIMIZE__ -g -g0 -W -Wall -Wtraditional -D__MCORELE__ -D__M340__ -DCROSS_COMPILE -DIN_GCC -DDONT_HAVE_STDIO -DDONT_HAVE_SETJMP -Dinhibit_libc -DCRT_END -isystem /usr/local/mcore-mcore-elf/include -isystem ./include ../../egcs-20000501/gcc/crtstuff.c crtstuff.i
GNU CPP version 2.96 20000501 (experimental) (cpplib)
 (Motorola MCORE/elf)
ignoring nonexistent directory `/usr/local/mcore-mcore-elf/bin/include'
ignoring nonexistent directory `../lib/gcc-lib/mcore-mcore-elf/2.96/include'
ignoring nonexistent directory `../mcore-mcore-elf/sys-include'
ignoring nonexistent directory `../mcore-mcore-elf/include'
ignoring nonexistent directory `/usr/local/mcore-mcore-elf/sys-include'
ignoring duplicate directory `include'
ignoring duplicate directory `/usr/local/mcore-mcore-elf/include'
#include "..." search starts here:
#include <...> search starts here:
 .
 ../../egcs-20000501/gcc
 ../../egcs-20000501/gcc/config
 ../../egcs-20000501/include
 include
 /usr/local/mcore-mcore-elf/include
 /usr/local/lib/gcc-lib/mcore-mcore-elf/2.96/include
End of search list.
 ./cc1 crtstuff.i -funsigned-bitfields -quiet -dumpbase crtstuff.c -g -g0 -O2 -W -Wall -Wtraditional -version -finhibit-size-directive -fno-inline-functions -fno-exceptions -o crtstuff.s
GNU C version 2.96 20000501 (experimental) (mcore-mcore-elf) compiled by GNU C version 2.7.2.3.
 /usr/local/mcore-mcore-elf/bin/as -o crtend.o crtstuff.s
cat crtstuff.s
	.file	"crtstuff.c"
gcc2_compiled.:
	.text
	.align	1
	.type	 __do_global_ctors_aux,@function
__do_global_ctors_aux:
	subi	sp,16
	stm	r13-r15,(sp)
	lrw	r14, __CTOR_END__-4
	ldw	r7,(r14)
	bmaski	r6,32	// -1 0xffffffff
	cmpne	r7,r6
	jbf	.L8
	mov	r13,r6
.L6:
	jsr	r7
	subi	r14,4
	ldw	r7,(r14)
	cmpne	r7,r13
	jbt	.L6
.L8:
	jmp	r15
	.align	1
	.type	 init_dummy,@function
init_dummy:
	subi	sp,8
	stw	r15,(sp)
// inline asm begin
		.section	.init
// inline asm end
	jbsr	__do_global_ctors_aux
// inline asm begin
	br 1f ; .literals ; 1:
		.text
// inline asm end
	jmp	r15
	.data
	.align	2
	.type	 force_to_data,@object
force_to_data:
// inline asm begin
	.section	.ctors,"aw"
// inline asm end
	.align	2
	.type	 __CTOR_END__,@object
__CTOR_END__:
	.long	0
// inline asm begin
	.section	.dtors,"aw"
// inline asm end
	.align	2
	.type	 __DTOR_END__,@object
__DTOR_END__:
	.long	0
	.weak	__deregister_frame_info
	.weak	__register_frame_info
	.ident	"GCC: (GNU) 2.96 20000501 (experimental)"
./xgcc -v --save-temps -B/usr/local/mcore-mcore-elf/bin/ -B./ -isystem \
    /usr/local/mcore-mcore-elf/include \
    -DCROSS_COMPILE -DIN_GCC -DDONT_HAVE_STDIO -DDONT_HAVE_SETJMP \
    -Dinhibit_libc -g -W -Wall -Wtraditional -isystem ./include \
    -I. -I../../egcs-20000501/gcc -I../../egcs-20000501/gcc/config \
    -I../../egcs-20000501/gcc/../include \
    -g0 \
    -finhibit-size-directive -fno-inline-functions -fno-exceptions   \
    -c ../../egcs-20000501/gcc/crtstuff.c -DCRT_END -o crtend.o
Reading specs from ./specs
gcc version 2.96 20000501 (experimental)
 ./cpp -lang-c -v -I. -I../../egcs-20000501/gcc -I../../egcs-20000501/gcc/config -I../../egcs-20000501/gcc/../include -iprefix ./../lib/gcc-lib/mcore-mcore-elf/2.96/ -isystem ./include -isystem /usr/local/mcore-mcore-elf/bin/include -D__GNUC__=2 -D__GNUC_MINOR__=96 -D__GNUC_PATCHLEVEL__=0 -D__mcore__ -D__MCORE__=1 -D__declspec(x)=__attribute__((x)) -D__ELF__ -D__mcore__ -D__MCORE__=1 -D__declspec(x)=__attribute__((x)) -D__ELF__ -D__CHAR_UNSIGNED__ -g -g0 -W -Wall -Wtraditional -D__MCORELE__ -D__M340__ -DCROSS_COMPILE -DIN_GCC -DDONT_HAVE_STDIO -DDONT_HAVE_SETJMP -Dinhibit_libc -DCRT_END -isystem /usr/local/mcore-mcore-elf/include -isystem ./include ../../egcs-20000501/gcc/crtstuff.c crtstuff.i
GNU CPP version 2.96 20000501 (experimental) (cpplib)
 (Motorola MCORE/elf)
ignoring nonexistent directory `/usr/local/mcore-mcore-elf/bin/include'
ignoring nonexistent directory `../lib/gcc-lib/mcore-mcore-elf/2.96/include'
ignoring nonexistent directory `../mcore-mcore-elf/sys-include'
ignoring nonexistent directory `../mcore-mcore-elf/include'
ignoring nonexistent directory `/usr/local/mcore-mcore-elf/sys-include'
ignoring duplicate directory `include'
ignoring duplicate directory `/usr/local/mcore-mcore-elf/include'
#include "..." search starts here:
#include <...> search starts here:
 .
 ../../egcs-20000501/gcc
 ../../egcs-20000501/gcc/config
 ../../egcs-20000501/include
 include
 /usr/local/mcore-mcore-elf/include
 /usr/local/lib/gcc-lib/mcore-mcore-elf/2.96/include
End of search list.
 ./cc1 crtstuff.i -funsigned-bitfields -quiet -dumpbase crtstuff.c -g -g0 -W -Wall -Wtraditional -version -finhibit-size-directive -fno-inline-functions -fno-exceptions -o crtstuff.s
GNU C version 2.96 20000501 (experimental) (mcore-mcore-elf) compiled by GNU C version 2.7.2.3.
 /usr/local/mcore-mcore-elf/bin/as -o crtend.o crtstuff.s
cat crtstuff.s
	.file	"crtstuff.c"
gcc2_compiled.:
	.text
	.align	1
	.type	 __do_global_ctors_aux,@function
__do_global_ctors_aux:
	subi	sp,16
	stw	r15,(sp,8)
	stw	r8,(sp,12)
	mov	r8,sp
	or	r0,r0
	lrw	r7, __CTOR_END__
	subi	r7,4
	stw	r7,(r8)
.L3:
	ldw	r7,(r8)
	ldw	r6,(r7)
	bmaski	r7,32	// -1 0xffffffff
	cmpne	r6,r7
	jbt	.L6
	jbr	.L4
.L6:
	ldw	r7,(r8)
	ldw	r7,(r7)
	jsr	r7
	ldw	r7,(r8)
	subi	r7,4
	stw	r7,(r8)
	jbr	.L3
.L4:
	mov	sp,r8
	ldw	r15,(sp,8)
	ldw	r8,(sp,12)
	addi	sp,16
	jmp	r15
	.align	1
	.type	 init_dummy,@function
init_dummy:
	subi	sp,8
	stw	r15,(sp)
	stw	r8,(sp,4)
	mov	r8,sp
// inline asm begin
		.section	.init
// inline asm end
	jbsr	__do_global_ctors_aux
// inline asm begin
	br 1f ; .literals ; 1:
		.text
// inline asm end
	mov	sp,r8
	ldw	r15,(sp)
	ldw	r8,(sp,4)
	addi	sp,8
	jmp	r15
	.data
	.align	2
	.type	 force_to_data,@object
force_to_data:
// inline asm begin
	.section	.ctors,"aw"
// inline asm end
	.align	2
	.type	 __CTOR_END__,@object
__CTOR_END__:
	.long	0
// inline asm begin
	.section	.dtors,"aw"
// inline asm end
	.align	2
	.type	 __DTOR_END__,@object
__DTOR_END__:
	.long	0
	.weak	__deregister_frame_info
	.weak	__register_frame_info
	.ident	"GCC: (GNU) 2.96 20000501 (experimental)"



# Editted simulator trace
0028: inst = 710a LRW of 0x80000 from 0x50 to reg 1
002a: inst = 1210 MOV 80000 into reg 0
002c: inst = 710a LRW of 0x2080 from 0x54 to reg 1
002e: inst = 720a LRW of 0x2084 from 0x58 to reg 2
0030: inst = 6003 
0032: inst = 9301 store reg 3 (containing 0x0) to 0x2080
0034: inst = 2031 
0036: inst = 0c21 
0038: inst = effc 
003a: inst = 7f08 func call: r2 = 2084 r3 = 0 r4 = 0 r5 = 7ffff8 r6 = 0 r7 = 0

0000: inst = 24f0 
0002: inst = 9f30 store reg 15 (containing 0x3c) to 0x7fffc
0004: inst = 1200 MOV 7fff0 into reg 0
0006: inst = 1200 MOV 7fff0 into reg 0
0008: inst = 1200 MOV 7fff0 into reg 0
000a: inst = 1200 MOV 7fff0 into reg 0
000c: inst = 1200 MOV 7fff0 into reg 0
000e: inst = 1200 MOV 7fff0 into reg 0
0010: inst = 7f01 func call: r2 = 2084 r3 = 0 r4 = 0 r5 = 7ffff8 r6 = 0 r7 = 0

08d8: inst = 24f0 
08da: inst = 007d 
08dc: inst = 7e07 LRW of 0x2070 from 0x8f8 to reg 14
08de: inst = 870e load reg 7 from 0x2070 with 0xffffffff
08e0: inst = 2c06 
08e2: inst = 0f67 
08e4: inst = e806 
08f2: inst = 00cf Func return, r2 = 2084, r3 = 0

0012: inst = f002 
0018: inst = 0e0e 
001a: inst = 0e0e 
001c: inst = 0e0e 
001e: inst = 0e0e 
0020: inst = 8f30 load reg 15 from 0x7ffec with 0x0
0022: inst = 20f0 
0024: inst = 00cf Func return, r2 = 2084, r3 = 0

0000: inst = 24f0 
0002: inst = 9f30 store reg 15 (containing 0x0) to 0x7ffec
0004: inst = 1200 MOV 7ffe0 into reg 0
0006: inst = 1200 MOV 7ffe0 into reg 0
0008: inst = 1200 MOV 7ffe0 into reg 0
000a: inst = 1200 MOV 7ffe0 into reg 0
000c: inst = 1200 MOV 7ffe0 into reg 0
000e: inst = 1200 MOV 7ffe0 into reg 0
0010: inst = 7f01 func call: r2 = 2084 r3 = 0 r4 = 0 r5 = 7ffff8 r6 = ffffffff r7 = ffffffff

08d8: inst = 24f0 
08da: inst = 007d 
08dc: inst = 7e07 LRW of 0x2070 from 0x8f8 to reg 14
08de: inst = 870e load reg 7 from 0x2070 with 0xffffffff
08e0: inst = 2c06 
08e2: inst = 0f67 
08e4: inst = e806 
08f2: inst = 00cf Func return, r2 = 2084, r3 = 0

0012: inst = f002 
0018: inst = 0e0e 
001a: inst = 0e0e 
001c: inst = 0e0e 
001e: inst = 0e0e 
0020: inst = 8f30 load reg 15 from 0x7ffdc with 0x0
0022: inst = 20f0 
0024: inst = 00cf Func return, r2 = 2084, r3 = 0

...

08d8: inst = 24f0 
08da: inst = 007d 
08dc: inst = 7e07 LRW of 0x2070 from 0x8f8 to reg 14
08de: inst = 870e load reg 7 from 0x2070 with 0x0
08e0: inst = 2c06 
08e2: inst = 0f67 
08e4: inst = e806 
08e6: inst = 126d MOV ffffffff into reg 13
08e8: inst = 00d7 
0000: inst = 24f0 
0002: inst = 9f30 store reg 15 (containing 0x8ea) to 0x92c
0004: inst = 1200 MOV 920 into reg 0
0006: inst = 1200 MOV 920 into reg 0
0008: inst = 1200 MOV 920 into reg 0
000a: inst = 1200 MOV 920 into reg 0
000c: inst = 1200 MOV 920 into reg 0
000e: inst = 1200 MOV 920 into reg 0
0010: inst = 7f01 func call: r2 = 2084 r3 = 0 r4 = 0 r5 = 7ffff8 r6 = ffffffff r7 = 0

08d8: inst = 24f0 
08da: inst = 007d 
08dc: inst = 7e07 LRW of 0x2070 from 0x8f8 to reg 14
08de: inst = 870e load reg 7 from 0x2070 with 0x0
08e0: inst = 2c06 
08e2: inst = 0f67 
08e4: inst = e806 
08e6: inst = 126d MOV ffffffff into reg 13
08e8: inst = 00d7 
0000: inst = 24f0 
0002: inst = 9f30 store reg 15 (containing 0x8ea) to 0x90c
0004: inst = 1200 MOV 900 into reg 0
0006: inst = 1200 MOV 900 into reg 0
0008: inst = 1200 MOV 900 into reg 0
000a: inst = 1200 MOV 900 into reg 0
000c: inst = 1200 MOV 900 into reg 0
000e: inst = 1200 MOV 900 into reg 0
0010: inst = 7f01 func call: r2 = 2084 r3 = 0 r4 = 0 r5 = 7ffff8 r6 = ffffffff r7 = 0

08d8: inst = 24f0 
08da: inst = 007d 
08dc: inst = 7e07 LRW of 0x12 from 0x8f8 to reg 14
08de: inst = 870e word read from unaligned address: 0x12
load reg 7 from 0x12 with 0x0
program stopped with signal 7.
mcore-mcore-elf-run mcore-min


# instructions executed      809582
# cycles                    1230499
# pipeline stalls                 0
# virtual time taken         0.0342

Number of watched functions: 0
Total cycles for watched functions: 0


# Editted objdump --disassemble
mcore-min:     file format elf32-mcore-little

Disassembly of section .init:

00000000 <_init>:
   0:	24f0      	subi	r0, 16
   2:	9f30      	st	r15, (r0, 12)
   4:	1200      	mov	r0, r0
   6:	1200      	mov	r0, r0
   8:	1200      	mov	r0, r0
   a:	1200      	mov	r0, r0
   c:	1200      	mov	r0, r0
   e:	1200      	mov	r0, r0
  10:	7f01      	jsri	0x8D8	// 8d8 <__do_global_ctors_aux>
  12:	f002      	br	0x18
  14:	08d8      	.short 0x08d8
  16:	0000      	bkpt
  18:	0e0e      	tst	r14, r0
  1a:	0e0e      	tst	r14, r0
  1c:	0e0e      	tst	r14, r0
  1e:	0e0e      	tst	r14, r0
  20:	8f30      	ld	r15, (r0, 12)
  22:	20f0      	addi	r0, 16
  24:	00cf      	jmp	r15
Disassembly of section .text:

00000028 <_mainCRTStartup>:
  28:	710a      	lrw	r1, 0x80000
  2a:	1210      	mov	r0, r1
  2c:	710a      	lrw	r1, 0x2080
  2e:	720a      	lrw	r2, 0x2084
  30:	6003      	movi	r3, 0
  32:	9301      	st	r3, (r1, 0)
  34:	2031      	addi	r1, 4
  36:	0c21      	cmphs	r1, r2
  38:	effc      	bf	0x32
  3a:	7f08      	jsri	0x0	// from address pool at 0x5c
  3c:	7209      	lrw	r2, 0x900
  3e:	7f09      	jsri	0xC8	// c8 <atexit>
  40:	6002      	movi	r2, 0
  42:	6003      	movi	r3, 0
  44:	6004      	movi	r4, 0
  46:	7f08      	jsri	0xB4	// b4 <main>
  48:	6002      	movi	r2, 0
  4a:	7f08      	jsri	0x12C	// 12c <exit>
  4c:	0000      	bkpt
  4e:	0000      	bkpt
  50:	0000      	bkpt
  52:	0008      	trap	0
  54:	2080      	addi	r0, 9
  56:	0000      	bkpt
  58:	2084      	addi	r4, 9
  5a:	0000      	bkpt
  5c:	0000      	bkpt
  5e:	0000      	bkpt
  60:	0900      	.short 0x0900
  62:	0000      	bkpt
  64:	00c8      	jmp	r8
  66:	0000      	bkpt
  68:	00b4      	incf	r4
  6a:	0000      	bkpt
  6c:	012c      	xtrb1	r1, r12
	...

...

000000b4 <main>:
  b4:	24f0      	subi	r0, 16
  b6:	9f20      	st	r15, (r0, 8)
  b8:	9830      	st	r8, (r0, 12)
  ba:	1208      	mov	r8, r0
  bc:	9208      	st	r2, (r8, 0)
  be:	9318      	st	r3, (r8, 4)
  c0:	6002      	movi	r2, 0
  c2:	7f00      	jsri	0x12C	// 12c <exit>
  c4:	012c      	xtrb1	r1, r12
	...

...

000008d8 <__do_global_ctors_aux>:
 8d8:	24f0      	subi	r0, 16
 8da:	007d      	stm	r13-r15, (r0)
 8dc:	7e07      	lrw	r14, 0x2070
 8de:	870e      	ld	r7, (r14, 0)
 8e0:	2c06      	bmaski	r6, 0
 8e2:	0f67      	cmpne	r7, r6
 8e4:	e806      	bf	0x8f2
 8e6:	126d      	mov	r13, r6
 8e8:	00d7      	jsr	r7
 8ea:	243e      	subi	r14, 4
 8ec:	870e      	ld	r7, (r14, 0)
 8ee:	0fd7      	cmpne	r7, r13
 8f0:	e7fb      	bt	0x8e8
 8f2:	00cf      	jmp	r15

000008f4 <init_dummy>:
 8f4:	2470      	subi	r0, 8
 8f6:	9f00      	st	r15, (r0, 0)
 8f8:	2070      	addi	r0, 8
 8fa:	0000      	bkpt
 8fc:	00cf      	jmp	r15

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