So I am trying to learn about dynamic linking. On SysV ABI on amd64, functions from other shared libraries can be loaded lazily via the Procedure Linkage Table by initializing the GOT entry for the function to point at the next instruction in its plt entry. This will eventually pass control on to the dynamic …
Tag: dynamic-linking
How are external symbols of a shared library resolved in the main program?
I’ve been reading a lot about the semantics of load-time linking of shared libraries and one thing that I’m having trouble understanding is how can the main program make references to functions defined in shared libraries? For example, say I have this code myShared.sh main.c I understand that, sin…
Dumpout Process Memory Layout During Loading Time
I am working on a project where I need to use LD_PRELOAD to load some libraries into the memory space. It’s like: Due to certain reasons (I am actually working on some binary hacking), I must know the memory address (not a symbol) of certain functions (let’s say, foo) in libapp.so and instrument t…
Resolving symbols differently in different dynamically loaded objects
After reading these questions, I’m looking for some more detail about how to control symbol resolution order. In my problem, I have main executable exec. exec dynamically links to a.so and c.so. a.so dynamically links to b.so. b.so calls function foo, which is normally provided by c.so but in this case …
ld undefined reference, despite library found and symbols exported
Been fighting with this on and off for 48 hours now; I’m still getting undefined reference errors when attempting to link a dynamic library with its dependency – despite all exports existing, and the library being found successfully. Scenario: libmemory (C++) – exports functions with extern …
Compiling pintool with sqlite3 database
I am writing a pintool to instrument my binary. I would like to use sqlite3 database to store the information about instructions. I can compile and execute sqlite3 “helloworld” example without any problem. As well I can compile and execute my pintool without sqlite connection. However, whenever I …
How does dynamic linker changes text segment of process?
If i understand correctly when user tries to execute dynamically linked executable (with execve(“foo”, “”, “”)) instead of loading text segment of “foo” dynamic linker is loaded (ld-linux.so.2) and executed. It have to load libraries required for program (“…
dynamic linker error with rand() function
I already asked a question about this before but with reference to the following code again Why does compiling this result in the following error Why would this happen? How does the linker know that this is just another rand() function I have declared myself but rather an existing version of rand()? Answer On…
LD_LIBRARY_PATH failing while trying to run Qt app
I want to run a Qt 5 based application usind dynamic libraries on Linux. In summary, a script will copy the executable and other relevant files, including all required .so inside a lib folder, to the desired destination and a script calling gksudo will work as caller to the app. Till now everything works fine…
Linking binary compiled with “-g” with library without “-g”
Will there be any issues if a binary compiled with gdb symbols (-g) is linked with a library without gdb symbols? I am debugging this issue, and I am checking if the “-g” might be causing this. Answer Linking libraries compiled with debug symbols and without debug symbols should not cause Segmenta…