linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* scripts/kallsyms: extending region checking for Blackfin memory  regions
@ 2009-06-08 23:23 Mike Frysinger
  2009-06-14 20:44 ` Sam Ravnborg
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Frysinger @ 2009-06-08 23:23 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: kbuild-devel, Linux kernel mailing list, uclinux-dist-devel

[-- Attachment #1: Type: text/plain, Size: 1166 bytes --]

intro: the current Blackfin memory architecture is (1) no virtualized
memory and (2) distinctly harvard.  that means we cannot create a
linear map of start/end text sections.  we end up with distinct
regions like so:
00001000 T __stext
000dc4c0 T __etext
feb00000 A __etext_l2
feb00010 A __stext_l2
ffa00000 T __stext_l1
ffa0160c T __etext_l1
this is because external memory starts at address 0 while on-chip
regions have different discontiguous hardcoded addresses (L1
instruction in this case starts at 0xffa00000 while L2 starts at
0xfeb00000).

the current kallsyms is written to search for the special stext/etext
symbols only which means the resulting kallsyms output knows nothing
of the Blackfin symbols living in these on-chip regions.  we've
written two patches to fix this: the first one is straight forward and
simply copies & pastes the existing hardcoded regions.  the second
creates an array of text regions which makes it much easier to extend
in the future for other people (and can be squashed into the first
one).

doesnt matter to me which method is picked :)

(yes, another change is needed to kernel/kallsysms.c, but one thing at a time)
-mike

[-- Attachment #2: 0001-kallsyms-support-kernel-symbols-in-Blackfin-on-chip-.patch --]
[-- Type: application/octet-stream, Size: 2205 bytes --]

From efafce5dd0ceba132c80fb937412684aab5e8f16 Mon Sep 17 00:00:00 2001
From: Robin Getz <robin.getz@analog.com>
Date: Mon, 10 Jul 2006 06:25:40 +0000
Subject: [PATCH] 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 <robin.getz@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
---
 scripts/kallsyms.c |   13 ++++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 6654cbe..fb82a5b 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
-- 
1.6.3.1


[-- Attachment #3: 0005-kallsyms-generalize-text-region-handling.patch --]
[-- Type: application/octet-stream, Size: 4603 bytes --]

From 21a5308cb2144f7268ceaa150897b8a7995a26c3 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Mon, 8 Jun 2009 19:12:13 -0400
Subject: [PATCH] kallsyms: generalize text region handling

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 scripts/kallsyms.c |   87 ++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 61 insertions(+), 26 deletions(-)

diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index fb82a5b..3cb5789 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -23,6 +23,10 @@
 #include <string.h>
 #include <ctype.h>
 
+#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;
 	}
 
-- 
1.6.3.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: scripts/kallsyms: extending region checking for Blackfin memory regions
  2009-06-08 23:23 scripts/kallsyms: extending region checking for Blackfin memory regions Mike Frysinger
@ 2009-06-14 20:44 ` Sam Ravnborg
  2009-06-15  1:59   ` Robin Getz
  0 siblings, 1 reply; 6+ messages in thread
From: Sam Ravnborg @ 2009-06-14 20:44 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: kbuild-devel, Linux kernel mailing list, uclinux-dist-devel

On Mon, Jun 08, 2009 at 07:23:16PM -0400, Mike Frysinger wrote:
> intro: the current Blackfin memory architecture is (1) no virtualized
> memory and (2) distinctly harvard.  that means we cannot create a
> linear map of start/end text sections.  we end up with distinct
> regions like so:
> 00001000 T __stext
> 000dc4c0 T __etext
> feb00000 A __etext_l2
> feb00010 A __stext_l2
> ffa00000 T __stext_l1
> ffa0160c T __etext_l1
> this is because external memory starts at address 0 while on-chip
> regions have different discontiguous hardcoded addresses (L1
> instruction in this case starts at 0xffa00000 while L2 starts at
> 0xfeb00000).
> 
> the current kallsyms is written to search for the special stext/etext
> symbols only which means the resulting kallsyms output knows nothing
> of the Blackfin symbols living in these on-chip regions.  we've
> written two patches to fix this: the first one is straight forward and
> simply copies & pastes the existing hardcoded regions.  the second
> creates an array of text regions which makes it much easier to extend
> in the future for other people (and can be squashed into the first
> one).
> 
> doesnt matter to me which method is picked :)

I added both as I liked the generalization.
I had to rearrange the "Signed-off-by" in the first patch
as this patch came in vai you and not Robin.

	Sam

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: scripts/kallsyms: extending region checking for Blackfin memory regions
  2009-06-14 20:44 ` Sam Ravnborg
@ 2009-06-15  1:59   ` Robin Getz
  2009-06-15  2:05     ` Mike Frysinger
  0 siblings, 1 reply; 6+ messages in thread
From: Robin Getz @ 2009-06-15  1:59 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Mike Frysinger, kbuild-devel, Linux kernel mailing list,
	uclinux-dist-devel

On Sun 14 Jun 2009 16:44, Sam Ravnborg pondered:
> On Mon, Jun 08, 2009 at 07:23:16PM -0400, Mike Frysinger wrote:
> > intro: the current Blackfin memory architecture is (1) no virtualized
> > memory and (2) distinctly harvard.  that means we cannot create a
> > linear map of start/end text sections.  we end up with distinct
> > regions like so:
> > 00001000 T __stext
> > 000dc4c0 T __etext
> > feb00000 A __etext_l2
> > feb00010 A __stext_l2
> > ffa00000 T __stext_l1
> > ffa0160c T __etext_l1
> > this is because external memory starts at address 0 while on-chip
> > regions have different discontiguous hardcoded addresses (L1
> > instruction in this case starts at 0xffa00000 while L2 starts at
> > 0xfeb00000).
> > 
> > the current kallsyms is written to search for the special stext/etext
> > symbols only which means the resulting kallsyms output knows nothing
> > of the Blackfin symbols living in these on-chip regions.  we've
> > written two patches to fix this: the first one is straight forward and
> > simply copies & pastes the existing hardcoded regions.  the second
> > creates an array of text regions which makes it much easier to extend
> > in the future for other people (and can be squashed into the first
> > one).
> > 
> > doesnt matter to me which method is picked :)
> 
> I added both as I liked the generalization.
> I had to rearrange the "Signed-off-by" in the first patch
> as this patch came in vai you and not Robin.

I think Mike pulled this from some work I did awhile ago, (and sent to you) 
that obviously never got added (since I didn't send it in the proper patch 
format).

http://lkml.indiana.edu/hypermail/linux/kernel/0607.1/0558.html


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: scripts/kallsyms: extending region checking for Blackfin memory  regions
  2009-06-15  1:59   ` Robin Getz
@ 2009-06-15  2:05     ` Mike Frysinger
  2009-06-15  4:37       ` [kbuild-devel] " Sam Ravnborg
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Frysinger @ 2009-06-15  2:05 UTC (permalink / raw)
  To: Robin Getz
  Cc: Sam Ravnborg, kbuild-devel, Linux kernel mailing list,
	uclinux-dist-devel

On Sun, Jun 14, 2009 at 21:59, Robin Getz wrote:
> On Sun 14 Jun 2009 16:44, Sam Ravnborg pondered:
>> On Mon, Jun 08, 2009 at 07:23:16PM -0400, Mike Frysinger wrote:
>> > intro: the current Blackfin memory architecture is (1) no virtualized
>> > memory and (2) distinctly harvard.  that means we cannot create a
>> > linear map of start/end text sections.  we end up with distinct
>> > regions like so:
>> > 00001000 T __stext
>> > 000dc4c0 T __etext
>> > feb00000 A __etext_l2
>> > feb00010 A __stext_l2
>> > ffa00000 T __stext_l1
>> > ffa0160c T __etext_l1
>> > this is because external memory starts at address 0 while on-chip
>> > regions have different discontiguous hardcoded addresses (L1
>> > instruction in this case starts at 0xffa00000 while L2 starts at
>> > 0xfeb00000).
>> >
>> > the current kallsyms is written to search for the special stext/etext
>> > symbols only which means the resulting kallsyms output knows nothing
>> > of the Blackfin symbols living in these on-chip regions.  we've
>> > written two patches to fix this: the first one is straight forward and
>> > simply copies & pastes the existing hardcoded regions.  the second
>> > creates an array of text regions which makes it much easier to extend
>> > in the future for other people (and can be squashed into the first
>> > one).
>> >
>> > doesnt matter to me which method is picked :)
>>
>> I added both as I liked the generalization.
>> I had to rearrange the "Signed-off-by" in the first patch
>> as this patch came in vai you and not Robin.
>
> I think Mike pulled this from some work I did awhile ago, (and sent to you)
> that obviously never got added (since I didn't send it in the proper patch
> format).
>
> http://lkml.indiana.edu/hypermail/linux/kernel/0607.1/0558.html

yeah, the first patch was by Robin ... the "From:" line in the patch
should have shown that (and git-am would have respected) ...
-mike

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [kbuild-devel] scripts/kallsyms: extending region checking for Blackfin memory regions
  2009-06-15  2:05     ` Mike Frysinger
@ 2009-06-15  4:37       ` Sam Ravnborg
  2009-06-15  4:39         ` Mike Frysinger
  0 siblings, 1 reply; 6+ messages in thread
From: Sam Ravnborg @ 2009-06-15  4:37 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: Robin Getz, kbuild-devel, Linux kernel mailing list, uclinux-dist-devel

On Sun, Jun 14, 2009 at 10:05:26PM -0400, Mike Frysinger wrote:
> On Sun, Jun 14, 2009 at 21:59, Robin Getz wrote:
> > On Sun 14 Jun 2009 16:44, Sam Ravnborg pondered:
> >> On Mon, Jun 08, 2009 at 07:23:16PM -0400, Mike Frysinger wrote:
> >> > intro: the current Blackfin memory architecture is (1) no virtualized
> >> > memory and (2) distinctly harvard.  that means we cannot create a
> >> > linear map of start/end text sections.  we end up with distinct
> >> > regions like so:
> >> > 00001000 T __stext
> >> > 000dc4c0 T __etext
> >> > feb00000 A __etext_l2
> >> > feb00010 A __stext_l2
> >> > ffa00000 T __stext_l1
> >> > ffa0160c T __etext_l1
> >> > this is because external memory starts at address 0 while on-chip
> >> > regions have different discontiguous hardcoded addresses (L1
> >> > instruction in this case starts at 0xffa00000 while L2 starts at
> >> > 0xfeb00000).
> >> >
> >> > the current kallsyms is written to search for the special stext/etext
> >> > symbols only which means the resulting kallsyms output knows nothing
> >> > of the Blackfin symbols living in these on-chip regions.  we've
> >> > written two patches to fix this: the first one is straight forward and
> >> > simply copies & pastes the existing hardcoded regions.  the second
> >> > creates an array of text regions which makes it much easier to extend
> >> > in the future for other people (and can be squashed into the first
> >> > one).
> >> >
> >> > doesnt matter to me which method is picked :)
> >>
> >> I added both as I liked the generalization.
> >> I had to rearrange the "Signed-off-by" in the first patch
> >> as this patch came in vai you and not Robin.
> >
> > I think Mike pulled this from some work I did awhile ago, (and sent to you)
> > that obviously never got added (since I didn't send it in the proper patch
> > format).
> >
> > http://lkml.indiana.edu/hypermail/linux/kernel/0607.1/0558.html
> 
> yeah, the first patch was by Robin ... the "From:" line in the patch
> should have shown that (and git-am would have respected) ...

So does the patch.
What I had to change was that the Signed-off-by: lines indicated
that this patch came in like this:

Robin -> Mike -> Bryan Wu -> Sam
So I rearranged the signed-off-by: lines so it indicated
the following order:

Robin -> Bryan Wu -> Mike -> Sam


I trust that Bryan really did add his sob, and it
was only a mistake that Mike added his sob before
that of Bryans.

	Sam

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [kbuild-devel] scripts/kallsyms: extending region checking for  Blackfin memory regions
  2009-06-15  4:37       ` [kbuild-devel] " Sam Ravnborg
@ 2009-06-15  4:39         ` Mike Frysinger
  0 siblings, 0 replies; 6+ messages in thread
From: Mike Frysinger @ 2009-06-15  4:39 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Robin Getz, kbuild-devel, Linux kernel mailing list, uclinux-dist-devel

On Mon, Jun 15, 2009 at 00:37, Sam Ravnborg wrote:
> On Sun, Jun 14, 2009 at 10:05:26PM -0400, Mike Frysinger wrote:
>> On Sun, Jun 14, 2009 at 21:59, Robin Getz wrote:
>> > On Sun 14 Jun 2009 16:44, Sam Ravnborg pondered:
>> >> On Mon, Jun 08, 2009 at 07:23:16PM -0400, Mike Frysinger wrote:
>> >> > intro: the current Blackfin memory architecture is (1) no virtualized
>> >> > memory and (2) distinctly harvard.  that means we cannot create a
>> >> > linear map of start/end text sections.  we end up with distinct
>> >> > regions like so:
>> >> > 00001000 T __stext
>> >> > 000dc4c0 T __etext
>> >> > feb00000 A __etext_l2
>> >> > feb00010 A __stext_l2
>> >> > ffa00000 T __stext_l1
>> >> > ffa0160c T __etext_l1
>> >> > this is because external memory starts at address 0 while on-chip
>> >> > regions have different discontiguous hardcoded addresses (L1
>> >> > instruction in this case starts at 0xffa00000 while L2 starts at
>> >> > 0xfeb00000).
>> >> >
>> >> > the current kallsyms is written to search for the special stext/etext
>> >> > symbols only which means the resulting kallsyms output knows nothing
>> >> > of the Blackfin symbols living in these on-chip regions.  we've
>> >> > written two patches to fix this: the first one is straight forward and
>> >> > simply copies & pastes the existing hardcoded regions.  the second
>> >> > creates an array of text regions which makes it much easier to extend
>> >> > in the future for other people (and can be squashed into the first
>> >> > one).
>> >> >
>> >> > doesnt matter to me which method is picked :)
>> >>
>> >> I added both as I liked the generalization.
>> >> I had to rearrange the "Signed-off-by" in the first patch
>> >> as this patch came in vai you and not Robin.
>> >
>> > I think Mike pulled this from some work I did awhile ago, (and sent to you)
>> > that obviously never got added (since I didn't send it in the proper patch
>> > format).
>> >
>> > http://lkml.indiana.edu/hypermail/linux/kernel/0607.1/0558.html
>>
>> yeah, the first patch was by Robin ... the "From:" line in the patch
>> should have shown that (and git-am would have respected) ...
>
> So does the patch.
> What I had to change was that the Signed-off-by: lines indicated
> that this patch came in like this:
>
> Robin -> Mike -> Bryan Wu -> Sam
> So I rearranged the signed-off-by: lines so it indicated
> the following order:
>
> Robin -> Bryan Wu -> Mike -> Sam
>
>
> I trust that Bryan really did add his sob, and it
> was only a mistake that Mike added his sob before
> that of Bryans.

yes, i took a bunch of patches from Bryan like this one
-mike

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-06-15  4:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-08 23:23 scripts/kallsyms: extending region checking for Blackfin memory regions Mike Frysinger
2009-06-14 20:44 ` Sam Ravnborg
2009-06-15  1:59   ` Robin Getz
2009-06-15  2:05     ` Mike Frysinger
2009-06-15  4:37       ` [kbuild-devel] " Sam Ravnborg
2009-06-15  4:39         ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).