1 /* A small program used to check that LOCAL_WHOLE_STATIC_LIBRARIES builds 2 * and works properly. Here, we check that the 'foo2' function which is 3 * never called from main is still included in the final executable 4 * image. 5 */ 6 #include <stdio.h> 7 #include <unistd.h> 8 #include <dlfcn.h> 9 10 int main(int argc, char *argv[]) 11 { 12 char cwd[PATH_MAX]; 13 if (getcwd(cwd, sizeof(cwd)) == NULL) { 14 perror("getcwd"); 15 return 1; 16 } 17 18 char buf[PATH_MAX]; 19 sprintf(buf, "%s/libbar.so", cwd); 20 21 void* lib = dlopen(buf, RTLD_NOW); 22 if (lib == NULL) { 23 fprintf(stderr, "Could not dlopen(\"libbar.so\"): %s\n", dlerror()); 24 return 1; 25 } 26 if (dlsym(lib, "foo2") == NULL) { 27 fprintf(stderr, "Symbol 'foo2' is missing from shared library!!\n"); 28 return 2; 29 } 30 dlclose(lib); 31 return 0; 32 } 33