Lecture 4
Libraries and binary file format
Lecture
Outline
- Linking
- Relocatable object files
- Executable and Linkable Format (ELF)
- Shared libraries
- Linked libraries
- Library interpositioning
Tools for Manipulating Object Files
- ar - creates static libraries, and inserts, deletes, lists, and extracts members.
- strings - lists all of the printable strings contained in an object file.
- strip - deletes symbol table information from an object file.
- nm - lists the symbols defined in the symbol table of an object file.
- size - lists the names and sizes of the sections in an object file.
- readelf -
displays the complete structure of an object file, including all of the information
encoded in the ELF header. Subsumes the functionality of
size
andnm
. - objdump -
the mother of all binary tools. Can display all of the information in an object file.
Its most useful function is disassembling the binary instructions in the
.text
section. - ldd - lists the shared libraries that an executable needs at run time.
Library Interpositioning
Examples:
Workshop
Outline
- Creating static libraries
- Creating shared librarires
- Library interpositioning
- Make scripts
Practice
Homework
- Improve Task 1 from Part 1:
- Provide link-time interpositioning for the
fred
andjohn
functions - Provide load-time interpositioning for the
bill
andsam
functions - Create a Make script to build the program
- Provide link-time interpositioning for the
Note: interposed functions can just print a message like “fred is called”.