static unsigned int table_size, table_cnt;
static int all_symbols = 0;
static int absolute_percpu = 0;
-static char symbol_prefix_char = '\0';
static int base_relative = 0;
int token_profit[0x10000];
static void usage(void)
{
fprintf(stderr, "Usage: kallsyms [--all-symbols] "
- "[--symbol-prefix=<prefix char>] "
"[--base-relative] < in.map > out.S\n");
exit(1);
}
static int read_symbol(FILE *in, struct sym_entry *s)
{
- char str[500];
- char *sym, stype;
+ char sym[500], stype;
int rc;
- rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, str);
+ rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, sym);
if (rc != 3) {
- if (rc != EOF && fgets(str, 500, in) == NULL)
+ if (rc != EOF && fgets(sym, 500, in) == NULL)
fprintf(stderr, "Read error or end of file.\n");
return -1;
}
- if (strlen(str) > KSYM_NAME_LEN) {
+ if (strlen(sym) > KSYM_NAME_LEN) {
fprintf(stderr, "Symbol %s too long for kallsyms (%zu vs %d).\n"
"Please increase KSYM_NAME_LEN both in kernel and kallsyms.c\n",
- str, strlen(str), KSYM_NAME_LEN);
+ sym, strlen(sym), KSYM_NAME_LEN);
return -1;
}
- sym = str;
- /* skip prefix char */
- if (symbol_prefix_char && str[0] == symbol_prefix_char)
- sym++;
-
/* Ignore most absolute/undefined (?) symbols. */
if (strcmp(sym, "_text") == 0)
_text = s->addr;
is_arm_mapping_symbol(sym))
return -1;
/* exclude also MIPS ELF local symbols ($L123 instead of .L123) */
- else if (str[0] == '$')
+ else if (sym[0] == '$')
return -1;
/* exclude debugging symbols */
else if (stype == 'N' || stype == 'n')
/* include the type field in the symbol name, so that it gets
* compressed together */
- s->len = strlen(str) + 1;
+ s->len = strlen(sym) + 1;
s->sym = malloc(s->len + 1);
if (!s->sym) {
fprintf(stderr, "kallsyms failure: "
"unable to allocate required amount of memory\n");
exit(EXIT_FAILURE);
}
- strcpy((char *)s->sym + 1, str);
+ strcpy((char *)s->sym + 1, sym);
s->sym[0] = stype;
s->percpu_absolute = 0;
int i;
char *sym_name = (char *)s->sym + 1;
- /* skip prefix char */
- if (symbol_prefix_char && *sym_name == symbol_prefix_char)
- sym_name++;
-
-
/* if --all-symbols is not specified, then symbols outside the text
* and inittext sections are discarded */
if (!all_symbols) {
static void output_label(char *label)
{
- if (symbol_prefix_char)
- printf(".globl %c%s\n", symbol_prefix_char, label);
- else
- printf(".globl %s\n", label);
+ printf(".globl %s\n", label);
printf("\tALGN\n");
- if (symbol_prefix_char)
- printf("%c%s:\n", symbol_prefix_char, label);
- else
- printf("%s:\n", label);
+ printf("%s:\n", label);
}
/* uncompress a compressed symbol. When this function is called, the best table
all_symbols = 1;
else if (strcmp(argv[i], "--absolute-percpu") == 0)
absolute_percpu = 1;
- else if (strncmp(argv[i], "--symbol-prefix=", 16) == 0) {
- char *p = &argv[i][16];
- /* skip quote */
- if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\''))
- p++;
- symbol_prefix_char = *p;
- } else if (strcmp(argv[i], "--base-relative") == 0)
+ else if (strcmp(argv[i], "--base-relative") == 0)
base_relative = 1;
else
usage();