From 028f042613c3c99db20dd7f4e4069fbbcea92dd7 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Mon, 10 Jul 2006 06:25:40 +0000 Subject: kallsyms: support kernel symbols in Blackfin on-chip memory The Blackfin arch has a discontiguous .text layout due to having on-chip instruction memory and no virtual memory support. As such, we need to add explicit checks for these additional .text regions. Signed-off-by: Robin Getz Signed-off-by: Bryan Wu Signed-off-by: Mike Frysinger Signed-off-by: Sam Ravnborg --- scripts/kallsyms.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'scripts/kallsyms.c') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 6654cbed965..fb82a5b4980 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -35,6 +35,7 @@ struct sym_entry { static struct sym_entry *table; static unsigned int table_size, table_cnt; static unsigned long long _text, _stext, _etext, _sinittext, _einittext; +static unsigned long long _stext_l1, _etext_l1, _stext_l2, _etext_l2; static int all_symbols = 0; static char symbol_prefix_char = '\0'; @@ -92,6 +93,14 @@ static int read_symbol(FILE *in, struct sym_entry *s) _sinittext = s->addr; else if (strcmp(sym, "_einittext") == 0) _einittext = s->addr; + else if (strcmp(sym, "_stext_l1") == 0) + _stext_l1 = s->addr; + else if (strcmp(sym, "_etext_l1") == 0) + _etext_l1 = s->addr; + else if (strcmp(sym, "_stext_l2") == 0) + _stext_l2 = s->addr; + else if (strcmp(sym, "_etext_l2") == 0) + _etext_l2 = s->addr; else if (toupper(stype) == 'A') { /* Keep these useful absolute symbols */ @@ -157,7 +166,9 @@ static int symbol_valid(struct sym_entry *s) * and inittext sections are discarded */ if (!all_symbols) { if ((s->addr < _stext || s->addr > _etext) - && (s->addr < _sinittext || s->addr > _einittext)) + && (s->addr < _sinittext || s->addr > _einittext) + && (s->addr < _stext_l1 || s->addr > _etext_l1) + && (s->addr < _stext_l2 || s->addr > _etext_l2)) return 0; /* Corner case. Discard any symbols with the same value as * _etext _einittext; they can move between pass 1 and 2 when -- cgit v1.2.3-70-g09d2 From 17b1f0de79dbdf5cfb2686b63a7fb9ecc440da7c Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 8 Jun 2009 19:12:13 -0400 Subject: kallsyms: generalize text region handling Signed-off-by: Mike Frysinger Signed-off-by: Sam Ravnborg --- scripts/kallsyms.c | 87 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 26 deletions(-) (limited to 'scripts/kallsyms.c') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index fb82a5b4980..3cb57895c9e 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -23,6 +23,10 @@ #include #include +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) +#endif + #define KSYM_NAME_LEN 128 struct sym_entry { @@ -32,10 +36,23 @@ struct sym_entry { unsigned char *sym; }; +struct text_range { + const char *stext, *etext; + unsigned long long start, end; +}; + +static unsigned long long _text; +static struct text_range text_ranges[] = { + { "_stext", "_etext" }, + { "_sinittext", "_einittext" }, + { "_stext_l1", "_etext_l1" }, /* Blackfin on-chip L1 inst SRAM */ + { "_stext_l2", "_etext_l2" }, /* Blackfin on-chip L2 SRAM */ +}; +#define text_range_text (&text_ranges[0]) +#define text_range_inittext (&text_ranges[1]) + static struct sym_entry *table; static unsigned int table_size, table_cnt; -static unsigned long long _text, _stext, _etext, _sinittext, _einittext; -static unsigned long long _stext_l1, _etext_l1, _stext_l2, _etext_l2; static int all_symbols = 0; static char symbol_prefix_char = '\0'; @@ -62,6 +79,26 @@ static inline int is_arm_mapping_symbol(const char *str) && (str[2] == '\0' || str[2] == '.'); } +static int read_symbol_tr(const char *sym, unsigned long long addr) +{ + size_t i; + struct text_range *tr; + + for (i = 0; i < ARRAY_SIZE(text_ranges); ++i) { + tr = &text_ranges[i]; + + if (strcmp(sym, tr->stext) == 0) { + tr->start = addr; + return 0; + } else if (strcmp(sym, tr->etext) == 0) { + tr->end = addr; + return 0; + } + } + + return 1; +} + static int read_symbol(FILE *in, struct sym_entry *s) { char str[500]; @@ -85,22 +122,8 @@ static int read_symbol(FILE *in, struct sym_entry *s) /* Ignore most absolute/undefined (?) symbols. */ if (strcmp(sym, "_text") == 0) _text = s->addr; - else if (strcmp(sym, "_stext") == 0) - _stext = s->addr; - else if (strcmp(sym, "_etext") == 0) - _etext = s->addr; - else if (strcmp(sym, "_sinittext") == 0) - _sinittext = s->addr; - else if (strcmp(sym, "_einittext") == 0) - _einittext = s->addr; - else if (strcmp(sym, "_stext_l1") == 0) - _stext_l1 = s->addr; - else if (strcmp(sym, "_etext_l1") == 0) - _etext_l1 = s->addr; - else if (strcmp(sym, "_stext_l2") == 0) - _stext_l2 = s->addr; - else if (strcmp(sym, "_etext_l2") == 0) - _etext_l2 = s->addr; + else if (read_symbol_tr(sym, s->addr) == 0) + /* nothing to do */; else if (toupper(stype) == 'A') { /* Keep these useful absolute symbols */ @@ -136,6 +159,21 @@ static int read_symbol(FILE *in, struct sym_entry *s) return 0; } +static int symbol_valid_tr(struct sym_entry *s) +{ + size_t i; + struct text_range *tr; + + for (i = 0; i < ARRAY_SIZE(text_ranges); ++i) { + tr = &text_ranges[i]; + + if (s->addr >= tr->start && s->addr < tr->end) + return 0; + } + + return 1; +} + static int symbol_valid(struct sym_entry *s) { /* Symbols which vary between passes. Passes 1 and 2 must have @@ -165,10 +203,7 @@ static int symbol_valid(struct sym_entry *s) /* if --all-symbols is not specified, then symbols outside the text * and inittext sections are discarded */ if (!all_symbols) { - if ((s->addr < _stext || s->addr > _etext) - && (s->addr < _sinittext || s->addr > _einittext) - && (s->addr < _stext_l1 || s->addr > _etext_l1) - && (s->addr < _stext_l2 || s->addr > _etext_l2)) + if (symbol_valid_tr(s) == 0) return 0; /* Corner case. Discard any symbols with the same value as * _etext _einittext; they can move between pass 1 and 2 when @@ -176,10 +211,10 @@ static int symbol_valid(struct sym_entry *s) * they may get dropped in pass 2, which breaks the kallsyms * rules. */ - if ((s->addr == _etext && - strcmp((char *)s->sym + offset, "_etext")) || - (s->addr == _einittext && - strcmp((char *)s->sym + offset, "_einittext"))) + if ((s->addr == text_range_text->end && + strcmp((char *)s->sym + offset, text_range_text->etext)) || + (s->addr == text_range_inittext->end && + strcmp((char *)s->sym + offset, text_range_inittext->etext))) return 0; } -- cgit v1.2.3-70-g09d2 From ac6ca5c86c63dd95acc6a34dff8d33c23b703a37 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 15 Jun 2009 07:52:48 -0400 Subject: kallsyms: fix inverted valid symbol checking The previous commit (17b1f0de) introduced a slightly broken consolidation of the memory text range checking. Signed-off-by: Mike Frysinger Signed-off-by: Sam Ravnborg --- scripts/kallsyms.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts/kallsyms.c') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 3cb57895c9e..64343cc084b 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -167,11 +167,11 @@ static int symbol_valid_tr(struct sym_entry *s) for (i = 0; i < ARRAY_SIZE(text_ranges); ++i) { tr = &text_ranges[i]; - if (s->addr >= tr->start && s->addr < tr->end) - return 0; + if (s->addr >= tr->start && s->addr <= tr->end) + return 1; } - return 1; + return 0; } static int symbol_valid(struct sym_entry *s) -- cgit v1.2.3-70-g09d2