SPO600 Compiled C Lab
Revision as of 00:49, 17 January 2014 by Chris Tyler (talk | contribs)
Lab 2
1. Write a basic C program which prints a message on the screen, Hello World!-style -- something like this:
#include <stdio.h> int main() { printf("Hello World!\n"); }
2. Compile the program using the GCC compiler. Include these compiler options:
-g # enable debugging information -O0 # do not optimize (that's a capital letter and then the digit zero) -fno-builtins # do not use builtin function optimizations
3. The resulting binary is an ELF (Executable and Linkable Format) file, which contains multiple sections. These sections may contain object code, link tables, debugging symbols, program data (such as constants and the initial values of variables), metadata about the program and ELF sections, and comments.
Examine the binary produced by the previous step using the objdump program. These options may be useful -- see the manpage for objdump for other options:
-f # display header information for the entire file -s # display per-section summary information -d # disassemble sections containing code --source # (implies -d) show source code, if available, along with disassembly
External Resources
- For a general overview of ELF, see the Wikipedia article on Executable and Linkable Format).