1 /* CLI utility for creating rmodules */
2 /* SPDX-License-Identifier: GPL-2.0-only */
12 static const char *optstring
= "i:o:vh?";
13 static struct option long_options
[] = {
14 {"inelf", required_argument
, 0, 'i' },
15 {"outelf", required_argument
, 0, 'o' },
16 {"verbose", no_argument
, 0, 'v' },
17 {"help", no_argument
, 0, 'h' },
21 static void usage(char *name
)
24 "rmodtool: utility for creating rmodules\n\n"
25 "USAGE: %s [-h] [-v] <-i|--inelf name> <-o|--outelf name>\n",
30 int main(int argc
, char *argv
[])
35 const char *input_file
= NULL
;
36 const char *output_file
= NULL
;
46 c
= getopt_long(argc
, argv
, optstring
, long_options
, &optindex
);
69 if (input_file
== NULL
|| output_file
== NULL
) {
74 if (buffer_from_file(&elfin
, input_file
)) {
75 ERROR("Couldn't read in file '%s'.\n", input_file
);
79 if (rmodule_create(&elfin
, &elfout
)) {
80 ERROR("Unable to create rmodule from '%s'.\n", input_file
);
84 if (buffer_write_file(&elfout
, output_file
)) {
85 ERROR("Unable to write rmodule elf '%s'.\n", output_file
);