aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--explore-elf.txt51
-rw-r--r--runtime-ld.txt62
2 files changed, 113 insertions, 0 deletions
diff --git a/explore-elf.txt b/explore-elf.txt
new file mode 100644
index 0000000..d5bde46
--- /dev/null
+++ b/explore-elf.txt
@@ -0,0 +1,51 @@
+.:: Explore Elf ::.
+--------------------------------------------------------------------------------
+
+# toc
+------
+ |readelf|
+ |objdump|
+ |nm|
+ |c++filt|
+
+# readelf(1) *readelf*
+=============
+ args:
+ --wide dont break output at 80 chars
+ -h print ELF header
+ -S print sections headers
+ -l print program headers
+ -d print dynamic section
+ -s print symbol table
+
+# objdump(1) *objdump*
+=============
+ args:
+ -M intel use intil syntax
+ -d disassemble text section
+ -D disassemble all sections
+ -S mix disassembly with source code
+ -C demangle
+ -j <section> display info for section
+ --[no-]show-raw-insn [dont] show object code next to disassembly
+
+ ## disassemble .plt section
+ objdump -j .plt -d <elf_file>
+
+# nm(1) *nm*
+========
+ args:
+ -C demangle
+ -u undefined only
+
+# c++filt(1) *c++filt*
+=============
+ ## demangle symbol
+ c++-filt <symbol_str>
+
+ ## demangle stream
+ nm <elf_file> | c++filt
+
+--------------------------------------------------------------------------------
+vim:sts=2:et:tw=80:cc=80:fo+=t:ft=help
+
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=<l_so> colon separated list of libso's to be pre loaded
+ LD_DEBUG=<opts> 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: <path>/libb.so
+ >> calling init: <path>/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=<path>/liba.so [0]
+ >> symbol=memcpy; lookup in file=<path>/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
+