vfs: check userland buffers before reading them.
[haiku.git] / src / tests / system / runtime_loader / test_suite / dlopen_lookup_order1
blob44a7130ddd85d5a60a8aaf0ca486f6747da30b70
1 #!/bin/sh
3 # program
5 # dlopen():
6 # liba.so
7 # libb.so
8 # <- libb_dependency.so
10 # Expected: Global lookup: symbol in liba.so supersedes symbol in
11 # libb_dependency.so.
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 liba = dlopen("./liba.so", RTLD_NOW | RTLD_GLOBAL);
58 if (liba == NULL) {
59 fprintf(stderr, "Error opening liba.so: %s\n", dlerror());
60 exit(117);
63 libb = dlopen("./libb.so", RTLD_NOW | RTLD_GLOBAL);
64 if (libb == NULL) {
65 fprintf(stderr, "Error opening libb.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