aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/tests/rtdl/scope3/test.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-07 17:28:52 -0500
committerIan Moffett <ian@osmora.org>2024-03-07 18:24:51 -0500
commitf5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 (patch)
tree93b156621dc0303816b37f60ba88051b702d92f6 /lib/mlibc/tests/rtdl/scope3/test.c
parentbd5969fc876a10b18613302db7087ef3c40f18e1 (diff)
build: Build mlibc + add distclean target
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/tests/rtdl/scope3/test.c')
-rw-r--r--lib/mlibc/tests/rtdl/scope3/test.c39
1 files changed, 0 insertions, 39 deletions
diff --git a/lib/mlibc/tests/rtdl/scope3/test.c b/lib/mlibc/tests/rtdl/scope3/test.c
deleted file mode 100644
index 30fc662..0000000
--- a/lib/mlibc/tests/rtdl/scope3/test.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <dlfcn.h>
-#include <stdio.h>
-#include <assert.h>
-
-#ifdef USE_HOST_LIBC
-#define LIBBAR "libnative-bar.so"
-#define LIBBAZ "libnative-baz.so"
-#else
-#define LIBBAR "libbar.so"
-#define LIBBAZ "libbaz.so"
-#endif
-
-int main() {
- // In this test, we have bar -> foo and baz -> foo (where -> means 'depends on').
- // All three objects contain a definition of a symbol g. Bar calls into foo to retrieve
- // what foo thinks g is, but since bar appears earlier in the scope than foo, bar's copy
- // of g wins.
- //
- // Next, we load baz, which is identical to bar. When baz calls into foo to retrieve g,
- // foo still sees bar's definition of g, so bar's copy of g wins.
- //
- // Swapping the load order of bar and baz should therefore change the value of g which
- // foo sees. This behaviour is why dlmopen exists. If we ever implement that, we should
- // write a similar test and assert that the calls return different results.
-
- void *libbar = dlopen(LIBBAR, RTLD_LAZY | RTLD_LOCAL);
- int (*call_bar)(void) = dlsym(libbar, "call_bar");
- printf("call_bar: %d\n", call_bar());
- assert(call_bar() == 1);
-
- void *libbaz = dlopen(LIBBAZ, RTLD_LAZY | RTLD_LOCAL);
- int (*call_baz)(void) = dlsym(libbaz, "call_baz");
- printf("call_baz: %d\n", call_baz());
- assert(call_baz() == 1);
-
-
- dlclose(libbar);
- dlclose(libbaz);
-}