Kenwood HP 9000 Personal Computer User Manual


 
Chapter 3 69
Linker Tasks
Using Linker commands
The Build Environment. Before seeing the program's source code,
it may help to see how the program and the various object files were
built. The following shows the makefile used to generate the various
files.
Makefile Used to Create Dynamic Link Files
CFLAGS = -Aa -D_POSIX_SOURCE
dynprog: dynprog.o dynload.o flush_cache.o
# Compile line:
cc -o dynprog dynprog.o dynload.o flush_cache.o -Wl,-a,archive
file1.o: file1.c dynprog.c
file2.o: file2.c
# Create flush_cache.o:
flush_cache.o:
as flush_cache.s
This makefile assumes that the following files are found in the current
directory:
dynload.c The file containing the alloc_load_space and
dyn_load functions.
dynprog.c The main program that calls functions from
dynload.c and dynamically links and loads file1.o
and file2.o. Also contains the function glorp, which
is called by foo and bar.
file1.c Contains the functions foo and bar.
file2.c Contains the variable counter, which is incremented
by foo, bar, and main.
flush_cache.s
Assembly language source for function flush_cache,
which is called by the dyn_load function.
To create the executable program dynprog from this makefile, you would
simply run:
$ make dynprog file1.o file2.o
cc -Aa -D_POSIX_SOURCE -c dynprog.c
cc -Aa -D_POSIX_SOURCE -c dynload.c
cc -o dynprog dynprog.o dynload.o -Wl,-a,archive
cc -Aa -D_POSIX_SOURCE -c file1.c
cc -Aa -D_POSIX_SOURCE -c file2.c
as -o flush_cache flush_cache.s