[Cbe-oss-dev] elf format detection in MARS

Tomas Carnecky tom at dbservice.com
Tue Oct 13 08:17:21 EST 2009


I see that mars manually sets the address of the .init section for  
tasks and modules (-Wl,--section-start,.init=0x3000), and later when  
loading the elf images it checks if the addresses are correct. But, it  
checks the program header addresses and not the section addresses! And  
these can be different, which makes the check fail and mars refuses to  
run. Mars should be checking the address of the .init section instead  
of relying on .init starting at the same address as are in the program  
headers. I'd even go further and define a section '.mars.task' and  
check the presence of that. But I know very little about the elf  
format, so you can ignore my advice if it is totally stupid. I know  
the linux kernel uses some dark magic with elf section to get things  
done.

Anyway, here is the objdump -x of my mars_task_module. As you can see  
the .init section correctly starts at 0x3000, but the read-only (r-x)  
LOAD program header starts at 0x2f00:

src/mpu/module/mars_task_module:     file format elf32-big
src/mpu/module/mars_task_module
architecture: UNKNOWN!, flags 0x00000102:
EXEC_P, D_PAGED
start address 0x00003968

Program Header:
     LOAD off    0x00000000 vaddr 0x00002f00 paddr 0x00002f00 align 2**7
          filesz 0x00000bc0 memsz 0x00000bc0 flags r-x
     LOAD off    0x00000c00 vaddr 0x00003b00 paddr 0x00003b00 align 2**7
          filesz 0x00000070 memsz 0x00000400 flags rw-
     NOTE off    0x00000d90 vaddr 0x00000000 paddr 0x00000000 align 2**4
          filesz 0x00000028 memsz 0x00000000 flags r--
PAX_FLAGS off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**2
          filesz 0x00000000 memsz 0x00000000 flags --- 2800

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
   0 .init         00000024  00003000  00003000  00000100  2**2
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
   1 .text         00000a4c  00003030  00003030  00000130  2**4
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
   2 .fini         0000001c  00003a7c  00003a7c  00000b7c  2**2
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
   3 .rodata       00000020  00003aa0  00003aa0  00000ba0  2**4
                   CONTENTS, ALLOC, LOAD, READONLY, DATA



More information about the cbe-oss-dev mailing list