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: redboot elf loader


On Mon, 2003-09-29 at 07:36, Artur Lipowski wrote:
> Gary Thomas wrote:
> ...
> > Also, there have been recent changes to RedBoot which would allow for
> >  your SRAM section to be defined as a usable memory region that fixes
> >  this problem.  This is done on a platform basis - look at the MOAB 
> > (PowerPC) platform for an example.
> Not exactly, because this region cannot be loaded (written) by redboot
> (AFAIK there are ISR vectors and redboot data). After my program takes 
> control it destroys it at all.
> 
> I am not sure if we really think about the same - my poor Eglish, sorry 
> for that 8-)
> During startup I want to put (relocate) some code at address 0 which not 
> available during program loading phase, so I declare (in linker script) 
> that virtual addres of the section is 0 and load address is somewhere 
> after BSS section in conventional RAM. Now I expect that elf loader 
> place my code at the load address (LMA) _not_ at virtual address (VMA). 
> And even more, I think that loader cannot efectively check VMA ranges 
> because of MMU and other things. It can and should check only load 
> addresses.
> Am I right?

It may not even be possible for this to work at all, since that memory
may be actively used by the loader (hence the checks).

I'd suggest that you leave this to your startup code.  Have it copy the
data from the VMA to the LMA - that's how we handle it in eCos.

> 
> > How about sending a patch which shows this more fully?
> No problem, below patch against version included in eCos 2.0
> 
> --- ecos/packages/redboot/current/src/load.c        2003-09-29
> 09:41:47.858057600 +0200
> +++ dropzone/load.c     2003-09-29 14:13:38.000000000 +0200
> @@ -340,8 +333,8 @@
>           // Set address offset based on lowest address in file.
>           addr_offset = 0xFFFFFFFF;
>           for (phx = 0;  phx < ehdr.e_phnum;  phx++) {
> -            if (phdr[phx].p_vaddr < addr_offset) {
> -                addr_offset = phdr[phx].p_vaddr;
> +            if (phdr[phx].p_paddr < addr_offset) {
> +                addr_offset = phdr[phx].p_paddr;
>               }
>           }
>           addr_offset = (unsigned long)base - addr_offset;
> @@ -351,7 +344,7 @@
>       for (phx = 0;  phx < ehdr.e_phnum;  phx++) {
>           if (phdr[phx].p_type == PT_LOAD) {
>               // Loadable segment
> -            addr = (unsigned char *)phdr[phx].p_vaddr;
> +            addr = (unsigned char *)phdr[phx].p_paddr;
>               len = phdr[phx].p_filesz;
>               if ((unsigned long)addr < lowest_address) {
>                   lowest_address = (unsigned long)addr;
> 
> Regards,
> -- 
> Artur Lipowski
-- 
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]