vfs: check userland buffers before reading them.
[haiku.git] / src / tests / system / runtime_loader / test_suite / dlopen_resolve_order4
blob862c830592d47381a1ebf6024da5747ffff9c183
1 #!/bin/sh
3 # program
5 # dlopen():
6 # libd.so
7 # liba.so
8 # <- libb.so
9 # <- libb_dependency.so
11 # Expected: Undefined symbol in liba.so resolves to symbol in libd.so,
12 # not to symbol in libb_dependency.so.
15 . ./test_setup
18 # create libb_dependency.so
19 cat > libb_dependency.c << EOI
20 int c() { return 1; }
21 EOI
23 # build
24 compile_lib -o libb_dependency.so libb_dependency.c
27 # create libb.so
28 cat > libb.c << EOI
29 int b() { return 1; }
30 EOI
32 # build
33 compile_lib -o libb.so libb.c ./libb_dependency.so
36 # create liba.so
37 cat > liba.c << EOI
38 extern int c();
39 int a() { return c(); }
40 EOI
42 # build
43 compile_lib -o liba.so liba.c ./libb.so
46 # create libd.so
47 cat > libd.c << EOI
48 int c() { return 2; }
49 EOI
51 # build
52 compile_lib -o libd.so libd.c
55 # create program
56 cat > program.c << EOI
57 #include <dlfcn.h>
58 #include <stdio.h>
59 #include <stdlib.h>
60 int
61 main()
63 void* liba;
64 void* libd;
65 int (*a)();
67 libd = dlopen("./libd.so", RTLD_NOW | RTLD_GLOBAL);
68 if (libd == NULL) {
69 fprintf(stderr, "Error opening libd.so: %s\n", dlerror());
70 exit(117);
73 liba = dlopen("./liba.so", RTLD_NOW | RTLD_GLOBAL);
74 if (liba == NULL) {
75 fprintf(stderr, "Error opening liba.so: %s\n", dlerror());
76 exit(117);
79 a = (int (*)())dlsym(liba, "a");
80 if (a == NULL) {
81 fprintf(stderr, "Error getting symbol a: %s\n", dlerror());
82 exit(116);
85 return a();
87 EOI
89 # build
90 compile_lib_dl -o program program.c
92 # run
93 test_run_ok ./program 2