summaryrefslogtreecommitdiff
path: root/tests/libs/ld_config_test_helper_lib2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/libs/ld_config_test_helper_lib2.cpp')
-rw-r--r--tests/libs/ld_config_test_helper_lib2.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/libs/ld_config_test_helper_lib2.cpp b/tests/libs/ld_config_test_helper_lib2.cpp
index a620a6cf5..d5bca2c36 100644
--- a/tests/libs/ld_config_test_helper_lib2.cpp
+++ b/tests/libs/ld_config_test_helper_lib2.cpp
@@ -1,3 +1,11 @@
-int get_value_from_another_lib() {
- return 12345;
+#include <dlfcn.h>
+#include <stdio.h>
+
+// Mark foo and bar weak so that Clang allows the run-time linker to decide which DSO's symbol to
+// use.
+
+__attribute__((weak)) extern "C" void bar() {
+ printf("bar lib2\n");
+ void (*next)(void) = reinterpret_cast<void (*)()>(dlsym(RTLD_NEXT, "bar"));
+ if (next != nullptr) next();
}