Search code examples
carmcortex-mmachine-code

Absolute address of function in object file


I have ARM Cortex-M object file (.o) in which I have following code: BL $testFunc. In the same object file I can also find a implementation of the testFunc. Can I get the absolute address that the call will be made during the program execution? I have ONLY the object file


Solution

  • $testFunc is an unresolved link. You have to link the object file with the C runtime and MCU initialisation code along with any other dependencies (libraries separate object modules) before an absolute address is determined.

    The compiler has no awareness of the memory environment of the target. The linker takes the separate object code modules and the linker script (which defines the memory map) and resolves links and locates code and data.

    The linker can output a MAP file that will include the absolute addresses of all externally linker code and data items.