Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
  Previous   Contents   Next 
   
 
Chapter 3

Executable and Linking Format

The type of object files created by the SPARC assembler version for SunOS 5.x are now Executable and Linking Format (ELF) files. These relocatable ELF files hold code and data suitable for linking with other object files to create an executable or a shared object file, and are the assembler normal output. The assembler can also write information to standard output (for example, under the -S option) and to standard error (for example, under the -V option). The SPARC assembler creates a default output file when standard input or multiple files are used.

This chapter is organized into the following sections:

The ELF object file format consists of:

  • Header

  • Sections

  • Locations

  • Addresses

  • Relocation tables

  • Symbol tables

  • String tables

For more information, see the System V Application Binary Interface: SPARC™ Processor Supplement.

3.1 ELF Header

The ELF header is always located at the beginning of the ELF file. It describes the ELF file organization and contains the actual sizes of the object file control structures. The initial bytes of an ELF header specify how the file is to be interpreted.

The ELF header contains the following information:

 

ehsize

ELF header size in bytes.

 

entry

Virtual address at which the process is to start. A value of 0 indicates no associated entry point.

 

flag

Processor-specific flags associated with the file.

 

ident

Marks the file as an object file and provides machine-independent data to decode and interpret the file contents.

 

machine

Specifies the required architecture for an individual file. A value of 2 specifies SPARC.

 

phentsize

Size in bytes of entries in the program header table. All entries are the same size.

 

phnum

Number of entries in program header table. A value of 0 indicates the file has no program header table.

 

phoff

Program header table file offset in bytes. The value of 0 indicates no program header.

 

shentsize

Size in bytes of the section header. A section header is one entry in the section header table; all entries are the same size.

 

shnum

Number of entries in section header table. A value of 0 indicates the file has no section header table.

 

shoff

Section header table file offset in bytes. The value of 0 indicates no section header.

 

shstrndx

Section header table index of the entry associated with the section name string table. A value of SHN_UNDEF indicates the file does not have a section name string table.

 

type

Identifies the object file type. Table 3-1 describes the reserved object file types.

 

version

Identifies the object file version.

Table 3-1 shows reserved object file types:

Table 3-1

Type

Value

Description

none

0

No file type

rel

1

Relocatable file

exec

2

Executable file

dyn

3

Shared object file

core

4

Core file

loproc

0xff00

Processor-specific

hiproc

0xffff

Processor-specific

3.2 Sections

A section is the smallest unit of an object that can be relocated. The following sections are commonly present in an ELF file:

  • Section header

  • Executable text

  • Read-only data

  • Read-write data

  • Read-write uninitialized data (section header only)

Sections do not need to be specified in any particular order. The current section is the section to which code is generated.

These sections contain all other information in an object file and satisfy several conditions.

  1. Every section must have one section header describing the section. However, a section header does not need to be followed by a section.

  2. Each section occupies one contiguous sequence of bytes within a file. The section may be empty (that is, of zero-length).

  3. A byte in a file can reside in only one section. Sections in a file cannot overlap.

  4. An object file may have inactive space. The contents of the data in the inactive space are unspecified.

 
 
 
  Previous   Contents   Next