vfs: check userland buffers before reading them.
[haiku.git] / src / tests / system / runtime_loader / test_suite / dlopen_lookup_order4
blob4105f5fb2741ca7f0d33837441515bd3e18d0f29
1 #!/bin/sh
3 # program
5 # dlopen():
6 # libb.so (local)
7 # <- libb_dependency.so
8 # liba.so
10 # Expected: Global lookup: Symbol in libb_dependency.so does not supersede
11 # symbol in liba.so, since libb.so is loaded RTLD_LOCAL.
14 . ./test_setup
17 # create liba.so
18 cat > liba.c << EOI
19 int a() { return 1; }
20 EOI
22 # build
23 compile_lib -o liba.so liba.c
26 # create libb_dependency.so
27 cat > libb_dependency.c << EOI
28 int a() { return 2; }
29 EOI
31 # build
32 compile_lib -o libb_dependency.so libb_dependency.c
35 # create libb.so
36 cat > libb.c << EOI
37 int b() { return 1; }
38 EOI
40 # build
41 compile_lib -o libb.so libb.c ./libb_dependency.so
44 # create program
45 cat > program.c << EOI
46 #include <dlfcn.h>
47 #include <stdio.h>
48 #include <stdlib.h>
49 int
50 main()
52 void* liba;
53 void* libb;
54 void* self;
55 int (*a)();
57 libb = dlopen("./libb.so", RTLD_NOW | RTLD_LOCAL);
58 if (libb == NULL) {
59 fprintf(stderr, "Error opening libb.so: %s\n", dlerror());
60 exit(117);
63 liba = dlopen("./liba.so", RTLD_NOW | RTLD_GLOBAL);
64 if (liba == NULL) {
65 fprintf(stderr, "Error opening liba.so: %s\n", dlerror());
66 exit(117);
69 self = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL);
70 if (self == NULL) {
71 fprintf(stderr, "Error opening self: %s\n", dlerror());
72 exit(117);
75 a = (int (*)())dlsym(self, "a");
76 if (a == NULL) {
77 fprintf(stderr, "Error getting symbol a: %s\n", dlerror());
78 exit(116);
81 return a();
83 EOI
85 # build
86 compile_program_dl -o program program.c
88 # run
89 test_run_ok ./program 1