public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/44888] New: Stack pointer corruption within interrupt routine when compiled with -Os
@ 2010-07-09 14:11 rob dot thornburrow at adder dot com
2010-07-12 9:35 ` [Bug target/44888] " ramana at gcc dot gnu dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: rob dot thornburrow at adder dot com @ 2010-07-09 14:11 UTC (permalink / raw)
To: gcc-bugs
# 1 "irq.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "irq.c"
extern void add_irq(int, void (*irq)(void));
extern void do_something(void);
static __attribute__ ((interrupt("IRQ"))) void irq(void)
{
unsigned long ints;
ints = (*(volatile unsigned long *)(0x00000000));
ints &= ~(*(volatile unsigned long *)(0x00000004));
if (ints & 0x1)
do_something();
(*(volatile unsigned long *)(0x00000000)) = ints;
}
void init(void)
{
add_irq(0, irq);
}
When compiled with -Os using gcc 4.5.0 (arm-none-eabi), the generated assembly
for irq() subtracts 4 from the stack pointer immediately prior to calling
do_something() but never adds 4 back before the function exits. This results
in the program counter (and all registers saved at the start of the function)
being loaded with incorrect values.
This doesn't happen with 4.5.0 when compiled with no optimisation (-O0) or with
4.4.2 (arm-elf) with any optimisation level.
It appears to only be a problem when the function is defined as an interrupt
handler as when defined as a normal function (with standard entry/exit
wrappers) the generated assembly looks correct.
Target: arm-none-eabi
Configured with: ../gcc-4.5.0/configure --target=arm-none-eabi
--prefix=/home/ya
garto/install --disable-nls --disable-shared --disable-threads --with-gcc
--with
-gnu-ld --with-gnu-as --with-dwarf2 --enable-languages=c,c++ --enable-interwork
--enable-multilib --with-newlib
--with-headers=../newlib-1.18.0/newlib/libc/incl
ude --disable-libssp --disable-libstdcxx-pch --disable-libmudflap
--disable-libg
omp -v
Thread model: single
gcc version 4.5.0 (GCC)
COLLECT_GCC_OPTIONS='-mcpu=arm7tdmi-s' '-std=gnu99' '-Wall' '-c' '-fno-common'
'-Os' '-o'
--
Summary: Stack pointer corruption within interrupt routine when
compiled with -Os
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rob dot thornburrow at adder dot com
GCC target triplet: arm-none-eabi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44888
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/44888] Stack pointer corruption within interrupt routine when compiled with -Os
2010-07-09 14:11 [Bug target/44888] New: Stack pointer corruption within interrupt routine when compiled with -Os rob dot thornburrow at adder dot com
@ 2010-07-12 9:35 ` ramana at gcc dot gnu dot org
2010-07-12 9:57 ` jiez at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ramana at gcc dot gnu dot org @ 2010-07-12 9:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from ramana at gcc dot gnu dot org 2010-07-12 09:35 -------
Confirmed - I think it should be fixed by this patch here.
http://gcc.gnu.org/ml/gcc-patches/2010-07/msg00495.html
Jie : do you think you could backport this to the 4.5 branch ?
cheers
Ramana
--
ramana at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jiez at gcc dot gnu dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Known to fail| |4.5.0
Known to work| |4.4.4 4.6.0
Last reconfirmed|0000-00-00 00:00:00 |2010-07-12 09:35:45
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44888
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/44888] Stack pointer corruption within interrupt routine when compiled with -Os
2010-07-09 14:11 [Bug target/44888] New: Stack pointer corruption within interrupt routine when compiled with -Os rob dot thornburrow at adder dot com
2010-07-12 9:35 ` [Bug target/44888] " ramana at gcc dot gnu dot org
@ 2010-07-12 9:57 ` jiez at gcc dot gnu dot org
2010-07-12 14:07 ` jiez at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jiez at gcc dot gnu dot org @ 2010-07-12 9:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jiez at gcc dot gnu dot org 2010-07-12 09:57 -------
Ramana, I will do it.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44888
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/44888] Stack pointer corruption within interrupt routine when compiled with -Os
2010-07-09 14:11 [Bug target/44888] New: Stack pointer corruption within interrupt routine when compiled with -Os rob dot thornburrow at adder dot com
2010-07-12 9:35 ` [Bug target/44888] " ramana at gcc dot gnu dot org
2010-07-12 9:57 ` jiez at gcc dot gnu dot org
@ 2010-07-12 14:07 ` jiez at gcc dot gnu dot org
2010-07-12 14:07 ` jiez at gcc dot gnu dot org
2010-07-13 8:25 ` rob dot thornburrow at adder dot com
4 siblings, 0 replies; 6+ messages in thread
From: jiez at gcc dot gnu dot org @ 2010-07-12 14:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jiez at gcc dot gnu dot org 2010-07-12 14:06 -------
My patch has been committed on trunk and 4.5 branch. This bug should be fixed
now. Please verify.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44888
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/44888] Stack pointer corruption within interrupt routine when compiled with -Os
2010-07-09 14:11 [Bug target/44888] New: Stack pointer corruption within interrupt routine when compiled with -Os rob dot thornburrow at adder dot com
` (2 preceding siblings ...)
2010-07-12 14:07 ` jiez at gcc dot gnu dot org
@ 2010-07-12 14:07 ` jiez at gcc dot gnu dot org
2010-07-13 8:25 ` rob dot thornburrow at adder dot com
4 siblings, 0 replies; 6+ messages in thread
From: jiez at gcc dot gnu dot org @ 2010-07-12 14:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jiez at gcc dot gnu dot org 2010-07-12 14:07 -------
The updated patch:
http://gcc.gnu.org/ml/gcc-patches/2010-07/msg00968.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44888
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/44888] Stack pointer corruption within interrupt routine when compiled with -Os
2010-07-09 14:11 [Bug target/44888] New: Stack pointer corruption within interrupt routine when compiled with -Os rob dot thornburrow at adder dot com
` (3 preceding siblings ...)
2010-07-12 14:07 ` jiez at gcc dot gnu dot org
@ 2010-07-13 8:25 ` rob dot thornburrow at adder dot com
4 siblings, 0 replies; 6+ messages in thread
From: rob dot thornburrow at adder dot com @ 2010-07-13 8:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from rob dot thornburrow at adder dot com 2010-07-13 08:25 -------
Patch verified against 4.5.0 (manual patch of config/arm/arm.c as I'm currently
unable to get the 4.5 branch).
--
rob dot thornburrow at adder dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44888
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-07-13 8:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-09 14:11 [Bug target/44888] New: Stack pointer corruption within interrupt routine when compiled with -Os rob dot thornburrow at adder dot com
2010-07-12 9:35 ` [Bug target/44888] " ramana at gcc dot gnu dot org
2010-07-12 9:57 ` jiez at gcc dot gnu dot org
2010-07-12 14:07 ` jiez at gcc dot gnu dot org
2010-07-12 14:07 ` jiez at gcc dot gnu dot org
2010-07-13 8:25 ` rob dot thornburrow at adder dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).