* [U-Boot-Users] Setting entry point in u-boot standalone apps
@ 2007-09-18 8:56 David Hearn
2007-09-18 9:22 ` Martin Krause
2007-09-18 19:07 ` Wolfgang Denk
0 siblings, 2 replies; 5+ messages in thread
From: David Hearn @ 2007-09-18 8:56 UTC (permalink / raw)
To: u-boot
I have a U-boot standalone app which runs on the Gumstix boards. It's based on the
/u-boot-1.2.0/examples/ folder. The problem I have is that my entry
function - lets call it app_entry() - isn't at the load address, it's
somewhere in the middle. I'm using the output from objdump -d <elf
file> > <elf file>.dis to determine where in the address range the
functions are located.
When I originally built the hello_world.c examples, the hello_world()
function was located at the load address and everything worked fine. I
would do issue the following commands to run it:
loadb a0000000
<send the .bin file>
go a0000000
However I discovered that as I made changes to this file the
hello_world() function was moved around within the address range (ie. it
was no longer at the start of the range) - this was discovered when the
app no longer worked. After investigating I found that I needed to
disassemble the file, locate where the entry function is now located,
and do the following commands:
loadb a0000000
<send the .bin file>
go a0000948 (or whatever the address of my entry function was)
This then worked every time.
My problem is that I wish to avoid this as every time I change any of
the functions located before my entry function, this address changes.
It would be far nicer, and easier, to just have my entry function always
located at the start of the range and I can then always execute my app by doing 'go a0000000' irrespective of any changes I make to the code..
I'm using a slightly modified version of the Makefile in the examples
folder, the particular interesting part (I think) which I've not changed is:
$(ELF):
$(obj)%: $(obj)%.o $(LIB)
$(LD) -g $(EX_LDFLAGS) -Ttext $(LOAD_ADDR) \
-o $@ -e $(notdir $(<:.o=)) $< $(LIB) \
-L$(gcclibdir) -lgcc
The -e part should be specifying the entry point of the ELF file,
however outputting the result of the $(notdir) part shows it's empty.
When I've replaced it with just the entry function's name, it makes no
difference either.
As I understand it (taken from:
<http://sourceware.org/binutils/docs-2.17/ld/Entry-Point.html>):
"There are several ways to set the entry point. The linker will set the
entry point by trying each of the following methods in order, and
stopping when one of them succeeds:
* the `-e' entry command-line option;
* the |ENTRY(|symbol|)| command in a linker script;
* the value of the symbol |start|, if defined;
* the address of the first byte of the `.text' section, if present;
* The address |0|."
Unfortunately, the examples don't use linker scripts, and I don't want
to start messing with these as it interacts with u-boot to some extent
(certainly built within u-boot's makefile), and it's all working as it
is. From what I understand though, the -e option should be sufficient.
Has anyone else experienced this problem, and can give any advice as to
how to solve it?
Thanks
David
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot-Users] Setting entry point in u-boot standalone apps
2007-09-18 8:56 [U-Boot-Users] Setting entry point in u-boot standalone apps David Hearn
@ 2007-09-18 9:22 ` Martin Krause
2007-09-19 11:57 ` David Hearn
2007-09-18 19:07 ` Wolfgang Denk
1 sibling, 1 reply; 5+ messages in thread
From: Martin Krause @ 2007-09-18 9:22 UTC (permalink / raw)
To: u-boot
Hi David,
u-boot-users-bounces at lists.sourceforge.net wrote on :
> I have a U-boot standalone app which runs on the Gumstix boards.
> It's based on the /u-boot-1.2.0/examples/ folder. The problem I have
> is that my entry
> function - lets call it app_entry() - isn't at the load address, it's
> somewhere in the middle. I'm using the output from objdump -d <elf
This is a known issue, please look at:
http://www.denx.de/wiki/view/DULG/MyStandaloneProgramDoesNotWork
> app no longer worked. After investigating I found that I needed to
> disassemble the file, locate where the entry function is now located,
> and do the following commands:
>
> loadb a0000000
> <send the .bin file>
> go a0000948 (or whatever the address of my entry function was)
>
> This then worked every time.
Yes, it should :-)
> The -e part should be specifying the entry point of the ELF file,
Yes, it specifies the entry point (= entry function) - but not at which
address the entry point is placed by the linker. So the entry option
does not, what you are looking for.
> Unfortunately, the examples don't use linker scripts, and I don't want
> to start messing with these as it interacts with u-boot to some extent
> (certainly built within u-boot's makefile), and it's all working as it
> is. From what I understand though, the -e option should be
> sufficient.
No, see comments above.
> Has anyone else experienced this problem, and can give any advice as
> to
> how to solve it?
You have to change your linker script. Tell the linker where it should
place your entry point function (I'm no linker expert, so I couldn't
give you advice at this ...)
Regards,
Martin Krause
--
TQ-Systems GmbH
Muehlstrasse 2, Gut Delling, D-82229 Seefeld
Amtsgericht Muenchen, HRB 105 018, UST-IdNr. DE 811 607 913
Geschaeftsfuehrer: Dipl.-Ing. (FH) Detlef Schneider, Dipl.-Ing. (FH) Ruediger Stahl
http://www.tq-group.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot-Users] Setting entry point in u-boot standalone apps
2007-09-18 8:56 [U-Boot-Users] Setting entry point in u-boot standalone apps David Hearn
2007-09-18 9:22 ` Martin Krause
@ 2007-09-18 19:07 ` Wolfgang Denk
2007-09-19 11:57 ` David Hearn
1 sibling, 1 reply; 5+ messages in thread
From: Wolfgang Denk @ 2007-09-18 19:07 UTC (permalink / raw)
To: u-boot
In message <46EF92C1.5050309@swampie.org.uk> you wrote:
>
> Unfortunately, the examples don't use linker scripts, and I don't want
> to start messing with these as it interacts with u-boot to some extent
You canhave only one or the other...
> (certainly built within u-boot's makefile), and it's all working as it
> is. From what I understand though, the -e option should be sufficient.
-e is sufficient to specify the entry point, but it is not sufficient
to force the linker to place specific objects at specific locations
in your image. For that you need alinker script.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I may be synthetic, but I'm not stupid" - the artificial person,
from _Aliens_
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot-Users] Setting entry point in u-boot standalone apps
2007-09-18 9:22 ` Martin Krause
@ 2007-09-19 11:57 ` David Hearn
0 siblings, 0 replies; 5+ messages in thread
From: David Hearn @ 2007-09-19 11:57 UTC (permalink / raw)
To: u-boot
Martin Krause wrote:
> Hi David,
>
> u-boot-users-bounces at lists.sourceforge.net wrote on :
>
>> I have a U-boot standalone app which runs on the Gumstix boards.
>> It's based on the /u-boot-1.2.0/examples/ folder. The problem I have
>> is that my entry
>> function - lets call it app_entry() - isn't at the load address, it's
>> somewhere in the middle. I'm using the output from objdump -d <elf
>>
>
> This is a known issue, please look at:
> http://www.denx.de/wiki/view/DULG/MyStandaloneProgramDoesNotWork
>
Very helpful - thanks for pointing that out.
>> Has anyone else experienced this problem, and can give any advice as
>> to
>> how to solve it?
>>
>
> You have to change your linker script. Tell the linker where it should
> place your entry point function (I'm no linker expert, so I couldn't
> give you advice at this ...)
>
> Regards,
>
> Martin Krause
I've now started using a linker script which does the job. The way I
did it was to create a separate object file which just contained a
single wrapper function which called my 'main' function. This function
would always be at the start of the resulting .o file, and this .o file
was then specified as the first entry in the .text section.
Consequently this wrapper function is now always at the start of my
final binary file.
Thanks for the pointers, and the explanations regarding entry points and
link locations.
David
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot-Users] Setting entry point in u-boot standalone apps
2007-09-18 19:07 ` Wolfgang Denk
@ 2007-09-19 11:57 ` David Hearn
0 siblings, 0 replies; 5+ messages in thread
From: David Hearn @ 2007-09-19 11:57 UTC (permalink / raw)
To: u-boot
Wolfgang Denk wrote:
> In message <46EF92C1.5050309@swampie.org.uk> you wrote:
>
>> Unfortunately, the examples don't use linker scripts, and I don't want
>> to start messing with these as it interacts with u-boot to some extent
>>
>
> You canhave only one or the other...
>
>
>> (certainly built within u-boot's makefile), and it's all working as it
>> is. From what I understand though, the -e option should be sufficient.
>>
>
> -e is sufficient to specify the entry point, but it is not sufficient
> to force the linker to place specific objects at specific locations
> in your image. For that you need alinker script.
>
Understood, implemented and now working.
David
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-09-19 11:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-18 8:56 [U-Boot-Users] Setting entry point in u-boot standalone apps David Hearn
2007-09-18 9:22 ` Martin Krause
2007-09-19 11:57 ` David Hearn
2007-09-18 19:07 ` Wolfgang Denk
2007-09-19 11:57 ` David Hearn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox