Merge series "ASoC: Intel: machine driver updates for 5.9" from Pierre-Louis Bossart...
[linux-2.6-microblaze.git] / tools / objtool / builtin-orc.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2017 Josh Poimboeuf <jpoimboe@redhat.com>
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>
16 #include "builtin.h"
17 #include "objtool.h"
18
19 static const char *orc_usage[] = {
20         "objtool orc generate [<options>] file.o",
21         "objtool orc dump file.o",
22         NULL,
23 };
24
25 int cmd_orc(int argc, const char **argv)
26 {
27         const char *objname;
28
29         argc--; argv++;
30         if (argc <= 0)
31                 usage_with_options(orc_usage, check_options);
32
33         if (!strncmp(argv[0], "gen", 3)) {
34                 argc = parse_options(argc, argv, check_options, orc_usage, 0);
35                 if (argc != 1)
36                         usage_with_options(orc_usage, check_options);
37
38                 objname = argv[0];
39
40                 return check(objname, true);
41         }
42
43         if (!strcmp(argv[0], "dump")) {
44                 if (argc != 2)
45                         usage_with_options(orc_usage, check_options);
46
47                 objname = argv[1];
48
49                 return orc_dump(objname);
50         }
51
52         usage_with_options(orc_usage, check_options);
53
54         return 0;
55 }