run script should use the loader
[ldtrace] / wrap_help.c
1 #define _GNU_SOURCE
2 #include <dlfcn.h>
3 #include <sys/uio.h>
4 #include <sys/syscall.h>
5
6 long __syscall(long,...);
7
8 static char *end(char *s) {while(*s) s++; return s;}
9
10 void *wrap_help(char *s)
11 {
12         struct iovec iov[2] = {
13                 { .iov_base = s, .iov_len = end(s)-s },
14                 { .iov_base = "\n", .iov_len = 1 }
15         };
16         __syscall(SYS_writev, 2, iov, 2);
17         return dlsym(RTLD_NEXT, s);
18 }