Videos: Linking
slides: linking.pdf |
Linking combines separately compiled objects to form an executable (either statically or dynamically). We look at the various ways that linking is supported and exposed by C and the compilation toolchain.
- A review and overview of separate compilation and linking.
- Declaring and defining variables and functions in C.
- How different declaration forms in C lead to weak and strong symbols in object files.
- Using the processor and #include to ensure that declarations and uses are consistent across multiple source files.
- Using static to make a definition local to its C file.
- Combining object files into a static-library archive.
- More details on the process of finding objects in an archive for linking.
- Creating and using shared libraries.
- Linking to installed libraries via the -l flag.
- Using dlopen and dlsym to dynamically access functions from a shared library.
- A case study in using various linking tools and techniques to redirect a function call, starting with using cpp macros.
- Using special linking flags to redirect function calls based on symbol renaming.
- Using the LD_PRELOAD flag to redirect function calls based on shared-library substitutions.