hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/tools/objtool/builtin-check.c
....@@ -1,18 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2015-2017 Josh Poimboeuf <jpoimboe@redhat.com>
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License
6
- * as published by the Free Software Foundation; either version 2
7
- * of the License, or (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
164 */
175
186 /*
....@@ -26,10 +14,12 @@
2614 */
2715
2816 #include <subcmd/parse-options.h>
17
+#include <string.h>
2918 #include "builtin.h"
30
-#include "check.h"
19
+#include "objtool.h"
3120
32
-bool no_fp, no_unreachable, retpoline, module;
21
+bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats,
22
+ validate_dup, vmlinux, mcount, noinstr, sls, unret, rethunk;
3323
3424 static const char * const check_usage[] = {
3525 "objtool check [<options>] file.o",
....@@ -40,13 +30,25 @@
4030 OPT_BOOLEAN('f', "no-fp", &no_fp, "Skip frame pointer validation"),
4131 OPT_BOOLEAN('u', "no-unreachable", &no_unreachable, "Skip 'unreachable instruction' warnings"),
4232 OPT_BOOLEAN('r', "retpoline", &retpoline, "Validate retpoline assumptions"),
33
+ OPT_BOOLEAN(0, "rethunk", &rethunk, "validate and annotate rethunk usage"),
34
+ OPT_BOOLEAN(0, "unret", &unret, "validate entry unret placement"),
4335 OPT_BOOLEAN('m', "module", &module, "Indicates the object will be part of a kernel module"),
36
+ OPT_BOOLEAN('b', "backtrace", &backtrace, "unwind on error"),
37
+ OPT_BOOLEAN('a', "uaccess", &uaccess, "enable uaccess checking"),
38
+ OPT_BOOLEAN('s', "stats", &stats, "print statistics"),
39
+ OPT_BOOLEAN('d', "duplicate", &validate_dup, "duplicate validation for vmlinux.o"),
40
+ OPT_BOOLEAN('n', "noinstr", &noinstr, "noinstr validation for vmlinux.o"),
41
+ OPT_BOOLEAN('l', "vmlinux", &vmlinux, "vmlinux.o validation"),
42
+ OPT_BOOLEAN('M', "mcount", &mcount, "generate __mcount_loc"),
43
+ OPT_BOOLEAN('S', "sls", &sls, "validate straight-line-speculation"),
4444 OPT_END(),
4545 };
4646
4747 int cmd_check(int argc, const char **argv)
4848 {
4949 const char *objname;
50
+ struct objtool_file *file;
51
+ int ret;
5052
5153 argc = parse_options(argc, argv, check_options, check_usage, 0);
5254
....@@ -55,5 +57,16 @@
5557
5658 objname = argv[0];
5759
58
- return check(objname, false);
60
+ file = objtool_open_read(objname);
61
+ if (!file)
62
+ return 1;
63
+
64
+ ret = check(file);
65
+ if (ret)
66
+ return ret;
67
+
68
+ if (file->elf->changed)
69
+ return elf_write(file->elf);
70
+
71
+ return 0;
5972 }