4 /* =================================================================
8 * =================================================================
9 * ####ECOSGPLCOPYRIGHTBEGIN####
10 * -------------------------------------------
11 * This file is part of eCos, the Embedded Configurable Operating
13 * Copyright (C) 2005 eCosCentric Ltd.
15 * eCos is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 or (at your option)
20 * eCos is distributed in the hope that it will be useful, but
21 * WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with eCos; if not, write to the Free Software Foundation,
27 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
29 * As a special exception, if other files instantiate templates or
30 * use macros or inline functions from this file, or you compile this
31 * file and link it with other works to produce a work based on this
32 * file, this file does not by itself cause the resulting work to be
33 * covered by the GNU General Public License. However the source code
34 * for this file must still be made available in accordance with
35 * section (3) of the GNU General Public License.
37 * This exception does not invalidate any other reasons why a work
38 * based on this file might be covered by the GNU General Public
41 * -------------------------------------------
42 * ####ECOSGPLCOPYRIGHTEND####
43 * =================================================================
44 * #####DESCRIPTIONBEGIN####
46 * Author(s): atonizzo@lycos.com
51 * ####DESCRIPTIONEND####
53 * =================================================================
56 typedef cyg_uint32 Elf32_Addr;
57 typedef cyg_uint16 Elf32_Half;
58 typedef cyg_uint32 Elf32_Off;
59 typedef cyg_int32 Elf32_Sword;
60 typedef cyg_uint32 Elf32_Word;
65 unsigned char e_ident[EI_NIDENT];
74 Elf32_Half e_phentsize;
76 Elf32_Half e_shentsize;
78 Elf32_Half e_shstrndx;
81 // The ELFCLASS* macros are the defined values of e_ident[EI_CLASS].
82 #define ELFCLASSNONE 0 // Invalid class.
83 #define ELFCLASS32 1 // 32-bit objects.
84 #define ELFCLASS64 2 // 64-bit objects.
86 // The ELFDATA* macros are the allowed values of e_ident[EI_DATA].
87 #define ELFDATA2LSB 1 // Little Endian
88 #define ELFDATA2MSB 2 // Big Endian.
90 // The ET_* macros define the values of the e_type field of the ElfXX_Ehdr
92 #define ET_NONE 0 // No file type.
93 #define ET_REL 1 // Relocatable file.
94 #define ET_EXEC 2 // Executable file.
95 #define ET_DYN 3 // Shared object file.
96 #define ET_CORE 4 // Core file.
97 #define ET_LOPROC 0xff00 // Processor-specific.
99 // The ELFMAG* macros are the values of e_ident[EI_MAG0-4]
100 #define ELFMAG0 0x7f // magic number, byte 0
101 #define ELFMAG1 'E' // magic number, byte 1
102 #define ELFMAG2 'L' // magic number, byte 2
103 #define ELFMAG3 'F' // magic number, byte 3
104 #define ELFMAG "\177ELF" // magic string
105 #define SELFMAG 4 // magic string length
118 Elf32_Word sh_name; // section name.
119 Elf32_Word sh_type; // SHT_...
120 Elf32_Word sh_flags; // SHF_...
121 Elf32_Addr sh_addr; // virtual address
122 Elf32_Off sh_offset; // file offset
123 Elf32_Word sh_size; // section size
124 Elf32_Word sh_link; // misc info
125 Elf32_Word sh_info; // misc info
126 Elf32_Word sh_addralign; // memory alignment
127 Elf32_Word sh_entsize; // entry size if table.
130 // Symbols table entry.
133 Elf32_Word st_name; // Symbol name (string tbl index).
134 Elf32_Addr st_value; // Symbol value.
135 Elf32_Word st_size; // Symbol size.
136 unsigned char st_info; // Symbol type and binding.
137 unsigned char st_other; // Symbol visibility.
138 Elf32_Half st_shndx; // Section index.
151 Elf32_Sword r_addend;
156 #define SHT_PROGBITS 1
161 #define SHT_DYNAMIC 6
166 #define SHT_DYNSYM 11
169 #define SHN_LORESERVE 0xff00
170 #define SHN_LOPROC 0xff00
171 #define SHN_HIPROC 0xff1f
172 #define SHN_ABS 0xfff1
173 #define SHN_COMMON 0xfff2
174 #define SHN_HIRESERVE 0xffff
179 #define STT_SECTION 3
181 #define STT_LOPROC 13
182 #define STT_HIPROC 15
187 #define STB_LOPROC 13
188 #define STB_HIPROC 15
190 // The ELF_STRING_xxx macros are names of common sections
191 #define ELF_STRING_bss ".bss"
192 #define ELF_STRING_hbss ".hbss"
193 #define ELF_STRING_sbss ".sbss"
194 #define ELF_STRING_tbss ".tbss"
195 #define ELF_STRING_data ".data"
196 #define ELF_STRING_hdata ".hdata"
197 #define ELF_STRING_sdata ".sdata"
198 #define ELF_STRING_sdata2 ".sdata2"
199 #define ELF_STRING_fini ".fini"
200 #define ELF_STRING_init ".init"
201 #define ELF_STRING_interp ".interp"
202 #define ELF_STRING_rodata ".rodata"
203 #define ELF_STRING_text ".text"
204 #define ELF_STRING_comment ".comment"
205 #define ELF_STRING_dynamic ".dynamic"
206 #define ELF_STRING_dynstr ".dynstr"
207 #define ELF_STRING_dynsym ".dynsym"
208 #define ELF_STRING_dlt ".dlt"
209 #define ELF_STRING_note ".note"
210 #define ELF_STRING_opd ".opd"
211 #define ELF_STRING_plt ".plt"
212 #define ELF_STRING_bss_rela ".rela.bss"
213 #define ELF_STRING_hbss_rela ".rela.hbss"
214 #define ELF_STRING_data_rela ".rela.data"
215 #define ELF_STRING_dlt_rela ".rela.dlt"
216 #define ELF_STRING_plt_rela ".rela.plt"
217 #define ELF_STRING_sdata_rela ".rela.sdata"
218 #define ELF_STRING_strtab ".strtab"
219 #define ELF_STRING_symtab ".symtab"
220 #define ELF_STRING_hash ".hash"
221 #define ELF_STRING_shstrtab ".shstrtab"
222 #define ELF_STRING_shsymtab ".shsymtab"
223 #define ELF_STRING_rela ".rela"
224 #define ELF_STRING_rel ".rel"
226 #define ELF32_R_SYM(i) ((i)>>8)
227 #define ELF32_R_TYPE(i) ((unsigned char)(i))
229 #define ELF32_ST_BIND(i) ((i)>>4)
230 #define ELF32_ST_TYPE(i) ((i)&0x0F)