[En-Nut-Discussion] NutOS relocatable?
andre at riesberg-net.de
Thu Apr 7 17:17:01 CEST 2011
Ole Reinhardt schrieb:
> Hi All,
>> AFAIK, you cannot force the compiler to avoid absolute locations.
>> Therefore the linker will create a binary, which can only run at a fixed
>> memory location on targets without MMU. In order to create relocatable
>> code, you need to use assembly language.
> At least it must be possible with non-MMU CPUs too, as at least µCLinux
> is running on non-MMU Platforms and can run the code more or less
> anywhere in the memory. But indeed it has it's own dynamic loader/linker
> (e.g. for the shared objects/libraries).
>> As you would need only 2 or 3 different binaries, a funny idea pops up.
>> You may create a basic binary for the default location and use some kind
>> of patching mechanism to modify this code to run at a different
>> location. Your custom binary would then consist of 2 parts, the patch
>> location table and the unpatched, default binary. In the most simple
>> case you'd only need to add/subtract a fixed offset to all patch locations.
> Another funny Idea would be runtime loadable code, as the OS could stay
> in one location and the code could run from anywhere in the memory and
> just use the existing API (that's how the dynamic linker works).
> But sound quite havy to implement...
the second funny idea gives you a quite big flash image. I made a Lua
wrapper that covers some part of NutOS. In the moment it is nearly 400k
big. If everythis is in, I think it will be bigger than my ARM7 flash.
But if you have enought RAM you can run NutOS always in RAM at the same
location, or load it from SD-CARD or Dataflash into RAM.
More information about the En-Nut-Discussion