diff --git a/Documentation/Makefile.build.txt b/Documentation/Makefile.build.txt index 9bc35a3f0..60fca7e8d 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 c9011a863..45d9d06a8 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 80f704fb4..f55bdb783 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 b9edcc959..772f16fff 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 177d09669..78360a9ec 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), \