ELF Header

Some object file control structures can grow, because the ELF header contains their actual sizes. If the object file format changes, a program may encounter control structures that are larger or smaller than expected. An ELF header is set by the following C structure declaration:

#define EI_NIDENT 16
typedef struct {

unsigned char
e_ident[EI_NIDENT];

Elf32_Half
e_type;

Elf32_Half
e_machine;

Elf32_Word
e_version;

Elf32_Addr
e_entry;

Elf32_Off
e_phoff;

Elf32_Off
e_shoff;

Elf32_Word
e_flags;

Elf32_Half
e_ehsize;

Elf32_Half
e_phentsize;

Elf32_Half
e_phnum;

Elf32_Half
e_shentsize;

Elf32_Half
e_shnum;

Elf32_Half
e_shstrndx;
} Elf32_Ehdr;

e_ident The first bytes mark the file as an object file and provide machine-independent data with which to decode and interpret the file's contents.

e_type Identifies the object file type. Possible types are:
Name Value Meaning
ET_NONE
0
No file type
ET_REL
1
Relocatable file
ET_EXEC
2
Executable file
ET_LOPROC
0xff00
Processor-specific
ET_HIPROC
0xffff
Processor-specific

e_machine Specifies the target architecture for an individual file:
Name
Value
Meaning
EM_NONE
0
e_machine
EM_SPARC
2
Sun SPARC
EM_386
3
Intel 80386
EM_68K
4
Motorola 68000
EM_88K
5
Motorola 88000
EM_486
6
Intel 80486
EM_ MIPS
8
MIPS
EM_960
19
Intel 80960
EM_PPC
20
Power PC
EM_V800
36
NEC V800 series
EM_FR20
37
Fujitsu FR20
EM_RH32
38
TRW RH32
EM_MCORE
39
Motorola MCORE
EM_ARM
40
ARM
EM_ALPHA
41
Digital Alpha
EM_SH
42
Hitachi SH
EM_TRICORE
44
Siemens TriCore
EM_MIPS_X
51
MIPS-X
EM_COLDFIRE
52
Motorola ColdFire
EM_MMA
54
Fujitsu MMA

e_version Identifies the object file version.
Name Value Meaning
EV_NONE
0
Invalid version
EV_CURRENT
1
Current version

The value 1 signifies the original file format; extensions will create new versions with higher numbers. The value of EV_CURRENT, though given as 1 above, will change as necessary to reflect the current version number.

e_entry Gives the virtual address to which the system first transfers control upon starting the process. If the file has no associated entry point, this member holds zero.

e_phoff Program header table's file offset in bytes. If the file has no program header table, it holds zero.

e_shoff Section header table's file offset in bytes. If the file has no section header table, this field holds zero.

e_flags Processor-specific flags associated with the file. Flag names take the form EF_machine_flag.

e_ehsize ELF header size in bytes.

e_phentsize Size in bytes of one entry in the file's program header table; all entries are the same size.

e_phnum Number of entries in the program header table. The product of e_phentsize and e_phnum gives the table's size in bytes. If a file has no program header table, e_phnum holds the value zero.

e_shentize Section header's size in bytes. A section header is one entry in the section header table; all entries are the same size.

e_shnum Number of entries in the section header table. The product of e_shentsize and e_shnum gives the section header table's size in bytes. If a file has no section header table, e_shnum holds the value zero.

e_shstrndx Section header table index of the entry associated with the section name string table. If the file has no section name string table, this member holds the value SHN_UNDEF.


Previous

Next



Copyright © 1999, Green Hills Software. All rights reserved.