vfs: check userland buffers before reading them.
[haiku.git] / src / tests / system / runtime_loader / test_suite / dlopen_resolve_order7
bloba12d6d9a834970b1a72084588b393de7ca5f9871
1 #!/bin/sh
3 # program
5 # dlopen():
6 # libd.so (local)
7 # liba.so
8 # <- libb.so
10 # Expected: Undefined symbol in liba.so resolves to symbol in libb.so,
11 # not to symbol in libd.so, since it's loaded RTLD_LOCAL.
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_LOCAL);
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 1