X-Git-Url: https://pd.if.org/git/?p=lice;a=blobdiff_plain;f=tests%2Fdl.c;fp=tests%2Fdl.c;h=80a9fc44d8bd5ec62c101ef3446828fd78ad98e7;hp=0000000000000000000000000000000000000000;hb=f1abb26903687c7967cf37c3f6c830051bdeb371;hpb=bb650f4a52a456c1aa0a34508d6f3dcce58291b6 diff --git a/tests/dl.c b/tests/dl.c new file mode 100644 index 0000000..80a9fc4 --- /dev/null +++ b/tests/dl.c @@ -0,0 +1,30 @@ +// dynamic loading +#include + +// should be good for the next ten thousand years :P +#define SOMAX 128 + +int main(void) { + int so = 0; + char buffer[32]; + void *handle = dlopen("libc.so", 1); + + if (!handle) { + for (so = 0; so < SOMAX; so++) { + snprintf(buffer, sizeof(buffer), "libc.so.%d", so); + if ((handle = dlopen(buffer, 1))) + break; + } + } + + if (!handle) { + printf("failed to load libc\n"); + return 1; + } + + // test must return 0 to succeed + int (*a)(int) = dlsym(handle, "exit"); + a(0); + + return 1; +}