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