Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emulate dynamic loader to fixup shared library offsets

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?.

like image 324
vamsi Avatar asked Nov 16 '12 17:11

vamsi


People also ask

How are dynamic libraries loaded?

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.

How are shared libraries loaded?

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.

How does Ld so work?

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.

What is load time relocation?

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.


1 Answers

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.

like image 87
Pedro Lamarão Avatar answered Sep 29 '22 14:09

Pedro Lamarão