Reproducable: Very easy to reproduce with the sample code
application provided. PLEASE COMPILE the code with -O2 option.
Product: GCC for ARMV5L
Component: C
Version: 3.2.1. (Reported also in ARM Linux community to
be see with gcc 3.3.4, gcc 3.4.2)
Host Platform: x86 Linux 2.4.x
Target Platform: Intel Xscale 80315 (ARMV5L) running Linux 2.4.28.
Issue should be seen with most of the ARM target.
Description:
Stack corruption is seen in ARM arch. when many variables
are passed to a function AND
if one of the variable is long long AND
if that long long variable is passed by its lower-32 use the
register and the upper-32 use the stack (a case when r0, r1,
r2 is already used by other passed variables)
Values are not correctly passed to the function.
Sample Code (PLEASE COMPILE with -O2 option):
------------------------------------------------------------
#include <stdio.h>
typedef unsigned char u8;
typedef unsigned int u32;
typedef unsigned long long u64;
void testfunction (void *buffer1, void *buffer2, u8 count, u64 startsector);
void calledfunction1(void *buffer, u64 startsector, u32 count, u8
opcode, u32 sign);
main()
{
testfunction (NULL, NULL, 8, 0x700ULL);
}
void testfunction (void *buffer1, void *buffer2, u8 count, u64 startsector)
{
calledfunction1 (NULL, startsector, 0x55, 0x20, 0x3a3a3a3a);
}
void calledfunction1 (void *buffer, u64 startsector, u32 count,
u8 opcode, u32 sign)
{
if(opcode == 0x3a)
printf( "opcode now is 0x3a!!!!\n");
printf ("opcode: %x, ", opcode);
printf( "sign:%x\n",sign);
return;
}
------------------------------------------------------------
Output of the Sample Code:
--------------------------------
opcode now is 0x3a!!!!
opcode: 3a, sign:40039420
--------------------------------
Expected Output of the Sample Code:
--------------------------------
opcode: 20, sign:3a3a3a3a
--------------------------------
--
Summary: Stack corruption in ARM arch. if 64bit variable is
passed to a function of which the low 32 use the
register and the up 32 use the stack
Product: gcc
Version: 3.2.1
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bill dot thompsons at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24675