add wrapasm: i386 tracer using tail call from asm
authorSzabolcs Nagy <nsz@port70.net>
Wed, 15 Jan 2014 01:50:47 +0000 (02:50 +0100)
committerSzabolcs Nagy <nsz@port70.net>
Wed, 15 Jan 2014 01:50:47 +0000 (02:50 +0100)
Makefile
funcnames [new file with mode: 0644]
genasm.sh [new file with mode: 0755]
wrap_help.c [new file with mode: 0644]

index a78a1ff..0e1313b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,14 +2,19 @@ CFLAGS=-std=c99 -Os -g
 #CFLAGS+=-fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables
 LDFLAGS=-g
 CC=musl-gcc
-all: wrap.so hello stress
+all: wrap.so hello stress wrapasm.so
 hello: hello.o
 stress: stress.o
 wrap.o: head.h func.h
 wrap.so: wrap.o
-       $(CC) $(LDFLAGS) -shared -o $@ $< -ldl -lm -lrt -lcrypt
+       $(CC) $(LDFLAGS) -shared -o $@ $< -ldl -lm -lrt -lpthread -lutil -lcrypt
+func.s: funcnames
+       ./genasm.sh <$< >$@
+func.o: func.s
+wrapasm.so: func.o wrap_help.o
+       $(CC) $(LDFLAGS) -shared -o $@ $^ -ldl -lm -lrt -lpthread -lutil -lcrypt
 clean:
-       rm -f wrap.so hello stress *.o
+       rm -f wrap.so hello stress *.o wrapasm.so
 test: all
        LD_PRELOAD=./wrap.so ./hello
        LD_PRELOAD=./wrap.so ./stress 2>&1 |wc -l
diff --git a/funcnames b/funcnames
new file mode 100644 (file)
index 0000000..02b42d7
--- /dev/null
+++ b/funcnames
@@ -0,0 +1,1701 @@
+_Exit
+_IO_getc
+_IO_getc_unlocked
+_IO_putc
+_IO_putc_unlocked
+_IO_feof_unlocked
+_IO_ferror_unlocked
+__acquire_ptc
+__aio_wake
+__asctime
+__assert_fail
+__block_all_sigs
+__block_app_sigs
+__brk
+__cachectl
+__cancel
+__clock_gettime
+__clone
+__copy_tls
+__cos
+__cosdf
+__cosl
+__crypt_blowfish
+__crypt_des
+__crypt_md5
+__crypt_r
+__crypt_sha256
+__crypt_sha512
+__ctype_b_loc
+__ctype_get_mb_cur_max
+__ctype_tolower_loc
+__ctype_toupper_loc
+__cxa_atexit
+__cxa_finalize
+__dladdr
+__dlinfo
+__dlsym
+__dn_comp
+__dn_expand
+__dns_count_addrs
+__dns_doqueries
+__dns_get_rr
+__dns_query
+__do_cleanup_pop
+__do_cleanup_push
+__dup3
+__duplocale
+__dynlink
+__errno_location
+__execvpe
+__expo2
+__expo2f
+__fbufsize
+__fclose_ca
+__fdopen
+__fesetround
+__fgetwc_unlocked
+__flbf
+__floatscan
+__flush_on_exit
+__fmodeflags
+__fopen_rb_ca
+__fork_handler
+__fpclassify
+__fpclassifyf
+__fpclassifyl
+__fpending
+__fpurge
+__fputwc_unlocked
+__freadable
+__freadahead
+__freading
+__freadptr
+__freadptrinc
+__freelocale
+__fseeko
+__fseeko_unlocked
+__fseterr
+__fsetlocking
+__fstatfs
+__ftello
+__ftello_unlocked
+__funcs_on_exit
+__funcs_on_quick_exit
+__futex
+__fwritable
+__fwritex
+__fwriting
+__fxstat
+__fxstat64
+__fxstatat
+__fxstatat64
+__get_handler_set
+__getdelim
+__getdents
+__getgrent_a
+__getpwent_a
+__gmtime_r
+__h_errno_location
+__inhibit_ptc
+__init_libc
+__init_security
+__init_ssp
+__init_tls
+__install_initial_tls
+__intscan
+__invtrigl_R
+__ipparse
+__isoc99_fscanf
+__isoc99_fwscanf
+__isoc99_scanf
+__isoc99_sscanf
+__isoc99_swscanf
+__isoc99_vfscanf
+__isoc99_vfwscanf
+__isoc99_vscanf
+__isoc99_vsscanf
+__isoc99_vswscanf
+__isoc99_vwscanf
+__isoc99_wscanf
+__iswctype_l
+__ldexp_cexp
+__ldexp_cexpf
+__lgamma_r
+__lgammaf_r
+__lgammal_r
+__libc_current_sigrtmax
+__libc_current_sigrtmin
+__libc_get_version
+__libc_loc
+__libc_sigaction
+__libc_start_main
+__localtime_r
+__lock
+__lockfile
+__longjmp
+__lxstat
+__lxstat64
+__madvise
+__map_file
+__memalign
+__memrchr
+__mkostemps
+__mmap
+__month_to_secs
+__mremap
+__munmap
+__newlocale
+__nl_langinfo
+__nl_langinfo_l
+__overflow
+__p1evll
+__parsespent
+__polevll
+__posix_getopt
+__posix_spawnx
+__procfdname
+__pthread_self_def
+__pthread_self_init
+__pthread_tsd_run_dtors
+__ptsname_r
+__putenv
+__rand48_step
+__randname
+__release_ptc
+__rem_pio2
+__rem_pio2_large
+__rem_pio2f
+__rem_pio2l
+__res_state
+__reset_tls
+__restore
+__restore_rt
+__restore_sigs
+__sched_cpucount
+__secs_to_tm
+__secs_to_zone
+__seek_on_exit
+__set_thread_area
+__setjmp
+__setrlimit
+__setxid
+__shgetc
+__shlim
+__shm_mapname
+__sigaction
+__signbit
+__signbitf
+__signbitl
+__simple_malloc
+__sin
+__sindf
+__sinl
+__stack_chk_fail
+__statfs
+__stdio_close
+__stdio_exit
+__stdio_read
+__stdio_seek
+__stdio_write
+__stdout_write
+__stpcpy
+__stpncpy
+__strchrnul
+__strcoll_l
+__strdup
+__strftime_fmt_1
+__strftime_l
+__string_read
+__strtod_l
+__strtof_l
+__strtoimax_internal
+__strtol_internal
+__strtold_l
+__strtoll_internal
+__strtoul_internal
+__strtoull_internal
+__strtoumax_internal
+__strxfrm_l
+__synccall
+__syscall
+__syscall_cp
+__syscall_cp_asm
+__syscall_ret
+__tan
+__tandf
+__tanl
+__testcancel
+__timedwait
+__tls_get_addr
+__tm_to_secs
+__tm_to_tzname
+__toread
+__towlower_l
+__towupper_l
+__towrite
+__tzset
+__uflow
+__unlock
+__unlockfile
+__unmapself
+__uselocale
+__vdso_clock_gettime
+__vfork
+__vm_lock
+__vm_lock_impl
+__vm_unlock
+__vm_unlock_impl
+__vsyslog
+__wait
+__wcscoll_l
+__wcsftime_l
+__wcsxfrm_l
+__wctype_l
+__xpg_basename
+__xpg_strerror_r
+__xstat
+__xstat64
+__year_to_secs
+__yield
+_dl_debug_state
+_exit
+_flush_cache
+_flushlbf
+_longjmp
+_pthread_cleanup_pop
+_pthread_cleanup_push
+_setjmp
+_start
+a64l
+abort
+abs
+accept
+accept4
+access
+acct
+acos
+acosf
+acosh
+acoshf
+acoshl
+acosl
+addmntent
+adjtime
+adjtimex
+aio_cancel
+aio_error
+aio_fsync
+aio_read
+aio_return
+aio_suspend
+aio_write
+alarm
+aligned_alloc
+alphasort
+alphasort64
+arch_prctl
+asctime
+asctime_r
+asin
+asinf
+asinh
+asinhf
+asinhl
+asinl
+asprintf
+at_quick_exit
+atan
+atan2
+atan2f
+atan2l
+atanf
+atanh
+atanhf
+atanhl
+atanl
+atexit
+atof
+atoi
+atol
+atoll
+basename
+bcmp
+bcopy
+bind
+bind_textdomain_codeset
+bindtextdomain
+brk
+bsd_signal
+bsearch
+btowc
+bzero
+cabs
+cabsf
+cabsl
+cachectl
+cacheflush
+cacos
+cacosf
+cacosh
+cacoshf
+cacoshl
+cacosl
+calloc
+capget
+capset
+carg
+cargf
+cargl
+casin
+casinf
+casinh
+casinhf
+casinhl
+casinl
+catan
+catanf
+catanh
+catanhf
+catanhl
+catanl
+catclose
+catgets
+catopen
+cbrt
+cbrtf
+cbrtl
+ccos
+ccosf
+ccosh
+ccoshf
+ccoshl
+ccosl
+ceil
+ceilf
+ceill
+cexp
+cexpf
+cexpl
+cfgetispeed
+cfgetospeed
+cfmakeraw
+cfsetispeed
+cfsetospeed
+cfsetspeed
+chdir
+chmod
+chown
+chroot
+cimag
+cimagf
+cimagl
+clearenv
+clearerr
+clearerr_unlocked
+clock
+clock_adjtime
+clock_getcpuclockid
+clock_getres
+clock_gettime
+clock_nanosleep
+clock_settime
+clog
+clogf
+clogl
+clone
+close
+closedir
+closelog
+confstr
+conj
+conjf
+conjl
+connect
+copysign
+copysignf
+copysignl
+cos
+cosf
+cosh
+coshf
+coshl
+cosl
+cpow
+cpowf
+cpowl
+cproj
+cprojf
+cprojl
+creal
+crealf
+creall
+creat
+creat64
+crypt
+crypt_r
+csin
+csinf
+csinh
+csinhf
+csinhl
+csinl
+csqrt
+csqrtf
+csqrtl
+ctan
+ctanf
+ctanh
+ctanhf
+ctanhl
+ctanl
+ctermid
+ctime
+ctime_r
+cuserid
+daemon
+dcgettext
+dcngettext
+delete_module
+dgettext
+difftime
+dirfd
+dirname
+div
+dl_iterate_phdr
+dladdr
+dlclose
+dlerror
+dlinfo
+dlopen
+dlsym
+dn_comp
+dn_expand
+dn_skipname
+dngettext
+dprintf
+drand48
+drem
+dremf
+dup
+dup2
+dup3
+duplocale
+eaccess
+ecvt
+endgrent
+endhostent
+endmntent
+endnetent
+endprotoent
+endpwent
+endservent
+endspent
+endusershell
+endutxent
+endutent
+epoll_create
+epoll_create1
+epoll_ctl
+epoll_pwait
+epoll_wait
+erand48
+erf
+erfc
+erfcf
+erfcl
+erff
+erfl
+err
+errx
+ether_aton
+ether_aton_r
+ether_hostton
+ether_line
+ether_ntoa
+ether_ntoa_r
+ether_ntohost
+euidaccess
+eventfd
+eventfd_read
+eventfd_write
+execl
+execle
+execlp
+execv
+execve
+execvp
+exit
+exp
+exp10
+exp10f
+exp10l
+exp2
+exp2f
+exp2l
+expf
+expl
+expm1
+expm1f
+expm1l
+fabs
+fabsf
+fabsl
+faccessat
+fallocate
+fanotify_init
+fanotify_mark
+fchdir
+fchmod
+fchmodat
+fchown
+fchownat
+fclose
+fcntl
+fcvt
+fdatasync
+fdim
+fdimf
+fdiml
+fdopen
+fdopendir
+feclearexcept
+fegetenv
+fegetexceptflag
+fegetround
+feholdexcept
+feof
+feof_unlocked
+feraiseexcept
+ferror
+ferror_unlocked
+fesetenv
+fesetexceptflag
+fesetround
+fetestexcept
+feupdateenv
+fexecve
+fflush
+fflush_unlocked
+ffs
+fgetc
+fgetc_unlocked
+fgetwc_unlocked
+fgetgrent
+fgetln
+fgetpos
+fgetpos64
+fgetpwent
+fgets
+fgets_unlocked
+fgetspent
+fgetwc
+fgetws
+fgetws_unlocked
+fgetxattr
+fileno
+fileno_unlocked
+finite
+finitef
+flistxattr
+flock
+flockfile
+floor
+floorf
+floorl
+fma
+fmaf
+fmal
+fmax
+fmaxf
+fmaxl
+fmemopen
+fmin
+fminf
+fminl
+fmod
+fmodf
+fmodl
+fnmatch
+fopen
+fopen64
+fork
+forkpty
+fpathconf
+fprintf
+fpurge
+fputc
+fputc_unlocked
+fputwc_unlocked
+fputs
+fputs_unlocked
+fputwc
+fputws
+fputws_unlocked
+fread
+fread_unlocked
+free
+freeaddrinfo
+freeifaddrs
+freelocale
+fremovexattr
+freopen
+freopen64
+frexp
+frexpf
+frexpl
+fscanf
+fseek
+fseeko
+fseeko64
+fsetpos
+fsetpos64
+fsetxattr
+fstat
+fstat64
+fstatat
+fstatat64
+fstatfs
+fstatfs64
+fstatvfs
+fstatvfs64
+fsync
+ftell
+ftello
+ftello64
+ftime
+ftok
+ftruncate
+ftruncate64
+ftrylockfile
+ftw
+ftw64
+funlockfile
+futimens
+futimes
+futimesat
+fwide
+fwprintf
+fwrite
+fwrite_unlocked
+fwscanf
+gai_strerror
+gcvt
+get_current_dir_name
+getaddrinfo
+getc
+getc_unlocked
+getchar
+getchar_unlocked
+getcwd
+getdate
+getdelim
+getdents
+getdents64
+getdomainname
+getdtablesize
+getegid
+getenv
+geteuid
+getgid
+getgrent
+getgrgid
+getgrgid_r
+getgrnam
+getgrnam_r
+getgrouplist
+getgroups
+gethostbyaddr
+gethostbyaddr_r
+gethostbyname
+gethostbyname2
+gethostbyname2_r
+gethostbyname_r
+gethostent
+gethostid
+gethostname
+getifaddrs
+getitimer
+getline
+getloadavg
+getlogin
+getlogin_r
+getmntent
+getmntent_r
+getnameinfo
+getnetent
+getnetbyaddr
+getnetbyname
+getopt
+getopt_long
+getopt_long_only
+getpagesize
+getpass
+getpeername
+getpgid
+getpgrp
+getpid
+getppid
+getpriority
+getprotobyname
+getprotobynumber
+getprotoent
+getpwent
+getpwnam
+getpwnam_r
+getpwuid
+getpwuid_r
+getresgid
+getresuid
+getrlimit
+getrlimit64
+getrusage
+gets
+getservbyname
+getservbyname_r
+getservbyport
+getservbyport_r
+getservent
+getsid
+getsockname
+getsockopt
+getspent
+getspnam
+getspnam_r
+getsubopt
+gettext
+gettimeofday
+getuid
+getusershell
+getutent
+getutid
+getutline
+getutxent
+getutxid
+getutxline
+getw
+getwc
+getwc_unlocked
+getwchar
+getwchar_unlocked
+getxattr
+glob
+glob64
+globfree
+globfree64
+gmtime
+gmtime_r
+grantpt
+hasmntopt
+hcreate
+hdestroy
+herror
+hsearch
+hstrerror
+htonl
+htons
+hypot
+hypotf
+hypotl
+iconv
+iconv_close
+iconv_open
+if_freenameindex
+if_indextoname
+if_nameindex
+if_nametoindex
+ilogb
+ilogbf
+ilogbl
+imaxabs
+imaxdiv
+index
+inet_addr
+inet_aton
+inet_lnaof
+inet_makeaddr
+inet_netof
+inet_network
+inet_ntoa
+inet_ntop
+inet_pton
+init_module
+initgroups
+initstate
+inotify_add_watch
+inotify_init
+inotify_init1
+inotify_rm_watch
+insque
+ioctl
+ioperm
+iopl
+isalnum
+isalnum_l
+isalpha
+isalpha_l
+isascii
+isastream
+isatty
+isblank
+isblank_l
+iscntrl
+iscntrl_l
+isdigit
+isdigit_l
+isgraph
+isgraph_l
+islower
+islower_l
+isprint
+isprint_l
+ispunct
+ispunct_l
+isspace
+isspace_l
+isupper
+isupper_l
+iswalnum
+iswalnum_l
+iswalpha
+iswalpha_l
+iswblank
+iswblank_l
+iswcntrl
+iswcntrl_l
+iswctype
+iswctype_l
+iswdigit
+iswdigit_l
+iswgraph
+iswgraph_l
+iswlower
+iswlower_l
+iswprint
+iswprint_l
+iswpunct
+iswpunct_l
+iswspace
+iswspace_l
+iswupper
+iswupper_l
+iswxdigit
+iswxdigit_l
+isxdigit
+isxdigit_l
+j0
+j0f
+j1
+j1f
+jn
+jnf
+jrand48
+kill
+killpg
+klogctl
+l64a
+labs
+lchmod
+lchown
+lckpwdf
+lcong48
+ldexp
+ldexpf
+ldexpl
+ldiv
+lfind
+lgamma
+lgamma_r
+lgammaf_r
+lgammal_r
+lgammaf
+lgammal
+lgetxattr
+link
+linkat
+lio_listio
+listen
+listxattr
+llabs
+lldiv
+llistxattr
+llrint
+llrintf
+llrintl
+llround
+llroundf
+llroundl
+localeconv
+localtime
+localtime_r
+lockf
+lockf64
+log
+log10
+log10f
+log10l
+log1p
+log1pf
+log1pl
+log2
+log2f
+log2l
+logb
+logbf
+logbl
+logf
+logl
+longjmp
+lrand48
+lremovexattr
+lrint
+lrintf
+lrintl
+lround
+lroundf
+lroundl
+lsearch
+lseek
+lseek64
+lsetxattr
+lstat
+lstat64
+lutimes
+madvise
+malloc
+mblen
+mbrlen
+mbrtowc
+mbsinit
+mbsnrtowcs
+mbsrtowcs
+mbstowcs
+mbtowc
+memalign
+memccpy
+memchr
+memcmp
+memcpy
+memmem
+memmove
+mempcpy
+memrchr
+memset
+mincore
+mkdir
+mkdirat
+mkdtemp
+mkfifo
+mkfifoat
+mknod
+mknodat
+mkostemp
+mkostemp64
+mkostemps
+mkostemps64
+mkstemp
+mkstemp64
+mkstemps
+mkstemps64
+mktemp
+mktime
+mlock
+mlockall
+mmap
+mmap64
+modf
+modff
+modfl
+mount
+mprotect
+mq_close
+mq_getattr
+mq_notify
+mq_open
+mq_receive
+mq_send
+mq_setattr
+mq_timedreceive
+mq_timedsend
+mq_unlink
+mrand48
+mremap
+msgctl
+msgget
+msgrcv
+msgsnd
+msync
+munlock
+munlockall
+munmap
+nan
+nanf
+nanl
+nanosleep
+nearbyint
+nearbyintf
+nearbyintl
+newlocale
+nextafter
+nextafterf
+nextafterl
+nexttoward
+nexttowardf
+nexttowardl
+nftw
+nftw64
+ngettext
+nice
+nl_langinfo
+nl_langinfo_l
+nrand48
+ntohl
+ntohs
+open
+open64
+open_memstream
+open_wmemstream
+openat
+openat64
+opendir
+openlog
+openpty
+pathconf
+pause
+pclose
+perror
+personality
+pipe
+pipe2
+pivot_root
+poll
+popen
+posix_close
+posix_fadvise
+posix_fallocate
+posix_madvise
+posix_memalign
+posix_openpt
+posix_spawn
+posix_spawn_file_actions_addclose
+posix_spawn_file_actions_adddup2
+posix_spawn_file_actions_addopen
+posix_spawn_file_actions_destroy
+posix_spawn_file_actions_init
+posix_spawnattr_destroy
+posix_spawnattr_getflags
+posix_spawnattr_getpgroup
+posix_spawnattr_getschedparam
+posix_spawnattr_getschedpolicy
+posix_spawnattr_getsigdefault
+posix_spawnattr_getsigmask
+posix_spawnattr_init
+posix_spawnattr_setflags
+posix_spawnattr_setpgroup
+posix_spawnattr_setschedparam
+posix_spawnattr_setschedpolicy
+posix_spawnattr_setsigdefault
+posix_spawnattr_setsigmask
+posix_spawnp
+pow
+pow10
+pow10f
+pow10l
+powf
+powl
+ppoll
+prctl
+pread
+pread64
+preadv
+preadv64
+printf
+prlimit
+prlimit64
+process_vm_readv
+process_vm_writev
+pselect
+psiginfo
+psignal
+pthread_atfork
+pthread_attr_destroy
+pthread_attr_getdetachstate
+pthread_attr_getguardsize
+pthread_attr_getinheritsched
+pthread_attr_getschedparam
+pthread_attr_getschedpolicy
+pthread_attr_getscope
+pthread_attr_getstack
+pthread_attr_getstacksize
+pthread_attr_init
+pthread_attr_setdetachstate
+pthread_attr_setguardsize
+pthread_attr_setinheritsched
+pthread_attr_setschedparam
+pthread_attr_setschedpolicy
+pthread_attr_setscope
+pthread_attr_setstack
+pthread_attr_setstacksize
+pthread_barrier_destroy
+pthread_barrier_init
+pthread_barrier_wait
+pthread_barrierattr_destroy
+pthread_barrierattr_getpshared
+pthread_barrierattr_init
+pthread_barrierattr_setpshared
+pthread_cancel
+pthread_cond_broadcast
+pthread_cond_destroy
+pthread_cond_init
+pthread_cond_signal
+pthread_cond_timedwait
+pthread_cond_wait
+pthread_condattr_destroy
+pthread_condattr_getclock
+pthread_condattr_getpshared
+pthread_condattr_init
+pthread_condattr_setclock
+pthread_condattr_setpshared
+pthread_create
+pthread_detach
+pthread_equal
+pthread_exit
+pthread_getaffinity_np
+pthread_getattr_np
+pthread_getconcurrency
+pthread_getcpuclockid
+pthread_getschedparam
+pthread_getspecific
+pthread_join
+pthread_key_create
+pthread_key_delete
+pthread_kill
+pthread_mutex_consistent
+pthread_mutex_destroy
+pthread_mutex_getprioceiling
+pthread_mutex_init
+pthread_mutex_lock
+pthread_mutex_setprioceiling
+pthread_mutex_timedlock
+pthread_mutex_trylock
+pthread_mutex_unlock
+pthread_mutexattr_destroy
+pthread_mutexattr_getprotocol
+pthread_mutexattr_getpshared
+pthread_mutexattr_getrobust
+pthread_mutexattr_gettype
+pthread_mutexattr_init
+pthread_mutexattr_setprotocol
+pthread_mutexattr_setpshared
+pthread_mutexattr_setrobust
+pthread_mutexattr_settype
+pthread_once
+pthread_rwlock_destroy
+pthread_rwlock_init
+pthread_rwlock_rdlock
+pthread_rwlock_timedrdlock
+pthread_rwlock_timedwrlock
+pthread_rwlock_tryrdlock
+pthread_rwlock_trywrlock
+pthread_rwlock_unlock
+pthread_rwlock_wrlock
+pthread_rwlockattr_destroy
+pthread_rwlockattr_getpshared
+pthread_rwlockattr_init
+pthread_rwlockattr_setpshared
+pthread_self
+pthread_setaffinity_np
+pthread_setcancelstate
+pthread_setcanceltype
+pthread_setconcurrency
+pthread_setschedparam
+pthread_setschedprio
+pthread_setspecific
+pthread_sigmask
+pthread_spin_destroy
+pthread_spin_init
+pthread_spin_lock
+pthread_spin_trylock
+pthread_spin_unlock
+pthread_testcancel
+ptrace
+ptsname
+ptsname_r
+putc
+putc_unlocked
+putchar
+putchar_unlocked
+putenv
+putgrent
+putpwent
+puts
+putspent
+pututline
+pututxline
+putw
+putwc
+putwc_unlocked
+putwchar
+putwchar_unlocked
+pwrite
+pwrite64
+pwritev
+pwritev64
+qsort
+quick_exit
+quotactl
+raise
+rand
+rand_r
+random
+read
+readahead
+readdir
+readdir64
+readdir_r
+readdir64_r
+readlink
+readlinkat
+readv
+realloc
+realpath
+reboot
+recv
+recvfrom
+recvmsg
+regcomp
+regerror
+regexec
+regfree
+remainder
+remainderf
+remainderl
+remap_file_pages
+remove
+removexattr
+remque
+remquo
+remquof
+remquol
+rename
+renameat
+res_init
+res_query
+res_search
+rewind
+rewinddir
+rindex
+rint
+rintf
+rintl
+rmdir
+round
+roundf
+roundl
+sbrk
+scalb
+scalbf
+scalbln
+scalblnf
+scalblnl
+scalbn
+scalbnf
+scalbnl
+scandir
+scandir64
+scanf
+sched_get_priority_max
+sched_get_priority_min
+sched_getaffinity
+sched_getparam
+sched_getscheduler
+sched_rr_get_interval
+sched_setaffinity
+sched_setparam
+sched_setscheduler
+sched_yield
+seed48
+seekdir
+select
+sem_close
+sem_destroy
+sem_getvalue
+sem_init
+sem_open
+sem_post
+sem_timedwait
+sem_trywait
+sem_unlink
+sem_wait
+semctl
+semget
+semop
+semtimedop
+send
+sendfile
+sendfile64
+sendmsg
+sendto
+setbuf
+setbuffer
+setdomainname
+setegid
+setenv
+seteuid
+setfsgid
+setfsuid
+setgid
+setgrent
+setgroups
+sethostent
+sethostname
+setitimer
+setjmp
+setlinebuf
+setlocale
+setlogmask
+setmntent
+setnetent
+setns
+setpgid
+setpgrp
+setpriority
+setprotoent
+setpwent
+setregid
+setresgid
+setresuid
+setreuid
+setrlimit
+setrlimit64
+setservent
+setsid
+setsockopt
+setspent
+setstate
+settimeofday
+setuid
+setusershell
+setutent
+setutxent
+setvbuf
+setxattr
+shm_open
+shm_unlink
+shmat
+shmctl
+shmdt
+shmget
+shutdown
+sigaction
+sigaddset
+sigaltstack
+sigandset
+sigdelset
+sigemptyset
+sigfillset
+sighold
+sigignore
+siginterrupt
+sigisemptyset
+sigismember
+siglongjmp
+signal
+signalfd
+significand
+significandf
+sigorset
+sigpause
+sigpending
+sigprocmask
+sigqueue
+sigrelse
+sigset
+sigsetjmp
+sigsuspend
+sigtimedwait
+sigwait
+sigwaitinfo
+sin
+sincos
+sincosf
+sincosl
+sinf
+sinh
+sinhf
+sinhl
+sinl
+sleep
+snprintf
+sockatmark
+socket
+socketpair
+splice
+sprintf
+sqrt
+sqrtf
+sqrtl
+srand
+srand48
+srandom
+sscanf
+stat
+stat64
+statfs
+statfs64
+statvfs
+statvfs64
+stime
+stpcpy
+stpncpy
+strcasecmp
+strcasecmp_l
+strcasestr
+strcat
+strchr
+strchrnul
+strcmp
+strcoll
+strcoll_l
+strcpy
+strcspn
+strdup
+strerror
+strerror_l
+strerror_r
+strfmon
+strfmon_l
+strftime
+strftime_l
+strlcat
+strlcpy
+strlen
+strncasecmp
+strncasecmp_l
+strncat
+strncmp
+strncpy
+strndup
+strnlen
+strpbrk
+strptime
+strrchr
+strsep
+strsignal
+strspn
+strstr
+strtod
+strtod_l
+strtof
+strtof_l
+strtoimax
+strtok
+strtok_r
+strtol
+strtold
+strtold_l
+strtoll
+strtoul
+strtoull
+strtoumax
+strverscmp
+strxfrm
+strxfrm_l
+swab
+swapoff
+swapon
+swprintf
+swscanf
+symlink
+symlinkat
+sync
+sync_file_range
+syncfs
+syscall
+sysconf
+sysinfo
+syslog
+system
+tan
+tanf
+tanh
+tanhf
+tanhl
+tanl
+tcdrain
+tcflow
+tcflush
+tcgetattr
+tcgetpgrp
+tcgetsid
+tcsendbreak
+tcsetattr
+tcsetpgrp
+tdelete
+tdestroy
+tee
+telldir
+tempnam
+textdomain
+tfind
+tgamma
+tgammaf
+tgammal
+time
+timegm
+timer_create
+timer_delete
+timer_getoverrun
+timer_gettime
+timer_settime
+timerfd_create
+timerfd_gettime
+timerfd_settime
+times
+tmpfile
+tmpfile64
+tmpnam
+toascii
+tolower
+tolower_l
+toupper
+toupper_l
+towctrans
+towctrans_l
+towlower
+towlower_l
+towupper
+towupper_l
+__tre_mem_alloc_impl
+__tre_mem_destroy
+__tre_mem_new_impl
+trunc
+truncate
+truncate64
+truncf
+truncl
+tsearch
+ttyname
+ttyname_r
+twalk
+tzset
+ualarm
+ulckpwdf
+ulimit
+umask
+umount
+umount2
+uname
+ungetc
+ungetwc
+unlink
+unlinkat
+unlockpt
+unsetenv
+unshare
+updwtmp
+updwtmpx
+uselocale
+usleep
+utime
+utimensat
+utimes
+valloc
+vasprintf
+vdprintf
+verr
+verrx
+versionsort
+vfork
+vfprintf
+vfscanf
+vfwprintf
+vfwscanf
+vhangup
+vmsplice
+vprintf
+vscanf
+vsnprintf
+vsprintf
+vsscanf
+vswprintf
+vswscanf
+vsyslog
+vwarn
+vwarnx
+vwprintf
+vwscanf
+wait
+wait3
+wait4
+waitid
+waitpid
+warn
+warnx
+wcpcpy
+wcpncpy
+wcrtomb
+wcscasecmp
+wcscasecmp_l
+wcscat
+wcschr
+wcscmp
+wcscoll
+wcscoll_l
+wcscpy
+wcscspn
+wcsdup
+wcsftime
+wcsftime_l
+wcslen
+wcsncasecmp
+wcsncasecmp_l
+wcsncat
+wcsncmp
+wcsncpy
+wcsnlen
+wcsnrtombs
+wcspbrk
+wcsrchr
+wcsrtombs
+wcsspn
+wcsstr
+wcstod
+wcstof
+wcstoimax
+wcstok
+wcstol
+wcstold
+wcstoll
+wcstombs
+wcstoul
+wcstoull
+wcstoumax
+wcswcs
+wcswidth
+wcsxfrm
+wcsxfrm_l
+wctob
+wctomb
+wctrans
+wctrans_l
+wctype
+wctype_l
+wcwidth
+wmemchr
+wmemcmp
+wmemcpy
+wmemmove
+wmemset
+wordexp
+wordfree
+wprintf
+write
+writev
+wscanf
+y0
+y0f
+y1
+y1f
+yn
+ynf
diff --git a/genasm.sh b/genasm.sh
new file mode 100755 (executable)
index 0000000..95112e1
--- /dev/null
+++ b/genasm.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+awk '
+/dlsym/ {next}
+/__syscall/ {next}
+{
+       a[++n] = $1
+       print ".global " $1
+       print ".type " $1 ",@function"
+       print $1 ":"
+       print " pushl $sym_" $1
+       print " call wrap_help"
+       print " pop %ecx"
+       print " jmp *%eax"
+}
+END{
+       print ".section .rodata"
+       for (i=1;i<=n;i++) {
+               print "sym_" a[i] ":"
+               print " .string \"" a[i] "\""
+       }
+}'
diff --git a/wrap_help.c b/wrap_help.c
new file mode 100644 (file)
index 0000000..e2a80fd
--- /dev/null
@@ -0,0 +1,18 @@
+#define _GNU_SOURCE
+#include <dlfcn.h>
+#include <sys/uio.h>
+#include <sys/syscall.h>
+
+long __syscall(long,...);
+
+static char *end(char *s) {while(*s) s++; return s;}
+
+void *wrap_help(char *s)
+{
+       struct iovec iov[2] = {
+               { .iov_base = s, .iov_len = end(s)-s },
+               { .iov_base = "\n", .iov_len = 1 }
+       };
+       __syscall(SYS_writev, 2, iov, 2);
+       return dlsym(RTLD_NEXT, s);
+}