This is the mail archive of the ecos-patches@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]

RedBoot - ELF load with offset


When loading ELF images using -b XXX, a bad address offset could
have been computed, leading to really wrong addresses being used.

-- 
Gary Thomas <gary@mlbassoc.com>
MLB Associates
Index: redboot/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/ChangeLog,v
retrieving revision 1.152
diff -u -5 -p -r1.152 ChangeLog
--- redboot/current/ChangeLog	15 Oct 2003 15:52:02 -0000	1.152
+++ redboot/current/ChangeLog	17 Oct 2003 21:38:21 -0000
@@ -1,5 +1,11 @@
+2003-10-17  Gary Thomas  <gary@mlbassoc.com>
+
+	* src/load.c: Only examine loadable segments when scanning to determine
+	lowest loadable address (only used when -b XXX option used).  Otherwise,
+	an offset into space could be chosen.
+
 2003-10-15  Gary Thomas  <gary@mlbassoc.com>
 
 	* src/flash.c: 
 	* src/fconfig.c: Better handling of layout of fconfig and fis
 	data within the FLASH.  Should work for even flash devices with
Index: redboot/current/src/load.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/redboot/current/src/load.c,v
retrieving revision 1.35
diff -u -5 -p -r1.35 load.c
--- redboot/current/src/load.c	29 Sep 2003 14:49:46 -0000	1.35
+++ redboot/current/src/load.c	17 Oct 2003 21:34:53 -0000
@@ -338,11 +338,11 @@ load_elf_image(getc_t getc, unsigned lon
     }
     if (base) {
         // Set address offset based on lowest address in file.
         addr_offset = 0xFFFFFFFF;
         for (phx = 0;  phx < ehdr.e_phnum;  phx++) {    
-            if (phdr[phx].p_paddr < addr_offset) {
+            if ((phdr[phx].p_type == PT_LOAD) && (phdr[phx].p_paddr < addr_offset)) {
                 addr_offset = phdr[phx].p_paddr;
             }
         }
         addr_offset = (unsigned long)base - addr_offset;
     } else {

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