diff --git a/Makefile b/Makefile index ea6a7c6c3..6ed4c9080 100644 --- a/Makefile +++ b/Makefile @@ -118,6 +118,16 @@ export ARCH SRCARCH $(if $(wildcard $(ARCH_DIR)),,$(error "The architecture $(ARCH) isn't supported")) +# +# piegen might be disabled by hands. Don't use it until +# you know what you're doing. +ifneq ($(filter i386 ia32 x86_64 ppc64le, $(ARCH)),) +ifneq ($(PIEGEN),no) + piegen-y := y + export piegen-y +endif +endif + cflags-y += -iquote include -iquote pie -iquote . cflags-y += -iquote $(ARCH_DIR) -iquote $(ARCH_DIR)/include cflags-y += -fno-strict-aliasing @@ -152,8 +162,8 @@ ARCH-LIB := $(ARCH_DIR)/crtools.built-in.o CRIU-SO := libcriu CRIU-LIB := lib/$(CRIU-SO).so CRIU-INC := lib/criu.h include/criu-plugin.h include/criu-log.h protobuf/rpc.proto -ifneq ($(filter i386 ia32 x86_64 ppc64le, $(ARCH)),) -PIEGEN := pie/piegen/piegen +ifeq ($(piegen-y),y) +piegen := pie/piegen/piegen endif export CC MAKE CFLAGS LIBS SRCARCH DEFINES MAKEFLAGS CRIU-SO @@ -197,20 +207,20 @@ $(ARCH_DIR)/%:: protobuf config $(ARCH_DIR): protobuf config $(Q) $(MAKE) $(build)=$(ARCH_DIR) all -ifneq ($(filter i386 ia32 x86_64 ppc64le, $(ARCH)),) +ifeq ($(piegen-y),y) pie/piegen/%: config $(Q) $(MAKE) $(build)=pie/piegen $@ pie/piegen: config $(Q) $(MAKE) $(build)=pie/piegen all -$(PIEGEN): pie/piegen/built-in.o +$(piegen): pie/piegen/built-in.o $(E) " LINK " $@ $(Q) $(CC) $(CFLAGS) pie/piegen/built-in.o $(LDFLAGS) -o $@ .PHONY: pie/piegen endif -pie/%:: $(ARCH_DIR) $(PIEGEN) +pie/%:: $(ARCH_DIR) $(piegen) $(Q) $(MAKE) $(build)=pie $@ -pie: $(ARCH_DIR) $(PIEGEN) +pie: $(ARCH_DIR) $(piegen) $(Q) $(MAKE) $(build)=pie all %.o %.i %.s %.d: $(VERSION_HEADER) pie diff --git a/Makefile.config b/Makefile.config index e1d2a3b8d..ce4b8d844 100644 --- a/Makefile.config +++ b/Makefile.config @@ -40,6 +40,9 @@ ifeq ($(VDSO),y) endif ifeq ($(call try-cc,$(SETPROCTITLE_INIT_TEST),-lbsd),y) $(Q) @echo '#define CONFIG_HAS_SETPROCTITLE_INIT' >> $@ +endif +ifeq ($(piegen-y),y) + $(Q) @echo '#define CONFIG_PIEGEN' >> $@ endif $(Q) @echo '#endif /* __CR_CONFIG_H__ */' >> $@ diff --git a/pie/Makefile b/pie/Makefile index f43746f38..03cd4bc2b 100644 --- a/pie/Makefile +++ b/pie/Makefile @@ -52,7 +52,7 @@ PIELDS := pie.lds.S .SECONDARY: -ifneq ($(filter i386 ia32 x86_64 ppc64le, $(ARCH)),) +ifeq ($(piegen-y),y) ldflags-y += -r target-name = $(patsubst pie/%-blob.h,%,$(1)) diff --git a/pie/pie-relocs.h b/pie/pie-relocs.h index 1caf266d0..354aa9bbd 100644 --- a/pie/pie-relocs.h +++ b/pie/pie-relocs.h @@ -6,7 +6,7 @@ #include "compiler.h" #include "config.h" -#if defined(CONFIG_X86_64) || defined(CONFIG_X86_32) || defined(CONFIG_PPC64) +#ifdef CONFIG_PIEGEN extern __maybe_unused void elf_relocs_apply(void *mem, void *vbase, size_t size, elf_reloc_t *elf_relocs, size_t nr_relocs);