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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
28 static const char *optstring
= "i:o:vh?";
29 static struct option long_options
[] = {
30 {"inelf", required_argument
, 0, 'i' },
31 {"outelf", required_argument
, 0, 'o' },
32 {"verbose", no_argument
, 0, 'v' },
33 {"help", no_argument
, 0, 'h' },
37 static void usage(char *name
)
40 "rmodtool: utility for creating rmodules\n\n"
41 "USAGE: %s [-h] [-v] <-i|--inelf name> <-o|--outelf name>\n",
46 int main(int argc
, char *argv
[])
51 const char *input_file
= NULL
;
52 const char *output_file
= NULL
;
62 c
= getopt_long(argc
, argv
, optstring
, long_options
, &optindex
);
85 if (input_file
== NULL
|| output_file
== NULL
) {
90 if (buffer_from_file(&elfin
, input_file
)) {
91 ERROR("Couldn't read in file '%s'.\n", input_file
);
95 if (rmodule_create(&elfin
, &elfout
)) {
96 ERROR("Unable to create rmodule from '%s'.\n", input_file
);
100 if (buffer_write_file(&elfout
, output_file
)) {
101 ERROR("Unable to write rmodule elf '%s'.\n", output_file
);