I am trying to create a simple linker for a barebone ARM application. Currently, the loader loading the module will simply add an offset to all the entries in the .got and .data.rel . This works fine in .got and for all characters that need to be moved inside .data.rel . It will be broken, although for all non-moving data, since they will also receive this offset.
Example:
void some_function() { return; } struct a { void* fptr; int number; }; static struct a = { .fptr = some_function, .number = 0x1000, };
Here a.fptr will correctly address the actual location of the function, but a.number will incorrectly hold 0x1000 + offset instead of just 0x1000 .
How should I distinguish between the two? Am I enough to check the .symtab section and move only the addresses that are there? But what if the character is really at location 0x1000 ? Or does the linker address this problem (therefore, it will not put the function at 0x1000 )? Does .symtabs include all the characters that can be found inside .got and .data.rel ?
source share