vfs: check userland buffers before reading them.
[haiku.git] / src / tests / system / runtime_loader / test_suite / dlopen_resolve_order1
blobf57f51fee88a6d04214cec352efeb6791cb13698
1 #!/bin/sh
3 # program
5 # dlopen():
6 # libb.so
7 # liba.so
9 # Expected: Undefined symbol in liba.so resolves to symbol in program, not
10 # to symbol in libb.so.
13 . ./test_setup
16 # create liba.so
17 cat > liba.c << EOI
18 extern int b();
19 int a() { return b(); }
20 EOI
22 # build
23 compile_lib -o liba.so liba.c
26 # create libb.so
27 cat > libb.c << EOI
28 int b() { return 2; }
29 EOI
31 # build
32 compile_lib -o libb.so libb.c
35 # create program
36 cat > program.c << EOI
37 #include <dlfcn.h>
38 #include <stdio.h>
39 #include <stdlib.h>
41 int b() { return 1; }
43 int
44 main()
46 void* liba;
47 void* libb;
48 int (*a)();
50 libb = dlopen("./libb.so", RTLD_NOW | RTLD_GLOBAL);
51 if (libb == NULL) {
52 fprintf(stderr, "Error opening libb.so: %s\n", dlerror());
53 exit(117);
56 liba = dlopen("./liba.so", RTLD_NOW | RTLD_GLOBAL);
57 if (liba == NULL) {
58 fprintf(stderr, "Error opening liba.so: %s\n", dlerror());
59 exit(117);
62 a = (int (*)())dlsym(liba, "a");
63 if (a == NULL) {
64 fprintf(stderr, "Error getting symbol a: %s\n", dlerror());
65 exit(116);
68 return a();
70 EOI
72 # build
73 compile_lib_dl -o program program.c
75 # run
76 test_run_ok ./program 1