#include <stdio.h> // fprintf(), NULL
#include <stdlib.h> // exit(), EXIT_SUCCESS
#include <string.h>
#include <dlfcn.h>
#include "test.h" // PASS(), FAIL(), XPASS(), XFAIL()
int main(int argc, const char* argv[])
{
void* handle = dlopen("./bar.dylib", RTLD_GLOBAL);
if ( handle == NULL ) {
const char* msg = dlerror();
FAIL("dlopen(\"%s\", RTLD_GLOBAL) failed: %s", argv[1], msg);
return EXIT_SUCCESS;
}
void* fooSym = dlsym(RTLD_DEFAULT, "foo");
if ( fooSym == NULL ) {
const char* msg = dlerror();
FAIL("dlsym(RTLD_DEFAULT, \"foo\") failed: %s", msg);
return EXIT_SUCCESS;
}
void* barSym = dlsym(RTLD_DEFAULT, "bar");
if ( barSym == NULL ) {
const char* msg = dlerror();
FAIL("dlsym(RTLD_DEFAULT, \"bar\") failed: %s", msg);
return EXIT_SUCCESS;
}
void* handleFoo = dlopen("./foo.dylib", RTLD_LOCAL);
if ( handleFoo == NULL ) {
const char* msg = dlerror();
FAIL("dlopen(\"%s\", RTLD_LOCAL) failed: %s", "./foo.dylib", msg);
return EXIT_SUCCESS;
}
void* handleBar = dlopen("./bar.dylib", RTLD_LOCAL);
if ( handleBar == NULL ) {
const char* msg = dlerror();
FAIL("dlopen(\"%s\", RTLD_LOCAL) failed: %s", "./bar.dylib", msg);
return EXIT_SUCCESS;
}
fooSym = dlsym(RTLD_DEFAULT, "foo");
if ( fooSym == NULL ) {
const char* msg = dlerror();
FAIL("dlsym(RTLD_DEFAULT, \"foo\") failed: %s", msg);
return EXIT_SUCCESS;
}
barSym = dlsym(RTLD_DEFAULT, "bar");
if ( barSym == NULL ) {
const char* msg = dlerror();
FAIL("dlsym(RTLD_DEFAULT, \"bar\") failed: %s", msg);
return EXIT_SUCCESS;
}
PASS("dlopen-RTLD_LOCAL-ignore");
return EXIT_SUCCESS;
}