[Bug c/20182] New: Improper code generation causes stack corruption

2005-02-23 Thread jay at systech dot com
LCFI8:
stmfd   sp!, {fp, ip, lr, pc}
.LCFI9:
mov r3, r3, asl #16
sub fp, ip, #4
.LCFI10:
mov r3, r3, asr #16
sub lr, fp, #12
strhr3, [fp, #-14]  @ movhi <-- This instruction is redundant
.LSM26:
mov r1, r1, asl #16
.LSM27:
strhr3, [lr, #-2]!  @ movhi <-- The 'Size' argument (register r3)
is copied to the local stack frame
here, BEFORE the stack frame is
allocated (below).
.LSM28:
mov r2, r2, asl #16
.LSM29:
sub sp, sp, #12  <-- Stack frame allocated.
.LCFI11:
.LSM30:
add ip, fp, #4
.LSM31:
.LSM32:
mov r1, r1, lsr #16
mov r2, r2, lsr #16
mov r3, #1
str lr, [sp, #0]
str ip, [sp, #4]
bl  HPIDrv_SendMessages
ldmea   fp, {fp, sp, pc}
.LFE3:

-- 
   Summary: Improper code generation causes stack corruption
   Product: gcc
       Version: 3.2.1
    Status: UNCONFIRMED
  Severity: critical
  Priority: P2
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jay at systech dot com
CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i386-redhat-linux
GCC target triplet: arm-elf


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20182


[Bug rtl-optimization/20182] Improper code generation causes stack corruption

2005-02-23 Thread jay at systech dot com

--- Additional Comments From jay at systech dot com  2005-02-23 23:29 
---
Subject: RE:  Improper code generation causes 
stack corruption

I tried the -fno-strict-aliasing option, but this generates the same code.
Although this may violate aliasing rules, the compiler is not messing up
with the '&V42Parms', but the 'Size' argument.  The problem seems to me to
be:

FunctionB(int *pSize)
{
}

FunctionA(int Size)
{
FunctionB(&Size);
}

When code calls FunctionA(), it passes Size in a register.  When FunctionA
tries to pass the address of Size to FunctionB(), it must first make a local
copy of Size on the stack (or somewhere in memory), so that it can take the
address of it.  This is where things are going wrong.

Jay
-Original Message-
From: pinskia at gcc dot gnu dot org [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 23, 2005 3:05 PM
To: [EMAIL PROTECTED]
Subject: [Bug rtl-optimization/20182] Improper code generation causes
stack corruption



--- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-23
23:05 ---
You are violating aliasing rules:
(uint16 *)&V42Parms

try with -fno-strict-aliasing or with an union.  Please read
http://gcc.gnu.org/bugs.html which talks 
about this problem.

-- 
   What|Removed |Added

   Severity|critical|normal
 Status|UNCONFIRMED |RESOLVED
  Component|c   |rtl-optimization
 Resolution||INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20182

--- You are receiving this mail because: ---
You reported the bug, or are watching the reporter.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20182