2 * cbfstool, CLI utility for creating rmodules
4 * Copyright (C) 2014 Google, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
24 static const char *optstring
= "i:o:vh?";
25 static struct option long_options
[] = {
26 {"inelf", required_argument
, 0, 'i' },
27 {"outelf", required_argument
, 0, 'o' },
28 {"verbose", no_argument
, 0, 'v' },
29 {"help", no_argument
, 0, 'h' },
33 static void usage(char *name
)
36 "rmodtool: utility for creating rmodules\n\n"
37 "USAGE: %s [-h] [-v] <-i|--inelf name> <-o|--outelf name>\n",
42 int main(int argc
, char *argv
[])
47 const char *input_file
= NULL
;
48 const char *output_file
= NULL
;
58 c
= getopt_long(argc
, argv
, optstring
, long_options
, &optindex
);
81 if (input_file
== NULL
|| output_file
== NULL
) {
86 if (buffer_from_file(&elfin
, input_file
)) {
87 ERROR("Couldn't read in file '%s'.\n", input_file
);
91 if (rmodule_create(&elfin
, &elfout
)) {
92 ERROR("Unable to create rmodule from '%s'.\n", input_file
);
96 if (buffer_write_file(&elfout
, output_file
)) {
97 ERROR("Unable to write rmodule elf '%s'.\n", output_file
);