Professional Documents
Culture Documents
printf (“hello,
world\n”)
• Symbol defined
elsewhere and used by
your program
• printf
}
printf (“hello,
world\n”) • Symbol defined
elsewhere and used by
<check errno for your program
errors>
• printf
}
• errno
CS-502 Fall 2007 Linking and Loading 5
Two-step operation
(in most systems)
• Requires:
– A load system call to invoke loader (not in Unix)
– ability to leave symbols unresolved and resolve at run time (not in
Unix)
• E.g.,
void myPrintf (**arg) {
static int loaded = 0;
if (!loaded ) {
load (“printf”);
loaded = 1;
printf(arg);
}
}
void main () {
printf (…);
IOLib
read() {…}
} printf() {…}
scanf() {…}
Printf.o HelloWorld.o
Linker
ar Save disk space.
a.Out Startup faster.
Shared Might not need all.
Library (or name of
your command)
Run-time
Loader Loader
Memory
CS-502 Fall 2007 Linking and Loading 17
Dynamic Linking