+/*
+ * Copyright (C) 2016 Antoine Busque <abusque@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
/* _GNU_SOURCE is defined by config.h */
#include <dlfcn.h>
#include <stdio.h>
-#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
+#include <common/compat/errno.h>
+
/*
* libfoo has a direct dependency on libbar.
* libbar has a direct dependency on libzzz.
*/
int main(int argc, char **argv)
{
- void *h0, *h1, *h2, *h3, *h4;
+ void *h0, *h2, *h3, *h4;
+
+#ifdef HAVE_DLMOPEN
+ void *h1;
+#endif
+
char *error;
int (*foo)(void);
if (!h0) {
goto get_error;
}
+
+#ifdef HAVE_DLMOPEN
h1 = dlmopen(LM_ID_BASE, "libfoo.so", RTLD_LAZY);
if (!h1) {
goto get_error;
}
+#endif
+
h2 = dlopen("libzzz.so", RTLD_LAZY);
if (!h2) {
goto get_error;
goto get_error;
}
- foo = dlsym(h1, "foo");
+ foo = dlsym(h3, "foo");
error = dlerror();
if (error != NULL) {
goto error;
if (dlclose(h0)) {
goto get_error;
}
+
+#ifdef HAVE_DLMOPEN
if (dlclose(h1)) {
goto get_error;
}
+#endif
+
if (dlclose(h2)) {
goto get_error;
}