[U-Boot-Users] Reading out version_string from a binary

Frank frannk_m1 at yahoo.com
Wed Nov 22 05:10:34 CET 2006


--- Fredrik Roubert <fredrik.roubert at barco.com> wrote:

> Hi!
> 
> I use U-Boot (1.1.4) on a custom PowerPC (MPC8347) based
> board, and from
> my application I need to read out the value of version_string
> from the
> U-Boot binary, for logging. I've written some code that does
> this (see
> attached sample program), but would like some comments if
> someone has
> suggestions on how to do it more robust.
> 
> On MPC83XX, version_string is stored at the beginning of
> .rodata, so if
> only the offset for .rodata is found, reading out
> version_string is
> quite straightforward.
> 
> The offset of .rodata changes, however, when code is added or
> removed
> from U-Boot. I've found that an offset is being written at the
> end of
> start.o, from which it is possible to calculate the offset of
> .rodata,
> and even though this works for my current needs, it's hardly
> what one
> would call a robust solutions.
> 
> Does anyone have ideas about a better way to do this?

Look at the way objdump finds the offset of the sections for an
elf file and do it the same way. The source to objdump is
readily available or you could pipe the output of objdump to
your application program, parse the output, open u-boot, seek to
the offset of the .rodata section and extract the information.
You could also use the same technique and extarct the symbol
itself from the elf binary. I've done this in the past....


 
____________________________________________________________________________________
Sponsored Link

Compare mortgage rates for today. 
Get up to 5 free quotes. www2.nextag.com




More information about the U-Boot mailing list