This commit is contained in:
Michael Kerrisk 2007-06-20 21:04:13 +00:00
parent de99e9e36d
commit dd0a09a557
1 changed files with 89 additions and 89 deletions

View File

@ -116,25 +116,25 @@ The ELF header is described by the type Elf32_Ehdr or Elf64_Ehdr:
#define EI_NIDENT 16
typedef struct {
unsigned char e_ident[EI_NIDENT];
uint16_t e_type;
uint16_t e_machine;
uint32_t e_version;
ElfN_Addr e_entry;
ElfN_Off e_phoff;
ElfN_Off e_shoff;
uint32_t e_flags;
uint16_t e_ehsize;
uint16_t e_phentsize;
uint16_t e_phnum;
uint16_t e_shentsize;
uint16_t e_shnum;
uint16_t e_shstrndx;
unsigned char e_ident[EI_NIDENT];
uint16_t e_type;
uint16_t e_machine;
uint32_t e_version;
ElfN_Addr e_entry;
ElfN_Off e_phoff;
ElfN_Off e_shoff;
uint32_t e_flags;
uint16_t e_ehsize;
uint16_t e_phentsize;
uint16_t e_phnum;
uint16_t e_shentsize;
uint16_t e_shnum;
uint16_t e_shstrndx;
} ElfN_Ehdr;
.Ed
.Pp
The fields have the following meanings:
.Bl -tag -width "e_phentsize" -offset indent
.Bl -tag -width "e_phentsize"
.It Dv e_ident
This array of bytes specifies to interpret the file,
independent of the processor or the file's remaining contents.
@ -499,26 +499,26 @@ The ELF program header is described by the type Elf32_Phdr or Elf64_Phdr
depending on the architecture:
.Bd -literal -offset indent
typedef struct {
uint32_t p_type;
Elf32_Off p_offset;
Elf32_Addr p_vaddr;
Elf32_Addr p_paddr;
uint32_t p_filesz;
uint32_t p_memsz;
uint32_t p_flags;
uint32_t p_align;
uint32_t p_type;
Elf32_Off p_offset;
Elf32_Addr p_vaddr;
Elf32_Addr p_paddr;
uint32_t p_filesz;
uint32_t p_memsz;
uint32_t p_flags;
uint32_t p_align;
} Elf32_Phdr;
.Ed
.Bd -literal -offset indent
typedef struct {
uint32_t p_type;
uint32_t p_flags;
Elf64_Off p_offset;
Elf64_Addr p_vaddr;
Elf64_Addr p_paddr;
uint64_t p_filesz;
uint64_t p_memsz;
uint64_t p_align;
uint32_t p_type;
uint32_t p_flags;
Elf64_Off p_offset;
Elf64_Addr p_vaddr;
Elf64_Addr p_paddr;
uint64_t p_filesz;
uint64_t p_memsz;
uint64_t p_align;
} Elf64_Phdr;
.Ed
.Pp
@ -526,7 +526,7 @@ The main difference between the 32-bit and the 64-bit program header lies
in the location of the
.Sy p_flags
member in the total struct.
.Bl -tag -width "p_offset" -offset indent
.Bl -tag -width "p_offset"
.It Dv p_type
This member of the Phdr struct tells what kind of segment this array
element describes or how to interpret the array element's information.
@ -702,35 +702,35 @@ reserved indices.
The section header has the following structure:
.Bd -literal -offset indent
typedef struct {
uint32_t sh_name;
uint32_t sh_type;
uint32_t sh_flags;
Elf32_Addr sh_addr;
Elf32_Off sh_offset;
uint32_t sh_size;
uint32_t sh_link;
uint32_t sh_info;
uint32_t sh_addralign;
uint32_t sh_entsize;
uint32_t sh_name;
uint32_t sh_type;
uint32_t sh_flags;
Elf32_Addr sh_addr;
Elf32_Off sh_offset;
uint32_t sh_size;
uint32_t sh_link;
uint32_t sh_info;
uint32_t sh_addralign;
uint32_t sh_entsize;
} Elf32_Shdr;
.Ed
.Bd -literal -offset indent
typedef struct {
uint32_t sh_name;
uint32_t sh_type;
uint64_t sh_flags;
Elf64_Addr sh_addr;
Elf64_Off sh_offset;
uint64_t sh_size;
uint32_t sh_link;
uint32_t sh_info;
uint64_t sh_addralign;
uint64_t sh_entsize;
uint32_t sh_name;
uint32_t sh_type;
uint64_t sh_flags;
Elf64_Addr sh_addr;
Elf64_Off sh_offset;
uint64_t sh_size;
uint32_t sh_link;
uint32_t sh_info;
uint64_t sh_addralign;
uint64_t sh_entsize;
} Elf64_Shdr;
.Ed
.Pp
No real differences exist between the 32-bit and 64-bit section headers.
.Bl -tag -width "sh_addralign" -offset indent
.Bl -tag -width "sh_addralign"
.It Dv sh_name
This member specifies the name of the section.
Its value is an index
@ -905,7 +905,7 @@ fixed-size entries.
.El
.Pp
Various sections hold program and control information:
.Bl -tag -width ".shstrtab" -offset indent
.Bl -tag -width ".shstrtab"
.It .bss
This section holds uninitialized data that contributes to the program's
memory image.
@ -1160,28 +1160,28 @@ A symbol table
index is a subscript into this array.
.Bd -literal -offset indent
typedef struct {
uint32_t st_name;
Elf32_Addr st_value;
uint32_t st_size;
unsigned char st_info;
unsigned char st_other;
uint16_t st_shndx;
uint32_t st_name;
Elf32_Addr st_value;
uint32_t st_size;
unsigned char st_info;
unsigned char st_other;
uint16_t st_shndx;
} Elf32_Sym;
.Ed
.Bd -literal -offset indent
typedef struct {
uint32_t st_name;
unsigned char st_info;
unsigned char st_other;
uint16_t st_shndx;
Elf64_Addr st_value;
uint64_t st_size;
uint32_t st_name;
unsigned char st_info;
unsigned char st_other;
uint16_t st_shndx;
Elf64_Addr st_value;
uint64_t st_size;
} Elf64_Sym;
.Ed
.Pp
The 32-bit and 64-bit versions have the same members, just in a different
order.
.Bl -tag -width "st_value" -offset indent
.Bl -tag -width "st_value"
.It Dv st_name
This member holds an index into the object file's symbol string table,
which holds character representations of the symbol names.
@ -1293,33 +1293,33 @@ Relocation entries are these data.
Relocation structures that do not need an addend:
.Bd -literal -offset indent
typedef struct {
Elf32_Addr r_offset;
uint32_t r_info;
Elf32_Addr r_offset;
uint32_t r_info;
} Elf32_Rel;
.Ed
.Bd -literal -offset indent
typedef struct {
Elf64_Addr r_offset;
uint64_t r_info;
Elf64_Addr r_offset;
uint64_t r_info;
} Elf64_Rel;
.Ed
.Pp
Relocation structures that need an addend:
.Bd -literal -offset indent
typedef struct {
Elf32_Addr r_offset;
uint32_t r_info;
int32_t r_addend;
Elf32_Addr r_offset;
uint32_t r_info;
int32_t r_addend;
} Elf32_Rela;
.Ed
.Bd -literal -offset indent
typedef struct {
Elf64_Addr r_offset;
uint64_t r_info;
int64_t r_addend;
Elf64_Addr r_offset;
uint64_t r_info;
int64_t r_addend;
} Elf64_Rela;
.Ed
.Bl -tag -width "r_offset" -offset indent
.Bl -tag -width "r_offset"
.It Dv r_offset
This member gives the location at which to apply the relocation action.
For a relocatable file, the value is the byte offset from the beginning
@ -1352,25 +1352,25 @@ The d_tag member controls the interpretation
of d_un.
.Bd -literal -offset indent
typedef struct {
Elf32_Sword d_tag;
union {
Elf32_Word d_val;
Elf32_Addr d_ptr;
} d_un;
Elf32_Sword d_tag;
union {
Elf32_Word d_val;
Elf32_Addr d_ptr;
} d_un;
} Elf32_Dyn;
extern Elf32_Dyn _DYNAMIC[];
.Ed
.Bd -literal -offset indent
typedef struct {
Elf64_Sxword d_tag;
union {
Elf64_Xword d_val;
Elf64_Addr d_ptr;
} d_un;
Elf64_Sxword d_tag;
union {
Elf64_Xword d_val;
Elf64_Addr d_ptr;
} d_un;
} Elf64_Dyn;
extern Elf64_Dyn _DYNAMIC[];
.Ed
.Bl -tag -width "d_tag" -offset indent
.Bl -tag -width "d_tag"
.It Dv d_tag
This member may have any of the following values:
.Bl -tag -width "DT_SYMBOLIC"