Keil Logo

ARM: FUNCTION POINTER VALUES DIFFER IN THUMB MODE


Information in this article applies to:

  • ARM Tools -- All versions

QUESTION

In the following ARM Thumb test program:

void (*ptr1)(void);
void main(void){
  while(1){
    ptr1=main;
  }
}

The linker map file shows main() function located at 0x15C, but ptr1 is set to 0x15D. What's wrong?  Why are the addresses different?

ANSWER

There is nothing wrong.  ARM mode instructions are located on 4-byte boundaries.  Thumb mode instructions are located on 2-byte boundaries.  In the ARM architecture, bit 0 of a function pointer indicates the mode (ARM or Thumb) of the called function, rather than a memory location.  When bit 0 = 1, Thumb mode is selected.

MORE INFORMATION

Last Reviewed: Friday, October 21, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.