win-pvdrivers

annotate common/include/public/elfstructs.h @ 62:edd4a2ad5b44

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