diff --git a/criu/arch/x86/restorer_unmap.S b/criu/arch/x86/restorer_unmap.S new file mode 100644 index 000000000..09c4c9583 --- /dev/null +++ b/criu/arch/x86/restorer_unmap.S @@ -0,0 +1,12 @@ +#include "common/asm/linkage.h" +#include "compel/plugins/std/syscall-codes.h" + + .text +ENTRY(__export_unmap_compat) + .code32 + mov bootstrap_start, %ebx + mov bootstrap_len, %ecx + movl $__NR32_munmap, %eax + int $0x80 + int $0x03 /* Guard */ + .code64 diff --git a/criu/pie/Makefile b/criu/pie/Makefile index 6a4fba9c1..73d95d5f1 100644 --- a/criu/pie/Makefile +++ b/criu/pie/Makefile @@ -25,6 +25,7 @@ restorer-obj-y += ./$(ARCH_DIR)/restorer.o ifeq ($(ARCH),x86) ifeq ($(CONFIG_COMPAT),y) restorer-obj-y += ./$(ARCH_DIR)/call32.o + restorer-obj-y += ./$(ARCH_DIR)/restorer_unmap.o restorer-obj-y += ./$(ARCH_DIR)/sigaction_compat_pie.o endif endif diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c index a106f79d4..807388743 100644 --- a/criu/pie/restorer.c +++ b/criu/pie/restorer.c @@ -929,35 +929,14 @@ static unsigned long vdso_rt_size; #define vdso_rt_size (0) #endif -static void *bootstrap_start; -static unsigned int bootstrap_len; +void *bootstrap_start = NULL; +unsigned int bootstrap_len = 0; void __export_unmap(void) { sys_munmap(bootstrap_start, bootstrap_len - vdso_rt_size); } -#ifdef CONFIG_X86_64 -asm ( - " .pushsection .text\n" - " .global __export_unmap_compat\n" - "__export_unmap_compat:\n" - " .code32\n" - " mov bootstrap_start, %ebx\n" - " mov bootstrap_len, %ecx\n" - " sub vdso_rt_size, %ecx\n" - " movl $"__stringify(__NR32_munmap)", %eax\n" - " int $0x80\n" - " .code64\n" - " .popsection\n" -); -extern char __export_unmap_compat; -#else -void __export_unmap_compat(void) -{ -} -#endif - /* * This function unmaps all VMAs, which don't belong to * the restored process or the restorer.