This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Address calculation in RedBoot load function


On Wed, 2003-09-03 at 07:22, Wolfram Kattanek wrote:
> Hi,
> 
> I'm wondering about the address calculation at the end of the
> function load_srec_image() in the file load.c . If there's a
> given base address (via "-b" option of the load command) then
> the entry address of the image will be calculated relative to
> that base address:
> 
> ---------- packages/redboot/current/src/load.c line 536 ----------
>     addr = (unsigned char *)_hex2(getc, ('9'-type+2), &sum);
>     offset += ('9'-type+2);
>     // Save load base/top, entry address
>     if (base) {
>         load_address = base;
>         load_address_end = base + (highest_address - lowest_address);
>         entry_address = (unsigned long)(base + (addr - lowest_address));
>     } else {
>         load_address = lowest_address;
>         load_address_end = highest_address;
>         entry_address = (unsigned long)addr;
>     }
> ------------------------------------------------------------------
> 
> This results in wrong entry and mem addresses when someone loads an
> image to an arbitrary address in RAM and afterwards tries to program
> it using the calculated addresses of the last loaded file.
> 
> Example (image built for address 0x450000 and loaded to RAM
>          address 0x220000):
> 
> RedBoot> load -m y -b 0x220000
> RedBoot> fis create foo
> 
> In that case the fis image "foo" will have 0x220000 as entry and mem
> address although the loaded s-record contains correct addresses
> starting at 0x450000 (a following "fis load foo" would load the image
> to a wrong address). Is this intended behaviour?
> 

Yes, this is how it is designed to work.  If you want RedBoot to be
able to load the code where it was compiled for (i.e. 0x450000), why
are you putting it at 0x220000 when you download it?

There are times when it makes sense to override the offsets in the
S-record (or ELF) file, but most of the time you should just let 
things get loaded where they "belong."

-- 
Gary Thomas <gary@mlbassoc.com>
MLB Associates


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]