Wrong values passed to a function using ARM Compiler - Sample program included

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

       I am using gcc version 3.2 that cross compiles for ARMV5L arch.
I see wrong values passed to a function. The original code is part of
a Linux driver.
I was able to write a small sample application program to recreate the issue.
Below is the sample program.

------------------- Sample Program - Code -----------------
#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;
}

------------------- Sample Program - Output -----------------
opcode now is 0x3a!!!!
opcode: 3a, sign:40039420
--------------------------------------------------------------------------

In function calledfunction1, the count is to be 0x20 but get 0x3a. The
sign is also
not 0x3a3a3a3a. It looks like the stack pointer is changed wrongly.
The optimization
level passed to gcc is -O2. With -O1 it looks ok. I am not sure if O1
is working
because things are now rearranged.

Any help on this appreciated.  If this is a known issue, can I know
the information on the patch.

Regards
Bill


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux