13 on linux systems the code segment always starts at

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (In fact, C compiler drivers always pass libc.a to the linker, so the reference to libc.a above is unnecessary.) On Unix systems, static libraries are stored on disk in a particular file format known as an archive. An archive is a collection of concatenated relocatable object files, with a header that describes the size and location of each member object file. Archive filenames are denoted with the .a suffix. To make our discussion of libraries concrete, suppose that we want to provide the vector routines in Figure 7.5 in a static library called libvector.a. To create the library, we would use the AR tool: unix> gcc -c addvec.c multvec.c unix> ar rcs libvector.a addvec.o multvec.o To use the library, we might write an application such as main2.c in Figure 7.6, which invokes the addvec library routine. (The include file vector.h defines the function prototypes for the routines in libvector.a.) To build the executable, we would compile and link the input files main.o and libvector.a: unix> gcc -O2 -c main2.c...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online