diff options
Diffstat (limited to 'scripts/kallsyms.c')
-rw-r--r-- | scripts/kallsyms.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 487ac6f37ca2..10085de886fe 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c | |||
@@ -55,6 +55,7 @@ static struct sym_entry *table; | |||
55 | static unsigned int table_size, table_cnt; | 55 | static unsigned int table_size, table_cnt; |
56 | static int all_symbols = 0; | 56 | static int all_symbols = 0; |
57 | static char symbol_prefix_char = '\0'; | 57 | static char symbol_prefix_char = '\0'; |
58 | static unsigned long long kernel_start_addr = 0; | ||
58 | 59 | ||
59 | int token_profit[0x10000]; | 60 | int token_profit[0x10000]; |
60 | 61 | ||
@@ -65,7 +66,10 @@ unsigned char best_table_len[256]; | |||
65 | 66 | ||
66 | static void usage(void) | 67 | static void usage(void) |
67 | { | 68 | { |
68 | fprintf(stderr, "Usage: kallsyms [--all-symbols] [--symbol-prefix=<prefix char>] < in.map > out.S\n"); | 69 | fprintf(stderr, "Usage: kallsyms [--all-symbols] " |
70 | "[--symbol-prefix=<prefix char>] " | ||
71 | "[--page-offset=<CONFIG_PAGE_OFFSET>] " | ||
72 | "< in.map > out.S\n"); | ||
69 | exit(1); | 73 | exit(1); |
70 | } | 74 | } |
71 | 75 | ||
@@ -111,6 +115,12 @@ static int read_symbol(FILE *in, struct sym_entry *s) | |||
111 | fprintf(stderr, "Read error or end of file.\n"); | 115 | fprintf(stderr, "Read error or end of file.\n"); |
112 | return -1; | 116 | return -1; |
113 | } | 117 | } |
118 | if (strlen(str) > KSYM_NAME_LEN) { | ||
119 | fprintf(stderr, "Symbol %s too long for kallsyms (%zu vs %d).\n" | ||
120 | "Please increase KSYM_NAME_LEN both in kernel and kallsyms.c\n", | ||
121 | str, strlen(str), KSYM_NAME_LEN); | ||
122 | return -1; | ||
123 | } | ||
114 | 124 | ||
115 | sym = str; | 125 | sym = str; |
116 | /* skip prefix char */ | 126 | /* skip prefix char */ |
@@ -194,6 +204,9 @@ static int symbol_valid(struct sym_entry *s) | |||
194 | int i; | 204 | int i; |
195 | int offset = 1; | 205 | int offset = 1; |
196 | 206 | ||
207 | if (s->addr < kernel_start_addr) | ||
208 | return 0; | ||
209 | |||
197 | /* skip prefix char */ | 210 | /* skip prefix char */ |
198 | if (symbol_prefix_char && *(s->sym + 1) == symbol_prefix_char) | 211 | if (symbol_prefix_char && *(s->sym + 1) == symbol_prefix_char) |
199 | offset++; | 212 | offset++; |
@@ -646,6 +659,9 @@ int main(int argc, char **argv) | |||
646 | if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\'')) | 659 | if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\'')) |
647 | p++; | 660 | p++; |
648 | symbol_prefix_char = *p; | 661 | symbol_prefix_char = *p; |
662 | } else if (strncmp(argv[i], "--page-offset=", 14) == 0) { | ||
663 | const char *p = &argv[i][14]; | ||
664 | kernel_start_addr = strtoull(p, NULL, 16); | ||
649 | } else | 665 | } else |
650 | usage(); | 666 | usage(); |
651 | } | 667 | } |