vfs: check userland buffers before reading them.
[haiku.git] / src / tests / system / runtime_loader / test_suite / dlopen_resolve_order5
blobacb358d26a638e1845228b1a567cd9d3845f1e29
1 #!/bin/sh
3 # program
5 # dlopen():
6 # liba.so
7 # <- libb.so
8 # <- libb_dependency.so
9 # <- libd.so
10 # libe.so
12 # Expected: Undefined symbol in libe.so resolves to symbol in
13 # libd.so, not to symbol in libb_dependency.so.
16 . ./test_setup
19 # create libb_dependency.so
20 cat > libb_dependency.c << EOI
21 int c() { return 1; }
22 EOI
24 # build
25 compile_lib -o libb_dependency.so libb_dependency.c
28 # create libb.so
29 cat > libb.c << EOI
30 int b() { return 1; }
31 EOI
33 # build
34 compile_lib -o libb.so libb.c ./libb_dependency.so
37 # create libd.so
38 cat > libd.c << EOI
39 int c() { return 2; }
40 EOI
42 # build
43 compile_lib -o libd.so libd.c
46 # create liba.so
47 cat > liba.c << EOI
48 int e() { return 0; }
49 EOI
51 # build
52 compile_lib -o liba.so liba.c ./libb.so ./libd.so
55 # create libe.so
56 cat > libe.c << EOI
57 extern int c();
58 int a() { return c(); }
59 EOI
61 # build
62 compile_lib -o libe.so libe.c
65 # create program
66 cat > program.c << EOI
67 #include <dlfcn.h>
68 #include <stdio.h>
69 #include <stdlib.h>
70 int
71 main()
73 void* liba;
74 void* libe;
75 int (*a)();
77 liba = dlopen("./liba.so", RTLD_NOW | RTLD_GLOBAL);
78 if (liba == NULL) {
79 fprintf(stderr, "Error opening liba.so: %s\n", dlerror());
80 exit(117);
83 libe = dlopen("./libe.so", RTLD_NOW | RTLD_GLOBAL);
84 if (libe == NULL) {
85 fprintf(stderr, "Error opening libe.so: %s\n", dlerror());
86 exit(117);
89 a = (int (*)())dlsym(libe, "a");
90 if (a == NULL) {
91 fprintf(stderr, "Error getting symbol a: %s\n", dlerror());
92 exit(116);
95 return a();
97 EOI
99 # build
100 compile_program_dl -o program program.c
102 # run
103 test_run_ok ./program 2