vfs: check userland buffers before reading them.
[haiku.git] / src / tests / system / runtime_loader / test_suite / dlopen_resolve_basic2
blob9324b09e8a78189fb2c4f9c1458d907396449c1a
1 #!/bin/sh
3 # program
4 # <- libb.so
6 # dlopen():
7 # liba.so
9 # Expected: Undefined symbol in liba.so resolves to symbol in libb.so.
12 . ./test_setup
15 # create liba.so
16 cat > liba.c << EOI
17 extern int b();
18 int a() { return b(); }
19 EOI
21 # build
22 compile_lib -o liba.so liba.c
25 # create libb.so
26 cat > libb.c << EOI
27 int b() { return 1; }
28 EOI
30 # build
31 compile_lib -o libb.so libb.c
34 # create program
35 cat > program.c << EOI
36 #include <dlfcn.h>
37 #include <stdio.h>
38 #include <stdlib.h>
40 int
41 main()
43 void* liba;
44 int (*a)();
46 liba = dlopen("./liba.so", RTLD_NOW | RTLD_GLOBAL);
47 if (liba == NULL) {
48 fprintf(stderr, "Error opening liba.so: %s\n", dlerror());
49 exit(117);
52 a = (int (*)())dlsym(liba, "a");
53 if (a == NULL) {
54 fprintf(stderr, "Error getting symbol a: %s\n", dlerror());
55 exit(116);
58 return a();
60 EOI
62 # build
63 compile_program_dl -o program program.c ./libb.so
65 # run
66 test_run_ok ./program 1