linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: TCM memory bug on newer compilers
@ 2010-05-25 16:45 Linus Walleij
  2010-05-25 20:16 ` Russell King - ARM Linux
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2010-05-25 16:45 UTC (permalink / raw)
  To: linux-arm-kernel

Apparently newer compilers don't like you to refer to linker
symbols as extern char *foo, we must use char foo and refer to
the address of the char instead.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
---
 arch/arm/mm/init.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 1ba6cf5..f6a9994 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -678,10 +678,10 @@ void __init mem_init(void)
 void free_initmem(void)
 {
 #ifdef CONFIG_HAVE_TCM
-	extern char *__tcm_start, *__tcm_end;
+	extern char __tcm_start, __tcm_end;
 
-	totalram_pages += free_area(__phys_to_pfn(__pa(__tcm_start)),
-				    __phys_to_pfn(__pa(__tcm_end)),
+	totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
+				    __phys_to_pfn(__pa(&__tcm_end)),
 				    "TCM link");
 #endif
 
-- 
1.6.3.3

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

* [PATCH] ARM: TCM memory bug on newer compilers
  2010-05-25 16:45 [PATCH] ARM: TCM memory bug on newer compilers Linus Walleij
@ 2010-05-25 20:16 ` Russell King - ARM Linux
  2010-05-26  6:23   ` Linus WALLEIJ
  0 siblings, 1 reply; 3+ messages in thread
From: Russell King - ARM Linux @ 2010-05-25 20:16 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, May 25, 2010 at 06:45:47PM +0200, Linus Walleij wrote:
> Apparently newer compilers don't like you to refer to linker
> symbols as extern char *foo, we must use char foo and refer to
> the address of the char instead.

afaik, that's always been the case.

Let's take an example.  Location 0x1234 contains value 0x89abcdef.
The symbol __tcm_start has the address of 0x1234.

Now:

extern char *__tcm_start;

declares a pointer to a char.  The address of the __tcm_start storage
will be 0x1234.  The value of __tcm_start will be 0x89abcdef - and
this is the value that would be passed to __pa(__tcm_start).  The
value of __tcm_start[0] is whatever is stored at the address
0x89abcdef.

extern char __tcm_start[];

declares an array of char.  The address of the __tcm_start storage will
be 0x1234.  The value of __tcm_start is in this case defined to be the
same as the value of a pointer to the first element - so 0x1234.
The value of __tcm_start[0] will be whatever is stored at 0x1234, and in
LE that will be 0xef.

extern char __tcm_start;

declares a single char.  The address of the __tcm_start storage will be
0x1234.  The value of __tcm_start is the value at this address, and
still assuming LE, 0xef.

So, either use:

	extern char __tcm_start;
	pa_start = __pa(&__tcm_start);

or:

	extern char __tcm_start[];
	pa_start = __pa(__tcm_start);

which reveal the same answer.  However, this will give you something
completely different:

	extern char *__tcm_start;
	pa_start = __pa(__tcm_start);

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

* [PATCH] ARM: TCM memory bug on newer compilers
  2010-05-25 20:16 ` Russell King - ARM Linux
@ 2010-05-26  6:23   ` Linus WALLEIJ
  0 siblings, 0 replies; 3+ messages in thread
From: Linus WALLEIJ @ 2010-05-26  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

[Russell]

> On Tue, May 25, 2010 at 06:45:47PM +0200, Linus Walleij wrote:
> > Apparently newer compilers don't like you to refer to linker
> > symbols as extern char *foo, we must use char foo and refer to
> > the address of the char instead.
> 
> afaik, that's always been the case.

Thanks a lot of the education session Russell, I get it now.
What I don't get is how this code worked on earlier GCC:s :-P

Anyway, I'll put the patch in the tracker with a new patch
description that is more enlightened.

Yours,
Linus Walleij

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

end of thread, other threads:[~2010-05-26  6:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-25 16:45 [PATCH] ARM: TCM memory bug on newer compilers Linus Walleij
2010-05-25 20:16 ` Russell King - ARM Linux
2010-05-26  6:23   ` Linus WALLEIJ

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).