I have some code that I am running on an atmega169. I am building a static array of function pointers like so:
typedef uint8_t (*routine)(void);
extern routine testRoutine; extern routine testRoutine2;
routine routines[] = { (routine)&testRoutine, (routine)&testRoutine2 };
This compiles and links fine and at runtime the "routines" array contains the addresses that are found for testRoutine and testRoutine2 when I do avr-nm on the .elf file for the project. However, when I load the hex file onto the device and debug it - there is no code at those addresses so when the jump is performed it executes the opcode
0xff which is found there. This seems impossible as I thought that avr- nm was using post link addresses. I don't see how the addresses could change post link. I am sure I am missing something obvious here. Please enlighten me. Thanks.