Skip to content

Latest commit

 

History

History
14 lines (11 loc) · 551 Bytes

ld.md

File metadata and controls

14 lines (11 loc) · 551 Bytes

ld

rpath (now runpath) is used by ld to find dependencies.

remember that the library doing the actual dlopen call is the one who needs the rpath, so if dlopen is in B and C calls B.loadSomething to get D, then B is the one who needs the rpath.

cheatsheet:

  • set rpath when compiling/linking: -Wl,-rpath,\$ORIGIN
  • add rpath after compiling: patchelf --add-rpath <rpath> <binary>
  • check current rpath: readelf -d <binary>
  • debug libs loaded: LD_DEBUG=libs <binary>
  • debug libs loaded from explicit dlopen calls: lsof -T -P -p <pid>