I have an application that runs on a bare metal object and has the following structure
It is compiled into an executable ELF (system.elf) using standard sequence gcc -c, ld. I use the linker to create a map file with the addresses of all the characters.
Now, without flashing my system again, I need to add extra functionality with a custom runtime loader. Remember that this is bare metal without an OS.
I would like to
- compile extra.c, which uses the APIs defined in service.h (and somehow a link to the existing service.o / system.elf)
- copy the resulting executable to my sdram at runtime and navigate to it
- loaded code should be able to run and access exported characters from service.c, as expected
I thought I could reuse the map file to associate extra.o with system.elf, but this did not work:
ld -o extraExe extra.o system.map
Does gcc or ld have any mode for this late binding procedure? If not, how can I achieve loading the dynamic code that I outlined above?
source
share