[CRIU] [PATCH 06/20] criu/pie: drop second compat parasite

Dmitry Safonov dsafonov at virtuozzo.com
Fri Dec 2 11:53:30 PST 2016


Let's try having one with two entries/exits.

Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 .gitignore               |   2 +-
 criu/parasite-syscall.c  |  55 +++++++++++---------
 criu/pie/Makefile        | 133 ++++++++++++-----------------------------------
 criu/pie/parasite-blob.h |   5 --
 4 files changed, 64 insertions(+), 131 deletions(-)
 delete mode 100644 criu/pie/parasite-blob.h

diff --git a/.gitignore b/.gitignore
index 9193c6f140f0..1879db4632da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,7 +34,7 @@ criu/include/syscall-codes*.h
 criu/include/syscall*.h
 criu/include/version.h
 criu/pie/restorer-blob.h
-criu/pie/parasite-*-blob.h
+criu/pie/parasite-blob.h
 criu/pie/pie.lds*.S
 criu/protobuf-desc-gen.h
 lib/build/
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index f7a812f5ad76..be5e72e456e3 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -533,29 +533,41 @@ static int make_sigframe(void *arg, struct rt_sigframe *sf, struct rt_sigframe *
 }
 
 /* the parasite prefix is added by gen_offsets.sh */
-#define pblob_offset(ptype, symbol)					\
-	parasite_ ## ptype ## _blob_offset__ ## symbol
+#define pblob_offset(symbol) parasite_blob_offset__ ## symbol
 
 #ifdef CONFIG_PIEGEN
-#define init_blob_relocs(bdesc, blob_type)						\
-	do {										\
-		bdesc->hdr.relocs = parasite_##blob_type##_relocs;			\
-		bdesc->hdr.nr_relocs = ARRAY_SIZE(parasite_##blob_type##_relocs);	\
-	} while (0)
+static inline void init_blob_relocs(struct parasite_blob_desc *bdesc)
+{
+	bdesc->hdr.relocs = parasite_relocs;
+	bdesc->hdr.nr_relocs = ARRAY_SIZE(parasite_relocs);
+}
 #else
-#define init_blob_relocs(bdesc, blob_type)
+#define init_blob_relocs(bdesc)
 #endif
 
-#define init_blob_desc(bdesc, blob_type) do {						\
-	bdesc->hdr.mem = parasite_##blob_type##_blob;					\
-	bdesc->hdr.bsize = sizeof(parasite_##blob_type##_blob);				\
-	bdesc->hdr.nr_gotpcrel = pie_nr_gotpcrel(parasite_##blob_type);			\
-	/* Setup the rest of a control block */						\
-	bdesc->hdr.parasite_ip_off = pblob_offset(blob_type, __export_parasite_head_start);\
-	bdesc->hdr.addr_cmd_off    = pblob_offset(blob_type, __export_parasite_cmd);	\
-	bdesc->hdr.addr_arg_off    = pblob_offset(blob_type, __export_parasite_args);	\
-	init_blob_relocs(bdesc, blob_type);						\
-	} while (0)
+static void init_blob_desc(struct parasite_blob_desc *bdesc, bool native_entry)
+{
+	unsigned long parasite_entry_ip;
+
+	if (native_entry) {
+		parasite_entry_ip = pblob_offset(__export_parasite_head_start);
+	} else {
+#ifdef CONFIG_COMPAT
+		parasite_entry_ip = pblob_offset(__export_parasite_head_start_compat);
+#else
+		BUG();
+		parasite_entry_ip = 0; /* gcc uninitialize warning silencer */
+#endif
+	}
+
+	bdesc->hdr.mem = parasite_blob;
+	bdesc->hdr.bsize = sizeof(parasite_blob);
+	/* Setup the rest of a control block */
+	bdesc->hdr.parasite_ip_off = parasite_entry_ip;
+	bdesc->hdr.addr_cmd_off    = pblob_offset(__export_parasite_cmd);
+	bdesc->hdr.addr_arg_off    = pblob_offset(__export_parasite_args);
+	init_blob_relocs(bdesc);
+}
 
 struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 		struct vm_area_list *vma_area_list)
@@ -607,12 +619,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 	pbd = compel_parasite_blob_desc(ctl);
 	pbd->parasite_type = COMPEL_BLOB_CHEADER;
 
-	if (compel_mode_native(ctl))
-		init_blob_desc(pbd, native);
-#ifdef CONFIG_COMPAT
-	else
-		init_blob_desc(pbd, compat);
-#endif
+	init_blob_desc(pbd, compel_mode_native(ctl));
 
 	parasite_ensure_args_size(dump_pages_args_size(vma_area_list));
 	parasite_ensure_args_size(aio_rings_args_size(vma_area_list));
diff --git a/criu/pie/Makefile b/criu/pie/Makefile
index 9b14916c1290..555208a15a68 100644
--- a/criu/pie/Makefile
+++ b/criu/pie/Makefile
@@ -1,124 +1,66 @@
-# native/compat target names are _only_ for parasite
-# restorer is always native (64-bit)
-parasite_target		:= native
+target		+= parasite restorer
 
-ifeq ($(CONFIG_COMPAT),y)
-        parasite_target	+= compat
-endif
-
-compel_pack_lds-native	:= $(SRC_DIR)/compel/arch/$(ARCH)/scripts/compel-pack.lds.S
-compel_pack_lds-compat	:= $(SRC_DIR)/compel/arch/$(ARCH)/scripts/compel-pack-compat.lds.S
-compel_std-native	:= $(SRC_DIR)/compel/plugins/std.built-in.o
-compel_std-compat	:= $(SRC_DIR)/compel/plugins/std-compat.built-in.o
-
-native-obj-y           += parasite.o
-compat-obj-y           += compat/parasite-compat.o
+compel_lds	:= $(SRC_DIR)/compel/arch/$(ARCH)/scripts/compel-pack.lds.S
+compel_std	:= $(SRC_DIR)/compel/plugins/std.built-in.o
+parasite-obj-e	+= ./compel/plugins/std.built-in.o
+restorer-obj-e	+= ./compel/plugins/std.built-in.o
 
-restorer-obj-y		+= restorer.o
-restorer-obj-y		+= ./$(ARCH_DIR)/restorer.o
+parasite-obj-y	+= parasite.o
+restorer-obj-y	+= restorer.o
+restorer-obj-y	+= ./$(ARCH_DIR)/restorer.o
 
 ifeq ($(ARCH),x86)
-        restorer-obj-e		+= ./compel/plugins/std.built-in.o
-
         ifeq ($(CONFIG_COMPAT),y)
                 restorer-obj-y	+= ./$(ARCH_DIR)/call32.o
                 restorer-obj-y	+= ./$(ARCH_DIR)/sigaction_compat_pie.o
         endif
-
-        native-obj-e		+= ./compel/plugins/std.built-in.o
-        compat-obj-e		+= ./compel/plugins/std-compat.built-in.o
-else
-        native-obj-e		+= ./compel/plugins/std.built-in.o
-        restorer-obj-e		+= ./compel/plugins/std.built-in.o
 endif
 
-target			+= $(parasite_target) restorer
-
 #
 # We can't provide proper mount implementation
 # in parasite code -- it requires run-time rellocation
 # applications, which is not the target of the
 # project.
 #
-CFLAGS			:= $(filter-out -pg $(CFLAGS-GCOV),$(CFLAGS))
-CFLAGS			:= $(filter-out -DCONFIG_X86_64,$(CFLAGS))
-CFLAGS			+= -iquote $(SRC_DIR)/criu/arch/$(ARCH)/include
-CFLAGS			+= -iquote $(SRC_DIR)/criu/include
-CFLAGS			+= -iquote $(SRC_DIR)/include
-CFLAGS			+= -iquote $(SRC_DIR)
-
-ccflags-y		+= -I compel/include/uapi
-ccflags-y		+= -I compel/plugins/include/uapi
-ccflags-y		+= -DCR_NOGLIBC
-ccflags-y		+= -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
-ifneq ($(filter-out clean mrproper,$(MAKECMDGOALS)),)
-NATIVE_CFLAGS		:= $(shell $(SRC_DIR)/compel/compel-host --arch=$(ARCH) cflags)
-ifeq ($(ARCH),x86)
-        COMPAT_CFLAGS	:= $(shell $(SRC_DIR)/compel/compel-host --arch=ia32 cflags)
-endif
-endif
+CFLAGS		:= $(filter-out -pg $(CFLAGS-GCOV),$(CFLAGS))
+CFLAGS		+= -iquote $(SRC_DIR)/criu/arch/$(ARCH)/include
+CFLAGS		+= -iquote $(SRC_DIR)/criu/include
+CFLAGS		+= -iquote $(SRC_DIR)/include
+CFLAGS		+= -iquote $(SRC_DIR)
 
-ifeq ($(ARCH),x86)
-        NATIVE_CFLAGS	+= -DCONFIG_X86_64
-        COMPAT_CFLAGS	+= -m32 -DCONFIG_X86_32
-        COMPAT_LDFLAGS	+= -m elf_i386
-endif
+ccflags-y	+= -I compel/include/uapi
+ccflags-y	+= -I compel/plugins/include/uapi
+ccflags-y	+= -DCR_NOGLIBC
+ccflags-y	+= -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
 
-CFLAGS_restorer.o	+= $(NATIVE_CFLAGS)
-# $1 - object name
-define obj-export-native-flags
-        CFLAGS_$(notdir $(1))	:= $(NATIVE_CFLAGS)
-endef
-# $1 - object name
-define obj-export-compat-flags
-        CFLAGS_$(notdir $(1))	:= $(COMPAT_CFLAGS)
-        LDFLAGS_$(notdir $(1))	:= $(COMPAT_LDFLAGS)
-endef
-
-$(eval $(call map,obj-export-native-flags,$(restorer-obj-y)))
-$(eval $(call map,obj-export-native-flags,$(native-obj-y) native))
-$(eval $(call map,obj-export-compat-flags,$(compat-obj-y) compat))
+ifneq ($(filter-out clean mrproper,$(MAKECMDGOALS)),)
+        CFLAGS	+= $(shell $(SRC_DIR)/compel/compel-host --arch=$(ARCH) cflags)
+endif
 
 ifeq ($(SRCARCH),arm)
         ccflags-y	+= -marm
 endif
 
-asflags-y		+= -D__ASSEMBLY__
+asflags-y	+= -D__ASSEMBLY__
 
-GEN-OFFSETS		:= $(obj)/../../scripts/gen-offsets.sh
+GEN-OFFSETS	:= $(obj)/../../scripts/gen-offsets.sh
 
-BLOBS			+= $(obj)/restorer-blob.h
-
-define gen-pields-blobs-var
-BLOBS			+= $(obj)/parasite-$(1)-blob.h
-endef
-$(eval $(call map,gen-pields-blobs-var,$(parasite_target)))
+BLOBS		+= $(obj)/restorer-blob.h $(obj)/parasite-blob.h
 
 .SECONDARY:
 
-# for C files, we need "parasite-native" to be "parasite_native"
-target-name = $(patsubst criu/pie/%_blob.h,%,$(subst -,_,$(1)))
+target-name = $(patsubst criu/pie/%-blob.h,%,$(1))
 
 ifeq ($(piegen-y),y)
 ifeq ($(strip $(V)),)
         piegen_stdout := >/dev/null
 endif
 
-$(obj)/restorer.built-in.o: $(compel_std-native)
-$(obj)/restorer.built-in.bin.o: $(obj)/restorer.built-in.o		\
-				$(obj)/pie.lib.a $(compel_pack_lds-native)
+$(obj)/restorer.built-in.o: $(compel_std)
+$(obj)/parasite.built-in.o: $(compel_std)
+$(obj)/%.built-in.bin.o: $(obj)/%.built-in.o $(obj)/pie.lib.a $(compel_lds)
 	$(call msg-gen, $@)
-	$(Q) $(LD) -r -T $(compel_pack_lds-native) -o $@ $< $(obj)/pie.lib.a
-
-# $1 - binary mode: native/compat
-define gen-rule-built-in.bin.o
-$(obj)/$(1).built-in.o: $(compel_std-$(1))
-$(obj)/parasite-$(1).built-in.bin.o: $(obj)/$(1).built-in.o		\
-				$(obj)/pie.lib.a $(compel_pack_lds-$(1))
-	$$(call msg-gen, $$@)
-	$(Q) $(LD) -r -T $(compel_pack_lds-$(1)) -o $$@ $$< $(obj)/pie.lib.a
-endef
-$(eval $(call map,gen-rule-built-in.bin.o,$(parasite_target)))
+	$(Q) $(LD) -r -T $(compel_lds) -o $@ $< $(obj)/pie.lib.a
 
 $(obj)/%-blob.h: $(obj)/%.built-in.bin.o $(SRC_DIR)/compel/compel-host
 	$(call msg-gen, $@)
@@ -138,21 +80,11 @@ ifeq ($(filter arm aarch64,$(ARCH)),)
         LD_R := -r
 endif
 
-define gen-rule-built-in.bin.o
-$(obj)/$(1).built-in.o: $(compel_std-$(1))
-$(obj)/parasite-$(1).built-in.bin.o: $(obj)/$(1).built-in.o		\
-				$(compel_pack_lds-$(1)) $(obj)/pie.lib.a
-	$$(call msg-gen, $$@)
-	$(Q) $(LD) $(LD_R) -T $(compel_pack_lds-$(1)) -o $$@ $$< $(obj)/pie.lib.a
-endef
-
-$(eval $(call map,gen-rule-built-in.bin.o,$(parasite_target)))
-
-$(obj)/restorer.built-in.o: $(compel_std-native)
-$(obj)/restorer.built-in.bin.o: $(obj)/restorer.built-in.o		\
-				$(compel_pack_lds-native) $(obj)/pie.lib.a
+$(obj)/restorer.built-in.o: $(compel_std)
+$(obj)/parasite.built-in.o: $(compel_std)
+$(obj)/%.built-in.bin.o: $(obj)/%.built-in.o $(compel_lds) $(obj)/pie.lib.a
 	$(call msg-gen, $@)
-	$(Q) $(LD) $(LD_R) -T $(compel_pack_lds-native) -o $@ $< $(obj)/pie.lib.a
+	$(Q) $(LD) $(LD_R) -T $(compel_lds) -o $@ $< $(obj)/pie.lib.a
 
 $(obj)/%.built-in.bin: $(obj)/%.built-in.bin.o
 	$(call msg-gen, $@)
@@ -162,7 +94,6 @@ $(obj)/%-blob.h: $(obj)/%.built-in.bin $(GEN-OFFSETS)
 	$(call msg-gen, $@)
 	$(Q) $(SH) $(GEN-OFFSETS) $(@:-blob.h=) $(call target-name,$@) $(CROSS_COMPILE) > $@
 
-
 endif # !piegen-y
 
 all-y += $(BLOBS)
diff --git a/criu/pie/parasite-blob.h b/criu/pie/parasite-blob.h
deleted file mode 100644
index ddafd05f50ed..000000000000
--- a/criu/pie/parasite-blob.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "parasite-native-blob.h"
-
-#ifdef CONFIG_COMPAT
-# include "parasite-compat-blob.h"
-#endif
-- 
2.10.2



More information about the CRIU mailing list