1/* $NetBSD: exec_elf.h,v 1.5 2008/04/28 20:23:15 martin Exp $ */ 2 3/*- 4 * Copyright (c) 1994 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Christos Zoulas. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#ifndef _LIBTOS_EXEC_ELF_H_ 33#define _LIBTOS_EXEC_ELF_H_ 34 35/* 36 * The current ELF ABI specification is available at: 37 * http://www.sco.com/developer/gabi/ 38 * 39 * Current header definitions are in: 40 * http://www.sco.com/developer/gabi/latest/ch4.eheader.html 41 */ 42 43/* 44 * Leo 10/10/2001: 45 * This is a copy of the file in sys/sys, but modified a bit to 46 * be used in a TOS/MiNT environment. I will probably trim it down 47 * in the near future. It is only used for loading kernels. 48 */ 49#ifdef TOSTOOLS 50typedef signed char __int8_t; 51typedef unsigned char __uint8_t; 52typedef short int __int16_t; 53typedef unsigned short int __uint16_t; 54typedef int __int32_t; 55typedef unsigned int __uint32_t; 56typedef long long int __int64_t; 57typedef unsigned long long int __uint64_t; 58#else 59#include <machine/int_types.h> 60#endif /* TOSTOOLS */ 61 62typedef __uint8_t Elf_Byte; 63 64typedef __uint32_t Elf32_Addr; 65#define ELF32_FSZ_ADDR 4 66typedef __uint32_t Elf32_Off; 67#define ELF32_FSZ_OFF 4 68typedef __int32_t Elf32_Sword; 69#define ELF32_FSZ_SWORD 4 70typedef __uint32_t Elf32_Word; 71#define ELF32_FSZ_WORD 4 72typedef __uint16_t Elf32_Half; 73#define ELF32_FSZ_HALF 2 74 75typedef __uint64_t Elf64_Addr; 76#define ELF64_FSZ_ADDR 8 77typedef __uint64_t Elf64_Off; 78#define ELF64_FSZ_OFF 8 79typedef __int32_t Elf64_Shalf; 80#define ELF64_FSZ_SHALF 4 81 82#ifdef __alpha__ 83typedef __int64_t Elf64_Sword; 84#define ELF64_FSZ_SWORD 8 85typedef __uint64_t Elf64_Word; 86#define ELF64_FSZ_WORD 8 87#else 88typedef __int32_t Elf64_Sword; 89#define ELF64_FSZ_SWORD 4 90typedef __uint32_t Elf64_Word; 91#define ELF64_FSZ_WORD 4 92#endif /* __alpha__ */ 93 94typedef __int64_t Elf64_Sxword; 95#define ELF64_FSZ_XWORD 8 96typedef __uint64_t Elf64_Xword; 97#define ELF64_FSZ_XWORD 8 98typedef __uint16_t Elf64_Half; 99#define ELF64_FSZ_HALF 2 100 101/* 102 * ELF Header 103 */ 104#define ELF_NIDENT 16 105 106typedef struct { 107 unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ 108 Elf32_Half e_type; /* file type */ 109 Elf32_Half e_machine; /* machine type */ 110 Elf32_Word e_version; /* version number */ 111 Elf32_Addr e_entry; /* entry point */ 112 Elf32_Off e_phoff; /* Program hdr offset */ 113 Elf32_Off e_shoff; /* Section hdr offset */ 114 Elf32_Word e_flags; /* Processor flags */ 115 Elf32_Half e_ehsize; /* sizeof ehdr */ 116 Elf32_Half e_phentsize; /* Program header entry size */ 117 Elf32_Half e_phnum; /* Number of program headers */ 118 Elf32_Half e_shentsize; /* Section header entry size */ 119 Elf32_Half e_shnum; /* Number of section headers */ 120 Elf32_Half e_shstrndx; /* String table index */ 121} Elf32_Ehdr; 122 123/* e_ident offsets */ 124#define EI_MAG0 0 /* '\177' */ 125#define EI_MAG1 1 /* 'E' */ 126#define EI_MAG2 2 /* 'L' */ 127#define EI_MAG3 3 /* 'F' */ 128#define EI_CLASS 4 /* File class */ 129#define EI_DATA 5 /* Data encoding */ 130#define EI_VERSION 6 /* File version */ 131#define EI_OSABI 7 /* Operating system/ABI identification */ 132#define EI_ABIVERSION 8 /* ABI version */ 133#define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/ 134 135/* e_ident[ELFMAG0,ELFMAG3] */ 136#define ELFMAG0 0x7f 137#define ELFMAG1 'E' 138#define ELFMAG2 'L' 139#define ELFMAG3 'F' 140#define ELFMAG "\177ELF" 141#define SELFMAG 4 142 143/* e_ident[EI_CLASS] */ 144#define ELFCLASSNONE 0 /* Invalid class */ 145#define ELFCLASS32 1 /* 32-bit objects */ 146#define ELFCLASS64 2 /* 64-bit objects */ 147#define ELFCLASSNUM 3 148 149/* e_ident[EI_DATA] */ 150#define ELFDATANONE 0 /* Invalid data encoding */ 151#define ELFDATA2LSB 1 /* 2's complement values, LSB first */ 152#define ELFDATA2MSB 2 /* 2's complement values, MSB first */ 153 154/* e_ident[EI_VERSION] */ 155#define EV_NONE 0 /* Invalid version */ 156#define EV_CURRENT 1 /* Current version */ 157#define EV_NUM 2 158 159/* e_ident[EI_OSABI] */ 160#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ 161#define ELFOSABI_HPUX 1 /* HP-UX operating system */ 162#define ELFOSABI_NETBSD 2 /* NetBSD */ 163#define ELFOSABI_LINUX 3 /* GNU/Linux */ 164#define ELFOSABI_HURD 4 /* GNU/Hurd */ 165#define ELFOSABI_86OPEN 5 /* 86Open */ 166#define ELFOSABI_SOLARIS 6 /* Solaris */ 167#define ELFOSABI_MONTEREY 7 /* Monterey */ 168#define ELFOSABI_IRIX 8 /* IRIX */ 169#define ELFOSABI_FREEBSD 9 /* FreeBSD */ 170#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ 171#define ELFOSABI_MODESTO 11 /* Novell Modesto */ 172#define ELFOSABI_OPENBSD 12 /* OpenBSD */ 173/* Unofficial OSABIs follow */ 174#define ELFOSABI_ARM 97 /* ARM */ 175#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ 176 177/* e_type */ 178#define ET_NONE 0 /* No file type */ 179#define ET_REL 1 /* Relocatable file */ 180#define ET_EXEC 2 /* Executable file */ 181#define ET_DYN 3 /* Shared object file */ 182#define ET_CORE 4 /* Core file */ 183#define ET_NUM 5 184 185#define ET_LOOS 0xfe00 /* Operating system specific range */ 186#define ET_HIOS 0xfeff 187#define ET_LOPROC 0xff00 /* Processor-specific range */ 188#define ET_HIPROC 0xffff 189 190/* e_machine */ 191#define EM_NONE 0 /* No machine */ 192#define EM_M32 1 /* AT&T WE 32100 */ 193#define EM_SPARC 2 /* SPARC */ 194#define EM_386 3 /* Intel 80386 */ 195#define EM_68K 4 /* Motorola 68000 */ 196#define EM_88K 5 /* Motorola 88000 */ 197#define EM_486 6 /* Intel 80486 */ 198#define EM_860 7 /* Intel 80860 */ 199#define EM_MIPS 8 /* MIPS I Architecture */ 200#define EM_S370 9 /* Amdahl UTS on System/370 */ 201#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */ 202 /* 11-14 - Reserved */ 203#define EM_RS6000 11 /* IBM RS/6000 XXX reserved */ 204#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */ 205#define EM_NCUBE 16 /* NCube XXX reserved */ 206#define EM_VPP500 17 /* Fujitsu VPP500 */ 207#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ 208#define EM_960 19 /* Intel 80960 */ 209#define EM_PPC 20 /* PowerPC */ 210#define EM_PPC64 21 /* 64-bit PowerPC */ 211 /* 22-35 - Reserved */ 212#define EM_V800 36 /* NEC V800 */ 213#define EM_FR20 37 /* Fujitsu FR20 */ 214#define EM_RH32 38 /* TRW RH-32 */ 215#define EM_RCE 39 /* Motorola RCE */ 216#define EM_ARM 40 /* Advanced RISC Machines ARM */ 217#define EM_ALPHA 41 /* DIGITAL Alpha */ 218#define EM_SH 42 /* Hitachi Super-H */ 219#define EM_SPARCV9 43 /* SPARC Version 9 */ 220#define EM_TRICORE 44 /* Siemens Tricore */ 221#define EM_ARC 45 /* Argonaut RISC Core */ 222#define EM_H8_300 46 /* Hitachi H8/300 */ 223#define EM_H8_300H 47 /* Hitachi H8/300H */ 224#define EM_H8S 48 /* Hitachi H8S */ 225#define EM_H8_500 49 /* Hitachi H8/500 */ 226#define EM_IA_64 50 /* Intel Merced Processor */ 227#define EM_MIPS_X 51 /* Stanford MIPS-X */ 228#define EM_COLDFIRE 52 /* Motorola Coldfire */ 229#define EM_68HC12 53 /* Motorola MC68HC12 */ 230#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */ 231#define EM_PCP 55 /* Siemens PCP */ 232#define EM_NCPU 56 /* Sony nCPU embedded RISC processor */ 233#define EM_NDR1 57 /* Denso NDR1 microprocessor */ 234#define EM_STARCORE 58 /* Motorola Star*Core processor */ 235#define EM_ME16 59 /* Toyota ME16 processor */ 236#define EM_ST100 60 /* STMicroelectronics ST100 processor */ 237#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ embedded family processor */ 238#define EM_X86_64 62 /* AMD x86-64 architecture */ 239#define EM_PDSP 63 /* Sony DSP Processor */ 240 /* 64-65 - Reserved */ 241#define EM_FX66 66 /* Siemens FX66 microcontroller */ 242#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 bit microcontroller */ 243#define EM_ST7 68 /* STMicroelectronics ST7 8-bit microcontroller */ 244#define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */ 245#define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */ 246#define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */ 247#define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */ 248#define EM_SVX 73 /* Silicon Graphics SVx */ 249#define EM_ST19 74 /* STMicroelectronics ST19 8-bit CPU */ 250#define EM_VAX 75 /* Digital VAX */ 251#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ 252#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded CPU */ 253#define EM_FIREPATH 78 /* Element 14 64-bit DSP processor */ 254#define EM_ZSP 79 /* LSI Logic's 16-bit DSP processor */ 255#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ 256#define EM_HUANY 81 /* Harvard's machine-independent format */ 257#define EM_PRISM 82 /* SiTera Prism */ 258#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ 259#define EM_FR30 84 /* Fujitsu FR30 */ 260#define EM_D10V 85 /* Mitsubishi D10V */ 261#define EM_D30V 86 /* Mitsubishi D30V */ 262#define EM_V850 87 /* NEC v850 */ 263#define EM_M32R 88 /* Mitsubishi M32R */ 264#define EM_MN10300 89 /* Matsushita MN10300 */ 265#define EM_MN10200 90 /* Matsushita MN10200 */ 266#define EM_PJ 91 /* picoJava */ 267#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ 268#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ 269#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ 270/* Unofficial machine types follow */ 271#define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */ 272#define EM_NUM 36903 273 274/* 275 * Program Header 276 */ 277typedef struct { 278 Elf32_Word p_type; /* entry type */ 279 Elf32_Off p_offset; /* offset */ 280 Elf32_Addr p_vaddr; /* virtual address */ 281 Elf32_Addr p_paddr; /* physical address */ 282 Elf32_Word p_filesz; /* file size */ 283 Elf32_Word p_memsz; /* memory size */ 284 Elf32_Word p_flags; /* flags */ 285 Elf32_Word p_align; /* memory & file alignment */ 286} Elf32_Phdr; 287 288/* p_type */ 289#define PT_NULL 0 /* Program header table entry unused */ 290#define PT_LOAD 1 /* Loadable program segment */ 291#define PT_DYNAMIC 2 /* Dynamic linking information */ 292#define PT_INTERP 3 /* Program interpreter */ 293#define PT_NOTE 4 /* Auxiliary information */ 294#define PT_SHLIB 5 /* Reserved, unspecified semantics */ 295#define PT_PHDR 6 /* Entry for header table itself */ 296#define PT_NUM 7 297 298/* p_flags */ 299#define PF_R 0x4 /* Segment is readable */ 300#define PF_W 0x2 /* Segment is writable */ 301#define PF_X 0x1 /* Segment is executable */ 302 303#define PF_MASKOS 0x0ff00000 /* Opersting system specific values */ 304#define PF_MASKPROC 0xf0000000 /* Processor-specific values */ 305 306#define PT_LOPROC 0x70000000 /* Processor-specific range */ 307#define PT_HIPROC 0x7fffffff 308 309#define PT_MIPS_REGINFO 0x70000000 310 311/* 312 * Section Headers 313 */ 314typedef struct { 315 Elf32_Word sh_name; /* section name (.shstrtab index) */ 316 Elf32_Word sh_type; /* section type */ 317 Elf32_Word sh_flags; /* section flags */ 318 Elf32_Addr sh_addr; /* virtual address */ 319 Elf32_Off sh_offset; /* file offset */ 320 Elf32_Word sh_size; /* section size */ 321 Elf32_Word sh_link; /* link to another */ 322 Elf32_Word sh_info; /* misc info */ 323 Elf32_Word sh_addralign; /* memory alignment */ 324 Elf32_Word sh_entsize; /* table entry size */ 325} Elf32_Shdr; 326 327/* sh_type */ 328#define SHT_NULL 0 /* Section header table entry unused */ 329#define SHT_PROGBITS 1 /* Program information */ 330#define SHT_SYMTAB 2 /* Symbol table */ 331#define SHT_STRTAB 3 /* String table */ 332#define SHT_RELA 4 /* Relocation information w/ addend */ 333#define SHT_HASH 5 /* Symbol hash table */ 334#define SHT_DYNAMIC 6 /* Dynamic linking information */ 335#define SHT_NOTE 7 /* Auxiliary information */ 336#define SHT_NOBITS 8 /* No space allocated in file image */ 337#define SHT_REL 9 /* Relocation information w/o addend */ 338#define SHT_SHLIB 10 /* Reserved, unspecified semantics */ 339#define SHT_DYNSYM 11 /* Symbol table for dynamic linker */ 340#define SHT_NUM 12 341 342#define SHT_LOOS 0x60000000 /* Operating system specific range */ 343#define SHT_HIOS 0x6fffffff 344#define SHT_LOPROC 0x70000000 /* Processor-specific range */ 345#define SHT_HIPROC 0x7fffffff 346#define SHT_LOUSER 0x80000000 /* Application-specific range */ 347#define SHT_HIUSER 0xffffffff 348 349/* sh_flags */ 350#define SHF_WRITE 0x1 /* Section contains writable data */ 351#define SHF_ALLOC 0x2 /* Section occupies memory */ 352#define SHF_EXECINSTR 0x4 /* Section contains executable insns */ 353 354#define SHF_MASKOS 0x0f000000 /* Operating system specific values */ 355#define SHF_MASKPROC 0xf0000000 /* Processor-specific values */ 356 357/* 358 * Symbol Table 359 */ 360typedef struct { 361 Elf32_Word st_name; /* Symbol name (.symtab index) */ 362 Elf32_Word st_value; /* value of symbol */ 363 Elf32_Word st_size; /* size of symbol */ 364 Elf_Byte st_info; /* type / binding attrs */ 365 Elf_Byte st_other; /* unused */ 366 Elf32_Half st_shndx; /* section index of symbol */ 367} Elf32_Sym; 368 369/* Symbol Table index of the undefined symbol */ 370#define ELF_SYM_UNDEFINED 0 371 372/* st_info: Symbol Bindings */ 373#define STB_LOCAL 0 /* local symbol */ 374#define STB_GLOBAL 1 /* global symbol */ 375#define STB_WEAK 2 /* weakly defined global symbol */ 376#define STB_NUM 3 377 378#define STB_LOOS 10 /* Operating system specific range */ 379#define STB_HIOS 12 380#define STB_LOPROC 13 /* Processor-specific range */ 381#define STB_HIPROC 15 382 383/* st_info: Symbol Types */ 384#define STT_NOTYPE 0 /* Type not specified */ 385#define STT_OBJECT 1 /* Associated with a data object */ 386#define STT_FUNC 2 /* Associated with a function */ 387#define STT_SECTION 3 /* Associated with a section */ 388#define STT_FILE 4 /* Associated with a file name */ 389#define STT_NUM 5 390 391#define STT_LOOS 10 /* Operating system specific range */ 392#define STT_HIOS 12 393#define STT_LOPROC 13 /* Processor-specific range */ 394#define STT_HIPROC 15 395 396/* st_info utility macros */ 397#define ELF32_ST_BIND(info) ((Elf32_Word)(info) >> 4) 398#define ELF32_ST_TYPE(info) ((Elf32_Word)(info) & 0xf) 399#define ELF32_ST_INFO(bind,type) ((Elf_Byte)(((bind) << 4) | ((type) & 0xf))) 400 401/* 402 * Special section indexes 403 */ 404#define SHN_UNDEF 0 /* Undefined section */ 405 406#define SHN_LORESERVE 0xff00 /* Reserved range */ 407#define SHN_ABS 0xfff1 /* Absolute symbols */ 408#define SHN_COMMON 0xfff2 /* Common symbols */ 409#define SHN_HIRESERVE 0xffff 410 411#define SHN_LOPROC 0xff00 /* Processor-specific range */ 412#define SHN_HIPROC 0xff1f 413#define SHN_LOOS 0xff20 /* Operating system specific range */ 414#define SHN_HIOS 0xff3f 415 416#define SHN_MIPS_ACOMMON 0xff00 417#define SHN_MIPS_TEXT 0xff01 418#define SHN_MIPS_DATA 0xff02 419#define SHN_MIPS_SCOMMON 0xff03 420 421/* 422 * Relocation Entries 423 */ 424typedef struct { 425 Elf32_Word r_offset; /* where to do it */ 426 Elf32_Word r_info; /* index & type of relocation */ 427} Elf32_Rel; 428 429typedef struct { 430 Elf32_Word r_offset; /* where to do it */ 431 Elf32_Word r_info; /* index & type of relocation */ 432 Elf32_Sword r_addend; /* adjustment value */ 433} Elf32_Rela; 434 435/* r_info utility macros */ 436#define ELF32_R_SYM(info) ((info) >> 8) 437#define ELF32_R_TYPE(info) ((info) & 0xff) 438#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) 439 440/* 441 * Dynamic Section structure array 442 */ 443typedef struct { 444 Elf32_Word d_tag; /* entry tag value */ 445 union { 446 Elf32_Addr d_ptr; 447 Elf32_Word d_val; 448 } d_un; 449} Elf32_Dyn; 450 451/* d_tag */ 452#define DT_NULL 0 /* Marks end of dynamic array */ 453#define DT_NEEDED 1 /* Name of needed library (DT_STRTAB offset) */ 454#define DT_PLTRELSZ 2 /* Size, in bytes, of relocations in PLT */ 455#define DT_PLTGOT 3 /* Address of PLT and/or GOT */ 456#define DT_HASH 4 /* Address of symbol hash table */ 457#define DT_STRTAB 5 /* Address of string table */ 458#define DT_SYMTAB 6 /* Address of symbol table */ 459#define DT_RELA 7 /* Address of Rela relocation table */ 460#define DT_RELASZ 8 /* Size, in bytes, of DT_RELA table */ 461#define DT_RELAENT 9 /* Size, in bytes, of one DT_RELA entry */ 462#define DT_STRSZ 10 /* Size, in bytes, of DT_STRTAB table */ 463#define DT_SYMENT 11 /* Size, in bytes, of one DT_SYMTAB entry */ 464#define DT_INIT 12 /* Address of initialization function */ 465#define DT_FINI 13 /* Address of termination function */ 466#define DT_SONAME 14 /* Shared object name (DT_STRTAB offset) */ 467#define DT_RPATH 15 /* Library search path (DT_STRTAB offset) */ 468#define DT_SYMBOLIC 16 /* Start symbol search within local object */ 469#define DT_REL 17 /* Address of Rel relocation table */ 470#define DT_RELSZ 18 /* Size, in bytes, of DT_REL table */ 471#define DT_RELENT 19 /* Size, in bytes, of one DT_REL entry */ 472#define DT_PLTREL 20 /* Type of PLT relocation entries */ 473#define DT_DEBUG 21 /* Used for debugging; unspecified */ 474#define DT_TEXTREL 22 /* Relocations might modify non-writable seg */ 475#define DT_JMPREL 23 /* Address of relocations associated with PLT */ 476#define DT_BIND_NOW 24 /* Process all relocations at load-time */ 477#define DT_INIT_ARRAY 25 /* Address of initialization function array */ 478#define DT_FINI_ARRAY 26 /* Size, in bytes, of DT_INIT_ARRAY array */ 479#define DT_INIT_ARRAYSZ 27 /* Address of termination function array */ 480#define DT_FINI_ARRAYSZ 28 /* Size, in bytes, of DT_FINI_ARRAY array*/ 481#define DT_NUM 29 482 483#define DT_LOOS 0x60000000 /* Operating system specific range */ 484#define DT_HIOS 0x6fffffff 485#define DT_LOPROC 0x70000000 /* Processor-specific range */ 486#define DT_HIPROC 0x7fffffff 487 488/* 489 * Auxiliary Vectors 490 */ 491typedef struct { 492 Elf32_Word a_type; /* 32-bit id */ 493 Elf32_Word a_v; /* 32-bit id */ 494} Aux32Info; 495 496/* a_type */ 497#define AT_NULL 0 /* Marks end of array */ 498#define AT_IGNORE 1 /* No meaning, a_un is undefined */ 499#define AT_EXECFD 2 /* Open file descriptor of object file */ 500#define AT_PHDR 3 /* &phdr[0] */ 501#define AT_PHENT 4 /* sizeof(phdr[0]) */ 502#define AT_PHNUM 5 /* # phdr entries */ 503#define AT_PAGESZ 6 /* PAGESIZE */ 504#define AT_BASE 7 /* Interpreter base addr */ 505#define AT_FLAGS 8 /* Processor flags */ 506#define AT_ENTRY 9 /* Entry address of executable */ 507#define AT_DCACHEBSIZE 10 /* Data cache block size */ 508#define AT_ICACHEBSIZE 11 /* Instruction cache block size */ 509#define AT_UCACHEBSIZE 12 /* Unified cache block size */ 510 511 /* Vendor specific */ 512#define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */ 513 514#define AT_SUN_UID 2000 /* euid */ 515#define AT_SUN_RUID 2001 /* ruid */ 516#define AT_SUN_GID 2002 /* egid */ 517#define AT_SUN_RGID 2003 /* rgid */ 518 519 /* Solaris kernel specific */ 520#define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */ 521#define AT_SUN_LDSHDR 2005 /* dynamic linker's section header */ 522#define AT_SUN_LDNAME 2006 /* dynamic linker's name */ 523#define AT_SUN_LPGSIZE 2007 /* large pagesize */ 524 525 /* Other information */ 526#define AT_SUN_PLATFORM 2008 /* sysinfo(SI_PLATFORM) */ 527#define AT_SUN_HWCAP 2009 /* process hardware capabilities */ 528#define AT_SUN_IFLUSH 2010 /* do we need to flush the instruction cache? */ 529#define AT_SUN_CPU 2011 /* CPU name */ 530 /* ibcs2 emulation band aid */ 531#define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */ 532#define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */ 533 /* Executable's fully resolved name */ 534#define AT_SUN_EXECNAME 2014 535 536/* 537 * Note Headers 538 */ 539typedef struct { 540 Elf32_Word n_namesz; 541 Elf32_Word n_descsz; 542 Elf32_Word n_type; 543} Elf32_Nhdr; 544 545#define ELF_NOTE_TYPE_ABI_TAG 1 546 547/* GNU-specific note name and description sizes */ 548#define ELF_NOTE_ABI_NAMESZ 4 549#define ELF_NOTE_ABI_DESCSZ 16 550/* GNU-specific note name */ 551#define ELF_NOTE_ABI_NAME "GNU\0" 552 553/* GNU-specific OS/version value stuff */ 554#define ELF_NOTE_ABI_OS_LINUX 0 555#define ELF_NOTE_ABI_OS_HURD 1 556#define ELF_NOTE_ABI_OS_SOLARIS 2 557 558/* NetBSD-specific note type: Emulation name. desc is emul name string. */ 559#define ELF_NOTE_TYPE_NETBSD_TAG 1 560 561/* NetBSD-specific note name and description sizes */ 562#define ELF_NOTE_NETBSD_NAMESZ 7 563#define ELF_NOTE_NETBSD_DESCSZ 4 564/* NetBSD-specific note name */ 565#define ELF_NOTE_NETBSD_NAME "NetBSD\0\0" 566 567#if defined(ELFSIZE) 568#define CONCAT(x,y) __CONCAT(x,y) 569#define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x))) 570#define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y)))) 571#define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE)) 572#define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x))) 573#endif 574 575/* 576 * Leo: This is actually from machine/elf_machdep.h 577 */ 578#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB 579#define ELF32_MACHDEP_ID_CASES \ 580 case EM_68K: \ 581 break; 582 583#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ 584#define ELF64_MACHDEP_ID_CASES \ 585 /* no 64-bit ELF machine types supported */ 586 587#define ARCH_ELFSIZE 32 /* MD native binary size */ 588 589/* m68k relocation types */ 590#define R_68K_NONE 0 591#define R_68K_32 1 592#define R_68K_16 2 593#define R_68K_8 3 594#define R_68K_PC32 4 595#define R_68K_PC16 5 596#define R_68K_PC8 6 597#define R_68K_GOT32 7 598#define R_68K_GOT16 8 599#define R_68K_GOT8 9 600#define R_68K_GOT32O 10 601#define R_68K_GOT16O 11 602#define R_68K_GOT8O 12 603#define R_68K_PLT32 13 604#define R_68K_PLT16 14 605#define R_68K_PLT8 15 606#define R_68K_PLT32O 16 607#define R_68K_PLT16O 17 608#define R_68K_PLT8O 18 609#define R_68K_COPY 19 610#define R_68K_GLOB_DAT 20 611#define R_68K_JMP_SLOT 21 612#define R_68K_RELATIVE 22 613 614#define R_TYPE(name) __CONCAT(R_68K_,name) 615 616#define Elf_Ehdr Elf32_Ehdr 617#define Elf_Phdr Elf32_Phdr 618#define Elf_Shdr Elf32_Shdr 619#define Elf_Sym Elf32_Sym 620#define Elf_Rel Elf32_Rel 621#define Elf_Rela Elf32_Rela 622#define Elf_Dyn Elf32_Dyn 623#define Elf_Word Elf32_Word 624#define Elf_Sword Elf32_Sword 625#define Elf_Addr Elf32_Addr 626#define Elf_Off Elf32_Off 627#define Elf_Nhdr Elf32_Nhdr 628 629#define ELF_R_SYM ELF32_R_SYM 630#define ELF_R_TYPE ELF32_R_TYPE 631#define ELFCLASS ELFCLASS32 632 633#define ELF_ST_BIND ELF32_ST_BIND 634#define ELF_ST_TYPE ELF32_ST_TYPE 635#define ELF_ST_INFO ELF32_ST_INFO 636 637#define AuxInfo Aux32Info 638 639#ifdef _KERNEL 640 641#define ELF_AUX_ENTRIES 8 /* Size of aux array passed to loader */ 642#define ELF32_NO_ADDR (~(Elf32_Addr)0) /* Indicates addr. not yet filled in */ 643#define ELF64_NO_ADDR (~(Elf64_Addr)0) /* Indicates addr. not yet filled in */ 644 645#if defined(ELFSIZE) && (ELFSIZE == 64) 646#define ELF_NO_ADDR ELF64_NO_ADDR 647#elif defined(ELFSIZE) && (ELFSIZE == 32) 648#define ELF_NO_ADDR ELF32_NO_ADDR 649#endif 650 651#if defined(ELFSIZE) 652struct elf_args { 653 Elf_Addr arg_entry; /* program entry point */ 654 Elf_Addr arg_interp; /* Interpreter load address */ 655 Elf_Addr arg_phaddr; /* program header address */ 656 Elf_Addr arg_phentsize; /* Size of program header */ 657 Elf_Addr arg_phnum; /* Number of program headers */ 658}; 659#endif 660 661#endif /* _KERNEL */ 662 663#endif /* !_LIBTOS_EXEC_ELF_H_ */ 664