1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2017 Josh Poimboeuf <jpoimboe@redhat.com>
9 * This command analyzes a .o file and adds .orc_unwind and .orc_unwind_ip
10 * sections to it, which is used by the in-kernel ORC unwinder.
12 * This command is a superset of "objtool check".
16 #include <objtool/builtin.h>
17 #include <objtool/objtool.h>
19 static const char *orc_usage[] = {
20 "objtool orc generate [<options>] file.o",
21 "objtool orc dump file.o",
25 int cmd_orc(int argc, const char **argv)
31 usage_with_options(orc_usage, check_options);
33 if (!strncmp(argv[0], "gen", 3)) {
34 struct objtool_file *file;
37 argc = cmd_parse_options(argc, argv, orc_usage);
40 file = objtool_open_read(objname);
48 if (list_empty(&file->insn_list))
51 ret = orc_create(file);
55 if (!file->elf->changed)
58 return elf_write(file->elf);
61 if (!strcmp(argv[0], "dump")) {
63 usage_with_options(orc_usage, check_options);
67 return orc_dump(objname);
70 usage_with_options(orc_usage, check_options);