elf32.h
Go to the documentation of this file.
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 1996-1998 John D. Polstra.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30 
31 #include <stdint.h>
32 
33 #ifndef _FREEBSD_ELF_SYS_ELF32_H_
34 #define _FREEBSD_ELF_SYS_ELF32_H_
35 
37 
38 /*
39  * ELF definitions common to all 32-bit architectures.
40  */
41 
48 
50 
51 /* Non-standard class-dependent datatype used for abstraction. */
54 
55 /*
56  * ELF header.
57  */
58 
59 typedef struct {
60  unsigned char e_ident[EI_NIDENT]; /* File identification. */
61  Elf32_Half e_type; /* File type. */
62  Elf32_Half e_machine; /* Machine architecture. */
63  Elf32_Word e_version; /* ELF format version. */
64  Elf32_Addr e_entry; /* Entry point. */
65  Elf32_Off e_phoff; /* Program header file offset. */
66  Elf32_Off e_shoff; /* Section header file offset. */
67  Elf32_Word e_flags; /* Architecture-specific flags. */
68  Elf32_Half e_ehsize; /* Size of ELF header in bytes. */
69  Elf32_Half e_phentsize; /* Size of program header entry. */
70  Elf32_Half e_phnum; /* Number of program header entries. */
71  Elf32_Half e_shentsize; /* Size of section header entry. */
72  Elf32_Half e_shnum; /* Number of section header entries. */
73  Elf32_Half e_shstrndx; /* Section name strings section. */
74 } Elf32_Ehdr;
75 
76 /*
77  * Shared object information, found in SHT_MIPS_LIBLIST.
78  */
79 
80 typedef struct {
81  Elf32_Word l_name; /* The name of a shared object. */
82  Elf32_Word l_time_stamp; /* 32-bit timestamp. */
83  Elf32_Word l_checksum; /* Checksum of visible symbols, sizes. */
84  Elf32_Word l_version; /* Interface version string index. */
85  Elf32_Word l_flags; /* Flags (LL_*). */
86 } Elf32_Lib;
87 
88 /*
89  * Section header.
90  */
91 
92 typedef struct {
93  Elf32_Word sh_name; /* Section name (index into the
94  section header string table). */
95  Elf32_Word sh_type; /* Section type. */
96  Elf32_Word sh_flags; /* Section flags. */
97  Elf32_Addr sh_addr; /* Address in memory image. */
98  Elf32_Off sh_offset; /* Offset in file. */
99  Elf32_Word sh_size; /* Size in bytes. */
100  Elf32_Word sh_link; /* Index of a related section. */
101  Elf32_Word sh_info; /* Depends on section type. */
102  Elf32_Word sh_addralign; /* Alignment in bytes. */
103  Elf32_Word sh_entsize; /* Size of each entry in section. */
104 } Elf32_Shdr;
105 
106 /*
107  * Program header.
108  */
109 
110 typedef struct {
111  Elf32_Word p_type; /* Entry type. */
112  Elf32_Off p_offset; /* File offset of contents. */
113  Elf32_Addr p_vaddr; /* Virtual address in memory image. */
114  Elf32_Addr p_paddr; /* Physical address (not used). */
115  Elf32_Word p_filesz; /* Size of contents in file. */
116  Elf32_Word p_memsz; /* Size of contents in memory. */
117  Elf32_Word p_flags; /* Access permission flags. */
118  Elf32_Word p_align; /* Alignment in memory and file. */
119 } Elf32_Phdr;
120 
121 /*
122  * Dynamic structure. The ".dynamic" section contains an array of them.
123  */
124 
125 typedef struct {
126  Elf32_Sword d_tag; /* Entry type. */
127  union {
128  Elf32_Word d_val; /* Integer value. */
129  Elf32_Addr d_ptr; /* Address value. */
130  } d_un;
131 } Elf32_Dyn;
132 
133 /*
134  * Relocation entries.
135  */
136 
137 /* Relocations that don't need an addend field. */
138 typedef struct {
139  Elf32_Addr r_offset; /* Location to be relocated. */
140  Elf32_Word r_info; /* Relocation type and symbol index. */
141 } Elf32_Rel;
142 
143 /* Relocations that need an addend field. */
144 typedef struct {
145  Elf32_Addr r_offset; /* Location to be relocated. */
146  Elf32_Word r_info; /* Relocation type and symbol index. */
147  Elf32_Sword r_addend; /* Addend. */
148 } Elf32_Rela;
149 
150 /* Macros for accessing the fields of r_info. */
151 #define ELF32_R_SYM(info) ((info) >> 8)
152 #define ELF32_R_TYPE(info) ((unsigned char)(info))
153 
154 /* Macro for constructing r_info from field values. */
155 #define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type))
156 
157 /*
158  * Note entry header
159  */
161 
162 /*
163  * Move entry
164  */
165 typedef struct {
166  Elf32_Lword m_value; /* symbol value */
167  Elf32_Word m_info; /* size + index */
168  Elf32_Word m_poffset; /* symbol offset */
169  Elf32_Half m_repeat; /* repeat count */
170  Elf32_Half m_stride; /* stride info */
171 } Elf32_Move;
172 
173 /*
174  * The macros compose and decompose values for Move.r_info
175  *
176  * sym = ELF32_M_SYM(M.m_info)
177  * size = ELF32_M_SIZE(M.m_info)
178  * M.m_info = ELF32_M_INFO(sym, size)
179  */
180 #define ELF32_M_SYM(info) ((info)>>8)
181 #define ELF32_M_SIZE(info) ((unsigned char)(info))
182 #define ELF32_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size))
183 
184 /*
185  * Hardware/Software capabilities entry
186  */
187 typedef struct {
188  Elf32_Word c_tag; /* how to interpret value */
189  union {
192  } c_un;
193 } Elf32_Cap;
194 
195 /*
196  * Symbol table entries.
197  */
198 
199 typedef struct {
200  Elf32_Word st_name; /* String table index of name. */
201  Elf32_Addr st_value; /* Symbol value. */
202  Elf32_Word st_size; /* Size of associated object. */
203  unsigned char st_info; /* Type and binding information. */
204  unsigned char st_other; /* Reserved (not used). */
205  Elf32_Half st_shndx; /* Section index of symbol. */
206 } Elf32_Sym;
207 
208 /* Macros for accessing the fields of st_info. */
209 #define ELF32_ST_BIND(info) ((info) >> 4)
210 #define ELF32_ST_TYPE(info) ((info) & 0xf)
211 
212 /* Macro for constructing st_info from field values. */
213 #define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
214 
215 /* Macro for accessing the fields of st_other. */
216 #define ELF32_ST_VISIBILITY(oth) ((oth) & 0x3)
217 
218 /* Structures used by Sun & GNU symbol versioning. */
219 typedef struct
220 {
228 } Elf32_Verdef;
229 
230 typedef struct
231 {
234 } Elf32_Verdaux;
235 
236 typedef struct
237 {
243 } Elf32_Verneed;
244 
245 typedef struct
246 {
252 } Elf32_Vernaux;
253 
255 
256 typedef struct {
257  Elf32_Half si_boundto; /* direct bindings - symbol bound to */
258  Elf32_Half si_flags; /* per symbol flags */
259 } Elf32_Syminfo;
260 
261 typedef struct {
265 } Elf32_Chdr;
266 
267 #endif /* !_FREEBSD_ELF_SYS_ELF32_H_ */
Elf32_Dyn::d_val
Elf32_Word d_val
Definition: elf32.h:128
Elf32_Hashelt
Elf32_Word Elf32_Hashelt
Definition: elf32.h:49
Elf32_Verneed::vn_file
Elf32_Word vn_file
Definition: elf32.h:240
Elf32_Shdr::sh_type
Elf32_Word sh_type
Definition: elf32.h:95
Elf32_Verneed
Definition: elf32.h:236
Elf32_Ehdr::e_version
Elf32_Word e_version
Definition: elf32.h:63
Elf32_Syminfo::si_flags
Elf32_Half si_flags
Definition: elf32.h:258
Elf32_Rela::r_offset
Elf32_Addr r_offset
Definition: elf32.h:145
Elf32_Shdr::sh_size
Elf32_Word sh_size
Definition: elf32.h:99
Elf32_Phdr::p_align
Elf32_Word p_align
Definition: elf32.h:118
Elf32_Cap::c_tag
Elf32_Word c_tag
Definition: elf32.h:188
Elf32_Dyn
Definition: elf32.h:125
uint16_t
unsigned short uint16_t
Definition: stdint-msvc2008.h:79
Elf32_Sym::st_value
Elf32_Addr st_value
Definition: elf32.h:201
Elf32_Lib
Definition: elf32.h:80
Elf32_Ehdr::e_ehsize
Elf32_Half e_ehsize
Definition: elf32.h:68
Elf32_Nhdr
Elf_Note Elf32_Nhdr
Definition: elf32.h:160
Elf32_Vernaux::vna_name
Elf32_Word vna_name
Definition: elf32.h:250
Elf32_Rel
Definition: elf32.h:138
Elf32_Ehdr::e_phoff
Elf32_Off e_phoff
Definition: elf32.h:65
Elf32_Shdr::sh_addr
Elf32_Addr sh_addr
Definition: elf32.h:97
Elf32_Phdr::p_memsz
Elf32_Word p_memsz
Definition: elf32.h:116
Elf32_Shdr::sh_entsize
Elf32_Word sh_entsize
Definition: elf32.h:103
Elf32_Verneed::vn_cnt
Elf32_Half vn_cnt
Definition: elf32.h:239
Elf_Note
Definition: elf_common.h:51
Elf32_Chdr::ch_size
Elf32_Word ch_size
Definition: elf32.h:263
Elf32_Shdr::sh_offset
Elf32_Off sh_offset
Definition: elf32.h:98
Elf32_Verdef::vd_flags
Elf32_Half vd_flags
Definition: elf32.h:222
Elf32_Cap::c_val
Elf32_Word c_val
Definition: elf32.h:190
Elf32_Off
uint32_t Elf32_Off
Definition: elf32.h:44
Elf32_Ehdr::e_shentsize
Elf32_Half e_shentsize
Definition: elf32.h:71
Elf32_Vernaux::vna_hash
Elf32_Word vna_hash
Definition: elf32.h:247
Elf32_Vernaux
Definition: elf32.h:245
Elf32_Verdef::vd_aux
Elf32_Word vd_aux
Definition: elf32.h:226
Elf32_Sword
int32_t Elf32_Sword
Definition: elf32.h:45
Elf32_Verdef::vd_version
Elf32_Half vd_version
Definition: elf32.h:221
Elf32_Versym
Elf32_Half Elf32_Versym
Definition: elf32.h:254
Elf32_Phdr::p_type
Elf32_Word p_type
Definition: elf32.h:111
Elf32_Verdef
Definition: elf32.h:219
Elf32_Ssize
Elf32_Sword Elf32_Ssize
Definition: elf32.h:53
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
Elf32_Move::m_repeat
Elf32_Half m_repeat
Definition: elf32.h:169
Elf32_Move::m_value
Elf32_Lword m_value
Definition: elf32.h:166
Elf32_Syminfo
Definition: elf32.h:256
Elf32_Ehdr::e_shoff
Elf32_Off e_shoff
Definition: elf32.h:66
Elf32_Phdr::p_offset
Elf32_Off p_offset
Definition: elf32.h:112
Elf32_Ehdr::e_flags
Elf32_Word e_flags
Definition: elf32.h:67
Elf32_Lib::l_version
Elf32_Word l_version
Definition: elf32.h:84
Elf32_Phdr::p_vaddr
Elf32_Addr p_vaddr
Definition: elf32.h:113
Elf32_Move::m_info
Elf32_Word m_info
Definition: elf32.h:167
Elf32_Phdr::p_paddr
Elf32_Addr p_paddr
Definition: elf32.h:114
Elf32_Verneed::vn_next
Elf32_Word vn_next
Definition: elf32.h:242
Elf32_Lib::l_time_stamp
Elf32_Word l_time_stamp
Definition: elf32.h:82
Elf32_Shdr::sh_flags
Elf32_Word sh_flags
Definition: elf32.h:96
Elf32_Verdaux::vda_next
Elf32_Word vda_next
Definition: elf32.h:233
Elf32_Move
Definition: elf32.h:165
Elf32_Cap::c_ptr
Elf32_Addr c_ptr
Definition: elf32.h:191
Elf32_Ehdr::e_shstrndx
Elf32_Half e_shstrndx
Definition: elf32.h:73
Elf32_Sym::st_other
unsigned char st_other
Definition: elf32.h:204
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
Elf32_Phdr::p_filesz
Elf32_Word p_filesz
Definition: elf32.h:115
Elf32_Lib::l_checksum
Elf32_Word l_checksum
Definition: elf32.h:83
Elf32_Chdr::ch_addralign
Elf32_Word ch_addralign
Definition: elf32.h:264
Elf32_Lib::l_flags
Elf32_Word l_flags
Definition: elf32.h:85
Elf32_Verdef::vd_hash
Elf32_Word vd_hash
Definition: elf32.h:225
Elf32_Ehdr::e_entry
Elf32_Addr e_entry
Definition: elf32.h:64
Elf32_Sym::st_name
Elf32_Word st_name
Definition: elf32.h:200
Elf32_Phdr
Definition: elf32.h:110
Elf32_Vernaux::vna_next
Elf32_Word vna_next
Definition: elf32.h:251
Elf32_Size
Elf32_Word Elf32_Size
Definition: elf32.h:52
Elf32_Ehdr::e_machine
Elf32_Half e_machine
Definition: elf32.h:62
Elf32_Verdef::vd_cnt
Elf32_Half vd_cnt
Definition: elf32.h:224
Elf32_Phdr::p_flags
Elf32_Word p_flags
Definition: elf32.h:117
stdint.h
Elf32_Sym::st_shndx
Elf32_Half st_shndx
Definition: elf32.h:205
Elf32_Lib::l_name
Elf32_Word l_name
Definition: elf32.h:81
Elf32_Verdaux::vda_name
Elf32_Word vda_name
Definition: elf32.h:232
Elf32_Vernaux::vna_flags
Elf32_Half vna_flags
Definition: elf32.h:248
EI_NIDENT
#define EI_NIDENT
Definition: elf_common.h:137
Elf32_Verdef::vd_next
Elf32_Word vd_next
Definition: elf32.h:227
Elf32_Shdr::sh_name
Elf32_Word sh_name
Definition: elf32.h:93
Elf32_Dyn::d_ptr
Elf32_Addr d_ptr
Definition: elf32.h:129
Elf32_Addr
uint32_t Elf32_Addr
Definition: elf32.h:42
Elf32_Verneed::vn_aux
Elf32_Word vn_aux
Definition: elf32.h:241
Elf32_Chdr::ch_type
Elf32_Word ch_type
Definition: elf32.h:262
Elf32_Syminfo::si_boundto
Elf32_Half si_boundto
Definition: elf32.h:257
Elf32_Ehdr
Definition: elf32.h:59
Elf32_Shdr
Definition: elf32.h:92
Elf32_Rela::r_info
Elf32_Word r_info
Definition: elf32.h:146
Elf32_Ehdr::e_shnum
Elf32_Half e_shnum
Definition: elf32.h:72
Elf32_Chdr
Definition: elf32.h:261
Elf32_Verneed::vn_version
Elf32_Half vn_version
Definition: elf32.h:238
elf_common.h
Elf32_Dyn::d_tag
Elf32_Sword d_tag
Definition: elf32.h:126
Elf32_Move::m_stride
Elf32_Half m_stride
Definition: elf32.h:170
Elf32_Rela::r_addend
Elf32_Sword r_addend
Definition: elf32.h:147
Elf32_Cap
Definition: elf32.h:187
Elf32_Shdr::sh_addralign
Elf32_Word sh_addralign
Definition: elf32.h:102
Elf32_Word
uint32_t Elf32_Word
Definition: elf32.h:46
Elf32_Ehdr::e_phentsize
Elf32_Half e_phentsize
Definition: elf32.h:69
Elf32_Sym::st_size
Elf32_Word st_size
Definition: elf32.h:202
Elf32_Ehdr::e_type
Elf32_Half e_type
Definition: elf32.h:61
Elf32_Move::m_poffset
Elf32_Word m_poffset
Definition: elf32.h:168
Elf32_Vernaux::vna_other
Elf32_Half vna_other
Definition: elf32.h:249
Elf32_Rela
Definition: elf32.h:144
Elf32_Sym::st_info
unsigned char st_info
Definition: elf32.h:203
Elf32_Shdr::sh_link
Elf32_Word sh_link
Definition: elf32.h:100
Elf32_Shdr::sh_info
Elf32_Word sh_info
Definition: elf32.h:101
Elf32_Verdef::vd_ndx
Elf32_Half vd_ndx
Definition: elf32.h:223
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
Elf32_Half
uint16_t Elf32_Half
Definition: elf32.h:43
Elf32_Sym
Definition: elf32.h:199
Elf32_Verdaux
Definition: elf32.h:230
Elf32_Lword
uint64_t Elf32_Lword
Definition: elf32.h:47
Elf32_Rel::r_info
Elf32_Word r_info
Definition: elf32.h:140
Elf32_Rel::r_offset
Elf32_Addr r_offset
Definition: elf32.h:139
Elf32_Ehdr::e_phnum
Elf32_Half e_phnum
Definition: elf32.h:70


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:14