Bug 9372 - [arm] incorrect instructions for functions with __attribute__ ((interrupt ("IRQ")))
Summary: [arm] incorrect instructions for functions with __attribute__ ((interrupt ("I...
Status: RESOLVED DUPLICATE of bug 10834
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.2.1
: P2 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2003-01-20 12:06 UTC by dong_geming
Modified: 2003-05-28 15:20 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-05-26 20:36:42


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dong_geming 2003-01-20 12:06:00 UTC
/* begin of file ext_irq.c */
void ext_IRQ0_handler(void) __attribute__ ((interrupt ("IRQ")));

void ext_IRQ0_handler(void)
{
   int i = 0;
   i = i++;
}
/* end of file ext_irq.c */

Compiled with the following command:
arm-elf-gcc -gdwarf ext_irq.c -o.\debug\ext_irq.o

Dump the ext_irq.o, and we can get the following code:

020001d4 <ext_IRQ0_handler>:
 20001d4:	e52dc004 	str	ip, [sp, -#4]!
 20001d8:	e1a0c00d 	mov	ip, sp
 20001dc:	e24ee004 	sub	lr, lr, #4	; 0x4
 20001e0:	e92dd80e 	stmdb	sp!, {r1, r2, r3, fp, ip, lr, pc}
 20001e4:	e24cb004 	sub	fp, ip, #4	; 0x4
 20001e8:	e24dd004 	sub	sp, sp, #4	; 0x4
 20001ec:	e3a03000 	mov	r3, #0	; 0x0
 20001f0:	e50b3020 	str	r3, [fp, -#32]
 20001f4:	e24b1020 	sub	r1, fp, #32	; 0x20
 20001f8:	e5913000 	ldr	r3, [r1]
 20001fc:	e1a02003 	mov	r2, r3
 2000200:	e50b2020 	str	r2, [fp, -#32]
 2000204:	e2833001 	add	r3, r3, #1	; 0x1
 2000208:	e5813000 	str	r3, [r1]
 200020c:	e95b980e 	ldmdb	fp, {r1, r2, r3, fp, ip, pc}^

We know from the codes that the "sp" is not correct when it is pop out. As I use function with __attribute__ ((interrupt ("IRQ"))), the application can not run well, and the "SP" will collapsed. When I use option -mthumb-interwork, the instructions generated by gcc is absolutely wrong.

Can there someone help ASAP??

Release:
gcc 3.2 or 3.2.1

Environment:
cygwin --host=i686-pc-cygwin
Comment 1 Dara Hazeghi 2003-05-26 20:11:57 UTC
Hello,

I can confirm that the same bad code is generated by gcc 3.2.3, 3.3 branch and mainline 
(20030509). Please note that -gdwarf is deprecated in gcc 3.3 and later, and I suspect support for 
it may be removed in the near future.

Dara
Comment 2 Andrew Pinski 2003-05-26 20:36:42 UTC
see Dara's comment.
Comment 3 Andrew Pinski 2003-05-26 20:37:20 UTC
But I am going to suspend this one because dwarf-1 is out of date and might be removed 
soon.
Comment 4 Richard Earnshaw 2003-05-28 15:20:05 UTC
This has nothing to do with -gdwarf.  However, it is a duplicate of Bug 10834
which has already been fixed.

*** This bug has been marked as a duplicate of 10834 ***