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