public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [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
@ 2005-11-04 15:05 bill dot thompsons at gmail dot com
  2005-11-04 15:08 ` [Bug target/24675] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: bill dot thompsons at gmail dot com @ 2005-11-04 15:05 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-11-11  0:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-04 15:05 [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 bill dot thompsons at gmail dot com
2005-11-04 15:08 ` [Bug target/24675] " pinskia at gcc dot gnu dot org
2005-11-09  2:11 ` armcc2000 at yahoo dot com
2005-11-09  4:21 ` armcc2000 at yahoo dot com
2005-11-09  4:31 ` pinskia at gcc dot gnu dot org
2005-11-09  6:21 ` armcc2000 at yahoo dot com
2005-11-09 22:04 ` mikpe at csd dot uu dot se
2005-11-09 23:33 ` armcc2000 at yahoo dot com
2005-11-09 23:41 ` pinskia at gcc dot gnu dot org
2005-11-10  1:25 ` armcc2000 at yahoo dot com
2005-11-11  0:56 ` bill dot thompsons at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).