SIGILL at perfectly good native code

Discussion in 'Embedded Systems and Microcontrollers' started by m00ni, Feb 7, 2011.

  1. m00ni

    Thread Starter New Member

    Feb 7, 2011
    2
    0
    Hey,

    I have been having a strange problem for the last couple of days. I create code with a native code compiler (the code should be valid checked it a couple of times) and then I want to execute that Code. I am using a PowerPC microcontroller with some kind of linux OS. So I am running a C program where I have a Byte array containing the native Code. Then I do the usual trick where I create a function pointer to that array and call that function. When I debug/start this program I have the following behaviour:

    1. Debug with Breakpoint at native code call and single stepping:
    I start at the function call and step through my native Code operatior for operation. My crated native code is executed perfectly everything is fine.

    2. Debug without Breakpoint
    Program halts at the first instruction (depending on native code, sometimes a later instructions but always another instruction i.e. not alway LD or ST or whatever) with the error SIGILL (Illegal Instruction)

    3. Executing of binary file
    Program terminates with SIGILL

    I am using GDBServer for remote debugging. Additionally at the second case, I checked the instruction I checked the registers and I checked the memory everything seems to be ok. I can not figure out why my program works with single stepping but not when I execute it normally...

    Help would be very much appreciated =D
     
  2. m00ni

    Thread Starter New Member

    Feb 7, 2011
    2
    0
    As it turns out, the problem seems to be the memory address in which the code is stored. I am going to save you the details but if I copy my NC to a certain memory address and then again try to execute it then my program works fine.

    I know that there is something like a never execute bit on most microcontroller which makes it impossible to execute code that is stored at certain memory addresses. This is done to protect the operating system. Does anybody know how I can remove that security mechanism? I am using a PowerPC MPC5200 with a linux on it.

    Again help would be very much appreciated =D
     
Loading...