diff options
author | Kir Kolyshkin <kir@openvz.org> | 2016-12-17 14:22:11 +0300 |
---|---|---|
committer | Andrei Vagin <avagin@virtuozzo.com> | 2017-03-15 00:09:56 +0300 |
commit | 9f41af0325dade01d7fbf8aad4e96b70ecd3d664 (patch) | |
tree | 89ade0e4f3168d0b06d60c874c4346725ae4d01c /compel/src | |
parent | e3a9aefae4c1b45783f50e389f721478095e499e (diff) |
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>
Diffstat (limited to 'compel/src')
-rw-r--r-- | compel/src/main.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/compel/src/main.c b/compel/src/main.c index f91fe2729..cd4753c1c 100644 --- a/compel/src/main.c +++ b/compel/src/main.c @@ -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; } |