


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Lab; Class: INTRO TO SYSTEMS SOFTWARE; Subject: Computer Science; University: University of Pittsburgh; Term: Unknown 1989;
Typology: Lab Reports
1 / 4
This page cannot be seen from the preview
Don't miss anything!



A Shared Object is an executable file that acts as a shared library of functions. Dynamic linking provides a way for a process to call a function that is not part of its executable code. The executable code for the function is located in a .so file, which contains one or more functions that are compiled, linked, and stored separately from the processes that use them. Shared objects also facilitate the sharing of data and resources. Multiple applications can simultaneously access the contents of a single copy of a shared object in memory.
Dynamic linking differs from static linking in that it allows an executable file to include only the information needed at run time to locate the executable code for a shared object function. In static linking, the linker gets all of the referenced functions from the static link library and places it with your code into your executable.
pico mystr.c
void my_strcpy(char *dest, char src) { while(dest++ = *src++); }
gcc -fPIC -c mystr.c
ld -shared -soname libmystr.so.1 -o libmystr.so.1.0 -lc mystr.o
ln -s libmystr.so.1.0 libmystr.so
export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
man dlopen
#include <stdio.h> #include <dlfcn.h>
int main() { void handle; void (my_str_copy)(char *, char *); char *error; handle = dlopen("libmystr.so", RTLD_LAZY); if(!handle) { //handle == NULL printf("%s\n", dlerror()); //dlerror gives us a string with the error exit(1); } dlerror(); // Clear any existing error my_str_copy = dlsym(handle, "my_strcpy"); //lookup the function by name if ((error = dlerror()) != NULL) {
gzip USERNAME_lab3.tar cp USERNAME_lab3.tar.gz ~dsk6/incoming/449/lab