This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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

Re: Build a short executable


"Peter Barada (r1aaaa)" wrote:
Instead of strip, look at it with 'objdump --section-headers'
<foo.elf>.  This will tell you the size of each of the sections in the
executable(and where they are loaded) without losing any of the
symbols from the executable.
 
Thanks.

I have tried "the strip" : I obtained an executables file of more than 110000 bytes.
But the "objdump --section-headers" gave me :
Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .textrom      00000060  00000000  00000000  00008000  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         0000087c  00100000  00100000  00010000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  2 .ctors        00000004  0010087c  0010087c  0001087c  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  3 .dtors        00000004  00100880  00100880  00010880  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  4 .bss          00000184  00100884  00100884  00010884  2**2
                  ALLOC
  5 .text         00002c14  07800000  07800000  00018000  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE

If I add all the section sizes, I obtain 0x367c = 13948 bytes. But the total size of the executable file is explained by the file offset which is increased of 0x8000 = 32 Kbytes each time the section is put in a new memory region  (I have three memory regions defined in my linker script : 1 rom and two separated ram.
I do not understand what is the interest to align the file offsets (for different memory regions) to such segment size for a cross executable file. I searched a linker option/command to control this file alignment and I found only the PHDRS script command that allows to set the "program headers" (or "segments") of the ELF object file format.
The "objdump -p" gave me the following "program headers" :
Program Header:
    LOAD off    0x00008000 vaddr 0x00000000 paddr 0x00000000 align 2**15
         filesz 0x00000060 memsz 0x00000060 flags r-x
    LOAD off    0x00010000 vaddr 0x00100000 paddr 0x00100000 align 2**15
         filesz 0x00000884 memsz 0x00000a08 flags rw-
    LOAD off    0x00018000 vaddr 0x07800000 paddr 0x07800000 align 2**15
         filesz 0x00002c14 memsz 0x00002c14 flags r-x
private flags = 0: [interworking not enabled] [APCS-32] [floats passed in integer registers] [absolute position]

Does any know if I can put all my sections in the same program header ? How can I start this program header to the minimal value ?
 


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