]>
git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - tools/objtool/objtool.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com>
9 * The 'check' subcmd analyzes every .o file and ensures the validity of its
10 * stack trace metadata. It enforces a set of rules on asm code and C inline
11 * assembly code so that stack traces can be reliable.
13 * For more information, see tools/objtool/Documentation/stack-validation.txt.
20 #include <subcmd/exec-cmd.h>
21 #include <subcmd/pager.h>
22 #include <linux/kernel.h>
28 int (*fn
)(int, const char **);
32 static const char objtool_usage_string
[] =
33 "objtool COMMAND [ARGS]";
35 static struct cmd_struct objtool_cmds
[] = {
36 {"check", cmd_check
, "Perform stack metadata validation on an object file" },
37 {"orc", cmd_orc
, "Generate in-place ORC unwind tables for an object file" },
42 static void cmd_usage(void)
44 unsigned int i
, longest
= 0;
46 printf("\n usage: %s\n\n", objtool_usage_string
);
48 for (i
= 0; i
< ARRAY_SIZE(objtool_cmds
); i
++) {
49 if (longest
< strlen(objtool_cmds
[i
].name
))
50 longest
= strlen(objtool_cmds
[i
].name
);
54 for (i
= 0; i
< ARRAY_SIZE(objtool_cmds
); i
++) {
55 printf(" %-*s ", longest
, objtool_cmds
[i
].name
);
56 puts(objtool_cmds
[i
].help
);
66 static void handle_options(int *argc
, const char ***argv
)
69 const char *cmd
= (*argv
)[0];
74 if (!strcmp(cmd
, "--help") || !strcmp(cmd
, "-h")) {
78 fprintf(stderr
, "Unknown option: %s\n", cmd
);
87 static void handle_internal_command(int argc
, const char **argv
)
89 const char *cmd
= argv
[0];
92 for (i
= 0; i
< ARRAY_SIZE(objtool_cmds
); i
++) {
93 struct cmd_struct
*p
= objtool_cmds
+i
;
95 if (strcmp(p
->name
, cmd
))
98 ret
= p
->fn(argc
, argv
);
106 int main(int argc
, const char **argv
)
108 static const char *UNUSED
= "OBJTOOL_NOT_IMPLEMENTED";
111 exec_cmd_init("objtool", UNUSED
, UNUSED
, UNUSED
);
116 handle_options(&argc
, &argv
);
121 handle_internal_command(argc
, argv
);