Message board for the users of flat assembler.
> Linux > creating shared libraries - how to do make PIC with GOT
Goto page 1, 2 Next
The shared libraries in Linux are a bit like a DLL files in Windows, there is one important difference, however. In Windows' DLL there are relocations, so that when Windows loads it somewhere in the address space of given application, it can adjust all the addresses in code, so even though the DLL may get loaded at very different addresses, the ones in its code are always correct.
In case of shared libraries in Linux there are no relocations, and the main point is that the code should be position-independent, that is: unaware of at what address it is placed.
Since all the near jumps on x86 architecture are relative, they are position-independent by themselves - when you move the code to some other place, the jumps still work the same. So the only problem that may occur is with accessing the data.
The most simple method to make position-independent code in general case is to determine at what address the code resides, and calculate the valid address to the data then. Look at this function:
example_function call _origin _origin pop ebx mov eax,