Mercurial > ecos
annotate packages/services/objloader/current/include/elf.h @ 2890:f8dd12428f1d
* cdl/objloader.cdl, src/objelf.c, src/relocate_ppc.c,
src/relocate_arm.c: Eliminate dependency on CYGPKG_IO_FILEIO when
the filesystem loader is not required.
* src/relocate_arm.c : Added relocation software for the ARM .
* src/relocate_i386.c : Added a structure containing the relocation names
for every architecture. Only used (and compiled in) for pretty printing.
* src/relocate_ppc.c :
* include/relocate_arm.h : New header file for src/relocate_arm.c
* cdl/objloader.cdl: Added the option to relocate for the ARM.
* src/objloader.c :
* src/objelf.c : Erased some redundant debug printout and improved the
readability of the rest.
* src/loader_memory.c : Added the code to allow the objloader package
to load libraries from ROM memory, instead from a file system. The various
sections of the library are the copied from ROM to RAM and relocated.
* include/loader_memory.h : New header file for src/loader_memory.c
* src/objloader.c : Added a line to include the loader_memory header
file and code to flush the cache when calling cyg_ldr_find_symbol().
* cdl/objloader.cdl: Added one check boxe for each of the supported ways
of loading libraries (two for now) so that the user can compile out the
loading methods not used.
| author | jld |
|---|---|
| date | Fri, 03 Jul 2009 14:49:44 +0000 |
| parents | 74dbf4c3f2e1 |
| children |
| rev | line source |
|---|---|
| 2011 | 1 #ifndef __ELF_H__ |
| 2 #define __ELF_H__ | |
| 3 | |
| 4 /* ================================================================= | |
| 5 * | |
| 2243 | 6 * elf.h |
| 2011 | 7 * |
| 8 * ================================================================= | |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
9 * ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
10 * ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
11 * This file is part of eCos, the Embedded Configurable Operating System. |
|
2890
f8dd12428f1d
* cdl/objloader.cdl, src/objelf.c, src/relocate_ppc.c,
jld
parents:
2729
diff
changeset
|
12 * Copyright (C) 2005, 2008 Free Software Foundation, Inc. |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
13 * |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
14 * eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
15 * the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
16 * Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
17 * version. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
18 * |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
19 * eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
20 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
21 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
22 * for more details. |
| 2011 | 23 * |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
24 * You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
25 * along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 2011 | 27 * |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
28 * As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
29 * macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
30 * and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
31 * this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
32 * the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
33 * must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
34 * General Public License v2. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
35 * |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
36 * This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
37 * on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
38 * ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2243
diff
changeset
|
39 * ####ECOSGPLCOPYRIGHTEND#### |
| 2011 | 40 * ================================================================= |
| 41 * #####DESCRIPTIONBEGIN#### | |
| 42 * | |
| 2243 | 43 * Author(s): Anthony Tonizzo (atonizzo@gmail.com) |
| 2011 | 44 * Date: 2005-05-13 |
| 45 * Purpose: | |
| 46 * Description: | |
| 47 * | |
| 48 * ####DESCRIPTIONEND#### | |
| 49 * | |
| 50 * ================================================================= | |
| 51 */ | |
| 52 | |
| 53 typedef cyg_uint32 Elf32_Addr; | |
| 54 typedef cyg_uint16 Elf32_Half; | |
| 55 typedef cyg_uint32 Elf32_Off; | |
| 56 typedef cyg_int32 Elf32_Sword; | |
| 57 typedef cyg_uint32 Elf32_Word; | |
| 58 | |
| 59 #define EI_NIDENT 16 | |
| 60 typedef struct | |
| 61 { | |
| 62 unsigned char e_ident[EI_NIDENT]; | |
| 63 Elf32_Half e_type; | |
| 64 Elf32_Half e_machine; | |
| 65 Elf32_Word e_version; | |
| 66 Elf32_Addr e_entry; | |
| 67 Elf32_Off e_phoff; | |
| 68 Elf32_Off e_shoff; | |
| 69 Elf32_Word e_flags; | |
| 70 Elf32_Half e_ehsize; | |
| 71 Elf32_Half e_phentsize; | |
| 72 Elf32_Half e_phnum; | |
| 73 Elf32_Half e_shentsize; | |
| 74 Elf32_Half e_shnum; | |
| 75 Elf32_Half e_shstrndx; | |
| 76 } Elf32_Ehdr; | |
| 77 | |
| 78 // The ELFCLASS* macros are the defined values of e_ident[EI_CLASS]. | |
| 79 #define ELFCLASSNONE 0 // Invalid class. | |
| 80 #define ELFCLASS32 1 // 32-bit objects. | |
| 81 #define ELFCLASS64 2 // 64-bit objects. | |
| 82 | |
| 83 // The ELFDATA* macros are the allowed values of e_ident[EI_DATA]. | |
| 84 #define ELFDATA2LSB 1 // Little Endian | |
| 85 #define ELFDATA2MSB 2 // Big Endian. | |
| 86 | |
| 87 // The ET_* macros define the values of the e_type field of the ElfXX_Ehdr | |
| 88 // structure. | |
| 89 #define ET_NONE 0 // No file type. | |
| 90 #define ET_REL 1 // Relocatable file. | |
| 91 #define ET_EXEC 2 // Executable file. | |
| 92 #define ET_DYN 3 // Shared object file. | |
| 93 #define ET_CORE 4 // Core file. | |
| 94 #define ET_LOPROC 0xff00 // Processor-specific. | |
| 95 | |
| 96 // The ELFMAG* macros are the values of e_ident[EI_MAG0-4] | |
| 97 #define ELFMAG0 0x7f // magic number, byte 0 | |
| 98 #define ELFMAG1 'E' // magic number, byte 1 | |
| 99 #define ELFMAG2 'L' // magic number, byte 2 | |
| 100 #define ELFMAG3 'F' // magic number, byte 3 | |
| 101 #define ELFMAG "\177ELF" // magic string | |
| 102 #define SELFMAG 4 // magic string length | |
| 103 | |
| 104 #define EI_MAG0 0 | |
| 105 #define EI_MAG1 1 | |
| 106 #define EI_MAG2 2 | |
| 107 #define EI_MAG3 3 | |
| 108 #define EI_CLASS 4 | |
| 109 #define EI_DATA 5 | |
| 110 #define EI_VERSION 6 | |
| 111 #define EI_PAD 7 | |
| 112 | |
| 113 typedef struct | |
| 114 { | |
| 115 Elf32_Word sh_name; // section name. | |
| 116 Elf32_Word sh_type; // SHT_... | |
| 117 Elf32_Word sh_flags; // SHF_... | |
| 118 Elf32_Addr sh_addr; // virtual address | |
| 119 Elf32_Off sh_offset; // file offset | |
| 120 Elf32_Word sh_size; // section size | |
| 121 Elf32_Word sh_link; // misc info | |
| 122 Elf32_Word sh_info; // misc info | |
| 123 Elf32_Word sh_addralign; // memory alignment | |
| 124 Elf32_Word sh_entsize; // entry size if table. | |
| 125 } Elf32_Shdr; | |
| 126 | |
| 127 // Symbols table entry. | |
| 128 typedef struct | |
| 129 { | |
| 130 Elf32_Word st_name; // Symbol name (string tbl index). | |
| 131 Elf32_Addr st_value; // Symbol value. | |
| 132 Elf32_Word st_size; // Symbol size. | |
| 133 unsigned char st_info; // Symbol type and binding. | |
| 134 unsigned char st_other; // Symbol visibility. | |
| 135 Elf32_Half st_shndx; // Section index. | |
| 136 } Elf32_Sym; | |
| 137 | |
| 138 typedef struct | |
| 139 { | |
| 140 Elf32_Addr r_offset; | |
| 141 Elf32_Word r_info; | |
| 142 } Elf32_Rel; | |
| 143 | |
| 144 typedef struct | |
| 145 { | |
| 146 Elf32_Addr r_offset; | |
| 147 Elf32_Word r_info; | |
| 148 Elf32_Sword r_addend; | |
| 149 } Elf32_Rela; | |
| 150 | |
| 151 | |
| 152 #define SHT_NULL 0 | |
| 153 #define SHT_PROGBITS 1 | |
| 154 #define SHT_SYMTAB 2 | |
| 155 #define SHT_STRTAB 3 | |
| 156 #define SHT_RELA 4 | |
| 157 #define SHT_HASH 5 | |
| 158 #define SHT_DYNAMIC 6 | |
| 159 #define SHT_NOTE 7 | |
| 160 #define SHT_NOBITS 8 | |
| 161 #define SHT_REL 9 | |
| 162 #define SHT_SHLIB 10 | |
| 163 #define SHT_DYNSYM 11 | |
| 164 | |
| 165 #define SHN_UNDEF 0 | |
| 166 #define SHN_LORESERVE 0xff00 | |
| 167 #define SHN_LOPROC 0xff00 | |
| 168 #define SHN_HIPROC 0xff1f | |
| 169 #define SHN_ABS 0xfff1 | |
| 170 #define SHN_COMMON 0xfff2 | |
| 171 #define SHN_HIRESERVE 0xffff | |
| 172 | |
| 173 #define STT_NOTYPE 0 | |
| 174 #define STT_OBJECT 1 | |
| 175 #define STT_FUNC 2 | |
| 176 #define STT_SECTION 3 | |
| 177 #define STT_FILE 4 | |
| 178 #define STT_LOPROC 13 | |
| 179 #define STT_HIPROC 15 | |
| 180 | |
| 181 #define STB_LOCAL 0 | |
| 182 #define STB_GLOBAL 1 | |
| 183 #define STB_WEAK 2 | |
| 184 #define STB_LOPROC 13 | |
| 185 #define STB_HIPROC 15 | |
| 186 | |
| 187 // The ELF_STRING_xxx macros are names of common sections | |
| 188 #define ELF_STRING_bss ".bss" | |
| 189 #define ELF_STRING_hbss ".hbss" | |
| 190 #define ELF_STRING_sbss ".sbss" | |
| 191 #define ELF_STRING_tbss ".tbss" | |
| 192 #define ELF_STRING_data ".data" | |
| 193 #define ELF_STRING_hdata ".hdata" | |
| 194 #define ELF_STRING_sdata ".sdata" | |
| 195 #define ELF_STRING_sdata2 ".sdata2" | |
| 196 #define ELF_STRING_fini ".fini" | |
| 197 #define ELF_STRING_init ".init" | |
| 198 #define ELF_STRING_interp ".interp" | |
| 199 #define ELF_STRING_rodata ".rodata" | |
| 200 #define ELF_STRING_text ".text" | |
| 201 #define ELF_STRING_comment ".comment" | |
| 202 #define ELF_STRING_dynamic ".dynamic" | |
| 203 #define ELF_STRING_dynstr ".dynstr" | |
| 204 #define ELF_STRING_dynsym ".dynsym" | |
| 205 #define ELF_STRING_dlt ".dlt" | |
| 206 #define ELF_STRING_note ".note" | |
| 207 #define ELF_STRING_opd ".opd" | |
| 208 #define ELF_STRING_plt ".plt" | |
| 209 #define ELF_STRING_bss_rela ".rela.bss" | |
| 210 #define ELF_STRING_hbss_rela ".rela.hbss" | |
| 211 #define ELF_STRING_data_rela ".rela.data" | |
| 212 #define ELF_STRING_dlt_rela ".rela.dlt" | |
| 213 #define ELF_STRING_plt_rela ".rela.plt" | |
| 214 #define ELF_STRING_sdata_rela ".rela.sdata" | |
| 215 #define ELF_STRING_strtab ".strtab" | |
| 216 #define ELF_STRING_symtab ".symtab" | |
| 217 #define ELF_STRING_hash ".hash" | |
| 218 #define ELF_STRING_shstrtab ".shstrtab" | |
| 219 #define ELF_STRING_shsymtab ".shsymtab" | |
| 220 #define ELF_STRING_rela ".rela" | |
| 221 #define ELF_STRING_rel ".rel" | |
| 222 | |
| 223 #define ELF32_R_SYM(i) ((i)>>8) | |
| 224 #define ELF32_R_TYPE(i) ((unsigned char)(i)) | |
| 225 | |
| 226 #define ELF32_ST_BIND(i) ((i)>>4) | |
| 227 #define ELF32_ST_TYPE(i) ((i)&0x0F) | |
| 228 | |
| 229 | |
| 230 #endif | |
| 231 |
