This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/32838] gcc generates incorrect trampoline code in thumb mode
- From: "leo at marco dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Mar 2009 16:47:48 -0000
- Subject: [Bug target/32838] gcc generates incorrect trampoline code in thumb mode
- References: <bug-32838-14845@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from leo at marco dot de 2009-03-17 16:47 -------
Subject: Re: gcc generates incorrect trampoline code in
thumb mode
laurent at guerby dot net wrote:
> ------- Comment #3 from laurent at guerby dot net 2009-01-02 12:29 -------
> This needs a testcase
>
>
Testcase:
void
f(int aa, int bb, int cc, int dd, int ee, int ff)
{
extern int x(int (*)(void));
int
q(void)
{
extern int a(int);
return(a(ff)*55);
}
x(&q);
}
"arm-elf-gcc -mthumb -S -O tst.c" results in:
.code 16
.file "tst.c"
.section .rodata
.align 2
.LTRAMP0:
.code 32
.Ltrampoline_start:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ldr r9, [pc, #8]
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ldr ip, [pc, #8]
orr ip, ip, #1
bx ip
.word 0
.word 0
.code 16
.global __clear_cache
.text
.align 2
.global f
.code 16
.thumb_func
.type f, %function
f:
push {r4, r5, lr}
sub sp, sp, #28
ldr r0, [sp, #44]
str r0, [sp]
add r4, sp, #4
ldr r3, .L3
mov r2, r4
ldmia r3!, {r0, r1, r5}
stmia r2!, {r0, r1, r5}
ldmia r3!, {r0, r1, r5}
stmia r2!, {r0, r1, r5}
mov r3, sp
str r3, [sp, #20]
ldr r3, .L3+4
str r3, [sp, #24]
mov r0, r4
add r1, sp, #28
bl __clear_cache
mov r0, r4
bl x
add sp, sp, #28
@ sp needed for prologue
pop {r4, r5, pc}
.L4:
.align 2
.L3:
.word .LTRAMP0
.word q.1472
.size f, .-f
.align 2
.code 16
.thumb_func
.type q.1472, %function
q.1472:
mov r2, r9
push {r2, lr}
mov r3, r9
ldr r0, [r3]
bl a
mov r3, r0
lsl r0, r0, #3
sub r0, r0, r3
lsl r0, r0, #3
sub r0, r0, r3
@ sp needed for prologue
pop {r2}
mov r9, r2
pop {pc}
.size q.1472, .-q.1472
.ident "GCC: (GNU) 4.2.3"
Notice the line marked with "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
r9 is unconditionally destroyed when the trampoline code is called.
Regards, Matthias
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32838