Linux Kernel Architecture

(Jacob Rumans) #1
Mauerer runapp05.tex V1 - 09/04/2008 6:13pm Page 1244

Appendix E: The ELF Binary Format


Which fields differ if you look at an object file instead of an executable file? For the sake of simplicity, this
appendix deals only with the following fields displayed byreadelf:

wolfgang@meitner>readelf -h test.o
...
Type: REL (Relocatable file)
...
Start of program headers: 0 (bytes into file)
...
Size of program headers: 0 (bytes)
Number of program headers: 0
...

The file type is shown asREL. In other words it is a relocatable file whose code can be moved to any
position.^2 The file has no program header table because this is not needed for link objects — for this
reason, all sizes are set to 0 :

E.1.2 Program Header Table


The following is the program header table in an executable file (object files have no such table):

wolfgang@meitner>readelf -l test

Elf file type is EXEC (Executable file)
Entry point 0x80482d0
There are 6 program headers, starting at offset 52

Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x08048034 0x08048034 0x000c0 0x000c0 R E 0x4
INTERP 0x0000f4 0x080480f4 0x080480f4 0x00013 0x00013 R 0x1
[Requesting program interpreter: /lib/ld-linux.so.2]
LOAD 0x000000 0x08048000 0x08048000 0x0046d 0x0046d R E 0x1000
LOAD 0x000470 0x08049470 0x08049470 0x00108 0x0010c RW 0x1000
DYNAMIC 0x000480 0x08049480 0x08049480 0x000c8 0x000c8 RW 0x4
NOTE 0x000108 0x08048108 0x08048108 0x00020 0x00020 R 0x4

Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .note.ABI-tag .hash .dynsym .dynstr .gnu.version
.gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata
03 .data .eh_frame .dynamic .ctors .dtors .jcr .got .bss
04 .dynamic
05 .note.ABI-tag

Six sections are listed underProgram Headers— these constitute the final program in memory. Infor-
mation on size and position in virtual and physical address space,^3 flags, access authorizations, and

(^2) In particular, this means that relative branch addresses must be used instead of absolute addresses in assembly language code.
(^3) The physical address information is ignored because this information is allocated dynamically by the kernel depending on which
physical page frames are mapped onto the corresponding positions in virtual address space. This information is of relevance only on
systems that have no MMU and therefore no virtual memory — on small embedded processors, for instance.

Free download pdf