kallsyms: take the input file instead of reading stdin
This gets rid of the pipe operator connected with 'cat'. Also use getopt_long() to parse the command line. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
parent
a2833d1b07
commit
aa221f2ea5
@ -18,6 +18,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <getopt.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -71,7 +72,7 @@ static unsigned char best_table_len[256];
|
|||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: kallsyms [--all-symbols] [--absolute-percpu] "
|
fprintf(stderr, "Usage: kallsyms [--all-symbols] [--absolute-percpu] "
|
||||||
"[--base-relative] < in.map > out.S\n");
|
"[--base-relative] in.map > out.S\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,12 +311,19 @@ static void shrink_table(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void read_map(FILE *in)
|
static void read_map(const char *in)
|
||||||
{
|
{
|
||||||
|
FILE *fp;
|
||||||
struct sym_entry *sym;
|
struct sym_entry *sym;
|
||||||
|
|
||||||
while (!feof(in)) {
|
fp = fopen(in, "r");
|
||||||
sym = read_symbol(in);
|
if (!fp) {
|
||||||
|
perror(in);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!feof(fp)) {
|
||||||
|
sym = read_symbol(fp);
|
||||||
if (!sym)
|
if (!sym)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -326,12 +334,15 @@ static void read_map(FILE *in)
|
|||||||
table = realloc(table, sizeof(*table) * table_size);
|
table = realloc(table, sizeof(*table) * table_size);
|
||||||
if (!table) {
|
if (!table) {
|
||||||
fprintf(stderr, "out of memory\n");
|
fprintf(stderr, "out of memory\n");
|
||||||
|
fclose(fp);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table[table_cnt++] = sym;
|
table[table_cnt++] = sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void output_label(const char *label)
|
static void output_label(const char *label)
|
||||||
@ -762,22 +773,26 @@ static void record_relative_base(void)
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc >= 2) {
|
while (1) {
|
||||||
int i;
|
static struct option long_options[] = {
|
||||||
for (i = 1; i < argc; i++) {
|
{"all-symbols", no_argument, &all_symbols, 1},
|
||||||
if(strcmp(argv[i], "--all-symbols") == 0)
|
{"absolute-percpu", no_argument, &absolute_percpu, 1},
|
||||||
all_symbols = 1;
|
{"base-relative", no_argument, &base_relative, 1},
|
||||||
else if (strcmp(argv[i], "--absolute-percpu") == 0)
|
{},
|
||||||
absolute_percpu = 1;
|
};
|
||||||
else if (strcmp(argv[i], "--base-relative") == 0)
|
|
||||||
base_relative = 1;
|
int c = getopt_long(argc, argv, "", long_options, NULL);
|
||||||
else
|
|
||||||
usage();
|
if (c == -1)
|
||||||
}
|
break;
|
||||||
} else if (argc != 1)
|
if (c != 0)
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind >= argc)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
read_map(stdin);
|
read_map(argv[optind]);
|
||||||
shrink_table();
|
shrink_table();
|
||||||
if (absolute_percpu)
|
if (absolute_percpu)
|
||||||
make_percpus_absolute();
|
make_percpus_absolute();
|
||||||
|
@ -157,7 +157,7 @@ kallsyms()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
info KSYMS ${2}
|
info KSYMS ${2}
|
||||||
cat ${1} | scripts/kallsyms ${kallsymopt} > ${2}
|
scripts/kallsyms ${kallsymopt} ${1} > ${2}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Perform one step in kallsyms generation, including temporary linking of
|
# Perform one step in kallsyms generation, including temporary linking of
|
||||||
|
Loading…
Reference in New Issue
Block a user