]>
Commit | Line | Data |
---|---|---|
2d996e5d JG |
1 | /* ELF support for BFD. |
2 | Copyright (C) 1991 Free Software Foundation, Inc. | |
3 | ||
4 | Written by Fred Fish @ Cygnus Support, from information published | |
5 | in "UNIX System V Release 4, Programmers Guide: ANSI C and | |
6 | Programming Support Tools". | |
7 | ||
8 | This file is part of BFD, the Binary File Descriptor library. | |
9 | ||
10 | This program is free software; you can redistribute it and/or modify | |
11 | it under the terms of the GNU General Public License as published by | |
12 | the Free Software Foundation; either version 2 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | This program is distributed in the hope that it will be useful, | |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU General Public License | |
21 | along with this program; if not, write to the Free Software | |
22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
23 | ||
24 | ||
25 | /* This file is part of ELF support for BFD, and contains the portions | |
26 | that describe how ELF is represented internally in the BFD library. | |
27 | I.E. it describes the in-memory representation of ELF. It requires | |
28 | the elf-common.h file which contains the portions that are common to | |
29 | both the internal and external representations. */ | |
30 | ||
31 | /* Types used by various structures, functions, etc. */ | |
32 | ||
33 | typedef unsigned long Elf_Addr; /* Unsigned program address */ | |
34 | typedef unsigned long Elf_Off; /* Unsigned file offset */ | |
35 | typedef long Elf_Sword; /* Signed large integer */ | |
36 | typedef unsigned long Elf_Word; /* Unsigned large integer */ | |
37 | typedef unsigned short Elf_Half; /* Unsigned medium integer */ | |
38 | typedef unsigned char Elf_Char; /* Unsigned tiny integer */ | |
39 | ||
40 | /* ELF Header */ | |
41 | ||
42 | #define EI_NIDENT 16 /* Size of e_ident[] */ | |
43 | ||
44 | typedef struct { | |
45 | unsigned char e_ident[EI_NIDENT]; /* ELF "magic number" */ | |
46 | Elf_Half e_type; /* Identifies object file type */ | |
47 | Elf_Half e_machine; /* Specifies required architecture */ | |
48 | Elf_Word e_version; /* Identifies object file version */ | |
49 | Elf_Addr e_entry; /* Entry point virtual address */ | |
50 | Elf_Off e_phoff; /* Program header table file offset */ | |
51 | Elf_Off e_shoff; /* Section header table file offset */ | |
52 | Elf_Word e_flags; /* Processor-specific flags */ | |
53 | Elf_Half e_ehsize; /* ELF header size in bytes */ | |
54 | Elf_Half e_phentsize; /* Program header table entry size */ | |
55 | Elf_Half e_phnum; /* Program header table entry count */ | |
56 | Elf_Half e_shentsize; /* Section header table entry size */ | |
57 | Elf_Half e_shnum; /* Section header table entry count */ | |
58 | Elf_Half e_shstrndx; /* Section header string table index */ | |
59 | } Elf_Internal_Ehdr; | |
60 | ||
61 | /* Program header */ | |
62 | ||
63 | typedef struct { | |
64 | Elf_Word p_type; /* Identifies program segment type */ | |
65 | Elf_Off p_offset; /* Segment file offset */ | |
66 | Elf_Addr p_vaddr; /* Segment virtual address */ | |
67 | Elf_Addr p_paddr; /* Segment physical address */ | |
68 | Elf_Word p_filesz; /* Segment size in file */ | |
69 | Elf_Word p_memsz; /* Segment size in memory */ | |
70 | Elf_Word p_flags; /* Segment flags */ | |
71 | Elf_Word p_align; /* Segment alignment, file & memory */ | |
72 | } Elf_Internal_Phdr; | |
73 | ||
74 | /* Section header */ | |
75 | ||
76 | typedef struct { | |
77 | Elf_Word sh_name; /* Section name, index in string tbl */ | |
78 | Elf_Word sh_type; /* Type of section */ | |
79 | Elf_Word sh_flags; /* Miscellaneous section attributes */ | |
80 | Elf_Addr sh_addr; /* Section virtual addr at execution */ | |
81 | Elf_Off sh_offset; /* Section file offset */ | |
82 | Elf_Word sh_size; /* Size of section in bytes */ | |
83 | Elf_Word sh_link; /* Index of another section */ | |
84 | Elf_Word sh_info; /* Additional section information */ | |
85 | Elf_Word sh_addralign; /* Section alignment */ | |
86 | Elf_Word sh_entsize; /* Entry size if section holds table */ | |
87 | } Elf_Internal_Shdr; | |
88 | ||
89 | /* Symbol table entry */ | |
90 | ||
91 | typedef struct { | |
92 | Elf_Word st_name; /* Symbol name, index in string tbl */ | |
93 | Elf_Addr st_value; /* Value of the symbol */ | |
94 | Elf_Word st_size; /* Associated symbol size */ | |
95 | Elf_Char st_info; /* Type and binding attributes */ | |
96 | Elf_Char st_other; /* No defined meaning, 0 */ | |
97 | Elf_Half st_shndx; /* Associated section index */ | |
98 | } Elf_Internal_Sym; | |
d6fee238 FF |
99 | |
100 | /* Note segments */ | |
101 | ||
102 | typedef struct { | |
103 | Elf_Word namesz; /* Size of entry's owner string */ | |
104 | Elf_Word descsz; /* Size of the note descriptor */ | |
105 | Elf_Word type; /* Interpretation of the descriptor */ | |
106 | char name[1]; /* Start of the name+desc data */ | |
107 | } Elf_Internal_Note; |