Symbols can be linked at certain addresses with defsym
as illustrated here. My question is whether the same can be done with sections? That is, given some .o
object file, is it possible to specify the base address that sections will be relocated to?
Alternatively, is it possible to rebase a section after the final link? That is, to change the address of a section in a binary and have all information affected by relocation (such as relative branches out of the section, etc.) to be relocated properly.
If my question is not clear, I can edit it and add an image to explain better.
gcc -std=gnu99 -Wall -Wl,--section-start=.secname=0xABCDEF Lala.c -o Lala
– Character