I have an interesting situation at work that I am trying to find a good solution for. We have code that runs on a multi-core MIPS bare metal (no kernel). We have a requirement to integrate with some 3rd party code that needs to be upgradable. I was thinking of compiling the 3rd party code as PIC and then change the GOT for the code/data symbols when I download this code (I have control over where the code will reside). Also, assume the interfaces into the 3rd party code dont change so there are no new PLT/GOT entries. Will this work?. What other things should I be considering?.
Dynamic libraries are loaded at runtime and are not included in the executable. This reduces the size of executable files. Dynamic libraries use relocatable code format. This code is turned into absolute code by the runtime linker.
Shared libraries are the most common way to manage dependencies on Linux systems. These shared resources are loaded into memory before the application starts, and when several processes require the same library, it will be loaded only once on the system. This feature saves on memory usage by the application.
When a program linked with shared libraries runs, program execution does not immediately start with that program's first statement. Instead, the operating system loads and executes the dynamic linker (usually called ld.so), which then scans the list of library names embedded in the executable.
Load-time relocation is one of the methods used in Linux (and other OSes) to resolve internal data and code references in shared libraries when loading them into memory.
Is the correct answer longer than "embed a dynamic linker/loader"? Your problem seems the same as that solved by ld.so and the likes. Describing all the things which a dynamic linker/loader must consider is the topic of books such as Linkers and Loaders by John Levine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With