[U-Boot-Users] Does u-boot relocate absolute symbols?

Andreas Block andreas.block at esd-electronics.com
Fri Jul 1 09:57:06 CEST 2005


Jerry: I'm sorry for the inconvenience, but sent this mail to you instead  
of the U-Boot mailinglist.

I'm not quite sure, what happened on your side.
Here's the result on my side (together with the source as it ought look):

--- BEGIN OF CONSOLE OUTPUT
andreas at pc-linux-dev:~/arrtest> cat common.h
int showwrong(void);

andreas at pc-linux-dev:~/arrtest> cat common.c
#include <stdio.h>

extern const unsigned char test[];

int showwrong(void)
{
         printf("test[]: 0x%08X\n", (int)test);
         return 0;
}

andreas at pc-linux-dev:~/arrtest> cat array.c
#include "common.h"

const unsigned char *test = (unsigned char*)0x40000;

int main(void)
{
         printf("*test: 0x%08X\n", (int)test);
         showwrong();
         return 0;
}
andreas at pc-linux-dev:~/arrtest> gcc -o arrtest -I ./ ./common.c ./array.c
andreas at pc-linux-dev:~/arrtest> ./arrtest
*test: 0x00040000
test[]: 0x080494E4
--- END OF CONSOLE OUTPUT

What buffles me is, that on your side, the *test-output isn't 0x40000,  
because the
pointer is initialized directly in that object and used as pointer. And on  
the other
hand, the output can't be the same:
extern char test[]; ==> results in a symbol at the start address of the  
array.
char *test; ==> is a pointer containing the start-address of the array.  
This means one
more level of reference.

Could you please show your source files as they were used for your test to  
us. I'm
still sure, both notations are not the same, although they work the same  
in most cases.

Regards,
Andreas


30.06.2005 19:28:32, Jerry Van Baren  
<gerald.vanbaren at smiths-aerospace.com> wrote:

> Rune Torgersen wrote:
>> Wow.... This surprises me...
>> I have alwayts thought that *test and test[] would be the same thing.
>> Only solutionI can see is to change the definition in common.c to be
>> *test, this will still get the address of test[] defined elsewhere.
>> (See attached files)
>>
>>> Sure, I've tried this. This is the point, where my problemarose.  
>>> Attached you find twosmall files, you can easily compile under linux  
>>> (gcc -oarrtest -I ./ ./common.c./array.c). The file "common.c"  
>>> represents the code I can't(don't want to) touch."array.c" represents  
>>> my project dependent code. If you runarrtest it will show to you,
>
> With the patch in place (previously sent to the list), it works for  
> linux:
>
> vanbaren at sherwood:~/x> ll
> total 32
> -rwxr-----  1 vanbaren users  200 Jun 30 13:24 array.c
> -rwxr-xr-x  1 vanbaren users 8963 Jun 30 13:26 arrtest
> -rwxr-----  1 vanbaren users  132 Jun 30 08:03 common.c
> -rwxr-----  1 vanbaren users  121 Jun 30 08:03 common.c-original
> -rw-r--r--  1 vanbaren users  237 Jun 30 08:04 common.c.diff
> -rwxr-----  1 vanbaren users   24 Jun 30 13:23 common.h
> vanbaren at sherwood:~/x> gcc -o arrtest -I ./ ./common.c ./array.c
> vanbaren at sherwood:~/x> ./arrtest
> *test: 0x08048558
> test[]: 0x08048558
>
> gvb
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> U-Boot-Users mailing list
> U-Boot-Users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/u-boot-users
>
>
>





More information about the U-Boot mailing list