Skip to content

Commit 2daf7fa

Browse files
jpoimboePeter Zijlstra
authored andcommitted
objtool: Reorganize cmdline options
Split the existing options into two groups: actions, which actually do something; and options, which modify the actions in some way. Also there's no need to have short flags for all the non-action options. Reserve short flags for the more important actions. While at it: - change a few of the short flags to be more intuitive - make option descriptions more consistently descriptive - sort options in the source like they are when printed - move options to a global struct Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Miroslav Benes <[email protected]> Link: https://lkml.kernel.org/r/9dcaa752f83aca24b1b21f0b0eeb28a0c181c0b0.1650300597.git.jpoimboe@redhat.com
1 parent aa3d60e commit 2daf7fa

File tree

9 files changed

+108
-78
lines changed

9 files changed

+108
-78
lines changed

scripts/Makefile.build

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,14 @@ objtool := $(objtree)/tools/objtool/objtool
228228

229229
objtool_args = \
230230
$(if $(CONFIG_UNWINDER_ORC),orc generate,check) \
231-
$(if $(part-of-module), --module) \
232231
$(if $(CONFIG_X86_KERNEL_IBT), --lto --ibt) \
233-
$(if $(CONFIG_FRAME_POINTER),, --no-fp) \
234-
$(if $(CONFIG_GCOV_KERNEL), --no-unreachable) \
232+
$(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount) \
235233
$(if $(CONFIG_RETPOLINE), --retpoline) \
234+
$(if $(CONFIG_SLS), --sls) \
236235
$(if $(CONFIG_X86_SMAP), --uaccess) \
237-
$(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount) \
238-
$(if $(CONFIG_SLS), --sls)
236+
$(if $(part-of-module), --module) \
237+
$(if $(CONFIG_FRAME_POINTER),, --no-fp) \
238+
$(if $(CONFIG_GCOV_KERNEL), --no-unreachable)
239239

240240
cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@)
241241
cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd)

scripts/link-vmlinux.sh

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,41 +117,49 @@ objtool_link()
117117
objtoolcmd="orc generate"
118118
fi
119119

120-
objtoolopt="${objtoolopt} --lto"
121-
122120
if is_enabled CONFIG_X86_KERNEL_IBT; then
123121
objtoolopt="${objtoolopt} --ibt"
124122
fi
125123

126124
if is_enabled CONFIG_FTRACE_MCOUNT_USE_OBJTOOL; then
127125
objtoolopt="${objtoolopt} --mcount"
128126
fi
127+
128+
objtoolopt="${objtoolopt} --lto"
129129
fi
130130

131131
if is_enabled CONFIG_VMLINUX_VALIDATION; then
132132
objtoolopt="${objtoolopt} --noinstr"
133133
fi
134134

135135
if [ -n "${objtoolopt}" ]; then
136+
136137
if [ -z "${objtoolcmd}" ]; then
137138
objtoolcmd="check"
138139
fi
139-
objtoolopt="${objtoolopt} --vmlinux"
140-
if ! is_enabled CONFIG_FRAME_POINTER; then
141-
objtoolopt="${objtoolopt} --no-fp"
142-
fi
143-
if is_enabled CONFIG_GCOV_KERNEL; then
144-
objtoolopt="${objtoolopt} --no-unreachable"
145-
fi
140+
146141
if is_enabled CONFIG_RETPOLINE; then
147142
objtoolopt="${objtoolopt} --retpoline"
148143
fi
144+
145+
if is_enabled CONFIG_SLS; then
146+
objtoolopt="${objtoolopt} --sls"
147+
fi
148+
149149
if is_enabled CONFIG_X86_SMAP; then
150150
objtoolopt="${objtoolopt} --uaccess"
151151
fi
152-
if is_enabled CONFIG_SLS; then
153-
objtoolopt="${objtoolopt} --sls"
152+
153+
if ! is_enabled CONFIG_FRAME_POINTER; then
154+
objtoolopt="${objtoolopt} --no-fp"
154155
fi
156+
157+
if is_enabled CONFIG_GCOV_KERNEL; then
158+
objtoolopt="${objtoolopt} --no-unreachable"
159+
fi
160+
161+
objtoolopt="${objtoolopt} --vmlinux"
162+
155163
info OBJTOOL ${1}
156164
tools/objtool/objtool ${objtoolcmd} ${objtoolopt} ${1}
157165
fi

tools/objtool/arch/x86/decode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
581581
break;
582582

583583
case 0xc7: /* mov imm, r/m */
584-
if (!noinstr)
584+
if (!opts.noinstr)
585585
break;
586586

587587
if (insn.length == 3+4+4 && !strncmp(sec->name, ".init.text", 10)) {

tools/objtool/arch/x86/special.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void arch_handle_alternative(unsigned short feature, struct special_alt *alt)
2020
* find paths that see the STAC but take the NOP instead of
2121
* CLAC and the other way around.
2222
*/
23-
if (uaccess)
23+
if (opts.uaccess)
2424
alt->skip_orig = true;
2525
else
2626
alt->skip_alt = true;

tools/objtool/builtin-check.c

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
#include <objtool/builtin.h>
2020
#include <objtool/objtool.h>
2121

22-
bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats,
23-
lto, vmlinux, mcount, noinstr, backup, sls, dryrun,
24-
ibt;
22+
struct opts opts;
2523

2624
static const char * const check_usage[] = {
27-
"objtool check [<options>] file.o",
25+
"objtool check <actions> [<options>] file.o",
2826
NULL,
2927
};
3028

@@ -34,21 +32,25 @@ static const char * const env_usage[] = {
3432
};
3533

3634
const struct option check_options[] = {
37-
OPT_BOOLEAN('f', "no-fp", &no_fp, "Skip frame pointer validation"),
38-
OPT_BOOLEAN('u', "no-unreachable", &no_unreachable, "Skip 'unreachable instruction' warnings"),
39-
OPT_BOOLEAN('r', "retpoline", &retpoline, "Validate retpoline assumptions"),
40-
OPT_BOOLEAN('m', "module", &module, "Indicates the object will be part of a kernel module"),
41-
OPT_BOOLEAN('b', "backtrace", &backtrace, "unwind on error"),
42-
OPT_BOOLEAN('a', "uaccess", &uaccess, "enable uaccess checking"),
43-
OPT_BOOLEAN('s', "stats", &stats, "print statistics"),
44-
OPT_BOOLEAN(0, "lto", &lto, "whole-archive like runs"),
45-
OPT_BOOLEAN('n', "noinstr", &noinstr, "noinstr validation for vmlinux.o"),
46-
OPT_BOOLEAN('l', "vmlinux", &vmlinux, "vmlinux.o validation"),
47-
OPT_BOOLEAN('M', "mcount", &mcount, "generate __mcount_loc"),
48-
OPT_BOOLEAN('B', "backup", &backup, "create .orig files before modification"),
49-
OPT_BOOLEAN('S', "sls", &sls, "validate straight-line-speculation"),
50-
OPT_BOOLEAN(0, "dry-run", &dryrun, "don't write the modifications"),
51-
OPT_BOOLEAN(0, "ibt", &ibt, "validate ENDBR placement"),
35+
OPT_GROUP("Actions:"),
36+
OPT_BOOLEAN('i', "ibt", &opts.ibt, "validate and annotate IBT"),
37+
OPT_BOOLEAN('m', "mcount", &opts.mcount, "annotate mcount/fentry calls for ftrace"),
38+
OPT_BOOLEAN('n', "noinstr", &opts.noinstr, "validate noinstr rules"),
39+
OPT_BOOLEAN('r', "retpoline", &opts.retpoline, "validate and annotate retpoline usage"),
40+
OPT_BOOLEAN('l', "sls", &opts.sls, "validate straight-line-speculation mitigations"),
41+
OPT_BOOLEAN('u', "uaccess", &opts.uaccess, "validate uaccess rules for SMAP"),
42+
43+
OPT_GROUP("Options:"),
44+
OPT_BOOLEAN(0, "backtrace", &opts.backtrace, "unwind on error"),
45+
OPT_BOOLEAN(0, "backup", &opts.backup, "create .orig files before modification"),
46+
OPT_BOOLEAN(0, "dry-run", &opts.dryrun, "don't write modifications"),
47+
OPT_BOOLEAN(0, "lto", &opts.lto, "whole-archive like runs"),
48+
OPT_BOOLEAN(0, "module", &opts.module, "object is part of a kernel module"),
49+
OPT_BOOLEAN(0, "no-fp", &opts.no_fp, "skip frame pointer validation"),
50+
OPT_BOOLEAN(0, "no-unreachable", &opts.no_unreachable, "skip 'unreachable instruction' warnings"),
51+
OPT_BOOLEAN(0, "stats", &opts.stats, "print statistics"),
52+
OPT_BOOLEAN(0, "vmlinux", &opts.vmlinux, "vmlinux.o validation"),
53+
5254
OPT_END(),
5355
};
5456

0 commit comments

Comments
 (0)