]> git.sur5r.net Git - openocd/commitdiff
- The elf loader incorrectly assumed that the program header always follows the ELF...
authorntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Fri, 7 Mar 2008 16:38:02 +0000 (16:38 +0000)
committerntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Fri, 7 Mar 2008 16:38:02 +0000 (16:38 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@472 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/target/image.c

index 3fac057182f266fd803df2974d88fa62e2d12828..39df4aef163e9ab63257c3a0b7403090cfecb673 100644 (file)
@@ -381,6 +381,14 @@ int image_elf_read_headers(image_t *image)
                return ERROR_IMAGE_FORMAT_ERROR;
        }
 
+
+       if ((retval = fileio_seek(&elf->fileio, elf->header->e_phoff)) != ERROR_OK)
+       {
+               ERROR("cannot seek to ELF program header table, read failed");
+               return retval;
+       }
+
+
        elf->segments = malloc(elf->segment_count*sizeof(Elf32_Phdr));
 
        if ((retval = fileio_read(&elf->fileio, elf->segment_count*sizeof(Elf32_Phdr), (u8*)elf->segments, &read_bytes)) != ERROR_OK)
@@ -1001,3 +1009,4 @@ int image_calculate_checksum(u8* buffer, u32 nbytes, u32* checksum)
        return ERROR_OK;
 }
 
+