[CRIU] [PATCH] Build pie objects separately

Laurent Dufour ldufour at linux.vnet.ibm.com
Mon Oct 12 07:17:03 PDT 2015


This patch change the build chain to not use pie objects in the crtools
executable.

This done by building the shared source files twice:
 1. for parasite/restorer as '<file>-pie-build.o'
 2. for crtools as '<file>.o'

Signed-off-by: Laurent Dufour <ldufour at linux.vnet.ibm.com>
---
 Documentation/Makefile.build.txt |  5 +++++
 Makefile                         |  8 --------
 Makefile.crtools                 |  3 +++
 pie/Makefile                     |  9 ++++++---
 scripts/Makefile.build           | 12 ++++++++++++
 5 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/Documentation/Makefile.build.txt b/Documentation/Makefile.build.txt
index 9bc35a3f0875..60fca7e8d21e 100644
--- a/Documentation/Makefile.build.txt
+++ b/Documentation/Makefile.build.txt
@@ -57,6 +57,11 @@ obj-y::
 	Source code C file. Typically refered as *obj-y += 'some-file.o'*.
 	This implies you have real 'some-file.c' in '$(obj)' directory.
 
+obj-x::
+	Same as 'obj-y' but the output files have the suffix $(xsuffix).
+	This is used when building shared source file for both pie and crtools
+	The posfix '-x' came from word 'extra'.
+
 obj-e::
 	Same as 'obj-y' but implies that source code file lays in directory
 	other than '$(obj)'. The postfix '-e' came from word 'external'.
diff --git a/Makefile b/Makefile
index c9011a8635eb..45d9d06a8226 100644
--- a/Makefile
+++ b/Makefile
@@ -225,8 +225,6 @@ $(piegen): pie/piegen/built-in.o
 .PHONY: pie/piegen
 endif
 
-pie/%:: $(ARCH_DIR) $(piegen)
-	$(Q) $(MAKE) $(build)=pie $@
 pie: $(ARCH_DIR) $(piegen)
 	$(Q) $(MAKE) $(build)=pie all
 
@@ -240,12 +238,6 @@ lib/%:: $(VERSION_HEADER) config built-in.o
 lib: $(VERSION_HEADER) config built-in.o
 	$(Q) $(MAKE) $(build)=lib all
 
-ifeq ($(VDSO),y)
-PROGRAM-BUILTINS	+= pie/util-vdso.o
-endif
-
-PROGRAM-BUILTINS	+= pie/util-fd.o
-PROGRAM-BUILTINS	+= pie/util.o
 PROGRAM-BUILTINS	+= protobuf/built-in.o
 PROGRAM-BUILTINS	+= built-in.o
 
diff --git a/Makefile.crtools b/Makefile.crtools
index 80f704fb4be1..f55bdb783d18 100644
--- a/Makefile.crtools
+++ b/Makefile.crtools
@@ -67,6 +67,7 @@ obj-y	+= sigframe.o
 obj-y	+= lsm.o
 ifeq ($(VDSO),y)
 obj-y	+= vdso.o
+obj-y	+= pie/util-vdso.o
 endif
 obj-y	+= cr-service.o
 obj-y	+= sd-daemon.o
@@ -74,6 +75,8 @@ obj-y	+= plugin.o
 obj-y	+= cr-errno.o
 obj-y	+= pie/pie-relocs.o
 obj-y	+= seize.o
+obj-y	+= pie/util-fd.o
+obj-y	+= pie/util.o
 
 ifneq ($(MAKECMDGOALS),clean)
 incdeps := y
diff --git a/pie/Makefile b/pie/Makefile
index b9edcc959e47..772f16fff845 100644
--- a/pie/Makefile
+++ b/pie/Makefile
@@ -1,12 +1,15 @@
 targets			+= parasite
 targets			+= restorer
 
+# used by obj-x to identify shared files built for parasite/restorer binaries
+xsuffix			:= -pie-build
+
 obj-y			+= log-simple.o
-obj-y			+= util.o
-obj-y			+= util-fd.o
+obj-x			+= util.o
+obj-x			+= util-fd.o
 
 ifeq ($(VDSO),y)
-obj-y			+= util-vdso.o
+obj-x			+= util-vdso.o
 obj-y			+= parasite-vdso.o
 obj-e			+= $(ARCH_DIR)/vdso-pie.o
 ifeq ($(SRCARCH),aarch64)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 177d09669f7f..78360a9ecf1a 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -64,6 +64,18 @@ all-objs += $(obj-y)
 deps += $(obj-y:.o=.d)
 endif
 
+ifneq ($(obj-x),)
+obj-x := $(addprefix $(obj)/, $(obj-x))
+obj-x := $(addsuffix $(xsuffix).o, $(obj-x:.o=))
+$(foreach file,						\
+	$(obj-x),					\
+	$(eval						\
+		$(call gen-target-c-bundle,		\
+			$(file:$(xsuffix).o=),$(file:.o=))))
+all-objs += $(obj-x)
+deps += $(obj-x:.o=.d)
+endif
+
 ifneq ($(obj-e),)
 $(foreach file,						\
 	$(obj-e),					\
-- 
1.9.1



More information about the CRIU mailing list