This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/77933] New: Stack corruption on ARM when using high registers and __builtin_return_address
- From: "thopre01 at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 11 Oct 2016 12:47:52 +0000
- Subject: [Bug target/77933] New: Stack corruption on ARM when using high registers and __builtin_return_address
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77933
Bug ID: 77933
Summary: Stack corruption on ARM when using high registers and
__builtin_return_address
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: thopre01 at gcc dot gnu.org
Target Milestone: ---
Target: arm-none-eabi
When compiling the following testcase with -march=armv6-m -mthumb -O1:
void* foo() {
asm volatile("" : : : "r8", "r9");
return __builtin_return_address(0);
}
GCC produces the following assembler:
mov r3, r9
push {r3, lr}
mov r3, r8
push {r3, lr}
mov r0, lr
pop {r2, r3}
mov r8, r2
mov r9, r3
pop {pc}
Note how 4 words are pushed on the stack but only 3 are popped, hence the stack
gets corrupted