mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 10:16:41 +00:00
compel cli: add linker script to ldflags / use it
This commit adds -T path/to/linker_script to the output of "compel ldflags", so compel user does not have to specify one manually. This commit also makes use of this functionality in criu/pie and compel/test. NOTE this commit also drops the linker script dependency in criu/pie/Makefile, meaning if it will be changed that won't cause a rebuild. I hope it's not a big issue, and it is sort of inevitable as compel is becoming a separate tool. travis-ci: success for More polishing for compel cli Signed-off-by: Kir Kolyshkin <kir@openvz.org> Acked-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
e3a9aefae4
commit
9f41af0325
4 changed files with 28 additions and 8 deletions
|
|
@ -3,6 +3,7 @@ include $(SRC_DIR)/Makefile.versions
|
|||
COMPEL_SO_VERSION := $(COMPEL_SO_VERSION_MAJOR)$(if $(COMPEL_SO_VERSION_MINOR),.$(COMPEL_SO_VERSION_MINOR))$(if $(COMPEL_SO_VERSION_SUBLEVEL),.$(COMPEL_SO_VERSION_SUBLEVEL))
|
||||
COMPEL_SO_VERSION_CODE := $(shell expr $(COMPEL_SO_VERSION_MAJOR) \* 65536 \+ $(COMPEL_SO_VERSION_MINOR) \* 256 \+ $(COMPEL_SO_VERSION_SUBLEVEL))
|
||||
ccflags-y += -DINCLUDEDIR=\"$(INCLUDEDIR)\"
|
||||
ccflags-y += -DLIBEXECDIR=\"$(LIBEXECDIR)\"
|
||||
ccflags-y += -iquote compel/arch/$(ARCH)/src/lib/include
|
||||
ccflags-y += -iquote compel/include
|
||||
ccflags-y += -fno-strict-aliasing
|
||||
|
|
|
|||
|
|
@ -25,22 +25,27 @@
|
|||
#define COMPEL_CFLAGS_PIE CFLAGS_DEFAULT_SET "-fpie"
|
||||
#define COMPEL_CFLAGS_NOPIC CFLAGS_DEFAULT_SET "-fno-pic"
|
||||
|
||||
#define COMPEL_LDFLAGS_DEFAULT "-r -z noexecstack"
|
||||
#define COMPEL_LDFLAGS_COMMON "-r -z noexecstack -T "
|
||||
|
||||
typedef struct {
|
||||
const char *arch; // dir name under arch/
|
||||
const char *cflags;
|
||||
const char *cflags_compat;
|
||||
} flags_t;
|
||||
|
||||
static const flags_t flags = {
|
||||
#if defined CONFIG_X86_64
|
||||
.arch = "x86",
|
||||
.cflags = COMPEL_CFLAGS_PIE,
|
||||
.cflags_compat = COMPEL_CFLAGS_NOPIC,
|
||||
#elif defined CONFIG_AARCH64
|
||||
.arch = "aarch64",
|
||||
.cflags = COMPEL_CFLAGS_PIE,
|
||||
#elif defined(CONFIG_ARMV6) || defined(CONFIG_ARMV7)
|
||||
.arch = "arm",
|
||||
.cflags = COMPEL_CFLAGS_PIE,
|
||||
#elif defined CONFIG_PPC64
|
||||
.arch = "ppc64",
|
||||
.cflags = COMPEL_CFLAGS_PIE,
|
||||
#else
|
||||
#error "CONFIG_<ARCH> not defined, or unsupported ARCH"
|
||||
|
|
@ -160,6 +165,23 @@ static void print_cflags(bool compat)
|
|||
print_includes();
|
||||
}
|
||||
|
||||
static void print_ldflags(bool compat)
|
||||
{
|
||||
const char *compat_str = (compat) ? "-compat" : "";
|
||||
|
||||
printf("%s", COMPEL_LDFLAGS_COMMON);
|
||||
|
||||
if (uninst_root) {
|
||||
printf("%s/arch/%s/scripts/compel-pack%s.lds.S\n",
|
||||
uninst_root, flags.arch, compat_str);
|
||||
}
|
||||
else {
|
||||
printf("%s/compel/scripts/compel-pack%s.lds.S\n",
|
||||
LIBEXECDIR, compat_str);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int log_level = DEFAULT_LOGLEVEL;
|
||||
|
|
@ -234,7 +256,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (!strcmp(action, "ldflags")) {
|
||||
printf("%s", COMPEL_LDFLAGS_DEFAULT);
|
||||
print_ldflags(compat);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
CC := gcc
|
||||
CFLAGS ?= -O2 -g -Wall -Werror
|
||||
ARCH ?= x86
|
||||
|
||||
COMPEL := ../../../compel/compel-host
|
||||
COMPEL_PACK_LDS := ../../../compel/arch/$(ARCH)/scripts/compel-pack.lds.S
|
||||
COMPEL_PLUGINS := ../../../compel/plugins
|
||||
COMPEL_LIBRARY := ../../../compel/libcompel.a
|
||||
|
||||
|
|
@ -28,7 +26,7 @@ parasite.h: parasite.po
|
|||
-o $@
|
||||
|
||||
parasite.po: parasite.o $(COMPEL_PLUGINS)/std.built-in.o
|
||||
ld -r -T $(COMPEL_PACK_LDS) -o $@ $^
|
||||
ld $(shell $(COMPEL) ldflags) -o $@ $^
|
||||
|
||||
parasite.o: parasite.c
|
||||
$(CC) $(CFLAGS) -c $(shell $(COMPEL) cflags) -o $@ $^
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
target += parasite restorer
|
||||
|
||||
compel_lds := $(SRC_DIR)/compel/arch/$(ARCH)/scripts/compel-pack.lds.S
|
||||
compel_std := $(SRC_DIR)/compel/plugins/std.built-in.o
|
||||
parasite-obj-e += ./compel/plugins/std.built-in.o
|
||||
restorer-obj-e += ./compel/plugins/std.built-in.o
|
||||
|
|
@ -57,9 +56,9 @@ endif
|
|||
|
||||
$(obj)/restorer.built-in.o: $(compel_std)
|
||||
$(obj)/parasite.built-in.o: $(compel_std)
|
||||
$(obj)/%.built-in.bin.o: $(obj)/%.built-in.o $(obj)/pie.lib.a $(compel_lds)
|
||||
$(obj)/%.built-in.bin.o: $(obj)/%.built-in.o $(obj)/pie.lib.a
|
||||
$(call msg-gen, $@)
|
||||
$(Q) $(LD) -r -T $(compel_lds) -o $@ $< $(obj)/pie.lib.a
|
||||
$(Q) $(LD) $(shell $(COMPEL_BIN) ldflags) -o $@ $< $(obj)/pie.lib.a
|
||||
|
||||
$(obj)/%-blob.h: $(obj)/%.built-in.bin.o $(SRC_DIR)/compel/compel-host-bin
|
||||
$(call msg-gen, $@)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue