Thomas Gleixner | 1ccea77 | 2019-05-19 15:51:43 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Josh Poimboeuf | 627fce1 | 2017-07-11 10:33:42 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2017 Josh Poimboeuf <jpoimboe@redhat.com> |
Josh Poimboeuf | 627fce1 | 2017-07-11 10:33:42 -0500 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * objtool orc: |
| 8 | * |
| 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. |
| 11 | * |
| 12 | * This command is a superset of "objtool check". |
| 13 | */ |
| 14 | |
| 15 | #include <string.h> |
Josh Poimboeuf | 627fce1 | 2017-07-11 10:33:42 -0500 | [diff] [blame] | 16 | #include "builtin.h" |
| 17 | #include "check.h" |
| 18 | |
| 19 | |
| 20 | static const char *orc_usage[] = { |
| 21 | "objtool orc generate [<options>] file.o", |
| 22 | "objtool orc dump file.o", |
| 23 | NULL, |
| 24 | }; |
| 25 | |
Josh Poimboeuf | 627fce1 | 2017-07-11 10:33:42 -0500 | [diff] [blame] | 26 | int cmd_orc(int argc, const char **argv) |
| 27 | { |
| 28 | const char *objname; |
| 29 | |
| 30 | argc--; argv++; |
Simon Ser | d89e426 | 2017-12-30 14:43:31 -0600 | [diff] [blame] | 31 | if (argc <= 0) |
| 32 | usage_with_options(orc_usage, check_options); |
| 33 | |
Josh Poimboeuf | 627fce1 | 2017-07-11 10:33:42 -0500 | [diff] [blame] | 34 | if (!strncmp(argv[0], "gen", 3)) { |
| 35 | argc = parse_options(argc, argv, check_options, orc_usage, 0); |
| 36 | if (argc != 1) |
| 37 | usage_with_options(orc_usage, check_options); |
| 38 | |
| 39 | objname = argv[0]; |
| 40 | |
Peter Zijlstra | 43a4525 | 2018-01-16 17:16:32 +0100 | [diff] [blame] | 41 | return check(objname, true); |
Josh Poimboeuf | 627fce1 | 2017-07-11 10:33:42 -0500 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | if (!strcmp(argv[0], "dump")) { |
| 45 | if (argc != 2) |
| 46 | usage_with_options(orc_usage, check_options); |
| 47 | |
| 48 | objname = argv[1]; |
| 49 | |
| 50 | return orc_dump(objname); |
| 51 | } |
| 52 | |
| 53 | usage_with_options(orc_usage, check_options); |
| 54 | |
| 55 | return 0; |
| 56 | } |