vfs: check userland buffers before reading them.
[haiku.git] / src / tests / system / runtime_loader / test_suite / dlopen_resolve_order3
blob9c489716dc2ca1fc183967dc6b28eb4d641fb6f4
1 #!/bin/sh
3 # program
5 # dlopen():
6 # libd.so
7 # liba.so
8 # <- libb.so
10 # Expected: Undefined symbol in liba.so resolves to symbol in libd.so,
11 # not to symbol in libb.so.
14 . ./test_setup
17 # create libb.so
18 cat > libb.c << EOI
19 int b() { return 1; }
20 EOI
22 # build
23 compile_lib -o libb.so libb.c
26 # create liba.so
27 cat > liba.c << EOI
28 extern int b();
29 int a() { return b(); }
30 EOI
32 # build
33 compile_lib -o liba.so liba.c ./libb.so
36 # create libd.so
37 cat > libd.c << EOI
38 int b() { return 2; }
39 EOI
41 # build
42 compile_lib -o libd.so libd.c
45 # create program
46 cat > program.c << EOI
47 #include <dlfcn.h>
48 #include <stdio.h>
49 #include <stdlib.h>
50 int
51 main()
53 void* liba;
54 void* libd;
55 int (*a)();
57 libd = dlopen("./libd.so", RTLD_NOW | RTLD_GLOBAL);
58 if (libd == NULL) {
59 fprintf(stderr, "Error opening libd.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 a = (int (*)())dlsym(liba, "a");
70 if (a == NULL) {
71 fprintf(stderr, "Error getting symbol a: %s\n", dlerror());
72 exit(116);
75 return a();
77 EOI
79 #build
80 compile_program_dl -o program program.c
82 # run
83 test_run_ok ./program 2