custom_alloc.vgtest \
custom_alloc_fiw.stderr.exp \
custom_alloc_fiw.vgtest \
+ dlopen.stderr.exp \
+ dlopen.vgtest \
fp_race.stderr.exp \
fp_race.stderr.exp-mips32-be \
fp_race.stderr.exp-mips32-le \
bug-235681 \
custom_alloc \
concurrent_close \
+ dlopen_main \
+ dlopen_lib.so \
fp_race \
free_is_write \
hold_lock \
concurrent_close_SOURCES = concurrent_close.cpp
+dlopen_main_LDADD = -ldl
+dlopen_lib_so_SOURCES = dlopen_lib.c
+dlopen_lib_so_CFLAGS = -fPIC
+dlopen_lib_so_LDFLAGS = -shared -fPIC
monitor_example_SOURCES = monitor_example.cpp
new_delete_SOURCES = new_delete.cpp
new_delete_CXXFLAGS = $(AM_CXXFLAGS) @FLAG_W_NO_MISMATCHED_NEW_DELETE@
--- /dev/null
+
+
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
--- /dev/null
+In main: creating thread 1
+Hello World! It's me, thread #1!
--- /dev/null
+prereq: test -e dlopen_main && ./supported_libpthread
+vgopts: --read-var-info=yes --check-stack-var=yes --show-confl-seg=no
+prog: dlopen_main ./dlopen_lib.so
+stderr_filter: filter_stderr
--- /dev/null
+#include <stdio.h>
+#include <stdint.h>
+#include <pthread.h>
+#include "dlopen_lib.h"
+
+void *PrintHello(void *threadid)
+{
+ const long tid = (uintptr_t)threadid;
+
+ printf("Hello World! It's me, thread #%ld!\n", tid);
+ pthread_exit(NULL);
+}
+
+
+void foo()
+{
+ pthread_t thread;
+ int rc;
+ uintptr_t t = 1;
+
+ printf("In main: creating thread %ld\n", t);
+ rc = pthread_create(&thread, NULL, PrintHello, (void *)t);
+ if (rc)
+ printf("ERROR; return code from pthread_create() is %d\n", rc);
+ else
+ pthread_join(thread, NULL);
+}
--- /dev/null
+extern void foo();
--- /dev/null
+#include <stdlib.h>
+#include <stdio.h>
+#include <dlfcn.h>
+#include "dlopen_lib.h"
+
+int main(int argc, char **argv)
+{
+ const char *lib = argc > 1 ? argv[1] : "./libfoo.so";
+ void *handle;
+ void (*function)();
+ const char *error;
+
+ handle = dlopen(lib, RTLD_NOW);
+ if (!handle) {
+ fputs (dlerror(), stderr);
+ exit(1);
+ }
+
+ function = dlsym(handle, "foo");
+ error = dlerror();
+ if (error) {
+ fputs(error, stderr);
+ exit(1);
+ }
+
+ (*function)();
+ dlclose(handle);
+ return 0;
+}