/*1* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 20092* The President and Fellows of Harvard College.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. Neither the name of the University nor the names of its contributors13* may be used to endorse or promote products derived from this software14* without specific prior written permission.15*16* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef _ELF_H_30#define _ELF_H_313233/*34* Simplified ELF definitions for OS/161 and System/161.35*36* Restrictions:37* 32-bit only38* No support for .o files or linker structures39* Does not define all the random symbols a standard elf header would.40*/4142/* Get MD bits */43#include <machine/elf.h>444546/*47* ELF file header. This appears at the very beginning of an ELF file.48*/49#define ELF_NIDENT 1650typedef struct {51unsigned char e_ident[ELF_NIDENT]; /* magic number et al. */52uint16_t e_type; /* type of file this is */53uint16_t e_machine; /* processor type file is for */54uint32_t e_version; /* ELF version */55uint32_t e_entry; /* address of program entry point */56uint32_t e_phoff; /* location in file of phdrs */57uint32_t e_shoff; /* ignore */58uint32_t e_flags; /* ignore */59uint16_t e_ehsize; /* actual size of file header */60uint16_t e_phentsize; /* actual size of phdr */61uint16_t e_phnum; /* number of phdrs */62uint16_t e_shentsize; /* ignore */63uint16_t e_shnum; /* ignore */64uint16_t e_shstrndx; /* ignore */65} Elf32_Ehdr;6667/* Offsets for the 1-byte fields within e_ident[] */68#define EI_MAG0 0 /* '\177' */69#define EI_MAG1 1 /* 'E' */70#define EI_MAG2 2 /* 'L' */71#define EI_MAG3 3 /* 'F' */72#define EI_CLASS 4 /* File class - always ELFCLASS32 */73#define EI_DATA 5 /* Data encoding - ELFDATA2LSB or ELFDATA2MSB*/74#define EI_VERSION 6 /* ELF version - EV_CURRENT*/75#define EI_OSABI 7 /* OS/syscall ABI identification */76#define EI_ABIVERSION 8 /* syscall ABI version */77#define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/7879/* Values for these fields */8081/* For e_ident[EI_MAG0..3] */82#define ELFMAG0 0x7f83#define ELFMAG1 'E'84#define ELFMAG2 'L'85#define ELFMAG3 'F'8687/* For e_ident[EI_CLASS] */88#define ELFCLASSNONE 0 /* Invalid class */89#define ELFCLASS32 1 /* 32-bit objects */90#define ELFCLASS64 2 /* 64-bit objects */9192/* e_ident[EI_DATA] */93#define ELFDATANONE 0 /* Invalid data encoding */94#define ELFDATA2LSB 1 /* 2's complement values, LSB first */95#define ELFDATA2MSB 2 /* 2's complement values, MSB first */9697/* e_ident[EI_VERSION] */98#define EV_NONE 0 /* Invalid version */99#define EV_CURRENT 1 /* Current version */100101/* e_ident[EI_OSABI] */102#define ELFOSABI_SYSV 0 /* UNIX System V ABI */103#define ELFOSABI_HPUX 1 /* HP-UX operating system */104#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */105106107/*108* Values for e_type109*/110#define ET_NONE 0 /* No file type */111#define ET_REL 1 /* Relocatable file */112#define ET_EXEC 2 /* Executable file */113#define ET_DYN 3 /* Shared object file */114#define ET_CORE 4 /* Core file */115#define ET_NUM 5116117/*118* Values for e_machine119*/120#define EM_NONE 0 /* No machine */121#define EM_M32 1 /* AT&T WE 32100 */122#define EM_SPARC 2 /* SPARC */123#define EM_386 3 /* Intel 80386 */124#define EM_68K 4 /* Motorola 68000 */125#define EM_88K 5 /* Motorola 88000 */126#define EM_486 6 /* Intel 80486 */127#define EM_860 7 /* Intel 80860 */128#define EM_MIPS 8 /* MIPS I Architecture */129#define EM_S370 9 /* Amdahl UTS on System/370 */130#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */131#define EM_RS6000 11 /* IBM RS/6000 XXX reserved */132#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */133#define EM_NCUBE 16 /* NCube XXX reserved */134#define EM_VPP500 17 /* Fujitsu VPP500 */135#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */136#define EM_960 19 /* Intel 80960 */137#define EM_PPC 20 /* PowerPC */138#define EM_V800 36 /* NEC V800 */139#define EM_FR20 37 /* Fujitsu FR20 */140#define EM_RH32 38 /* TRW RH-32 */141#define EM_RCE 39 /* Motorola RCE */142#define EM_ARM 40 /* Advanced RISC Machines ARM */143#define EM_ALPHA 41 /* DIGITAL Alpha */144#define EM_SH 42 /* Hitachi Super-H */145#define EM_SPARCV9 43 /* SPARC Version 9 */146#define EM_TRICORE 44 /* Siemens Tricore */147#define EM_ARC 45 /* Argonaut RISC Core */148#define EM_H8_300 46 /* Hitachi H8/300 */149#define EM_H8_300H 47 /* Hitachi H8/300H */150#define EM_H8S 48 /* Hitachi H8S */151#define EM_H8_500 49 /* Hitachi H8/500 */152#define EM_IA_64 50 /* Intel Merced Processor */153#define EM_MIPS_X 51 /* Stanford MIPS-X */154#define EM_COLDFIRE 52 /* Motorola Coldfire */155#define EM_68HC12 53 /* Motorola MC68HC12 */156#define EM_VAX 75 /* DIGITAL VAX */157#define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */158#define EM_NUM 36903159160161/*162* "Program Header" - runtime segment header.163* There are Ehdr.e_phnum of these located at one position within the file.164*165* Note: if p_memsz > p_filesz, the leftover space should be zero-filled.166*/167typedef struct {168uint32_t p_type; /* Type of segment */169uint32_t p_offset; /* Location of data within file */170uint32_t p_vaddr; /* Virtual address */171uint32_t p_paddr; /* Ignore */172uint32_t p_filesz; /* Size of data within file */173uint32_t p_memsz; /* Size of data to be loaded into memory*/174uint32_t p_flags; /* Flags */175uint32_t p_align; /* Required alignment - can ignore */176} Elf32_Phdr;177178/* values for p_type */179#define PT_NULL 0 /* Program header table entry unused */180#define PT_LOAD 1 /* Loadable program segment */181#define PT_DYNAMIC 2 /* Dynamic linking information */182#define PT_INTERP 3 /* Program interpreter */183#define PT_NOTE 4 /* Auxiliary information */184#define PT_SHLIB 5 /* Reserved, unspecified semantics */185#define PT_PHDR 6 /* Entry for header table itself */186#define PT_NUM 7187#define PT_MIPS_REGINFO 0x70000000188189/* values for p_flags */190#define PF_R 0x4 /* Segment is readable */191#define PF_W 0x2 /* Segment is writable */192#define PF_X 0x1 /* Segment is executable */193194195typedef Elf32_Ehdr Elf_Ehdr;196typedef Elf32_Phdr Elf_Phdr;197198199#endif /* _ELF_H_ */200201202