hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/tools/objtool/builtin-orc.c
....@@ -1,18 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 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,8 +14,7 @@
2614
2715 #include <string.h>
2816 #include "builtin.h"
29
-#include "check.h"
30
-
17
+#include "objtool.h"
3118
3219 static const char *orc_usage[] = {
3320 "objtool orc generate [<options>] file.o",
....@@ -44,13 +31,34 @@
4431 usage_with_options(orc_usage, check_options);
4532
4633 if (!strncmp(argv[0], "gen", 3)) {
34
+ struct objtool_file *file;
35
+ int ret;
36
+
4737 argc = parse_options(argc, argv, check_options, orc_usage, 0);
4838 if (argc != 1)
4939 usage_with_options(orc_usage, check_options);
5040
5141 objname = argv[0];
5242
53
- return check(objname, true);
43
+ file = objtool_open_read(objname);
44
+ if (!file)
45
+ return 1;
46
+
47
+ ret = check(file);
48
+ if (ret)
49
+ return ret;
50
+
51
+ if (list_empty(&file->insn_list))
52
+ return 0;
53
+
54
+ ret = orc_create(file);
55
+ if (ret)
56
+ return ret;
57
+
58
+ if (!file->elf->changed)
59
+ return 0;
60
+
61
+ return elf_write(file->elf);
5462 }
5563
5664 if (!strcmp(argv[0], "dump")) {