xref: /openbmc/linux/tools/objtool/builtin-check.c (revision dcc914f44f065ef73685b37e59877a5bb3cb7358)
1442f04c3SJosh Poimboeuf /*
2*dcc914f4SJosh Poimboeuf  * Copyright (C) 2015-2017 Josh Poimboeuf <jpoimboe@redhat.com>
3442f04c3SJosh Poimboeuf  *
4442f04c3SJosh Poimboeuf  * This program is free software; you can redistribute it and/or
5442f04c3SJosh Poimboeuf  * modify it under the terms of the GNU General Public License
6442f04c3SJosh Poimboeuf  * as published by the Free Software Foundation; either version 2
7442f04c3SJosh Poimboeuf  * of the License, or (at your option) any later version.
8442f04c3SJosh Poimboeuf  *
9442f04c3SJosh Poimboeuf  * This program is distributed in the hope that it will be useful,
10442f04c3SJosh Poimboeuf  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11442f04c3SJosh Poimboeuf  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12442f04c3SJosh Poimboeuf  * GNU General Public License for more details.
13442f04c3SJosh Poimboeuf  *
14442f04c3SJosh Poimboeuf  * You should have received a copy of the GNU General Public License
15442f04c3SJosh Poimboeuf  * along with this program; if not, see <http://www.gnu.org/licenses/>.
16442f04c3SJosh Poimboeuf  */
17442f04c3SJosh Poimboeuf 
18442f04c3SJosh Poimboeuf /*
19442f04c3SJosh Poimboeuf  * objtool check:
20442f04c3SJosh Poimboeuf  *
21442f04c3SJosh Poimboeuf  * This command analyzes every .o file and ensures the validity of its stack
22442f04c3SJosh Poimboeuf  * trace metadata.  It enforces a set of rules on asm code and C inline
23442f04c3SJosh Poimboeuf  * assembly code so that stack traces can be reliable.
24442f04c3SJosh Poimboeuf  *
25442f04c3SJosh Poimboeuf  * For more information, see tools/objtool/Documentation/stack-validation.txt.
26442f04c3SJosh Poimboeuf  */
27442f04c3SJosh Poimboeuf 
28442f04c3SJosh Poimboeuf #include <subcmd/parse-options.h>
29442f04c3SJosh Poimboeuf #include "builtin.h"
30*dcc914f4SJosh Poimboeuf #include "check.h"
31442f04c3SJosh Poimboeuf 
32*dcc914f4SJosh Poimboeuf bool nofp;
33442f04c3SJosh Poimboeuf 
34*dcc914f4SJosh Poimboeuf static const char * const check_usage[] = {
35442f04c3SJosh Poimboeuf 	"objtool check [<options>] file.o",
36442f04c3SJosh Poimboeuf 	NULL,
37442f04c3SJosh Poimboeuf };
38442f04c3SJosh Poimboeuf 
39*dcc914f4SJosh Poimboeuf const struct option check_options[] = {
40442f04c3SJosh Poimboeuf 	OPT_BOOLEAN('f', "no-fp", &nofp, "Skip frame pointer validation"),
41442f04c3SJosh Poimboeuf 	OPT_END(),
42442f04c3SJosh Poimboeuf };
43442f04c3SJosh Poimboeuf 
44*dcc914f4SJosh Poimboeuf int cmd_check(int argc, const char **argv)
45*dcc914f4SJosh Poimboeuf {
46*dcc914f4SJosh Poimboeuf 	const char *objname;
47*dcc914f4SJosh Poimboeuf 
48*dcc914f4SJosh Poimboeuf 	argc = parse_options(argc, argv, check_options, check_usage, 0);
49442f04c3SJosh Poimboeuf 
50442f04c3SJosh Poimboeuf 	if (argc != 1)
51*dcc914f4SJosh Poimboeuf 		usage_with_options(check_usage, check_options);
52442f04c3SJosh Poimboeuf 
53442f04c3SJosh Poimboeuf 	objname = argv[0];
54442f04c3SJosh Poimboeuf 
55*dcc914f4SJosh Poimboeuf 	return check(objname, nofp);
56442f04c3SJosh Poimboeuf }
57