+ void *h0, *h2, *h3, *h4;
+
+#ifdef HAVE_DLMOPEN
+ void *h1;
+#endif
+
+ char *error;
+ int (*foo)(void);
+
+ h0 = dlopen("libbar.so", RTLD_LAZY);
+ 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;
+ }
+ h3 = dlopen("libfoo.so", RTLD_LAZY);
+ if (!h3) {
+ goto get_error;
+ }
+ h4 = dlopen("libfoo.so", RTLD_LAZY);
+ if (!h4) {
+ goto get_error;
+ }
+
+ foo = dlsym(h3, "foo");
+ error = dlerror();
+ if (error != NULL) {
+ goto error;
+ }
+
+ foo();
+
+ if (dlclose(h0)) {
+ goto get_error;
+ }