Executable file size and program header alignment.

Pierre Saucourt-Harmel (r54698) pierre.saucourt-harmel@motorola.com
Thu Jan 11 02:18:00 GMT 2001


Hi everybody !
I have already post my problem to the crossgcc mailing but I did not
receive any response, but the advice to ask the binutils mailing list.
I am trying to analyse why my cross-generated ARM executable file is
so big (as my program is very short).
The command "arm-elf-objdump --section-headers"gives 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
I made my own linker script which desfines three memory regions (1 rom
and 2 rams). I did not define any program header in this script.
I discovered that each section output in a new memory region is coded
in the executable file with an offset corresponding to a 32Kbytes alignment.
My code size is 13 Kbytes but my executable file size is 107 Kbytes as
each defines memory region is aligned to the next 32 Kbytes.
The command "arm-elf-objdump --p" gives me :
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]
This command shows that three *default* program headers (one for each
used memory region) are defined.
1) Does anybody know why the default alignment of file offset is 32
Kbyte (for a cross linker dedicated to the ARM without any embedded OS)
?
2) What can I do to minimise this offset (to 1 byte ?) ?
3) What problem I will encounter if I put all the output sections
into the same program header ?
Thanks a lot.



More information about the Binutils mailing list