Skip to content

Commit 900b4df

Browse files
Peter Zijlstraingomolnar
authored andcommitted
objtool: Parse options from OBJTOOL_ARGS
Teach objtool to parse options from the OBJTOOL_ARGS environment variable. This enables things like: $ OBJTOOL_ARGS="--backup" make O=defconfig-build/ kernel/ponies.o to obtain both defconfig-build/kernel/ponies.o{,.orig} and easily inspect what objtool actually did. Suggested-by: Borislav Petkov <bp@alien8.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Link: https://lkml.kernel.org/r/20210226110004.252553847@infradead.org
1 parent a2f605f commit 900b4df

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎tools/objtool/builtin-check.c‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <subcmd/parse-options.h>
1717
#include <string.h>
18+
#include <stdlib.h>
1819
#include <objtool/builtin.h>
1920
#include <objtool/objtool.h>
2021

@@ -26,6 +27,11 @@ static const char * const check_usage[] = {
2627
NULL,
2728
};
2829

30+
static const char * const env_usage[] = {
31+
"OBJTOOL_ARGS=\"<options>\"",
32+
NULL,
33+
};
34+
2935
const struct option check_options[] = {
3036
OPT_BOOLEAN('f', "no-fp", &no_fp, "Skip frame pointer validation"),
3137
OPT_BOOLEAN('u', "no-unreachable", &no_unreachable, "Skip 'unreachable instruction' warnings"),
@@ -44,6 +50,25 @@ const struct option check_options[] = {
4450

4551
int cmd_parse_options(int argc, const char **argv, const char * const usage[])
4652
{
53+
const char *envv[16] = { };
54+
char *env;
55+
int envc;
56+
57+
env = getenv("OBJTOOL_ARGS");
58+
if (env) {
59+
envv[0] = "OBJTOOL_ARGS";
60+
for (envc = 1; envc < ARRAY_SIZE(envv); ) {
61+
envv[envc++] = env;
62+
env = strchr(env, ' ');
63+
if (!env)
64+
break;
65+
*env = '\0';
66+
env++;
67+
}
68+
69+
parse_options(envc, envv, check_options, env_usage, 0);
70+
}
71+
4772
argc = parse_options(argc, argv, check_options, usage, 0);
4873
if (argc != 1)
4974
usage_with_options(usage, check_options);

0 commit comments

Comments
 (0)