[U-Boot-Users] Setting entry point in u-boot standalone apps
dave at swampie.org.uk
Tue Sep 18 10:56:33 CEST 2007
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:
<send the .bin file>
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:
<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:
$(obj)%: $(obj)%.o $(LIB)
$(LD) -g $(EX_LDFLAGS) -Ttext $(LOAD_ADDR) \
-o $@ -e $(notdir $(<:.o=)) $< $(LIB) \
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
As I understand it (taken from:
"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?
More information about the U-Boot