Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Possible gcc bug?

2004-03-07 by Curt Powell

I've run into a situation that I've had several times before but never
done anything about.  All of the sudden, code that was working (and
should be working) fine causes a processor data abort exception.
Before, I've always been able to rearrange the code and have the problem
go away but today I decided I should try to get to the bottom of it.  

The C code is a simple save-max-value statement of the form: if (x>y)
y=x;  (x and y are global unsigned longs) Here's the output from
arm-elf-objdump:

        if (USBOutCount>HighUSBOutCount) HighUSBOutCount=USBOutCount;
     378:	e59f3160 	ldr	r3, [pc, #352]	; 4e0
<USBPoll+0x1f8>
     37c:	e59f2168 	ldr	r2, [pc, #360]	; 4ec
<USBPoll+0x204>
     380:	e5931000 	ldr	r1, [r3]
     384:	e5923000 	ldr	r3, [r2]
     388:	e1510003 	cmp	r1, r3

The exception occurs at 384.  The contents around 4ec (end of the
routine, apparently a literal pool) are:

}
     4d4:	e91ba800 	ldmdb	fp, {fp, sp, pc}
     4d8:	000004f0 	streqd	r0, [r0], -r0
     4dc:	000004f4 	streqd	r0, [r0], -r4
     4e0:	00000000 	andeq	r0, r0, r0
     4e4:	000004ec 	andeq	r0, r0, ip, ror #9
     4e8:	000004e8 	andeq	r0, r0, r8, ror #9
     4ec:	0000000c 	andeq	r0, r0, ip

000004f0 <USBInit>:

void USBInit()
{
     4f0:	e1a0c00d 	mov	ip, sp

I'm an arm assembler novice, but it looks like 0000000c is getting
loaded into r2 and being used to access a memory location, but 000000c
isn't a valid memory location.  Alternatively, if I add 360 decimal to
pc (37c) I get 4e4 which holds 4ec which seems to point to a valid
address; OTOH the first variable (0x378+0x160) points to 0x4d8 which in
turn points to 0x4f0 which is code in the following routine USBInit()
(but this operation appears to execute successfully).  Like I said, I'm
not exactly sure how to interpret the assembler but I do know that it is
causing an exception.  Perhaps an assembler guru on the list can tell me
if there is a problem with this code, and more importantly, if it is a
compiler problem, how to escalate the issue to get it fixed.

Development environment is Ashling AsIDE running arm-elf-gcc 3.3.1.
Debug environment is Ashling Pathfinder 1.0.9A.

TIA,

Curt

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.