{"enrichment":{"faq":[{"a":"dynamic-linking addresses this by teaching you to inspect library paths with ldd, set RPATH or RUNPATH during compilation, use LD_LIBRARY_PATH as a temporary override, or register libraries system-wide with ldconfig. The skill covers diagnosing missing dependencies, embedding absolute or relative search paths in your binary, and verifying correct soname references with readelf to resolve loading failures.","q":"How do I fix 'cannot open shared object file' error?"},{"a":"dynamic-linking explains that RPATH is a legacy search path embedded in binaries, checked before LD_LIBRARY_PATH, while RUNPATH is the modern replacement, checked after LD_LIBRARY_PATH, allowing environment overrides. Both are set at link time with -Wl,-rpath or -Wl,--runpath flags. RUNPATH is preferred because it respects LD_LIBRARY_PATH and supports relative paths like $ORIGIN for portable deployments.","q":"What is RPATH vs RUNPATH in Linux?"},{"a":"dynamic-linking teaches you to design plugin interfaces as header files, compile plugins as shared libraries with -fPIC -shared, then load them at runtime using dlopen with RTLD_LAZY or RTLD_NOW flags, and resolve function pointers with dlsym. The skill covers error handling via dlerror, managing plugin lifecycle with dlclose, and versioning plugin ABIs to maintain compatibility across updates.","q":"How do I create a dlopen dlsym plugin system?"},{"a":"dynamic-linking shows how to write a shared library that defines wrapper functions matching target signatures, compile it with -fPIC -shared, then preload it before execution: LD_PRELOAD=./wrapper.so ./program. The skill covers intercepting malloc, printf, or system calls for debugging or testing, preserving original behavior via dlsym(RTLD_NEXT), and avoiding infinite recursion in wrapper logic.","q":"How can I use LD_PRELOAD for function interception?"},{"a":"dynamic-linking explains soname versioning ensures backward compatibility: set soname at link time with -Wl,-soname,libfoo.so.1, create symlinks (libfoo.so.1 \u2192 libfoo.so.1.2.3), and increment MAJOR on breaking changes, MINOR on additions, PATCH on fixes. Clients link against libfoo.so.1, so you can release libfoo.so.1.2.4 without recompilation, while libfoo.so.2 signals incompatible changes requiring rebuilds.","q":"What is soname versioning and why does it matter?"},{"a":"dynamic-linking teaches symbol visibility control via -fvisibility=hidden compiler flag and __attribute__((visibility(\"default\"))) for exported symbols, or version scripts with linker directives. This hides internal symbols, reduces binary size, prevents namespace collisions, and improves load times. Combine with -fPIC for position-independent code, and use readelf -s to verify only intended symbols are exported.","q":"How do I control symbol visibility and reduce binary size?"}],"shadow_tags":["runtime-library-loading","symbol-resolution","binary-relocation","plugin-architecture","function-hooking","library-versioning","elf-metadata","deployment-flexibility"],"summary_rewrite":"Master Linux shared library fundamentals: create position-independent libraries with proper soname versioning, embed search paths using RPATH or RUNPATH, and debug loading failures with LD_DEBUG and ldd. Build plugin systems with dlopen/dlsym, intercept functions via LD_PRELOAD, and control symbol visibility to reduce binary bloat and namespace collisions."},"files":[{"bytes":6773,"path":"skills/binaries/dynamic-linking/SKILL.md","sha256":"eb57f022c7a88186f360e3f88931b509c68299367decf80a2d2069368448c0bf","url":"https://skillfed.io/files/mohitmishra786/low-level-dev-skills/dynamic-linking/1ee05bfb/SKILL.md"}],"id":"mohitmishra786/low-level-dev-skills/dynamic-linking","links":{"html":"https://skillfed.io/mohitmishra786/low-level-dev-skills/dynamic-linking","md":"https://skillfed.io/mohitmishra786/low-level-dev-skills/dynamic-linking.md","repo":"https://github.com/mohitmishra786/low-level-dev-skills"},"meta":{"agents_supported":[],"first_seen":"2026-07-28","forks":19,"language":"JavaScript","last_updated":"2026-06-27","license":"MIT","name":"dynamic-linking","publisher":"mohitmishra786","stars":148},"relations":{"similar":[{"id":"blacklanternsecurity/red-run/linux-file-path-abuse"},{"id":"mohitmishra786/low-level-dev-skills/binary-hardening"},{"id":"blacklanternsecurity/red-run/linux-sudo-suid-capabilities"},{"id":"mohitmishra786/low-level-dev-skills/linkers-lto"},{"id":"mohitmishra786/low-level-dev-skills/elf-inspection"},{"id":"yaklang/hack-skills/linux-privilege-escalation"},{"id":"blacklanternsecurity/red-run/linux-discovery"},{"id":"trailofbits/skills/ruzzy"},{"id":"zebbern/claude-code-guide/linux-privilege-escalation"},{"id":"yaklang/hack-skills/macos-process-injection"}]},"slug":{"owner":"mohitmishra786","repo":"low-level-dev-skills","skill":"dynamic-linking"},"version":"1ee05bfb"}
