File: builtin-klp.c

package info (click to toggle)
linux 6.19.2-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 1,759,612 kB
  • sloc: ansic: 27,004,852; asm: 273,402; sh: 151,313; python: 81,277; makefile: 58,544; perl: 34,311; xml: 21,064; cpp: 5,984; yacc: 4,841; lex: 2,901; awk: 1,707; sed: 30; ruby: 25
file content (53 lines) | stat: -rw-r--r-- 1,111 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-License-Identifier: GPL-2.0-or-later
#include <subcmd/parse-options.h>
#include <string.h>
#include <stdlib.h>
#include <objtool/builtin.h>
#include <objtool/objtool.h>
#include <objtool/klp.h>

struct subcmd {
	const char *name;
	const char *description;
	int (*fn)(int, const char **);
};

static struct subcmd subcmds[] = {
	{ "diff",		"Generate binary diff of two object files",		cmd_klp_diff, },
	{ "post-link",		"Finalize klp symbols/relocs after module linking",	cmd_klp_post_link, },
};

static void cmd_klp_usage(void)
{
	fprintf(stderr, "usage: objtool klp <subcommand> [<options>]\n\n");
	fprintf(stderr, "Subcommands:\n");

	for (int i = 0; i < ARRAY_SIZE(subcmds); i++) {
		struct subcmd *cmd = &subcmds[i];

		fprintf(stderr, "  %s\t%s\n", cmd->name, cmd->description);
	}

	exit(1);
}

int cmd_klp(int argc, const char **argv)
{
	argc--;
	argv++;

	if (!argc)
		cmd_klp_usage();

	if (argc) {
		for (int i = 0; i < ARRAY_SIZE(subcmds); i++) {
			struct subcmd *cmd = &subcmds[i];

			if (!strcmp(cmd->name, argv[0]))
				return cmd->fn(argc, argv);
		}
	}

	cmd_klp_usage();
	return 0;
}