Blame view
tools/objtool/builtin-check.c
1.99 KB
1ccea77e2 treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-or-later |
442f04c34 objtool: Add tool... |
2 |
/* |
dcc914f44 objtool: Move che... |
3 |
* Copyright (C) 2015-2017 Josh Poimboeuf <jpoimboe@redhat.com> |
442f04c34 objtool: Add tool... |
4 5 6 7 8 9 10 11 12 13 14 |
*/ /* * objtool check: * * This command analyzes every .o file and ensures the validity of its stack * trace metadata. It enforces a set of rules on asm code and C inline * assembly code so that stack traces can be reliable. * * For more information, see tools/objtool/Documentation/stack-validation.txt. */ |
442f04c34 objtool: Add tool... |
15 |
#include <subcmd/parse-options.h> |
c4a33939a objtool: Implemen... |
16 |
#include <string.h> |
442f04c34 objtool: Add tool... |
17 |
#include "builtin.h" |
0decf1f8d objtool: Enable c... |
18 |
#include "objtool.h" |
442f04c34 objtool: Add tool... |
19 |
|
8fdc2dc3c FROMLIST: objtool... |
20 |
bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats, validate_dup, vmlinux, mcount, noinstr; |
442f04c34 objtool: Add tool... |
21 |
|
dcc914f44 objtool: Move che... |
22 |
static const char * const check_usage[] = { |
442f04c34 objtool: Add tool... |
23 24 25 |
"objtool check [<options>] file.o", NULL, }; |
dcc914f44 objtool: Move che... |
26 |
const struct option check_options[] = { |
867ac9d73 objtool: Fix gcov... |
27 28 |
OPT_BOOLEAN('f', "no-fp", &no_fp, "Skip frame pointer validation"), OPT_BOOLEAN('u', "no-unreachable", &no_unreachable, "Skip 'unreachable instruction' warnings"), |
b5bc2231b objtool: Add retp... |
29 |
OPT_BOOLEAN('r', "retpoline", &retpoline, "Validate retpoline assumptions"), |
ca41b97ed objtool: Add modu... |
30 |
OPT_BOOLEAN('m', "module", &module, "Indicates the object will be part of a kernel module"), |
7697eee3d objtool: Add --ba... |
31 |
OPT_BOOLEAN('b', "backtrace", &backtrace, "unwind on error"), |
ea24213d8 objtool: Add UACC... |
32 |
OPT_BOOLEAN('a', "uaccess", &uaccess, "enable uaccess checking"), |
1e11f3fdc objtool: Add a st... |
33 |
OPT_BOOLEAN('s', "stats", &stats, "print statistics"), |
c4a33939a objtool: Implemen... |
34 |
OPT_BOOLEAN('d', "duplicate", &validate_dup, "duplicate validation for vmlinux.o"), |
8fdc2dc3c FROMLIST: objtool... |
35 |
OPT_BOOLEAN('n', "noinstr", &noinstr, "noinstr validation for vmlinux.o"), |
c4a33939a objtool: Implemen... |
36 |
OPT_BOOLEAN('l', "vmlinux", &vmlinux, "vmlinux.o validation"), |
7dcfcd46b FROMLIST: objtool... |
37 |
OPT_BOOLEAN('M', "mcount", &mcount, "generate __mcount_loc"), |
dcc914f44 objtool: Move che... |
38 39 |
OPT_END(), }; |
442f04c34 objtool: Add tool... |
40 41 |
int cmd_check(int argc, const char **argv) { |
3dc2da692 FROMLIST: objtool... |
42 |
const char *objname; |
6545eb030 objtool: Move obj... |
43 |
struct objtool_file *file; |
d44becb9d objtool: Move ORC... |
44 |
int ret; |
442f04c34 objtool: Add tool... |
45 |
|
dcc914f44 objtool: Move che... |
46 |
argc = parse_options(argc, argv, check_options, check_usage, 0); |
442f04c34 objtool: Add tool... |
47 48 |
if (argc != 1) |
dcc914f44 objtool: Move che... |
49 |
usage_with_options(check_usage, check_options); |
442f04c34 objtool: Add tool... |
50 51 |
objname = argv[0]; |
6545eb030 objtool: Move obj... |
52 53 54 |
file = objtool_open_read(objname); if (!file) return 1; |
d44becb9d objtool: Move ORC... |
55 56 57 58 59 60 61 62 |
ret = check(file); if (ret) return ret; if (file->elf->changed) return elf_write(file->elf); return 0; |
442f04c34 objtool: Add tool... |
63 |
} |