diff --git a/Makefile.crtools b/Makefile.crtools index 9e648b58c..07eaf6734 100644 --- a/Makefile.crtools +++ b/Makefile.crtools @@ -47,6 +47,7 @@ obj-y += page-xfer.o obj-y += page-read.o obj-y += kerndat.o obj-y += stats.o +obj-y += arch/$(ARCH)/vdso.o ifneq ($(MAKECMDGOALS),clean) incdeps := y diff --git a/arch/arm/vdso-pie.c b/arch/arm/vdso-pie.c index c0d50f460..f379babcb 100644 --- a/arch/arm/vdso-pie.c +++ b/arch/arm/vdso-pie.c @@ -1,19 +1,5 @@ -#include -#include -#include -#include -#include -#include - #include -#include -#include -#include "asm/string.h" -#include "asm/types.h" - -#include "compiler.h" -#include "crtools.h" #include "vdso.h" #include "log.h" diff --git a/arch/arm/vdso.c b/arch/arm/vdso.c new file mode 100644 index 000000000..aafdc504b --- /dev/null +++ b/arch/arm/vdso.c @@ -0,0 +1,16 @@ +#include + +#include "vdso.h" +#include "log.h" + +#ifdef LOG_PREFIX +# undef LOG_PREFIX +#endif +#define LOG_PREFIX "vdso: " + +struct vdso_symtable vdso_sym_rt = VDSO_SYMTABLE_INIT; + +int vdso_init(void) +{ + return 0; +} diff --git a/arch/x86/vdso.c b/arch/x86/vdso.c new file mode 100644 index 000000000..ac26d5a21 --- /dev/null +++ b/arch/x86/vdso.c @@ -0,0 +1,71 @@ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "asm/types.h" + +#include "compiler.h" +#include "crtools.h" +#include "kerndat.h" +#include "vdso.h" +#include "log.h" +#include "mem.h" + +#ifdef LOG_PREFIX +# undef LOG_PREFIX +#endif +#define LOG_PREFIX "vdso: " + +struct vdso_symtable vdso_sym_rt = VDSO_SYMTABLE_INIT; + +static int vdso_fill_self_symtable(struct vdso_symtable *s) +{ + char buf[512]; + int ret = -1; + FILE *maps; + + VDSO_INIT_SYMTABLE(s); + + maps = fopen("/proc/self/maps", "r"); + if (!maps) { + pr_perror("Can't open self-vma"); + return -1; + } + + while (fgets(buf, sizeof(buf), maps)) { + unsigned long start, end; + + if (strstr(buf, "[vdso]") == NULL) + continue; + + ret = sscanf(buf, "%lx-%lx", &start, &end); + if (ret != 2) { + ret = -1; + pr_err("Can't find vDSO bounds\n"); + break; + } + + s->vma_start = start; + s->vma_end = end; + + ret = vdso_fill_symtable((void *)start, end - start, s); + break; + } + + fclose(maps); + return ret; +} + +int vdso_init(void) +{ + if (vdso_fill_self_symtable(&vdso_sym_rt)) + return -1; + return 0; +} diff --git a/cr-dump.c b/cr-dump.c index 59d66ec93..91e565cb1 100644 --- a/cr-dump.c +++ b/cr-dump.c @@ -62,6 +62,7 @@ #include "stats.h" #include "mem.h" #include "page-pipe.h" +#include "vdso.h" #include "asm/dump.h" @@ -1683,6 +1684,9 @@ int cr_dump_tasks(pid_t pid) if (cpu_init()) goto err; + if (vdso_init()) + goto err; + if (write_img_inventory()) goto err; diff --git a/cr-restore.c b/cr-restore.c index 301d97a0a..ef8ea2ad0 100644 --- a/cr-restore.c +++ b/cr-restore.c @@ -57,6 +57,7 @@ #include "file-lock.h" #include "page-read.h" #include "sysctl.h" +#include "vdso.h" #include "protobuf.h" #include "protobuf/sa.pb-c.h" @@ -1315,6 +1316,9 @@ int cr_restore_tasks(struct cr_options *opts) if (cpu_init() < 0) return -1; + if (vdso_init()) + return -1; + if (prepare_task_entries() < 0) return -1; diff --git a/include/vdso.h b/include/vdso.h index b4e5b837d..c2282b3d5 100644 --- a/include/vdso.h +++ b/include/vdso.h @@ -66,4 +66,7 @@ static inline unsigned long vdso_vma_size(struct vdso_symtable *t) return t->vma_end - t->vma_start; } +extern struct vdso_symtable vdso_sym_rt; +extern int vdso_init(void); + #endif /* __CR_VDSO_H__ */