This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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

Possible bug in arm-linux-GCC 2.95.3 with inline asm


Hi

Recently I was trying some debug routines when I hit upon this bug in
arm-linux-gcc (unless I have done something wrong in the code, which I
don't think so). However to be sure I am sending this to Mr. Russell king
and the Cross GCC list so that others can verify the code.

The Bug
-------

Even thou I specify r11 in the mangle list of the inline asm segment, the
code generated by the compiler stores important value into r11 register
before the inline asm part and uses it after the inline asm part has
ended. But has r11 value is corrupted, the code when run misbehaves.

Version of tools
----------------
binutils version -> GNU objdump 2.10.1
GCC version -> 2.95.3

The code which showed the bug
-----------------------------

Code 1
-------

void debug_uart (unsigned int dbgchartoprint)
{
	__asm__ __volatile__
	(
	      " mov  r10, #0xd000
                add  r10, r10, #4
                mov  r10, r10, lsl #16
                add  r10, r10, #0x4000
	9:	ldr  r11, [r10, #0x018]
		ands r11, r11, #0x020 @0x08
		bne  9b
		str %0, [r10] "
            :
	    : "r" (dbgchartoprint)
            : "r10", "r11"
	);    /* o/p, i/p and mangle list */
}

c00101e4 <debug_uart>:
c00101e4:	e1a0c00d 	mov	r12, sp
c00101e8:	e92ddc00 	stmdb	sp!, {r10, r11, r12, lr, pc}
c00101ec:	e24cb004 	sub	r11, r12, #4	; 0x4
c00101f0:	e3a0aa0d 	mov	r10, #53248	; 0xd000
c00101f4:	e28aa004 	add	r10, r10, #4	; 0x4
c00101f8:	e1a0a80a 	mov	r10, r10, lsl #16
c00101fc:	e28aa901 	add	r10, r10, #16384	; 0x4000
c0010200:	e59ab018 	ldr	r11, [r10, #24]
c0010204:	e21bb020 	ands	r11, r11, #32	; 0x20
c0010208:	1afffffc 	bne	c0010200 <debug_uart+0x1c>
c001020c:	e58a0000 	str	r0, [r10]
c0010210:	e91bac00 	ldmdb	r11, {r10, r11, sp, pc}


Code 2
-------

void debug_uart_string(char *sMesg)
{
	/*
	while(*sMesg != NULL)
	{
		debug_uart(*sMesg++);
	}
	debug_uart('\n');
	debug_uart('\r');
	*/
	__asm__ __volatile__
	(
	      " mov  r10,  #0xd000
                add  r10,  r10,  #4
                mov  r10,  r10,  lsl #16
                add  r10,  r10,  #0x4000
		@ mov  r9,   #0
		@ str  r9,   [%0, #10]
	more:
	free:   ldr  r11,  [r10, #0x018]
		ands r11,  r11,  #0x20  @ 0x08
                bne  free
	        ldrb r11,  [%0]
		cmps r11,  #0
		beq  over
                str  r11,  [r10]
		add  %0,   %0,  #1
		b    more
	over:   mov  r9,   #'\n'
		str  r9,   [r10]
		mov  r9,   #'\r'
		str  r9,   [r10] "
            :
	    : "r" (sMesg)
            : "r10", "r11", "r9"
	); /* o/p, i/p and mangle list */
}

c0010214 <debug_uart_string>:
c0010214:	e1a0c00d 	mov	r12, sp
c0010218:	e92dde00 	stmdb	sp!, {r9, r10, r11, r12, lr, pc}
c001021c:	e24cb004 	sub	r11, r12, #4	; 0x4
c0010220:	e3a0aa0d 	mov	r10, #53248	; 0xd000
c0010224:	e28aa004 	add	r10, r10, #4	; 0x4
c0010228:	e1a0a80a 	mov	r10, r10, lsl #16
c001022c:	e28aa901 	add	r10, r10, #16384	; 0x4000

c0010230 <free>:
c0010230:	e59ab018 	ldr	r11, [r10, #24]
c0010234:	e21bb020 	ands	r11, r11, #32	; 0x20
c0010238:	1afffffc 	bne	c0010230 <free>
c001023c:	e5d0b000 	ldrb	r11, [r0]
c0010240:	e35b0000 	cmp	r11, #0	; 0x0
c0010244:	0a000002 	beq	c0010254 <over>
c0010248:	e58ab000 	str	r11, [r10]
c001024c:	e2800001 	add	r0, r0, #1	; 0x1
c0010250:	eafffff6 	b	c0010230 <free>

c0010254 <over>:
c0010254:	e3a0900a 	mov	r9, #10	; 0xa
c0010258:	e58a9000 	str	r9, [r10]
c001025c:	e3a0900d 	mov	r9, #13	; 0xd
c0010260:	e58a9000 	str	r9, [r10]
c0010264:	e91bae00 	ldmdb	r11, {r9, r10, r11, sp, pc}






------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


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