From 2083a4cf70120df25c89803c76324f76b18d7711 Mon Sep 17 00:00:00 2001 From: Hajime Tazaki Date: Wed, 10 Jan 2018 18:38:05 +0900 Subject: [PATCH] avoid using vtable verification by configuring dl_open_hook Fixes #57. Signed-off-by: Hajime Tazaki --- model/libc-dce.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/model/libc-dce.cc b/model/libc-dce.cc index 796a4eaf..cb7e3dc4 100644 --- a/model/libc-dce.cc +++ b/model/libc-dce.cc @@ -144,8 +144,28 @@ extern void __stack_chk_fail (void); typedef void (*func_t)(...); +struct dl_open_hook +{ + void *(*dlopen_mode) (const char *name, int mode); + void *(*dlsym) (void *map, const char *name); + int (*dlclose) (void *map); +}; + +void *niu_dlopen (const char *name, int mode) +{ + return dlopen(name, RTLD_LAZY); +} + extern "C" { +static struct dl_open_hook dce_dl_open_hook = + { + .dlopen_mode = niu_dlopen, + .dlsym = dlsym, + .dlclose = dlclose + }; + + extern int __libc_start_main(int *(main) (int, char * *, char * *), int argc, char * * ubp_av, void (*init) (void), void (*fini) (void), void (*rtld_fini) (void), void (* stack_end)); void libc_dce (struct Libc **libc) @@ -168,6 +188,9 @@ void libc_dce (struct Libc **libc) (*libc)->strpbrk_fn = dce_strpbrk; (*libc)->strstr_fn = dce_strstr; (*libc)->vsnprintf_fn = dce_vsnprintf; + + extern struct dl_open_hook *_dl_open_hook; + _dl_open_hook = (struct dl_open_hook *)&dce_dl_open_hook; } } // extern "C"