
CS485G Spring 2015 39
42 Interpositioning
1. Replace standard routine with a special one in order to monitor (for
example, to find memory leaks), profile (for improving efficiency),
add facility (like encryption), reduce facility (sandboxing).
2. At compile time: Build replacement, and use #define to force calls
to go to the replacement.
3. At link time: build replacement version wrap foo() that calls
real foo() when it needs it. Call the linker with --wrap,foo.
Gcc can pass this flag to the linker: -Wl,--wrap,foo. Then the
linker resolves calls to foo() as wrap foo() and calls to real foo()
as foo().
4. At load time: tell dynamic linker to resolve symbols by going first to
a special library. The dynamic linker uses the LD PRELOAD environ-
ment variable:
LD_PRELOAD="/usr/lib64/libdl.so ./mymalloc.so"
./myProg
43 Operating systems — Introduction
1. Lecture 23, 3/27/2015 Lab 5
2. Lecture 24, 3/30/2015
3. Goals
(a) abstract the hardware, hiding some features and providing new
ones.
(b) share resources among processes.
4. Layers
(a) Hardware, including instruction set, registers, memory, and de-
vices.
(b) OS kernel
(c) Applications (processes)
5. Kernel design alternatives
Komentarze do niniejszej Instrukcji