Working Notes: a commonplace notebook for recording & exploring ideas.
Home. Site Map. Subscribe. More at expLog.
Spent a little bit of time exploring linking and loading, and taking a break this week.
I've been spending time reading Linkers and Loaders, but decided to take a
detour and ended up reading a small book by Ulrich Drepper
that went into a lot of detail on how shared objects are located and linked,
alongwith the differences between RUNPATH
and RPATH
.
LD_LIBRARY_PATH
also honors $ORIGIN
, to be able to choose paths relative to the location of the object.
There are a lot of details on how the actual linking works, with offsets, tables and jump instructions that I need to re-read.
Per symbol visibility in C can be added by using __attribute__ ((visibility ("hidden")))
LD_PROFILE=<soname>
will profile intefaces that go through a PLT call.
API: Application Programming Interface; ABI: Application Binary Interface
DT_NEEDED
in the object stores references to other files
If both DT_RPATH
and DT_RUNPATH
are set, DT_RPATH
is ignored
gcc -Wl,-rpath,/some/dir:/dir file.o --enable-new-dtags
Accidentally adding an empty RPATH
or LD_LIBRARY_PATH
can have strange outcomes, and this is a mistake I've made myself.
Additional variables
$LIB
for lib32/lib64$PLATFORM
for an arch string--as-needed
helps keep libs limited.
— Kunal