ELF format

From: fearloathing2001 (fearloathing2001_at_yahoo.com)
Date: 10/13/05


Date: 13 Oct 2005 13:04:10 -0700

I've been pulling apart an ELF file to learn the ELF format. I'm able
to get the Section Headers:

Section Headers:
  [Nr] Name Type Addr Off Size ES Flg
Lk Inf Al
  [ 0] NULL 00000000 000000 000000 00
0 0 0
  [ 1] .interp PROGBITS 08048114 000114 000013 00 A
0 0 1
  [ 2] .note.ABI-tag NOTE 08048128 000128 000020 00 A
0 0 4
  [ 3] .hash HASH 08048148 000148 000024 04 A
4 0 4
  [ 4] .dynsym DYNSYM 0804816c 00016c 000040 10 A
5 1 4
  [ 5] .dynstr STRTAB 080481ac 0001ac 000045 00 A
0 0 1
  [ 6] .gnu.version VERSYM 080481f2 0001f2 000008 02 A
4 0 2
  [ 7] .gnu.version_r VERNEED 080481fc 0001fc 000020 00 A
5 1 4
  [ 8] .rel.dyn REL 0804821c 00021c 000008 08 A
4 0 4
  [ 9] .rel.plt REL 08048224 000224 000008 08 A
4 b 4
  [10] .init PROGBITS 0804822c 00022c 000017 00 AX
0 0 4
  [11] .plt PROGBITS 08048244 000244 000020 04 AX
0 0 4
  [12] .text PROGBITS 08048264 000264 000174 00 AX
0 0 4
  [13] .fini PROGBITS 080483d8 0003d8 00001b 00 AX
0 0 4
  [14] .rodata PROGBITS 080483f4 0003f4 000008 00 A
0 0 4
  [15] .eh_frame PROGBITS 080483fc 0003fc 000004 00 A
0 0 4
  [16] .data PROGBITS 08049400 000400 00000c 00 WA
0 0 4
  (etc.....)

and the Program Headers:

Program Headers:
  Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg
Align
  PHDR 0x000034 0x08048034 0x08048034 0x000e0 0x000e0 R E 0x4
  INTERP 0x000114 0x08048114 0x08048114 0x00013 0x00013 R 0x1
      [Requesting program interpreter: /lib/ld-linux.so.2]
  LOAD 0x000000 0x08048000 0x08048000 0x00400 0x00400 R E
0x1000
  LOAD 0x000400 0x08049400 0x08049400 0x000fc 0x00100 RW
0x1000
  DYNAMIC 0x00040c 0x0804940c 0x0804940c 0x000c8 0x000c8 RW 0x4
  NOTE 0x000128 0x08048128 0x08048128 0x00020 0x00020 R 0x4
  STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4

But how do you decide which Section Header maps onto which Program
Header (like in readelf's output)?

Thanks!

Shawn Windle