mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
compel: Initial commit for standalone tool
The compel component is a replacement for several aspects of CRIU functionality: binary blobs generation for PIE parasite/restore code, and a library for parasite code injection and execution (to be implemented). In the commit we rather shuffle compel into own directory and use it for 1) Fetching cflags when compiling PIE blobs 2) Use its "piegen" functionality to generate blobs themselves. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
dbc2edb83a
commit
acfa85ba5a
15 changed files with 42 additions and 47 deletions
11
Makefile
11
Makefile
|
|
@ -127,7 +127,7 @@ endif
|
|||
CFLAGS += $(WARNINGS) $(DEFINES) -iquote include/
|
||||
|
||||
# Default target
|
||||
all: criu lib
|
||||
all: compel criu lib
|
||||
.PHONY: all
|
||||
|
||||
#
|
||||
|
|
@ -201,6 +201,9 @@ $(eval $(call gen-built-in,images))
|
|||
|
||||
.PHONY: .FORCE
|
||||
|
||||
# Compel get used by CRIU, build it earlier
|
||||
$(eval $(call gen-built-in,compel))
|
||||
|
||||
#
|
||||
# Next the socket CR library
|
||||
#
|
||||
|
|
@ -222,9 +225,9 @@ $(SOCCR_A): |soccr/built-in.o
|
|||
#
|
||||
# But note that we're already included
|
||||
# the nmk so we can reuse it there.
|
||||
criu/%: images/built-in.o $(VERSION_HEADER) $(CONFIG_HEADER) .FORCE
|
||||
criu/%: images/built-in.o compel/compel $(VERSION_HEADER) $(CONFIG_HEADER) .FORCE
|
||||
$(Q) $(MAKE) $(build)=criu $@
|
||||
criu: images/built-in.o $(SOCCR_A) $(VERSION_HEADER) $(CONFIG_HEADER)
|
||||
criu: images/built-in.o compel/compel $(SOCCR_A) $(VERSION_HEADER) $(CONFIG_HEADER)
|
||||
$(Q) $(MAKE) $(build)=criu all
|
||||
.PHONY: criu
|
||||
|
||||
|
|
@ -248,6 +251,7 @@ clean: subclean
|
|||
$(Q) $(MAKE) $(build)=criu $@
|
||||
$(Q) $(MAKE) $(build)=soccr $@
|
||||
$(Q) $(MAKE) $(build)=lib $@
|
||||
$(Q) $(MAKE) $(build)=compel $@
|
||||
.PHONY: clean
|
||||
|
||||
# mrproper depends on clean in nmk
|
||||
|
|
@ -256,6 +260,7 @@ mrproper: subclean
|
|||
$(Q) $(MAKE) $(build)=criu $@
|
||||
$(Q) $(MAKE) $(build)=soccr $@
|
||||
$(Q) $(MAKE) $(build)=lib $@
|
||||
$(Q) $(MAKE) $(build)=compel $@
|
||||
$(Q) $(RM) $(CONFIG_HEADER)
|
||||
$(Q) $(RM) $(SOCCR_CONFIG)
|
||||
$(Q) $(RM) $(VERSION_HEADER)
|
||||
|
|
|
|||
|
|
@ -23,3 +23,8 @@ SOCCR_SO_VERSION_MAJOR := 1
|
|||
SOCCR_SO_VERSION_MINOR := 0
|
||||
|
||||
export SOCCR_SO_VERSION_MAJOR SOCCR_SO_VERSION_MINOR
|
||||
|
||||
COMPEL_SO_VERSION_MAJOR := 1
|
||||
COMPEL_SO_VERSION_MINOR := 0
|
||||
|
||||
export COMPEL_SO_VERSION_MAJOR COMPEL_SO_VERSION_MINOR
|
||||
|
|
|
|||
20
compel/Makefile
Normal file
20
compel/Makefile
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
include $(SRC_DIR)/Makefile.versions
|
||||
|
||||
ccflags-y += -iquote criu/include
|
||||
ccflags-y += -iquote compel/include
|
||||
ccflags-y += -DCOMPEL_VERSION=\"$(COMPEL_SO_VERSION_MAJOR).$(COMPEL_SO_VERSION_MINOR)\"
|
||||
|
||||
host-ccflags-y += $(filter-out -pg $(CFLAGS-GCOV),$(ccflags-y))
|
||||
HOSTCFLAGS += $(filter-out -pg $(CFLAGS-GCOV),$(WARNINGS) $(DEFINES))
|
||||
HOSTLDFLAGS += $(filter-out -pg $(CFLAGS-GCOV),$(LDFLAGS))
|
||||
|
||||
hostprogs-y += compel
|
||||
compel-objs += src/main.o
|
||||
|
||||
ifneq ($(filter ia32 x86, $(ARCH)),)
|
||||
compel-objs += src/elf-x86-32.o
|
||||
compel-objs += src/elf-x86-64.o
|
||||
endif
|
||||
ifeq ($(SRCARCH),ppc64)
|
||||
compel-objs += src/elf-ppc64.o
|
||||
endif
|
||||
|
|
@ -45,18 +45,6 @@ ARCH-LIB := $(ARCH_DIR)/crtools.built-in.o
|
|||
$(ARCH-LIB): syscalls_lib
|
||||
$(Q) $(MAKE) $(build)=$(ARCH_DIR) all
|
||||
|
||||
#
|
||||
# piegen tool needed for PIE code.
|
||||
ifeq ($(piegen-y),y)
|
||||
piegen-bin := criu/pie/piegen/piegen
|
||||
|
||||
criu/pie/piegen/%: $(CONFIG_HEADER)
|
||||
$(Q) CC=$(HOSTCC) LD=$(HOSTLD) CFLAGS="$(ccflags-y) $(HOSTCFLAGS) $(WARNINGS) $(DEFINES)" $(MAKE) $(build)=criu/pie/piegen $@
|
||||
$(piegen-bin): criu/pie/piegen/built-in.o
|
||||
$(call msg-link, $@)
|
||||
$(Q) $(HOSTCC) $(HOSTCFLAGS) $^ $(LDFLAGS) -o $@
|
||||
endif
|
||||
|
||||
#
|
||||
# PIE library code.
|
||||
criu/pie/lib.a: $(ARCH-LIB)
|
||||
|
|
@ -64,7 +52,7 @@ criu/pie/lib.a: $(ARCH-LIB)
|
|||
|
||||
#
|
||||
# PIE code blobs themseves.
|
||||
pie: $(piegen-bin) criu/pie/lib.a
|
||||
pie: criu/pie/lib.a
|
||||
$(Q) $(MAKE) $(build)=criu/pie all
|
||||
.PHONY: pie
|
||||
|
||||
|
|
@ -98,14 +86,12 @@ $(obj)/criu: $(PROGRAM-BUILTINS)
|
|||
subclean:
|
||||
$(Q) $(RM) $(obj)/*.{gcda,gcno,gcov}
|
||||
$(Q) $(RM) $(obj)/pie/*.{gcda,gcno,gcov}
|
||||
$(Q) $(RM) $(obj)/pie/piegen/*.{gcda,gcno,gcov}
|
||||
$(Q) $(RM) -r $(obj)/gcov
|
||||
$(Q) $(MAKE) $(call build-as,Makefile.syscalls,$(ARCH_DIR)) clean
|
||||
$(Q) $(MAKE) $(build)=$(ARCH_DIR) clean
|
||||
$(Q) $(MAKE) $(call build-as,Makefile.library,$(PIE_DIR)) clean
|
||||
$(Q) $(MAKE) $(call build-as,Makefile.crtools,criu) clean
|
||||
$(Q) $(MAKE) $(build)=$(PIE_DIR) clean
|
||||
$(Q) $(MAKE) $(build)=$(PIE_DIR)/piegen clean
|
||||
.PHONY: subclean
|
||||
cleanup-y += $(obj)/criu
|
||||
clean: subclean
|
||||
|
|
@ -118,7 +104,6 @@ subproper:
|
|||
$(Q) $(MAKE) $(call build-as,Makefile.library,$(PIE_DIR)) mrproper
|
||||
$(Q) $(MAKE) $(call build-as,Makefile.crtools,criu) mrproper
|
||||
$(Q) $(MAKE) $(build)=$(PIE_DIR) mrproper
|
||||
$(Q) $(MAKE) $(build)=$(PIE_DIR)/piegen mrproper
|
||||
.PHONY: subproper
|
||||
mrproper: subproper
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ restorer-obj-e += ./$(ARCH_DIR)/syscalls.built-in.o
|
|||
# project.
|
||||
#
|
||||
CFLAGS := $(filter-out -pg $(CFLAGS-GCOV),$(CFLAGS))
|
||||
CFLAGS += -iquote $(SRC_DIR)/criu/pie/piegen
|
||||
CFLAGS += -iquote $(SRC_DIR)/compel/include
|
||||
CFLAGS += -iquote $(SRC_DIR)/criu/arch/$(ARCH)/include
|
||||
CFLAGS += -iquote $(SRC_DIR)/criu/include
|
||||
CFLAGS += -iquote $(SRC_DIR)/include
|
||||
|
|
@ -25,10 +25,9 @@ CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
|
|||
CFLAGS += -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=0
|
||||
|
||||
|
||||
ifneq ($(filter-out ia32,$(ARCH)),)
|
||||
ccflags-y += -DCR_NOGLIBC -fpie -Wa,--noexecstack -fno-stack-protector
|
||||
else
|
||||
ccflags-y += -DCR_NOGLIBC -fno-pic -Wa,--noexecstack -fno-stack-protector
|
||||
ccflags-y += -DCR_NOGLIBC
|
||||
ifneq ($(filter-out clean mrproper,$(MAKECMDGOALS)),)
|
||||
ccflags-y += $(shell $(SRC_DIR)/compel/compel --arch=$(ARCH) cflags)
|
||||
endif
|
||||
|
||||
ifeq ($(SRCARCH),arm)
|
||||
|
|
@ -76,9 +75,9 @@ $(obj)/%.built-in.bin.o: $(obj)/%.built-in.o $(obj)/lib.a $(obj)/$(PIELDS)
|
|||
$(call msg-gen, $@)
|
||||
$(Q) $(LD) -r -T $(obj)/$(PIELDS) -o $@ $< $(obj)/lib.a
|
||||
|
||||
$(obj)/%-blob.h: $(obj)/%.built-in.bin.o $(obj)/$(PIELDS) criu/pie/piegen
|
||||
$(obj)/%-blob.h: $(obj)/%.built-in.bin.o $(obj)/$(PIELDS) compel/compel
|
||||
$(call msg-gen, $@)
|
||||
$(Q) criu/pie/piegen/piegen piegen -f $< -v $(call target-name,$@)_relocs -p $(call target-name,$@)_blob_offset__ -s $(call target-name,$@)_blob -o $@ $(piegen_stdout)
|
||||
$(Q) compel/compel piegen -f $< -v $(call target-name,$@)_relocs -p $(call target-name,$@)_blob_offset__ -s $(call target-name,$@)_blob -o $@ $(piegen_stdout)
|
||||
|
||||
else
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
#include "log.h"
|
||||
|
||||
#include "common/compiler.h"
|
||||
#include "piegen/uapi/types.h"
|
||||
#include "compel/include/uapi/types.h"
|
||||
#include "common/bug.h"
|
||||
|
||||
__maybe_unused void elf_relocs_apply(void *mem, void *vbase, size_t size, elf_reloc_t *elf_relocs, size_t nr_relocs)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __PIE_RELOCS_H__
|
||||
#define __PIE_RELOCS_H__
|
||||
|
||||
#include "piegen/uapi/types.h"
|
||||
#include "compel/include/uapi/types.h"
|
||||
|
||||
#include "common/compiler.h"
|
||||
#include "config.h"
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
CFLAGS += -iquote pie/piegen
|
||||
|
||||
obj-y += main.o
|
||||
ifneq ($(filter ia32 x86, $(ARCH)),)
|
||||
obj-y += elf-x86-32.o
|
||||
obj-y += elf-x86-64.o
|
||||
endif
|
||||
ifeq ($(SRCARCH),ppc64)
|
||||
obj-y += elf-ppc64.o
|
||||
endif
|
||||
|
||||
cleanup-y += $(obj)/piegen
|
||||
cleanup-y += $(obj)/*.o
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
ifneq ($(MAKECMDGOALS),mrproper)
|
||||
incdeps := y
|
||||
endif
|
||||
endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue