thumb

Hello,

I wrote a function which call another function through a pointer of function call.
When I trace the call, as soon as I reach the function the thumb bit is cleared, and of course the program no more run correctly.
When I call the same function directly the thumb bit is not cleared, of course.

What are the mechanism which could clear my thumb bit?

normal call

unsigned char *ip1;
fnEraseFlashSector(ip1 ,0);

special call

ulong ( *tempt_Fct )( ulong );
ulong tempData;
ulong tempData2;
tempData = ((ulong (*)(ulong,ulong))tempt_Fct)(tempData,tempData2);

I need to write generic function calls for RPC.

Parents
  • This:

    tempData = ((ulong (*)(ulong,ulong))tempt_Fct)(tempData,tempData2);
    

    is very unhealthy code. You should never get into a situation where you have to cast function pointers like that. Technically, that's quite likely to cause undefined behaviour. Losing a thumb bit on the way might be the least of your worries.

    You've also left out the most crucial past of your "special call" example: how you initialize that function pointer. For all you've allowed us to know, there never was a thumb bit in there to get lost.

    It's up to you to make sure that the function pointer is properly initialized before you use it.

Reply
  • This:

    tempData = ((ulong (*)(ulong,ulong))tempt_Fct)(tempData,tempData2);
    

    is very unhealthy code. You should never get into a situation where you have to cast function pointers like that. Technically, that's quite likely to cause undefined behaviour. Losing a thumb bit on the way might be the least of your worries.

    You've also left out the most crucial past of your "special call" example: how you initialize that function pointer. For all you've allowed us to know, there never was a thumb bit in there to get lost.

    It's up to you to make sure that the function pointer is properly initialized before you use it.

Children
More questions in this forum