vfs: check userland buffers before reading them.
[haiku.git] / src / tests / system / runtime_loader / test_suite / dlopen_resolve_order6
blob3ec50aa3e3f20af7f46ee04709cadc879d1a04ad
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 # libb_dependency.so, not to symbol in libd.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 extern int c();
49 int e() { return 0; }
50 EOI
52 # build
53 compile_lib -o liba.so liba.c ./libb.so
56 # create libe.so
57 cat > libe.c << EOI
58 extern int c();
59 int a() { return c(); }
60 EOI
62 # build
63 compile_lib -o libe.so libe.c
66 # create program
67 cat > program.c << EOI
68 #include <dlfcn.h>
69 #include <stdio.h>
70 #include <stdlib.h>
71 int
72 main()
74 void* liba;
75 void* libd;
76 void* libe;
77 int (*a)();
79 liba = dlopen("./liba.so", RTLD_NOW | RTLD_GLOBAL);
80 if (liba == NULL) {
81 fprintf(stderr, "Error opening liba.so: %s\n", dlerror());
82 exit(117);
85 libd = dlopen("./libd.so", RTLD_NOW | RTLD_GLOBAL);
86 if (libd == NULL) {
87 fprintf(stderr, "Error opening libd.so: %s\n", dlerror());
88 exit(117);
91 libe = dlopen("./libe.so", RTLD_NOW | RTLD_GLOBAL);
92 if (libe == NULL) {
93 fprintf(stderr, "Error opening libe.so: %s\n", dlerror());
94 exit(117);
97 a = (int (*)())dlsym(libe, "a");
98 if (a == NULL) {
99 fprintf(stderr, "Error getting symbol a: %s\n", dlerror());
100 exit(116);
103 return a();
107 # build
108 compile_program_dl -o program program.c
110 # run
111 test_run_ok ./program 1