ia64/xen-unstable

annotate xen/include/xen/elfstructs.h @ 19012:7df072566b8c

Move libelf headers out of xen public header dir.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 08 13:15:49 2009 +0000 (2009-01-08)
parents
children
rev   line source
keir@19012 1 #ifndef __XEN_ELFSTRUCTS_H__
keir@19012 2 #define __XEN_ELFSTRUCTS_H__
keir@19012 3 /*
keir@19012 4 * Copyright (c) 1995, 1996 Erik Theisen. All rights reserved.
keir@19012 5 *
keir@19012 6 * Redistribution and use in source and binary forms, with or without
keir@19012 7 * modification, are permitted provided that the following conditions
keir@19012 8 * are met:
keir@19012 9 * 1. Redistributions of source code must retain the above copyright
keir@19012 10 * notice, this list of conditions and the following disclaimer.
keir@19012 11 * 2. Redistributions in binary form must reproduce the above copyright
keir@19012 12 * notice, this list of conditions and the following disclaimer in the
keir@19012 13 * documentation and/or other materials provided with the distribution.
keir@19012 14 * 3. The name of the author may not be used to endorse or promote products
keir@19012 15 * derived from this software without specific prior written permission
keir@19012 16 *
keir@19012 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
keir@19012 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
keir@19012 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
keir@19012 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
keir@19012 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
keir@19012 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
keir@19012 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
keir@19012 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
keir@19012 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
keir@19012 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keir@19012 27 */
keir@19012 28
keir@19012 29 typedef uint8_t Elf_Byte;
keir@19012 30
keir@19012 31 typedef uint32_t Elf32_Addr; /* Unsigned program address */
keir@19012 32 typedef uint32_t Elf32_Off; /* Unsigned file offset */
keir@19012 33 typedef int32_t Elf32_Sword; /* Signed large integer */
keir@19012 34 typedef uint32_t Elf32_Word; /* Unsigned large integer */
keir@19012 35 typedef uint16_t Elf32_Half; /* Unsigned medium integer */
keir@19012 36
keir@19012 37 typedef uint64_t Elf64_Addr;
keir@19012 38 typedef uint64_t Elf64_Off;
keir@19012 39 typedef int32_t Elf64_Shalf;
keir@19012 40
keir@19012 41 typedef int32_t Elf64_Sword;
keir@19012 42 typedef uint32_t Elf64_Word;
keir@19012 43
keir@19012 44 typedef int64_t Elf64_Sxword;
keir@19012 45 typedef uint64_t Elf64_Xword;
keir@19012 46
keir@19012 47 typedef uint32_t Elf64_Half;
keir@19012 48 typedef uint16_t Elf64_Quarter;
keir@19012 49
keir@19012 50 /*
keir@19012 51 * e_ident[] identification indexes
keir@19012 52 * See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html
keir@19012 53 */
keir@19012 54 #define EI_MAG0 0 /* file ID */
keir@19012 55 #define EI_MAG1 1 /* file ID */
keir@19012 56 #define EI_MAG2 2 /* file ID */
keir@19012 57 #define EI_MAG3 3 /* file ID */
keir@19012 58 #define EI_CLASS 4 /* file class */
keir@19012 59 #define EI_DATA 5 /* data encoding */
keir@19012 60 #define EI_VERSION 6 /* ELF header version */
keir@19012 61 #define EI_OSABI 7 /* OS/ABI ID */
keir@19012 62 #define EI_ABIVERSION 8 /* ABI version */
keir@19012 63 #define EI_PAD 9 /* start of pad bytes */
keir@19012 64 #define EI_NIDENT 16 /* Size of e_ident[] */
keir@19012 65
keir@19012 66 /* e_ident[] magic number */
keir@19012 67 #define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
keir@19012 68 #define ELFMAG1 'E' /* e_ident[EI_MAG1] */
keir@19012 69 #define ELFMAG2 'L' /* e_ident[EI_MAG2] */
keir@19012 70 #define ELFMAG3 'F' /* e_ident[EI_MAG3] */
keir@19012 71 #define ELFMAG "\177ELF" /* magic */
keir@19012 72 #define SELFMAG 4 /* size of magic */
keir@19012 73
keir@19012 74 /* e_ident[] file class */
keir@19012 75 #define ELFCLASSNONE 0 /* invalid */
keir@19012 76 #define ELFCLASS32 1 /* 32-bit objs */
keir@19012 77 #define ELFCLASS64 2 /* 64-bit objs */
keir@19012 78 #define ELFCLASSNUM 3 /* number of classes */
keir@19012 79
keir@19012 80 /* e_ident[] data encoding */
keir@19012 81 #define ELFDATANONE 0 /* invalid */
keir@19012 82 #define ELFDATA2LSB 1 /* Little-Endian */
keir@19012 83 #define ELFDATA2MSB 2 /* Big-Endian */
keir@19012 84 #define ELFDATANUM 3 /* number of data encode defines */
keir@19012 85
keir@19012 86 /* e_ident[] Operating System/ABI */
keir@19012 87 #define ELFOSABI_SYSV 0 /* UNIX System V ABI */
keir@19012 88 #define ELFOSABI_HPUX 1 /* HP-UX operating system */
keir@19012 89 #define ELFOSABI_NETBSD 2 /* NetBSD */
keir@19012 90 #define ELFOSABI_LINUX 3 /* GNU/Linux */
keir@19012 91 #define ELFOSABI_HURD 4 /* GNU/Hurd */
keir@19012 92 #define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */
keir@19012 93 #define ELFOSABI_SOLARIS 6 /* Solaris */
keir@19012 94 #define ELFOSABI_MONTEREY 7 /* Monterey */
keir@19012 95 #define ELFOSABI_IRIX 8 /* IRIX */
keir@19012 96 #define ELFOSABI_FREEBSD 9 /* FreeBSD */
keir@19012 97 #define ELFOSABI_TRU64 10 /* TRU64 UNIX */
keir@19012 98 #define ELFOSABI_MODESTO 11 /* Novell Modesto */
keir@19012 99 #define ELFOSABI_OPENBSD 12 /* OpenBSD */
keir@19012 100 #define ELFOSABI_ARM 97 /* ARM */
keir@19012 101 #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
keir@19012 102
keir@19012 103 /* e_ident */
keir@19012 104 #define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
keir@19012 105 (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
keir@19012 106 (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
keir@19012 107 (ehdr).e_ident[EI_MAG3] == ELFMAG3)
keir@19012 108
keir@19012 109 /* ELF Header */
keir@19012 110 typedef struct elfhdr {
keir@19012 111 unsigned char e_ident[EI_NIDENT]; /* ELF Identification */
keir@19012 112 Elf32_Half e_type; /* object file type */
keir@19012 113 Elf32_Half e_machine; /* machine */
keir@19012 114 Elf32_Word e_version; /* object file version */
keir@19012 115 Elf32_Addr e_entry; /* virtual entry point */
keir@19012 116 Elf32_Off e_phoff; /* program header table offset */
keir@19012 117 Elf32_Off e_shoff; /* section header table offset */
keir@19012 118 Elf32_Word e_flags; /* processor-specific flags */
keir@19012 119 Elf32_Half e_ehsize; /* ELF header size */
keir@19012 120 Elf32_Half e_phentsize; /* program header entry size */
keir@19012 121 Elf32_Half e_phnum; /* number of program header entries */
keir@19012 122 Elf32_Half e_shentsize; /* section header entry size */
keir@19012 123 Elf32_Half e_shnum; /* number of section header entries */
keir@19012 124 Elf32_Half e_shstrndx; /* section header table's "section
keir@19012 125 header string table" entry offset */
keir@19012 126 } Elf32_Ehdr;
keir@19012 127
keir@19012 128 typedef struct {
keir@19012 129 unsigned char e_ident[EI_NIDENT]; /* Id bytes */
keir@19012 130 Elf64_Quarter e_type; /* file type */
keir@19012 131 Elf64_Quarter e_machine; /* machine type */
keir@19012 132 Elf64_Half e_version; /* version number */
keir@19012 133 Elf64_Addr e_entry; /* entry point */
keir@19012 134 Elf64_Off e_phoff; /* Program hdr offset */
keir@19012 135 Elf64_Off e_shoff; /* Section hdr offset */
keir@19012 136 Elf64_Half e_flags; /* Processor flags */
keir@19012 137 Elf64_Quarter e_ehsize; /* sizeof ehdr */
keir@19012 138 Elf64_Quarter e_phentsize; /* Program header entry size */
keir@19012 139 Elf64_Quarter e_phnum; /* Number of program headers */
keir@19012 140 Elf64_Quarter e_shentsize; /* Section header entry size */
keir@19012 141 Elf64_Quarter e_shnum; /* Number of section headers */
keir@19012 142 Elf64_Quarter e_shstrndx; /* String table index */
keir@19012 143 } Elf64_Ehdr;
keir@19012 144
keir@19012 145 /* e_type */
keir@19012 146 #define ET_NONE 0 /* No file type */
keir@19012 147 #define ET_REL 1 /* relocatable file */
keir@19012 148 #define ET_EXEC 2 /* executable file */
keir@19012 149 #define ET_DYN 3 /* shared object file */
keir@19012 150 #define ET_CORE 4 /* core file */
keir@19012 151 #define ET_NUM 5 /* number of types */
keir@19012 152 #define ET_LOPROC 0xff00 /* reserved range for processor */
keir@19012 153 #define ET_HIPROC 0xffff /* specific e_type */
keir@19012 154
keir@19012 155 /* e_machine */
keir@19012 156 #define EM_NONE 0 /* No Machine */
keir@19012 157 #define EM_M32 1 /* AT&T WE 32100 */
keir@19012 158 #define EM_SPARC 2 /* SPARC */
keir@19012 159 #define EM_386 3 /* Intel 80386 */
keir@19012 160 #define EM_68K 4 /* Motorola 68000 */
keir@19012 161 #define EM_88K 5 /* Motorola 88000 */
keir@19012 162 #define EM_486 6 /* Intel 80486 - unused? */
keir@19012 163 #define EM_860 7 /* Intel 80860 */
keir@19012 164 #define EM_MIPS 8 /* MIPS R3000 Big-Endian only */
keir@19012 165 /*
keir@19012 166 * Don't know if EM_MIPS_RS4_BE,
keir@19012 167 * EM_SPARC64, EM_PARISC,
keir@19012 168 * or EM_PPC are ABI compliant
keir@19012 169 */
keir@19012 170 #define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */
keir@19012 171 #define EM_SPARC64 11 /* SPARC v9 64-bit unoffical */
keir@19012 172 #define EM_PARISC 15 /* HPPA */
keir@19012 173 #define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
keir@19012 174 #define EM_PPC 20 /* PowerPC */
keir@19012 175 #define EM_PPC64 21 /* PowerPC 64-bit */
keir@19012 176 #define EM_ARM 40 /* Advanced RISC Machines ARM */
keir@19012 177 #define EM_ALPHA 41 /* DEC ALPHA */
keir@19012 178 #define EM_SPARCV9 43 /* SPARC version 9 */
keir@19012 179 #define EM_ALPHA_EXP 0x9026 /* DEC ALPHA */
keir@19012 180 #define EM_IA_64 50 /* Intel Merced */
keir@19012 181 #define EM_X86_64 62 /* AMD x86-64 architecture */
keir@19012 182 #define EM_VAX 75 /* DEC VAX */
keir@19012 183
keir@19012 184 /* Version */
keir@19012 185 #define EV_NONE 0 /* Invalid */
keir@19012 186 #define EV_CURRENT 1 /* Current */
keir@19012 187 #define EV_NUM 2 /* number of versions */
keir@19012 188
keir@19012 189 /* Section Header */
keir@19012 190 typedef struct {
keir@19012 191 Elf32_Word sh_name; /* name - index into section header
keir@19012 192 string table section */
keir@19012 193 Elf32_Word sh_type; /* type */
keir@19012 194 Elf32_Word sh_flags; /* flags */
keir@19012 195 Elf32_Addr sh_addr; /* address */
keir@19012 196 Elf32_Off sh_offset; /* file offset */
keir@19012 197 Elf32_Word sh_size; /* section size */
keir@19012 198 Elf32_Word sh_link; /* section header table index link */
keir@19012 199 Elf32_Word sh_info; /* extra information */
keir@19012 200 Elf32_Word sh_addralign; /* address alignment */
keir@19012 201 Elf32_Word sh_entsize; /* section entry size */
keir@19012 202 } Elf32_Shdr;
keir@19012 203
keir@19012 204 typedef struct {
keir@19012 205 Elf64_Half sh_name; /* section name */
keir@19012 206 Elf64_Half sh_type; /* section type */
keir@19012 207 Elf64_Xword sh_flags; /* section flags */
keir@19012 208 Elf64_Addr sh_addr; /* virtual address */
keir@19012 209 Elf64_Off sh_offset; /* file offset */
keir@19012 210 Elf64_Xword sh_size; /* section size */
keir@19012 211 Elf64_Half sh_link; /* link to another */
keir@19012 212 Elf64_Half sh_info; /* misc info */
keir@19012 213 Elf64_Xword sh_addralign; /* memory alignment */
keir@19012 214 Elf64_Xword sh_entsize; /* table entry size */
keir@19012 215 } Elf64_Shdr;
keir@19012 216
keir@19012 217 /* Special Section Indexes */
keir@19012 218 #define SHN_UNDEF 0 /* undefined */
keir@19012 219 #define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */
keir@19012 220 #define SHN_LOPROC 0xff00 /* reserved range for processor */
keir@19012 221 #define SHN_HIPROC 0xff1f /* specific section indexes */
keir@19012 222 #define SHN_ABS 0xfff1 /* absolute value */
keir@19012 223 #define SHN_COMMON 0xfff2 /* common symbol */
keir@19012 224 #define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */
keir@19012 225
keir@19012 226 /* sh_type */
keir@19012 227 #define SHT_NULL 0 /* inactive */
keir@19012 228 #define SHT_PROGBITS 1 /* program defined information */
keir@19012 229 #define SHT_SYMTAB 2 /* symbol table section */
keir@19012 230 #define SHT_STRTAB 3 /* string table section */
keir@19012 231 #define SHT_RELA 4 /* relocation section with addends*/
keir@19012 232 #define SHT_HASH 5 /* symbol hash table section */
keir@19012 233 #define SHT_DYNAMIC 6 /* dynamic section */
keir@19012 234 #define SHT_NOTE 7 /* note section */
keir@19012 235 #define SHT_NOBITS 8 /* no space section */
keir@19012 236 #define SHT_REL 9 /* relation section without addends */
keir@19012 237 #define SHT_SHLIB 10 /* reserved - purpose unknown */
keir@19012 238 #define SHT_DYNSYM 11 /* dynamic symbol table section */
keir@19012 239 #define SHT_NUM 12 /* number of section types */
keir@19012 240 #define SHT_LOPROC 0x70000000 /* reserved range for processor */
keir@19012 241 #define SHT_HIPROC 0x7fffffff /* specific section header types */
keir@19012 242 #define SHT_LOUSER 0x80000000 /* reserved range for application */
keir@19012 243 #define SHT_HIUSER 0xffffffff /* specific indexes */
keir@19012 244
keir@19012 245 /* Section names */
keir@19012 246 #define ELF_BSS ".bss" /* uninitialized data */
keir@19012 247 #define ELF_DATA ".data" /* initialized data */
keir@19012 248 #define ELF_DEBUG ".debug" /* debug */
keir@19012 249 #define ELF_DYNAMIC ".dynamic" /* dynamic linking information */
keir@19012 250 #define ELF_DYNSTR ".dynstr" /* dynamic string table */
keir@19012 251 #define ELF_DYNSYM ".dynsym" /* dynamic symbol table */
keir@19012 252 #define ELF_FINI ".fini" /* termination code */
keir@19012 253 #define ELF_GOT ".got" /* global offset table */
keir@19012 254 #define ELF_HASH ".hash" /* symbol hash table */
keir@19012 255 #define ELF_INIT ".init" /* initialization code */
keir@19012 256 #define ELF_REL_DATA ".rel.data" /* relocation data */
keir@19012 257 #define ELF_REL_FINI ".rel.fini" /* relocation termination code */
keir@19012 258 #define ELF_REL_INIT ".rel.init" /* relocation initialization code */
keir@19012 259 #define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */
keir@19012 260 #define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */
keir@19012 261 #define ELF_REL_TEXT ".rel.text" /* relocation code */
keir@19012 262 #define ELF_RODATA ".rodata" /* read-only data */
keir@19012 263 #define ELF_SHSTRTAB ".shstrtab" /* section header string table */
keir@19012 264 #define ELF_STRTAB ".strtab" /* string table */
keir@19012 265 #define ELF_SYMTAB ".symtab" /* symbol table */
keir@19012 266 #define ELF_TEXT ".text" /* code */
keir@19012 267
keir@19012 268
keir@19012 269 /* Section Attribute Flags - sh_flags */
keir@19012 270 #define SHF_WRITE 0x1 /* Writable */
keir@19012 271 #define SHF_ALLOC 0x2 /* occupies memory */
keir@19012 272 #define SHF_EXECINSTR 0x4 /* executable */
keir@19012 273 #define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */
keir@19012 274 /* specific section attributes */
keir@19012 275
keir@19012 276 /* Symbol Table Entry */
keir@19012 277 typedef struct elf32_sym {
keir@19012 278 Elf32_Word st_name; /* name - index into string table */
keir@19012 279 Elf32_Addr st_value; /* symbol value */
keir@19012 280 Elf32_Word st_size; /* symbol size */
keir@19012 281 unsigned char st_info; /* type and binding */
keir@19012 282 unsigned char st_other; /* 0 - no defined meaning */
keir@19012 283 Elf32_Half st_shndx; /* section header index */
keir@19012 284 } Elf32_Sym;
keir@19012 285
keir@19012 286 typedef struct {
keir@19012 287 Elf64_Half st_name; /* Symbol name index in str table */
keir@19012 288 Elf_Byte st_info; /* type / binding attrs */
keir@19012 289 Elf_Byte st_other; /* unused */
keir@19012 290 Elf64_Quarter st_shndx; /* section index of symbol */
keir@19012 291 Elf64_Xword st_value; /* value of symbol */
keir@19012 292 Elf64_Xword st_size; /* size of symbol */
keir@19012 293 } Elf64_Sym;
keir@19012 294
keir@19012 295 /* Symbol table index */
keir@19012 296 #define STN_UNDEF 0 /* undefined */
keir@19012 297
keir@19012 298 /* Extract symbol info - st_info */
keir@19012 299 #define ELF32_ST_BIND(x) ((x) >> 4)
keir@19012 300 #define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
keir@19012 301 #define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
keir@19012 302
keir@19012 303 #define ELF64_ST_BIND(x) ((x) >> 4)
keir@19012 304 #define ELF64_ST_TYPE(x) (((unsigned int) x) & 0xf)
keir@19012 305 #define ELF64_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
keir@19012 306
keir@19012 307 /* Symbol Binding - ELF32_ST_BIND - st_info */
keir@19012 308 #define STB_LOCAL 0 /* Local symbol */
keir@19012 309 #define STB_GLOBAL 1 /* Global symbol */
keir@19012 310 #define STB_WEAK 2 /* like global - lower precedence */
keir@19012 311 #define STB_NUM 3 /* number of symbol bindings */
keir@19012 312 #define STB_LOPROC 13 /* reserved range for processor */
keir@19012 313 #define STB_HIPROC 15 /* specific symbol bindings */
keir@19012 314
keir@19012 315 /* Symbol type - ELF32_ST_TYPE - st_info */
keir@19012 316 #define STT_NOTYPE 0 /* not specified */
keir@19012 317 #define STT_OBJECT 1 /* data object */
keir@19012 318 #define STT_FUNC 2 /* function */
keir@19012 319 #define STT_SECTION 3 /* section */
keir@19012 320 #define STT_FILE 4 /* file */
keir@19012 321 #define STT_NUM 5 /* number of symbol types */
keir@19012 322 #define STT_LOPROC 13 /* reserved range for processor */
keir@19012 323 #define STT_HIPROC 15 /* specific symbol types */
keir@19012 324
keir@19012 325 /* Relocation entry with implicit addend */
keir@19012 326 typedef struct {
keir@19012 327 Elf32_Addr r_offset; /* offset of relocation */
keir@19012 328 Elf32_Word r_info; /* symbol table index and type */
keir@19012 329 } Elf32_Rel;
keir@19012 330
keir@19012 331 /* Relocation entry with explicit addend */
keir@19012 332 typedef struct {
keir@19012 333 Elf32_Addr r_offset; /* offset of relocation */
keir@19012 334 Elf32_Word r_info; /* symbol table index and type */
keir@19012 335 Elf32_Sword r_addend;
keir@19012 336 } Elf32_Rela;
keir@19012 337
keir@19012 338 /* Extract relocation info - r_info */
keir@19012 339 #define ELF32_R_SYM(i) ((i) >> 8)
keir@19012 340 #define ELF32_R_TYPE(i) ((unsigned char) (i))
keir@19012 341 #define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t))
keir@19012 342
keir@19012 343 typedef struct {
keir@19012 344 Elf64_Xword r_offset; /* where to do it */
keir@19012 345 Elf64_Xword r_info; /* index & type of relocation */
keir@19012 346 } Elf64_Rel;
keir@19012 347
keir@19012 348 typedef struct {
keir@19012 349 Elf64_Xword r_offset; /* where to do it */
keir@19012 350 Elf64_Xword r_info; /* index & type of relocation */
keir@19012 351 Elf64_Sxword r_addend; /* adjustment value */
keir@19012 352 } Elf64_Rela;
keir@19012 353
keir@19012 354 #define ELF64_R_SYM(info) ((info) >> 32)
keir@19012 355 #define ELF64_R_TYPE(info) ((info) & 0xFFFFFFFF)
keir@19012 356 #define ELF64_R_INFO(s,t) (((s) << 32) + (u_int32_t)(t))
keir@19012 357
keir@19012 358 /* Program Header */
keir@19012 359 typedef struct {
keir@19012 360 Elf32_Word p_type; /* segment type */
keir@19012 361 Elf32_Off p_offset; /* segment offset */
keir@19012 362 Elf32_Addr p_vaddr; /* virtual address of segment */
keir@19012 363 Elf32_Addr p_paddr; /* physical address - ignored? */
keir@19012 364 Elf32_Word p_filesz; /* number of bytes in file for seg. */
keir@19012 365 Elf32_Word p_memsz; /* number of bytes in mem. for seg. */
keir@19012 366 Elf32_Word p_flags; /* flags */
keir@19012 367 Elf32_Word p_align; /* memory alignment */
keir@19012 368 } Elf32_Phdr;
keir@19012 369
keir@19012 370 typedef struct {
keir@19012 371 Elf64_Half p_type; /* entry type */
keir@19012 372 Elf64_Half p_flags; /* flags */
keir@19012 373 Elf64_Off p_offset; /* offset */
keir@19012 374 Elf64_Addr p_vaddr; /* virtual address */
keir@19012 375 Elf64_Addr p_paddr; /* physical address */
keir@19012 376 Elf64_Xword p_filesz; /* file size */
keir@19012 377 Elf64_Xword p_memsz; /* memory size */
keir@19012 378 Elf64_Xword p_align; /* memory & file alignment */
keir@19012 379 } Elf64_Phdr;
keir@19012 380
keir@19012 381 /* Segment types - p_type */
keir@19012 382 #define PT_NULL 0 /* unused */
keir@19012 383 #define PT_LOAD 1 /* loadable segment */
keir@19012 384 #define PT_DYNAMIC 2 /* dynamic linking section */
keir@19012 385 #define PT_INTERP 3 /* the RTLD */
keir@19012 386 #define PT_NOTE 4 /* auxiliary information */
keir@19012 387 #define PT_SHLIB 5 /* reserved - purpose undefined */
keir@19012 388 #define PT_PHDR 6 /* program header */
keir@19012 389 #define PT_NUM 7 /* Number of segment types */
keir@19012 390 #define PT_LOPROC 0x70000000 /* reserved range for processor */
keir@19012 391 #define PT_HIPROC 0x7fffffff /* specific segment types */
keir@19012 392
keir@19012 393 /* Segment flags - p_flags */
keir@19012 394 #define PF_X 0x1 /* Executable */
keir@19012 395 #define PF_W 0x2 /* Writable */
keir@19012 396 #define PF_R 0x4 /* Readable */
keir@19012 397 #define PF_MASKPROC 0xf0000000 /* reserved bits for processor */
keir@19012 398 /* specific segment flags */
keir@19012 399
keir@19012 400 /* Dynamic structure */
keir@19012 401 typedef struct {
keir@19012 402 Elf32_Sword d_tag; /* controls meaning of d_val */
keir@19012 403 union {
keir@19012 404 Elf32_Word d_val; /* Multiple meanings - see d_tag */
keir@19012 405 Elf32_Addr d_ptr; /* program virtual address */
keir@19012 406 } d_un;
keir@19012 407 } Elf32_Dyn;
keir@19012 408
keir@19012 409 typedef struct {
keir@19012 410 Elf64_Xword d_tag; /* controls meaning of d_val */
keir@19012 411 union {
keir@19012 412 Elf64_Addr d_ptr;
keir@19012 413 Elf64_Xword d_val;
keir@19012 414 } d_un;
keir@19012 415 } Elf64_Dyn;
keir@19012 416
keir@19012 417 /* Dynamic Array Tags - d_tag */
keir@19012 418 #define DT_NULL 0 /* marks end of _DYNAMIC array */
keir@19012 419 #define DT_NEEDED 1 /* string table offset of needed lib */
keir@19012 420 #define DT_PLTRELSZ 2 /* size of relocation entries in PLT */
keir@19012 421 #define DT_PLTGOT 3 /* address PLT/GOT */
keir@19012 422 #define DT_HASH 4 /* address of symbol hash table */
keir@19012 423 #define DT_STRTAB 5 /* address of string table */
keir@19012 424 #define DT_SYMTAB 6 /* address of symbol table */
keir@19012 425 #define DT_RELA 7 /* address of relocation table */
keir@19012 426 #define DT_RELASZ 8 /* size of relocation table */
keir@19012 427 #define DT_RELAENT 9 /* size of relocation entry */
keir@19012 428 #define DT_STRSZ 10 /* size of string table */
keir@19012 429 #define DT_SYMENT 11 /* size of symbol table entry */
keir@19012 430 #define DT_INIT 12 /* address of initialization func. */
keir@19012 431 #define DT_FINI 13 /* address of termination function */
keir@19012 432 #define DT_SONAME 14 /* string table offset of shared obj */
keir@19012 433 #define DT_RPATH 15 /* string table offset of library
keir@19012 434 search path */
keir@19012 435 #define DT_SYMBOLIC 16 /* start sym search in shared obj. */
keir@19012 436 #define DT_REL 17 /* address of rel. tbl. w addends */
keir@19012 437 #define DT_RELSZ 18 /* size of DT_REL relocation table */
keir@19012 438 #define DT_RELENT 19 /* size of DT_REL relocation entry */
keir@19012 439 #define DT_PLTREL 20 /* PLT referenced relocation entry */
keir@19012 440 #define DT_DEBUG 21 /* bugger */
keir@19012 441 #define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */
keir@19012 442 #define DT_JMPREL 23 /* add. of PLT's relocation entries */
keir@19012 443 #define DT_BIND_NOW 24 /* Bind now regardless of env setting */
keir@19012 444 #define DT_NUM 25 /* Number used. */
keir@19012 445 #define DT_LOPROC 0x70000000 /* reserved range for processor */
keir@19012 446 #define DT_HIPROC 0x7fffffff /* specific dynamic array tags */
keir@19012 447
keir@19012 448 /* Standard ELF hashing function */
keir@19012 449 unsigned int elf_hash(const unsigned char *name);
keir@19012 450
keir@19012 451 /*
keir@19012 452 * Note Definitions
keir@19012 453 */
keir@19012 454 typedef struct {
keir@19012 455 Elf32_Word namesz;
keir@19012 456 Elf32_Word descsz;
keir@19012 457 Elf32_Word type;
keir@19012 458 } Elf32_Note;
keir@19012 459
keir@19012 460 typedef struct {
keir@19012 461 Elf64_Half namesz;
keir@19012 462 Elf64_Half descsz;
keir@19012 463 Elf64_Half type;
keir@19012 464 } Elf64_Note;
keir@19012 465
keir@19012 466
keir@19012 467 #if defined(ELFSIZE)
keir@19012 468 #define CONCAT(x,y) __CONCAT(x,y)
keir@19012 469 #define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
keir@19012 470 #define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
keir@19012 471 #define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE))
keir@19012 472 #define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
keir@19012 473 #endif
keir@19012 474
keir@19012 475 #if defined(ELFSIZE) && (ELFSIZE == 32)
keir@19012 476 #define Elf_Ehdr Elf32_Ehdr
keir@19012 477 #define Elf_Phdr Elf32_Phdr
keir@19012 478 #define Elf_Shdr Elf32_Shdr
keir@19012 479 #define Elf_Sym Elf32_Sym
keir@19012 480 #define Elf_Rel Elf32_Rel
keir@19012 481 #define Elf_RelA Elf32_Rela
keir@19012 482 #define Elf_Dyn Elf32_Dyn
keir@19012 483 #define Elf_Word Elf32_Word
keir@19012 484 #define Elf_Sword Elf32_Sword
keir@19012 485 #define Elf_Addr Elf32_Addr
keir@19012 486 #define Elf_Off Elf32_Off
keir@19012 487 #define Elf_Nhdr Elf32_Nhdr
keir@19012 488 #define Elf_Note Elf32_Note
keir@19012 489
keir@19012 490 #define ELF_R_SYM ELF32_R_SYM
keir@19012 491 #define ELF_R_TYPE ELF32_R_TYPE
keir@19012 492 #define ELF_R_INFO ELF32_R_INFO
keir@19012 493 #define ELFCLASS ELFCLASS32
keir@19012 494
keir@19012 495 #define ELF_ST_BIND ELF32_ST_BIND
keir@19012 496 #define ELF_ST_TYPE ELF32_ST_TYPE
keir@19012 497 #define ELF_ST_INFO ELF32_ST_INFO
keir@19012 498
keir@19012 499 #define AuxInfo Aux32Info
keir@19012 500 #elif defined(ELFSIZE) && (ELFSIZE == 64)
keir@19012 501 #define Elf_Ehdr Elf64_Ehdr
keir@19012 502 #define Elf_Phdr Elf64_Phdr
keir@19012 503 #define Elf_Shdr Elf64_Shdr
keir@19012 504 #define Elf_Sym Elf64_Sym
keir@19012 505 #define Elf_Rel Elf64_Rel
keir@19012 506 #define Elf_RelA Elf64_Rela
keir@19012 507 #define Elf_Dyn Elf64_Dyn
keir@19012 508 #define Elf_Word Elf64_Word
keir@19012 509 #define Elf_Sword Elf64_Sword
keir@19012 510 #define Elf_Addr Elf64_Addr
keir@19012 511 #define Elf_Off Elf64_Off
keir@19012 512 #define Elf_Nhdr Elf64_Nhdr
keir@19012 513 #define Elf_Note Elf64_Note
keir@19012 514
keir@19012 515 #define ELF_R_SYM ELF64_R_SYM
keir@19012 516 #define ELF_R_TYPE ELF64_R_TYPE
keir@19012 517 #define ELF_R_INFO ELF64_R_INFO
keir@19012 518 #define ELFCLASS ELFCLASS64
keir@19012 519
keir@19012 520 #define ELF_ST_BIND ELF64_ST_BIND
keir@19012 521 #define ELF_ST_TYPE ELF64_ST_TYPE
keir@19012 522 #define ELF_ST_INFO ELF64_ST_INFO
keir@19012 523
keir@19012 524 #define AuxInfo Aux64Info
keir@19012 525 #endif
keir@19012 526
keir@19012 527 #endif /* __XEN_ELFSTRUCTS_H__ */