vfs: check userland buffers before reading them.
[haiku.git] / src / tests / system / runtime_loader / test_suite / dlopen_resolve_basic3
blob4a7ee4413180e1dd355d29978d9a7343085c6229
1 #!/bin/sh
3 # program
5 # dlopen():
6 # liba.so
7 # <- libb.so
8 # <- libb_dependency.so
10 # Expected: Undefined symbol in liba.so resolves to symbol in
11 # libb_dependency.so.
14 . ./test_setup
17 # create libb_dependency.so
18 cat > libb_dependency.c << EOI
19 int c() { return 1; }
20 EOI
22 # build
23 compile_lib -o libb_dependency.so libb_dependency.c
26 # create libb.so
27 cat > libb.c << EOI
28 int b() { return 1; }
29 EOI
31 # build
32 compile_lib -o libb.so libb.c ./libb_dependency.so
35 # create liba.so
36 cat > liba.c << EOI
37 extern int c();
38 int a() { return c(); }
39 EOI
41 # build
42 compile_lib -o liba.so liba.c ./libb.so
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 int (*a)();
56 liba = dlopen("./liba.so", RTLD_NOW | RTLD_GLOBAL);
57 if (liba == NULL) {
58 fprintf(stderr, "Error opening liba.so: %s\n", dlerror());
59 exit(117);
62 a = (int (*)())dlsym(liba, "a");
63 if (a == NULL) {
64 fprintf(stderr, "Error getting symbol a: %s\n", dlerror());
65 exit(116);
68 return a();
70 EOI
72 # build
73 compile_program_dl -o program program.c
75 # run
76 test_run_ok ./program 1