Build a short executable
Pierre Saucourt-Harmel (r54698)
pierre.saucourt-harmel@motorola.com
Wed Jan 10 02:16:00 GMT 2001
"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 ?
ÃÂ
More information about the crossgcc
mailing list