This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/23774] New: dealloc of dynamic stack space breaks backchain
- From: "amodra at bigpond dot net dot au" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Sep 2005 00:55:23 -0000
- Subject: [Bug target/23774] New: dealloc of dynamic stack space breaks backchain
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following compiled with -m32 -O2 -S
void badFunc (int size)
{
char temp[size];
temp[size-1] = '\0';
};
gives
badFunc:
mflr 0
stwu 1,-16(1)
stw 0,20(1)
addi 0,3,30
lwz 9,0(1)
mr 11,1
stw 31,12(1)
mr 31,1
rlwinm 0,0,0,0,27
neg 0,0
stwux 9,1,0
li 9,0
addi 0,1,23
rlwinm 0,0,0,0,27
add 3,3,0
stb 9,-1(3) <- old backchain possibly overwritten
nop
nop
nop
lwz 0,0(1)
mr 1,11 <- adjust stack, backchain possibly invalid!
stw 0,0(1) <- write backchain
nop
lwz 11,0(1)
lwz 0,4(11)
lwz 31,-4(11)
mr 1,11
mtlr 0
blr
This testcase also shows
a) excess allocation of dynamic stack space,
b) needless alignment of dynamic stack space,
c) poor epilogue code, with unnecesary stack adjustments.
--
Summary: dealloc of dynamic stack space breaks backchain
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: amodra at bigpond dot net dot au
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: powerpc-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23774