[CRIU] [PATCHv2 08/17] pie.lib: generate compatible pie object files

Dmitry Safonov dsafonov at virtuozzo.com
Tue Apr 12 09:10:46 PDT 2016


Now compatible objects will be in $(obj)/compat/$(basename)-compat.o
I can't use just $(obj)/compat/$(basename).o as basename for file
will be the same as for native object, which wouldn't work by
the reason of CFLAGS_$(F) in nmk-ccflags.
So, I need different names for compatible/native objects.
Because I don't want to make a mess in parent directories,
I put this symlinks to compat/ dirs.
This is how I came to that decision (even if I do not like it).

Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/arch/x86/compat/vdso-pie-compat.c |  1 +
 criu/pie/Makefile.library              | 53 ++++++++++++++++++++++------------
 criu/pie/compat/log-simple-compat.c    |  1 +
 criu/pie/compat/parasite-vdso-compat.c |  1 +
 criu/pie/compat/util-compat.c          |  1 +
 criu/pie/compat/util-fd-compat.c       |  1 +
 criu/pie/compat/util-vdso-compat.c     |  1 +
 7 files changed, 40 insertions(+), 19 deletions(-)
 create mode 120000 criu/arch/x86/compat/vdso-pie-compat.c
 create mode 120000 criu/pie/compat/log-simple-compat.c
 create mode 120000 criu/pie/compat/parasite-vdso-compat.c
 create mode 120000 criu/pie/compat/util-compat.c
 create mode 120000 criu/pie/compat/util-fd-compat.c
 create mode 120000 criu/pie/compat/util-vdso-compat.c

diff --git a/criu/arch/x86/compat/vdso-pie-compat.c b/criu/arch/x86/compat/vdso-pie-compat.c
new file mode 120000
index 000000000000..98b1f39da2a9
--- /dev/null
+++ b/criu/arch/x86/compat/vdso-pie-compat.c
@@ -0,0 +1 @@
+../vdso-pie.c
\ No newline at end of file
diff --git a/criu/pie/Makefile.library b/criu/pie/Makefile.library
index 097f9762f167..ecd862385222 100644
--- a/criu/pie/Makefile.library
+++ b/criu/pie/Makefile.library
@@ -1,45 +1,60 @@
-target				:= native
+target			:= native
 
-$(target)-lib-y			+= log-simple.o
-$(target)-lib-y			+= util-fd.o
-$(target)-lib-y			+= util.o
+CFLAGS			:= $(filter-out -DCONFIG_X86_64,$(CFLAGS))
+CFLAGS			+= -Wa,--noexecstack -fno-stack-protector -DCR_NOGLIBC
+
+CFLAGS_native		+= -fpie
+
+ifeq ($(ARCH),x86)
+        target		+= compat
+        CFLAGS_native	+= -DCONFIG_X86_64
+        CFLAGS_compat	+= -fno-pic -m32 -DCONFIG_X86_32
+endif
+
+OBJS			+= log-simple.o util-fd.o util.o
 
 ifeq ($(VDSO),y)
-        $(target)-lib-y		+= util-vdso.o
-        $(target)-lib-y		+= parasite-vdso.o
-        $(target)-lib-y		+= ./$(ARCH_DIR)/vdso-pie.o
+        OBJS		+= util-vdso.o parasite-vdso.o ./$(ARCH_DIR)/vdso-pie.o
 
         ifeq ($(SRCARCH),aarch64)
-                $(target)-lib-y	+= ./$(ARCH_DIR)/intraprocedure.o
+                OBJS	+= ./$(ARCH_DIR)/intraprocedure.o
         endif
 
         ifeq ($(SRCARCH),ppc64)
-                $(target)-lib-y	+= ./$(ARCH_DIR)/vdso-trampoline.o
+                OBJS	+= ./$(ARCH_DIR)/vdso-trampoline.o
         endif
 endif
 
 ifeq ($(SRCARCH),ppc64)
-        $(target)-lib-y	+= ./$(ARCH_DIR)/memcpy_power7.o
-        $(target)-lib-y	+= ./$(ARCH_DIR)/memcmp_64.o
-        $(target)-lib-y	+= ./$(ARCH_DIR)/misc.o
+        OBJS		+= ./$(ARCH_DIR)/memcpy_power7.o		\
+			   ./$(ARCH_DIR)/memcmp_64.o ./$(ARCH_DIR)/misc.o
 endif
 
+define gen-native-objs
+native-lib-y		+= $(1)
+CFLAGS_$(1)		:= $(CFLAGS_native)
+endef
+
+compat-obj		= $(basename $(notdir $(1)))-compat.o
+define gen-compat-objs
+compat-lib-y		+= $(dir ./$(call objectify,$(1)))compat/$(compat-obj)
+CFLAGS_$(compat-obj)	:= $(CFLAGS_compat)
+endef
+
+$(eval $(call map,gen-native-objs,$(OBJS)))
+$(eval $(call map,gen-compat-objs,$(OBJS)))
+
 #
 # We can't provide proper mount implementation
 # in parasite code -- it requires run-time rellocation
 # applications, which is not the target of the
 # project.
 #
-iquotes			:= -iquote pie/piegen -iquote arch/$(ARCH)/include -iquote $(SRC_DIR) -iquote $(SRC_DIR)/criu/include
+iquotes			:= -iquote pie/piegen -iquote arch/$(ARCH)/include
+iquotes			+= -iquote $(SRC_DIR) -iquote $(SRC_DIR)/criu/include
 CFLAGS			:= $(filter-out -pg $(CFLAGS-GCOV),$(CFLAGS)) $(iquotes)
 asflags-y		:= -D__ASSEMBLY__ $(iquotes)
 
 ifeq ($(SRCARCH),arm)
 	ccflags-y	+= -marm
 endif
-
-ifneq ($(filter-out ia32,$(ARCH)),)
-        ccflags-y	+= -DCR_NOGLIBC -fpie -Wa,--noexecstack -fno-stack-protector
-else
-        ccflags-y	+= -DCR_NOGLIBC -fno-pic -Wa,--noexecstack -fno-stack-protector
-endif
diff --git a/criu/pie/compat/log-simple-compat.c b/criu/pie/compat/log-simple-compat.c
new file mode 120000
index 000000000000..fd4c4bae29d3
--- /dev/null
+++ b/criu/pie/compat/log-simple-compat.c
@@ -0,0 +1 @@
+../log-simple.c
\ No newline at end of file
diff --git a/criu/pie/compat/parasite-vdso-compat.c b/criu/pie/compat/parasite-vdso-compat.c
new file mode 120000
index 000000000000..95158832fdef
--- /dev/null
+++ b/criu/pie/compat/parasite-vdso-compat.c
@@ -0,0 +1 @@
+../parasite-vdso.c
\ No newline at end of file
diff --git a/criu/pie/compat/util-compat.c b/criu/pie/compat/util-compat.c
new file mode 120000
index 000000000000..39606ede1d95
--- /dev/null
+++ b/criu/pie/compat/util-compat.c
@@ -0,0 +1 @@
+../util.c
\ No newline at end of file
diff --git a/criu/pie/compat/util-fd-compat.c b/criu/pie/compat/util-fd-compat.c
new file mode 120000
index 000000000000..358f069dc8e3
--- /dev/null
+++ b/criu/pie/compat/util-fd-compat.c
@@ -0,0 +1 @@
+../util-fd.c
\ No newline at end of file
diff --git a/criu/pie/compat/util-vdso-compat.c b/criu/pie/compat/util-vdso-compat.c
new file mode 120000
index 000000000000..4caac4510d14
--- /dev/null
+++ b/criu/pie/compat/util-vdso-compat.c
@@ -0,0 +1 @@
+../util-vdso.c
\ No newline at end of file
-- 
2.8.0



More information about the CRIU mailing list