vfs: check userland buffers before reading them.
[haiku.git] / src / tests / system / runtime_loader / test_suite / dlopen_resolve_order2
blobb82b5a1f8601a58f81f7bf4fd1a8b1ea4800a8f0
1 #!/bin/sh
3 # program
5 # dlopen():
6 # liba.so
7 # <- libb.so
8 # <- libb_dependency.so
9 # <- libd.so
11 # Expected: Undefined symbol in liba.so resolves to symbol in
12 # libd.so, 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 libd.so
37 cat > libd.c << EOI
38 int c() { return 2; }
39 EOI
41 # build
42 compile_lib -o libd.so libd.c
45 # create liba.so
46 cat > liba.c << EOI
47 extern int c();
48 int a() { return c(); }
49 EOI
51 # build
52 compile_lib -o liba.so liba.c ./libb.so ./libd.so
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 int (*a)();
66 liba = dlopen("./liba.so", RTLD_NOW | RTLD_GLOBAL);
67 if (liba == NULL) {
68 fprintf(stderr, "Error opening liba.so: %s\n", dlerror());
69 exit(117);
72 a = (int (*)())dlsym(liba, "a");
73 if (a == NULL) {
74 fprintf(stderr, "Error getting symbol a: %s\n", dlerror());
75 exit(116);
78 return a();
80 EOI
82 # build
83 compile_lib_dl -o program program.c
85 # run
86 test_run_ok ./program 2