Placing function in specific memory location Issue

Hello,
I would like to place function myFunction() at a specific memory address.
I have modified linker srcipt by adding section mySection at address 0x60002000.
In the source file I have added attribute section:

__attribute__((section(".mySection"), naked))
void myFunction(void)
{
    /* Code */
}

In the result in .map file I see:

 *(.mySection)
 .mySection   0x60002000       0x30 
                        0x60002000       myFunction

Unfortunately, pointer to the function myFunction() points to 0x60002001.

Why the pointer points to address 0x60002001 (not 0x60002000)? In the .map file I see that function myFunction() was placed at address 0x60002000. Could someone provide any explanation? Why does not pointer point to 0x60002000?

This is correct. The least significant bit is set to indicate that the function uses the Thumb instruction set:

Address-based interworking uses the lowest bit of the address to determine the instruction set at the target. If the lowest bit is 1, the branch will switch to Thumb state. If the lowest bit is 0, the branch will switch to Arm state. Note that the lowest bit is never actually used as part of the address as all instructions are either 4-byte aligned (as in Arm) or 2-byte aligned (as in Thumb).

Peter, Thank you.
After your reply I also found this explanation:
https://stackoverflow.com/a/37008902

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.