Commit ec973560 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Andrei Vagin

compel: piegen -- Add @arch option

This will be needed to print out cflags and ldflags.
Unused at moment.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent d771ffb9
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
#include "config.h" #include "config.h"
#include "piegen.h" #include "piegen.h"
static const char compel_cflags_pie[] = "-fpie -Wa,--noexecstack -fno-stack-protector";
static const char compel_cflags_nopic[] = "-fno-pic -Wa,--noexecstack -fno-stack-protector";
static const char compel_ldflags[] = "-r";
piegen_opt_t opts = { piegen_opt_t opts = {
.input_filename = NULL, .input_filename = NULL,
.uapi_dir = "piegen/uapi", .uapi_dir = "piegen/uapi",
...@@ -71,13 +75,39 @@ static int handle_elf(void *mem, size_t size) ...@@ -71,13 +75,39 @@ static int handle_elf(void *mem, size_t size)
*/ */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
const char *current_cflags = NULL;
struct stat st; struct stat st;
int opt, idx; int opt, idx, i;
void *mem; void *mem;
int fd; int fd;
static const char short_opts[] = "f:o:s:p:v:r:u:h"; typedef struct {
const char *arch;
const char *cflags;
} compel_cflags_t;
static const compel_cflags_t compel_cflags[] = {
{
.arch = "x86",
.cflags = compel_cflags_pie,
}, {
.arch = "ia32",
.cflags = compel_cflags_nopic,
}, {
.arch = "aarch64",
.cflags = compel_cflags_pie,
}, {
.arch = "arm",
.cflags = compel_cflags_pie,
}, {
.arch = "ppc64",
.cflags = compel_cflags_pie,
},
};
static const char short_opts[] = "a:f:o:s:p:v:r:u:h";
static struct option long_opts[] = { static struct option long_opts[] = {
{ "arch", required_argument, 0, 'a' },
{ "file", required_argument, 0, 'f' }, { "file", required_argument, 0, 'f' },
{ "output", required_argument, 0, 'o' }, { "output", required_argument, 0, 'o' },
{ "stream", required_argument, 0, 's' }, { "stream", required_argument, 0, 's' },
...@@ -98,6 +128,17 @@ int main(int argc, char *argv[]) ...@@ -98,6 +128,17 @@ int main(int argc, char *argv[])
if (opt == -1) if (opt == -1)
break; break;
switch (opt) { switch (opt) {
case 'a':
for (i = 0; i < ARRAY_SIZE(compel_cflags); i++) {
if (!strcmp(optarg, compel_cflags[i].arch)) {
current_cflags = compel_cflags[i].cflags;
break;
}
}
if (!current_cflags)
goto usage;
break;
case 'f': case 'f':
opts.input_filename = optarg; opts.input_filename = optarg;
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment