ARM: TCM memory bug on newer compilers
PATCH 1/1 ARM: TCM memory bug on newer compilers
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.
--- arch/arm/mm/init.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/mm/init.c +3 -3
@@ -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
Signature · 1 line
1.6.3.3
PATCH 1/1 ARM: TCM memory bug on newer compilers
Quoted 3 lines · Linus Walleij
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);
PATCH 1/1 ARM: TCM memory bug on newer compilers
[Russell]
Quoted 6 lines · Linus Walleij
Quoted 3 lines
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