Sun Microsystems Logo
Products & Services
 
Support & Training
 
 

Previous Previous     Contents     Index     Next Next
e_ident

The initial bytes mark the file as an object file and provide machine-independent data with which to decode and interpret the file's contents. Complete descriptions appear in ELF Identification.

e_type

Identifies the object file type, as listed in the following table.

Table 7-3 ELF File Identifiers

Name

Value

Meaning

ET_NONE

0

No file type

ET_REL

1

Relocatable file

ET_EXEC

2

Executable file

ET_DYN

3

Shared object file

ET_CORE

4

Core file

ET_LOPROC

0xff00

Processor-specific

ET_HIPROC

0xffff

Processor-specific

Although the core file contents are unspecified, type ET_CORE is reserved to mark the file. Values from ET_LOPROC through ET_HIPROC (inclusive) are reserved for processor-specific semantics. Other values are reserved and will be assigned to new object file types as necessary.

e_machine

Specifies the required architecture for an individual file. Relevant architectures are listed in the following table.

Table 7-4 ELF Machines

Name

Value

Meaning

EM_NONE

0

No machine

EM_SPARC

2

SPARC

EM_386

3

Intel 80386

EM_SPARC32PLUS

18

Sun SPARC 32+

EM_SPARCV9

43

SPARC V9

Other values are reserved and will be assigned to new machines as necessary (see sys/elf.h). Processor-specific ELF names use the machine name to distinguish them. For example, the flags defined in Table 7-5 use the prefix EF_. A flag named WIDGET for the EM_XYZ machine would be called EF_XYZ_WIDGET.

e_version

Identifies the object file version, as listed in the following table.

Table 7-5 ELF Versions

Name

Value

Meaning

EV_NONE

0

Invalid version

EV_CURRENT

>=1

Current version

The value 1 signifies the original file format. The value of EV_CURRENT changes as necessary to reflect the current version number.

e_entry

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

e_phoff

The program header table's file offset in bytes. If the file has no program header table, this member holds zero.

e_shoff

The section header table's file offset in bytes. If the file has no section header table, this member holds zero.

e_flags

Processor-specific flags associated with the file. Flag names take the form EF_machine_flag. This member is presently zero for x86. The SPARC flags are listed in the following table.

Table 7-6 SPARC: ELF Flags

Name

Value

Meaning

EF_SPARC_EXT_MASK

0xffff00

Vendor Extension mask

EF_SPARC_32PLUS

0x000100

Generic V8+ features

EF_SPARC_SUN_US1

0x000200

Sun UltraSPARC™ 1 Extensions

EF_SPARC_HAL_R1

0x000400

HAL R1 Extensions

EF_SPARC_SUN_US3

0x000800

Sun UltraSPARC 3 Extensions

EF_SPARCV9_MM

0x3

Mask for Memory Model

EF_SPARCV9_TSO

0x0

Total Store Ordering

EF_SPARCV9_PSO

0x1

Partial Store Ordering

EF_SPARCV9_RMO

0x2

Relaxed Memory Ordering

e_ehsize

The ELF header's size in bytes.

e_phentsize

The size in bytes of one entry in the file's program header table. All entries are the same size.

e_phnum

The 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_shentsize

A 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

The 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.

If the number of sections is greater than or equal to SHN_LORESERVE (0xff00), this member has the value zero and the actual number of section header table entries is contained in the sh_size field of the section header at index 0. Otherwise, the sh_size member of the initial entry contains 0.

e_shstrndx

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

If the section name string table section index is greater than or equal to SHN_LORESERVE (0xff00), this member has the value SHN_XINDEX (0xffff) and the actual index of the section name string table section is contained in thesh_link field of the section header at index 0. Otherwise, the sh_link member of the initial entry contains 0.

ELF Identification

ELF provides an object file framework to support multiple processors, multiple data encoding, and multiple classes of machines. To support this object file family, the initial bytes of the file specify how to interpret the file. These bytes are independent of the processor on which the inquiry is made and independent of the file's remaining contents.

The initial bytes of an ELF header and an object file correspond to the e_ident member.

Table 7-7 ELF Identification Index

Name

Value

Purpose

EI_MAG0

0

File identification

EI_MAG1

1

File identification

EI_MAG2

2

File identification

EI_MAG3

3

File identification

EI_CLASS

4

File class

EI_DATA

5

Data encoding

EI_VERSION

6

File version

EI_OSABI

7

Operating system/ABI identification

EI_ABIVERSION

8

ABI version

EI_PAD

9

Start of padding bytes

EI_NIDENT

16

Size of e_ident[]

These indexes access bytes that hold the values described below.

EI_MAG0 - EI_MAG3

A 4-byte magic number, identifying the file as an ELF object file, as listed in the following table.

Table 7-8 ELF Magic Number

Name

Value

Position

ELFMAG0

0x7f

e_ident[EI_MAG0]

ELFMAG1

'E'

e_ident[EI_MAG1]

ELFMAG2

'L'

e_ident[EI_MAG2]

ELFMAG3

'F'

e_ident[EI_MAG3]

EI_CLASS

Byte e_ident[EI_CLASS] identifies the file's class, or capacity, as listed in the following table.

Table 7-9 ELF File Class

Name

Value

Meaning

ELFCLASSNONE

0

Invalid class

ELFCLASS32

1

32-bit objects

ELFCLASS64

2

64-bit objects

The file format is designed to be portable among machines of various sizes, without imposing the sizes of the largest machine on the smallest. The class of the file defines the basic types used by the data structures of the object file container itself. The data contained in object file sections may follow a different programming model.

Class ELFCLASS32 supports machines with files and virtual address spaces up to 4 gigabytes. It uses the basic types defined in Table 7-1.

Class ELFCLASS64 is reserved for 64-bit architectures such as SPARC. It uses the basic types defined in Table 7-2.

EI_DATA

Byte e_ident[EI_DATA] specifies the data encoding of the processor-specific data in the object file, as listed in the following table.

Table 7-10 ELF Data Encoding

Name

Value

Meaning

ELFDATANONE

0

Invalid data encoding

ELFDATA2LSB

1

See Figure 7-2.

ELFDATA2MSB

2

See Figure 7-3.

More information on these encodings appears in the section Data Encoding. Other values are reserved and will be assigned to new encodings as necessary.

EI_VERSION

Byte e_ident[EI_VERSION] specifies the ELF header version number. Currently, this value must be EV_CURRENT.

EI_OSABI

Byte e_ident[EI_OSABI] identifies the operating system and ABI to which the object is targeted. Some fields in other ELF structures have flags and values that have operating system or ABI specific meanings. The interpretation of those fields is determined by the value of this byte.

EI_ABIVERSION

Byte e_ident[EI_ABIVERSION] identifies the version of the ABI to which the object is targeted. This field is used to distinguish among incompatible versions of an ABI. The interpretation of this version number is dependent on the ABI identified by the EI_OSABI field. If no values are specified for the EI_OSABI field for the processor, or no version values are specified for the ABI determined by a particular value of the EI_OSABI byte, the value 0 is used to indicate unspecified.

EI_PAD

This value marks the beginning of the unused bytes in e_ident. These bytes are reserved and set to zero. Programs that read object files should ignore them.

Previous Previous     Contents     Index     Next Next