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
10int main(int argc, char *argv[])
11{
12    void*  lib;
13    char buf[PATH_MAX];
14    sprintf(buf, "%s/libbar.so", getcwd(NULL, 0));
15    lib = dlopen(buf, RTLD_NOW);
16    if (lib == NULL) {
17        fprintf(stderr, "Could not dlopen(\"libbar.so\"): %s\n", dlerror());
18        return 1;
19    }
20    if (dlsym(lib, "foo2") == NULL) {
21        fprintf(stderr, "Symbol 'foo2' is missing from shared library!!\n");
22        return 2;
23    }
24    dlclose(lib);
25    return 0;
26}
27