From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18105 invoked by alias); 4 Nov 2005 15:05:43 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 18059 invoked by uid 48); 4 Nov 2005 15:05:38 -0000 Date: Fri, 04 Nov 2005 15:05:00 -0000 Subject: [Bug c/24675] New: 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 X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "bill dot thompsons at gmail dot com" X-SW-Source: 2005-11/txt/msg00646.txt.bz2 List-Id: 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 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