diff --git a/Makefile b/Makefile index ea76a1246..a8cc9de7e 100644 --- a/Makefile +++ b/Makefile @@ -176,16 +176,6 @@ include/common/asm: include/common/arch/$(ARCH)/asm $(Q) ln -s ./arch/$(ARCH)/asm $@ $(VERSION_HEADER): include/common/asm -# -# piegen tool might be disabled by hands. Don't use it until -# you know what you're doing. -ifneq ($(filter ia32 x86 ppc64,$(ARCH)),) - ifneq ($(PIEGEN),no) - piegen-y := y - export piegen-y - endif -endif - # # Configure variables. export CONFIG_HEADER := criu/include/config.h diff --git a/Makefile.config b/Makefile.config index 6ff42fe3f..ad9953323 100644 --- a/Makefile.config +++ b/Makefile.config @@ -54,10 +54,6 @@ $(call map,gen-feature-test,$(FEATURES_LIST)) ifeq ($$(VDSO),y) $(Q) @echo '#define CONFIG_VDSO' >> $$@ $(Q) @echo '' >> $$@ -endif -ifeq ($$(piegen-y),y) - $(Q) @echo '#define CONFIG_PIEGEN' >> $$@ - $(Q) @echo '' >> $$@ endif $(Q) @echo '#endif /* __CR_CONFIG_H__ */' >> $$@ endef diff --git a/compel/Makefile b/compel/Makefile index 8c580fdf3..65426d812 100644 --- a/compel/Makefile +++ b/compel/Makefile @@ -26,6 +26,12 @@ lib-y += src/lib/infect-util.o lib-y += src/lib/infect.o lib-y += src/lib/ptrace.o +# handle_elf() has no support of ELF relocations on ARM (yet?) +ifneq ($(filter arm aarch64,$(ARCH)),) +CFLAGS += -DNO_RELOCS +HOSTCFLAGS += -DNO_RELOCS +endif + ifeq ($(ARCH),x86) obj-y += src/lib/handle-elf-32.o endif diff --git a/compel/src/lib/handle-elf.c b/compel/src/lib/handle-elf.c index b28830195..035cd0dda 100644 --- a/compel/src/lib/handle-elf.c +++ b/compel/src/lib/handle-elf.c @@ -267,7 +267,7 @@ int __handle_elf(void *mem, size_t size) } pr_out("static __maybe_unused compel_reloc_t %s_relocs[] = {\n", opts.prefix); - +#ifndef NO_RELOCS pr_debug("Relocations\n"); pr_debug("------------\n"); for (i = 0; i < hdr->e_shnum; i++) { @@ -545,6 +545,7 @@ int __handle_elf(void *mem, size_t size) } } } +#endif /* !NO_RELOCS */ pr_out("};\n"); pr_out("static __maybe_unused size_t %s_nr_gotpcrel = %zd;\n", opts.prefix, nr_gotpcrel); diff --git a/criu/cr-restore.c b/criu/cr-restore.c index bbb499339..f2e5c5ea7 100644 --- a/criu/cr-restore.c +++ b/criu/cr-restore.c @@ -2459,7 +2459,9 @@ static int remap_restorer_blob(void *addr) return -1; } - ELF_RELOCS_APPLY(restorer, addr, addr); + compel_relocs_apply(addr, addr, sizeof(restorer_blob), + restorer_relocs, ARRAY_SIZE(restorer_relocs)); + return 0; } diff --git a/criu/pie/Makefile b/criu/pie/Makefile index 05c1b08da..cb5bcdecf 100644 --- a/criu/pie/Makefile +++ b/criu/pie/Makefile @@ -87,8 +87,6 @@ endif asflags-y += -D__ASSEMBLY__ -GEN-OFFSETS := $(obj)/../../scripts/gen-offsets.sh - BLOBS += $(obj)/restorer-blob.h define gen-pields-blobs-var @@ -101,7 +99,6 @@ $(eval $(call map,gen-pields-blobs-var,$(parasite_target))) # for C files, we need "parasite-native" to be "parasite_native" target-name = $(patsubst criu/pie/%_blob.h,%,$(subst -,_,$(1))) -ifeq ($(piegen-y),y) ifeq ($(strip $(V)),) piegen_stdout := >/dev/null endif @@ -129,40 +126,6 @@ $(obj)/%-blob.h: $(obj)/%.built-in.bin.o $(SRC_DIR)/compel/compel-host -p $(call target-name,$@) \ -o $@ $(piegen_stdout) -else # !piegen-y - -# ld on arm doesn't like -pie and -r options together -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)/native.lib.a - $$(call msg-gen, $$@) - $(Q) $(LD) $(LD_R) -T $(compel_pack_lds-$(1)) -o $$@ $$< $(obj)/native.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)/native.lib.a - $(call msg-gen, $@) - $(Q) $(LD) $(LD_R) -T $(compel_pack_lds-native) -o $@ $< $(obj)/native.lib.a - -$(obj)/%.built-in.bin: $(obj)/%.built-in.bin.o - $(call msg-gen, $@) - $(Q) $(OBJCOPY) -O binary $^ $@ - -$(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) # blobs and pields are in cleanup, rather than in mrproper because # we want them to be re-generated after `make clean && make` diff --git a/criu/pie/pie-relocs.h b/criu/pie/pie-relocs.h index 442e70d13..5a18d8c9d 100644 --- a/criu/pie/pie-relocs.h +++ b/criu/pie/pie-relocs.h @@ -6,19 +6,7 @@ #include "common/compiler.h" #include "config.h" -#ifdef CONFIG_PIEGEN - #define pie_size(__pie_name) (round_up(sizeof(__pie_name##_blob) + \ __pie_name ## _nr_gotpcrel * sizeof(long), page_size())) -#define ELF_RELOCS_APPLY(__pie_name, __mem, __vbase) \ - compel_relocs_apply(__mem, __vbase, sizeof(__pie_name##_blob), \ - __pie_name##_relocs, ARRAY_SIZE(__pie_name##_relocs)) - -#else - -#define pie_size(__pie_name) (round_up(sizeof(__pie_name##_blob), page_size())) -#define ELF_RELOCS_APPLY(__pie_name, __mem, __vbase) - -#endif #endif /* __PIE_RELOCS_H__ */ diff --git a/scripts/gen-offsets.sh b/scripts/gen-offsets.sh deleted file mode 100644 index 16a03942e..000000000 --- a/scripts/gen-offsets.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -set -e -set -u - -FILE=$1 -NAME=$2 - -if test $# -ge 3; then -CROSS_COMPILE=$3 -else -CROSS_COMPILE= -fi - -INC_GUARD=__${NAME}_h__ -SYM=${NAME}_sym -BLOB=${NAME}_blob -OBJNAME=${FILE}.built-in.bin.o -BINARY=${FILE}.built-in.bin - -AWK_CMD='$2 ~ /^[tTA]$/ { print "#define '$SYM'" $3 " 0x" $1; }' - -cat << EOF -/* Autogenerated by $0, do not edit */ -#ifndef $INC_GUARD -#define $INC_GUARD - -EOF - -${CROSS_COMPILE}nm $OBJNAME | grep "__export_" | tr . _ | awk "$AWK_CMD" - -cat << EOF - -static char $BLOB[] = { -EOF - -hexdump -v -e '"\t" 8/1 "0x%02x, " "\n"' $BINARY - -cat << EOF -}; - -#endif /* $INC_GUARD */ -EOF