This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Understanding Linker Map function addresses for Thumb code in Keil uVision

So this seems like a pretty simple question, but I have not been able to find a clear answer. 

I understand that function pointers with the LSB of the address set indicate that the function is in Thumb mode (https://www.keil.com/support/docs/3133.htm).

What I don't understand is the following specific behaviour in Keil uVision5 (ARMCC v5.06):

- The linker map generated during compilation shows the addresses of the functions in the Global Symbols section with the LSB set (ie. if function main() exists at 0x540, the map file shows 0x541). This contrasts with the map generated if I compile the same code in GCC, which shows the 2-byte aligned address instead. Is there a setting somewhere in uVision or a linker argument to change the address displayed in the map?

- Code which accesses the function pointer gets the Thumb mode address (ex. 0x541) as expected

- However, when debugging in the simulated target, if I attempt to set a variable using the function pointer by name in the watch window (ex. some_var = main), the value that gets set is the 2-byte aligned address (0x540 and not 0x541).

I assume this is environment specific, but why would use of the function pointer by the debug session not produce the same Thumb mode address value?