vfs: check userland buffers before reading them.
[haiku.git] / src / tests / system / runtime_loader / test_suite / dlopen_lookup_order3
blob3dd7032ae8fcd23bd0bacb52b26cdae72781d570
1 #!/bin/sh
3 # program
5 # dlopen():
6 # liba.so
7 # <- libb.so
8 # <- libb_dependency.so
9 # <- libd.so
11 # Expected: liba.so lookup: Symbol in libd.so supersedes symbol in
12 # libb_dependency.so.
15 . ./test_setup
18 # create libb_dependency.so
19 cat > libb_dependency.c << EOI
20 int a() { 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 > libd.c << EOI
38 int a() { return 2; }
39 EOI
41 # build
42 compile_lib -o libd.so libd.c
45 # create liba.so
46 cat > liba.c << EOI
47 int c() { return 1; }
48 EOI
50 # build
51 compile_lib -o liba.so liba.c ./libb.so ./libd.so
54 # create program
55 cat > program.c << EOI
56 #include <dlfcn.h>
57 #include <stdio.h>
58 #include <stdlib.h>
59 int
60 main()
62 void* liba;
63 int (*a)();
65 liba = dlopen("./liba.so", RTLD_NOW | RTLD_GLOBAL);
66 if (liba == NULL) {
67 fprintf(stderr, "Error opening liba.so: %s\n", dlerror());
68 exit(117);
71 a = (int (*)())dlsym(liba, "a");
72 if (a == NULL) {
73 fprintf(stderr, "Error getting symbol a: %s\n", dlerror());
74 exit(116);
77 return a();
79 EOI
81 # build
82 compile_program_dl -o program program.c
84 # run
85 test_run_ok ./program 2