This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: CS3214 Fall 2011 Exercise 5 Due: Monday, Oct 17, 2011. 11:59pm (no extensions). What to submit: Upload a tar archive that contains a text file answers.txt with your answers for the questions not requiring code, as well as individual files for those that do, as listed below. This exercise is intended to reinforce the content of the lectures related to linking using small examples. As some answers may be specified to our current environment, you must again do this exercise on our rlogin cluster or the lab machines. 1. Static Linking To effectively work with object files and use libraries, you should be familiar with a num- ber of tools. 1. Familiarize yourselves with the ’nm’ command (use info ’nm’, for instance), nm displays the values of symbols contained in object files and libraries along with their types. Create a file symbols.c that, when compiled, contains the following symbols: $ gcc -c symbols.c $ nm symbols.o 00000004 C C 00000000 D D 00000000 T T U U 00000000 b b 00000004 d d 00000004 r r 00000005 t t (The first column need not match.) Include symbols.c in your tarball! 2. What does the command strip do? 3. What does the command size do? What is the total amount of compiled machine code contained in all object modules of /usr/lib/libc.a? Provide the number as a decimal counted in bytes! 4. The directory /home/courses/cs3214/linking contains a subdirectory coreutils- 8.13-build which contains a number of object files and libraries. Unfortunately, the ’Makefile’ containing the build instructions is missing. Your task is to build the program ’cat’ whose main() function is defined in src/cat.o Start by issuing these commands: 1 CS3214 Fall 2011 Exercise 5 cp -R ˜cs3214/linking/coreutils-8.13-build . cd coreutils-8.13-build/src gcc -o cat cat.o As you encounter undefined symbols, determine which object files and/or libraries you need to add to the command line until your executable links successfully....
View Full Document
This note was uploaded on 12/31/2011 for the course CS 3214 taught by Professor Staff during the Fall '11 term at Virginia Tech.
- Fall '11