mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-22 09:39:13 +00:00
Since at the moment we're running only x86-64 not 32 bit tasks, and our code is not carrying any big statically defined structures we can use relocatable files directly with all relocation applied during building. This gonna be changed soon once we start supporting 32 bit tasks. IOW even currently we need (which is not yet done but it's safe) - check for gotpcrel relocations - apply relocations with generated elf_apply_relocs helper Currently overall scheme looks this way - our object files are linked together into parasite.built-in.bin.o file - then pie/piegen/piegen tool is called which parses this file and generates C source code file with bytestream and all information needed to rellocate this bytestream into a new place (see elf_apply_relocs helper) Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
110 lines
2.9 KiB
Makefile
110 lines
2.9 KiB
Makefile
targets += parasite
|
|
targets += restorer
|
|
|
|
obj-y += log-simple.o
|
|
obj-y += util.o
|
|
obj-y += util-fd.o
|
|
|
|
ifeq ($(VDSO),y)
|
|
obj-e += $(ARCH_DIR)/vdso-pie.o
|
|
ifeq ($(SRCARCH),aarch64)
|
|
asm-e += $(ARCH_DIR)/intraprocedure.o
|
|
endif
|
|
ifeq ($(SRCARCH), ppc64)
|
|
asm-e += $(ARCH_DIR)/vdso-trampoline.o
|
|
asm-e += $(ARCH_DIR)/memcpy_power7.o
|
|
asm-e += $(ARCH_DIR)/memcmp_64.o
|
|
endif
|
|
endif
|
|
|
|
parasite-obj-y += parasite.o
|
|
parasite-asm-e += $(ARCH_DIR)/parasite-head.o
|
|
parasite-libs-e += $(SYSCALL-LIB)
|
|
|
|
restorer-obj-y += restorer.o
|
|
restorer-obj-e += $(ARCH_DIR)/restorer.o
|
|
ifeq ($(SRCARCH), ppc64)
|
|
restorer-asm-e += $(ARCH_DIR)/restorer-trampoline.o
|
|
endif
|
|
restorer-libs-e += $(SYSCALL-LIB)
|
|
|
|
#
|
|
# We can't provide proper mount implementation
|
|
# in parasite code -- it requires run-time rellocation
|
|
# applications, which is not the target of the
|
|
# project.
|
|
#
|
|
CFLAGS := $(filter-out -pg,$(CFLAGS))
|
|
|
|
cflags-y += -DCR_NOGLIBC -fpie -Wa,--noexecstack -fno-stack-protector
|
|
ifeq ($(SRCARCH), arm)
|
|
cflags-y += -marm
|
|
endif
|
|
ASMFLAGS += -D__ASSEMBLY__
|
|
|
|
GEN-OFFSETS := ../scripts/gen-offsets.sh
|
|
BLOBS := $(obj)/parasite-blob.h $(obj)/restorer-blob.h
|
|
|
|
PIELDS := pie.lds.S
|
|
|
|
.SECONDARY:
|
|
|
|
ifneq ($(filter i386 ia32 x86_64, $(ARCH)),)
|
|
ldflags-y += -r
|
|
target-name = $(patsubst pie/%-blob.h,%,$(1))
|
|
|
|
ifeq ($(ARCH),x86_64)
|
|
$(obj)/$(PIELDS): $(obj)/pie-reloc.lds.S.in
|
|
$(E) " GEN " $@
|
|
$(Q) echo "OUTPUT_ARCH(i386:x86-64)" > $(obj)/$(PIELDS)
|
|
$(Q) echo "TARGET(elf64-x86-64)" >> $(obj)/$(PIELDS)
|
|
$(Q) cat $< >> $(obj)/$(PIELDS)
|
|
else
|
|
$(obj)/$(PIELDS): $(obj)/pie-reloc.lds.S.in
|
|
$(E) " GEN " $@
|
|
$(Q) echo "OUTPUT_ARCH(i386)" > $(obj)/$(PIELDS)
|
|
$(Q) echo "TARGET(elf32-i386)" >> $(obj)/$(PIELDS)
|
|
$(Q) cat $< >> $(obj)/$(PIELDS)
|
|
endif
|
|
|
|
$(obj)/%.built-in.bin.o: $(obj)/%.built-in.o $(obj)/$(PIELDS)
|
|
$(E) " GEN " $@
|
|
$(Q) $(LD) $(ldflags-y) -T $(obj)/$(PIELDS) -o $@ $<
|
|
|
|
$(obj)/%-blob.h: $(obj)/%.built-in.bin.o $(obj)/$(PIELDS) pie/piegen
|
|
$(E) " GEN " $@
|
|
$(Q) pie/piegen/piegen -f $< -p $(call target-name,$@)_blob_offset__ -s $(call target-name,$@)_blob > $@
|
|
|
|
else
|
|
|
|
$(obj)/$(PIELDS): $(obj)/$(PIELDS).in
|
|
$(E) " GEN " $@
|
|
$(Q) $(SH) -c "echo 'OUTPUT_ARCH($(LDARCH))' > $(obj)/$(PIELDS)"
|
|
$(Q) $(SH) -c "cat $(obj)/$(PIELDS).in >> $(obj)/$(PIELDS)"
|
|
|
|
$(obj)/%.built-in.bin.o: $(obj)/%.built-in.o $(obj)/$(PIELDS)
|
|
$(E) " GEN " $@
|
|
$(Q) $(LD) $(ldflags-y) -T $(obj)/$(PIELDS) -o $@ $<
|
|
|
|
$(obj)/%.built-in.bin: $(obj)/%.built-in.bin.o
|
|
$(E) " GEN " $@
|
|
$(Q) $(OBJCOPY) -O binary $^ $@
|
|
|
|
$(obj)/%-blob.h: $(obj)/%.built-in.bin $(obj)/$(GEN-OFFSETS)
|
|
$(E) " GEN " $@
|
|
$(Q) $(SH) $(obj)/$(GEN-OFFSETS) $(@:-blob.h=) $(notdir $(@:-blob.h=)) $(CROSS_COMPILE) > $@
|
|
|
|
endif
|
|
|
|
$(BLOBS): $(obj)/$(PIELDS)
|
|
_all += $(BLOBS)
|
|
|
|
cleanup-y += $(obj)/$(PIELDS)
|
|
cleanup-y += $(obj)/*.bin
|
|
cleanup-y += $(BLOBS)
|
|
cleanup-y += $(obj)/*.built-in.bin.o
|
|
cleanup-y += $(obj)/*.built-in.bin
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
incdeps := y
|
|
endif
|