From 257763be0ffc9fa42aa91a7c4e6d202ea55be5bc Mon Sep 17 00:00:00 2001 From: johannst Date: Thu, 20 Jun 2019 21:09:39 +0200 Subject: added explore-elf and runtime-ld --- runtime-ld.txt | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 runtime-ld.txt (limited to 'runtime-ld.txt') diff --git a/runtime-ld.txt b/runtime-ld.txt new file mode 100644 index 0000000..86fe9ad --- /dev/null +++ b/runtime-ld.txt @@ -0,0 +1,62 @@ +.:: Runtime ld ::. +-------------------------------------------------------------------------------- + +# toc +------ + |ld_so| + |load_init_order| + +# ld.so(8) *ld_so* +=========== + env: + LD_PRELOAD= colon separated list of libso's to be pre loaded + LD_DEBUG= comman separated list of debug options + =help list available options + =libs show library search path + =files processing of input files + =symbols show search path for symbol lookup + =bindings show against which definition a symbol is bound + + + ## LD_PRELOAD load & init order *load_init_order* + > ldd ./main + >> libc.so.6 => /usr/lib/libc.so.6 + + > LD_PRELOAD=liba.so:libb.so ./main + --> + preloaded in this order + <-- + initialized in this order + + - preload order determines the order libs are inserted into the link map + + - resulting link map: + +------+ +------+ +------+ +------+ + | main | -> | liba | -> | libb | -> | libc | + +------+ +------+ +------+ +------+ + + - see preload and init order in action + > LD_DEBUG=files LD_PRELOAD=liba.so:libb.so ./main + # load order (-> determines link map) + >> file=liba.so [0]; generating link map + >> file=libb.so [0]; generating link map + >> file=libc.so.6 [0]; generating link map + + # init order + >> calling init: /usr/lib/libc.so.6 + >> calling init: /libb.so + >> calling init: /liba.so + >> initialize program: ./main + + - see the symbol lookup in action and therefore the link map order + > LD_DEBUG=symbols,bindings LD_PRELOAD=liba.so:libb.so ./main + >> symbol=memcpy; lookup in file=./main [0] + >> symbol=memcpy; lookup in file=/liba.so [0] + >> symbol=memcpy; lookup in file=/libb.so [0] + >> symbol=memcpy; lookup in file=/usr/lib/libc.so.6 [0] + >> binding file ./main [0] to /usr/lib/libc.so.6 [0]: normal symbol + `memcpy' [GLIBC_2.14] + +-------------------------------------------------------------------------------- +vim:sts=2:et:tw=80:cc=80:fo+=t:ft=help + -- cgit v1.2.3