mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
make: pie -- Switch to a new scheme
Because we need util-net.c for both PIE code and a regular code, just move it to pie/ directory and build with -fpie option, this way we can reuse compiled file in main program without additional compilation pass. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
a210b5a1c5
commit
c405549934
5 changed files with 44 additions and 63 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -20,3 +20,4 @@ protobuf/*.h
|
|||
include/version.h
|
||||
arch/x86/sys-exec-tbl.c
|
||||
arch/x86/syscalls.S
|
||||
pie/pie.lds.S
|
||||
|
|
|
|||
11
Makefile
11
Makefile
|
|
@ -105,7 +105,6 @@ OBJS += cr-dump.o
|
|||
OBJS += cr-show.o
|
||||
OBJS += cr-check.o
|
||||
OBJS += util.o
|
||||
OBJS += util-net.o
|
||||
OBJS += sysctl.o
|
||||
OBJS += ptrace.o
|
||||
OBJS += kcmp-ids.o
|
||||
|
|
@ -162,8 +161,10 @@ arch/$(ARCH)/%:: protobuf
|
|||
arch/$(ARCH): protobuf
|
||||
$(Q) $(MAKE) $(build)=arch/$(ARCH) all
|
||||
|
||||
pie: arch/$(ARCH) protobuf
|
||||
$(Q) $(MAKE) -C pie/
|
||||
pie/%:: arch/$(ARCH)
|
||||
$(Q) $(MAKE) $(build)=pie $@
|
||||
pie: arch/$(ARCH)
|
||||
$(Q) $(MAKE) $(build)=pie all
|
||||
|
||||
%.o: %.c
|
||||
$(E) " CC " $@
|
||||
|
|
@ -181,7 +182,7 @@ pie: arch/$(ARCH) protobuf
|
|||
$(E) " DEP " $@
|
||||
$(Q) $(CC) -M -MT $@ -MT $(patsubst %.d,%.o,$@) $(CFLAGS) $< -o $@
|
||||
|
||||
$(PROGRAM): $(SYSCALL-LIB) $(ARCH-LIB) protobuf/built-in.o $(OBJS)
|
||||
$(PROGRAM): $(SYSCALL-LIB) $(ARCH-LIB) pie/util-net.o protobuf/built-in.o $(OBJS)
|
||||
$(E) " LINK " $@
|
||||
$(Q) $(CC) $(CFLAGS) $^ $(LIBS) -o $@
|
||||
|
||||
|
|
@ -204,6 +205,7 @@ clean:
|
|||
$(Q) $(RM) $(VERSION_HEADER)
|
||||
$(Q) $(MAKE) $(build)=arch/$(ARCH) clean
|
||||
$(Q) $(MAKE) $(build)=protobuf clean
|
||||
$(Q) $(MAKE) $(build)=pie clean
|
||||
$(Q) $(RM) ./*.o
|
||||
$(Q) $(RM) ./*.d
|
||||
$(Q) $(RM) ./*.i
|
||||
|
|
@ -216,7 +218,6 @@ clean:
|
|||
$(Q) $(RM) -r ./gcov
|
||||
$(Q) $(RM) -r ./test/lib/
|
||||
$(Q) $(RM) -r ./test/lib64/
|
||||
$(Q) $(MAKE) -C pie/ clean
|
||||
$(Q) $(MAKE) -C test/zdtm cleandep
|
||||
$(Q) $(MAKE) -C test/zdtm clean
|
||||
$(Q) $(MAKE) -C test/zdtm cleanout
|
||||
|
|
|
|||
88
pie/Makefile
88
pie/Makefile
|
|
@ -1,73 +1,51 @@
|
|||
CFLAGS += -c -I$(SRC_DIR)/syscall/
|
||||
CFLAGS += -fpie -Wa,--noexecstack -fno-strict-aliasing
|
||||
targets += parasite
|
||||
targets += restorer
|
||||
|
||||
GEN-OFFSETS := gen-offsets.sh
|
||||
obj-y += log-simple.o
|
||||
obj-y += util-net.o
|
||||
|
||||
PASM-OBJS += $(ARCH_DIR)/parasite-head.o
|
||||
RESTORER-ARCH-OBJS := $(ARCH_DIR)/restorer.o
|
||||
parasite-obj-y += parasite.o
|
||||
parasite-asm-e += $(ARCH_DIR)/parasite-head.o
|
||||
parasite-libs-e += $(SYSCALL-LIB)
|
||||
|
||||
PARASITE += parasite.bin.o parasite.bin
|
||||
RESTORER := restorer.bin.o restorer.bin
|
||||
BLOBS := parasite-blob.h restorer-blob.h
|
||||
PIELDS := pie.lds.S
|
||||
ASMFLAGS := -D__ASSEMBLY__
|
||||
restorer-obj-y += restorer.o
|
||||
restorer-obj-e += $(ARCH_DIR)/restorer.o
|
||||
restorer-libs-e += $(SYSCALL-LIB)
|
||||
|
||||
.DEFAULT_GOAL := pie
|
||||
CFLAGS += -fpie -Wa,--noexecstack -fno-strict-aliasing
|
||||
ASMFLAGS += -D__ASSEMBLY__
|
||||
|
||||
LIB-OBJS := log-simple.o blob-util-net.o
|
||||
DEPS := $(RESTORER-ARCH-OBJS:.o=.d) $(LIB-OBJS:.o=.d)
|
||||
GEN-OFFSETS := gen-offsets.sh
|
||||
BLOBS := $(obj)/parasite-blob.h $(obj)/restorer-blob.h
|
||||
|
||||
$(PARASITE): $(LIB-OBJS) $(PASM-OBJS) $(PIELDS)
|
||||
$(RESTORER): $(LIB-OBJS) $(RESTORER-ARCH-OBJS) $(PIELDS)
|
||||
PIELDS := pie.lds.S
|
||||
|
||||
$(PIELDS): $(PIELDS).in
|
||||
.SECONDARY:
|
||||
|
||||
$(obj)/$(PIELDS): $(obj)/$(PIELDS).in
|
||||
$(E) " GEN " $@
|
||||
$(Q) $(SH) -c "echo 'OUTPUT_ARCH($(LDARCH))' > $(PIELDS)"
|
||||
$(Q) $(SH) -c "cat $(PIELDS).in >> $(PIELDS)"
|
||||
$(Q) $(SH) -c "echo 'OUTPUT_ARCH($(LDARCH))' > $(obj)/$(PIELDS)"
|
||||
$(Q) $(SH) -c "cat $(obj)/$(PIELDS).in >> $(obj)/$(PIELDS)"
|
||||
|
||||
blob-util-net.d: $(SRC_DIR)/util-net.c
|
||||
%.d: %.c
|
||||
$(E) " DEP " $@
|
||||
$(Q) $(CC) -M -MT $@ -MT $(patsubst %.d,%.o,$@) $(CFLAGS) $< -o $@
|
||||
|
||||
blob-util-net.o: $(SRC_DIR)/util-net.c
|
||||
$(E) " CC " $@
|
||||
$(Q) $(CC) $(CFLAGS) $< -o $@
|
||||
|
||||
%.o: %.S
|
||||
$(E) " CC " $@
|
||||
$(Q) $(CC) $(ASMFLAGS) $(CFLAGS) $< -o $@
|
||||
|
||||
%.o: %.c
|
||||
$(E) " CC " $@
|
||||
$(Q) $(CC) $(CFLAGS) $< -o $@
|
||||
|
||||
%.bin.o: %.o
|
||||
$(obj)/%.built-in.bin.o: $(obj)/%.built-in.o $(obj)/$(PIELDS)
|
||||
$(E) " GEN " $@
|
||||
$(Q) $(LD) -T $(PIELDS) -o $@ $(^:$(PIELDS)=) ../$(SYSCALL-LIB)
|
||||
$(Q) $(LD) -T $(obj)/$(PIELDS) -o $@ $<
|
||||
|
||||
%.bin: %.bin.o
|
||||
$(obj)/%.built-in.bin: $(obj)/%.built-in.bin.o
|
||||
$(E) " GEN " $@
|
||||
$(Q) $(OBJCOPY) -O binary $< $@
|
||||
$(Q) $(OBJCOPY) -O binary $^ $@
|
||||
|
||||
%-blob.h: %.bin %.bin.o $(GEN-OFFSETS)
|
||||
$(obj)/%-blob.h: $(obj)/%.built-in.bin $(obj)/$(GEN-OFFSETS)
|
||||
$(E) " GEN " $@
|
||||
$(Q) $(SH) $(GEN-OFFSETS) $(@:-blob.h=) > $@ || rm -f $@
|
||||
$(Q) $(SH) $(obj)/$(GEN-OFFSETS) $(@:-blob.h=) $(notdir $(@:-blob.h=)) > $@
|
||||
|
||||
pie: $(BLOBS)
|
||||
$(BLOBS): $(obj)/$(PIELDS)
|
||||
_all += $(BLOBS)
|
||||
|
||||
cleanup-y += $(obj)/$(PIELDS)
|
||||
cleanup-y += $(obj)/*.bin
|
||||
cleanup-y += $(BLOBS)
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
-include $(DEPS)
|
||||
incdeps := y
|
||||
endif
|
||||
|
||||
clean:
|
||||
$(E) " CLEAN PIE"
|
||||
$(Q) $(RM) -f ./*-blob.h
|
||||
$(Q) $(RM) -f ./*.o
|
||||
$(Q) $(RM) -f ./*.d
|
||||
$(Q) $(RM) -f ./*.bin
|
||||
$(Q) $(RM) -f ./*.bin.o
|
||||
$(Q) $(RM) -f $(PIELDS)
|
||||
|
||||
.PHONY: clean pie
|
||||
.SECONDARY:
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
NAME=$1
|
||||
FILE=$1
|
||||
NAME=$2
|
||||
INC_GUARD=__${NAME}_h__
|
||||
PREFIX=${NAME}_blob_offset__
|
||||
BLOB=${NAME}_blob
|
||||
OBJNAME=${NAME}.bin.o
|
||||
BINARY=${NAME}.bin
|
||||
OBJNAME=${FILE}.built-in.bin.o
|
||||
BINARY=${FILE}.built-in.bin
|
||||
|
||||
AWK_CMD='$2 ~ /^[tT]$/ { print "#define '$PREFIX'" $3 " 0x" $1; }'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue