[U-Boot-Users] Re: how to run hello_world

Wolfgang Denk
2004-10-09T13:50:09Z

In message <6.1.1.1.0.20041008155338.01e26910@wheresmymailserver.com> you wrote:
>
> The only think I don't see (and have been looking for a standalone app that
> I am writing, is the difference between load address and entry address.
>
> In the hello_world.c application, it's configured to run at address
> 0x00040004, but the load address is 0x00040000 - why in this case is there
> a 4 byte difference.

If you create a linker map and have a look at it things might get
clearer; try for example:

bash$ ${CROSS_COMPILE}ld -g -Ttext 0x40000 \
> -Map hello_world.map \
> -o hello_world -e hello_world hello_world.o libstubs.a \
> -L/opt/eldk/3.0/usr/bin/../lib/gcc-lib/ppc-linux/3.2.2/m603 -lgcc

and then have a look at "hello_world.map":

...
86 .text 0x00040000 0xd4 hello_world.o
87 0x00040004 hello_world
88 .text 0x000400d4 0x154 libstubs.a(stubs.o)
...

As you can see, the code of hello_world() starts at 0x00040004.

Then check the assembler code generated for hello_world.c:

...
55 .section ".text"
56 .align 2
57 .globl hello_world
58 .LCL0:
59 .long .LCTOC1-.LCF0
60 .type hello_world, at function
61 hello_world:
...

As you can see, GCC places a ".long" immediately in front of the
hello_world() function.

> I assume that this is a toolchain issue, and may be offtopic for this list.

Yes, it's a tolchain issue.

> A slightly different issue - I know that you can load up an elf image as a
> standalone app as well, but I don't seem to be able to pass it any command
> line args.

Loading standalone programs using the "bootelf" comand was never
tested by me. It is easily possible that there are bugs or even
conceptual problems on that way. Please use the simpler & faster "go"
instead.

Best regards,

Wolfgang Denk

--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd at denx.de
"One planet is all you get."