170566Sobrien/*- 270566Sobrien * Copyright (c) 2001 David E. O'Brien 370566Sobrien * Copyright (c) 1996-1997 John D. Polstra. 470566Sobrien * All rights reserved. 570566Sobrien * 670566Sobrien * Redistribution and use in source and binary forms, with or without 770566Sobrien * modification, are permitted provided that the following conditions 870566Sobrien * are met: 970566Sobrien * 1. Redistributions of source code must retain the above copyright 1070566Sobrien * notice, this list of conditions and the following disclaimer. 1170566Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1270566Sobrien * notice, this list of conditions and the following disclaimer in the 1370566Sobrien * documentation and/or other materials provided with the distribution. 1470566Sobrien * 1570566Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1670566Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1770566Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1870566Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1970566Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2070566Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2170566Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2270566Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2370566Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2470566Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2570566Sobrien * SUCH DAMAGE. 2670566Sobrien * 2770566Sobrien * $FreeBSD$ 2870566Sobrien */ 2970566Sobrien 3070566Sobrien#ifndef _MACHINE_ELF_H_ 3170566Sobrien#define _MACHINE_ELF_H_ 1 3270566Sobrien 3370566Sobrien/* 3470566Sobrien * EABI ELF definitions for the PowerPC architecture. 3570566Sobrien * See "PowerPC Embedded Application Binary Interface, 32-Bit Impliementation" 3670566Sobrien * [ppc-eabi-1995-01.pdf] for details. 3770566Sobrien */ 3870566Sobrien 39209945Snwhitehorn#ifndef __ELF_WORD_SIZE 40209945Snwhitehorn#ifdef __powerpc64__ 41209945Snwhitehorn#define __ELF_WORD_SIZE 64 /* Used by <sys/elf_generic.h> */ 42209945Snwhitehorn#else 43209945Snwhitehorn#define __ELF_WORD_SIZE 32 /* Used by <sys/elf_generic.h> */ 44209945Snwhitehorn#endif 45209945Snwhitehorn#endif 46209945Snwhitehorn 4770566Sobrien#include <sys/elf32.h> /* Definitions common to all 32 bit architectures. */ 48209945Snwhitehorn#include <sys/elf64.h> /* Definitions common to all 64 bit architectures. */ 4970566Sobrien#include <sys/elf_generic.h> 5070566Sobrien 51209945Snwhitehorn#if __ELF_WORD_SIZE == 64 52209945Snwhitehorn#define ELF_ARCH EM_PPC64 53209945Snwhitehorn#define ELF_MACHINE_OK(x) ((x) == EM_PPC64) 54209945Snwhitehorn#else 5570566Sobrien#define ELF_ARCH EM_PPC 56209945Snwhitehorn#define ELF_ARCH32 EM_PPC 5770566Sobrien#define ELF_MACHINE_OK(x) ((x) == EM_PPC) 58209945Snwhitehorn#endif 5970566Sobrien 6070566Sobrien/* 6170566Sobrien * Auxiliary vector entries for passing information to the interpreter. 6270566Sobrien * 6370566Sobrien * The PowerPC supplement to the SVR4 ABI specification names this "auxv_t", 6470566Sobrien * but POSIX lays claim to all symbols ending with "_t". 6570566Sobrien */ 6670566Sobrien 6770566Sobrientypedef struct { /* Auxiliary vector entry on initial stack */ 6870566Sobrien int a_type; /* Entry type. */ 6970566Sobrien union { 7070566Sobrien long a_val; /* Integer value. */ 7170566Sobrien void *a_ptr; /* Address. */ 7270566Sobrien void (*a_fcn)(void); /* Function pointer (not used). */ 7370566Sobrien } a_un; 7470566Sobrien} Elf32_Auxinfo; 7570566Sobrien 76209945Snwhitehorntypedef struct { /* Auxiliary vector entry on initial stack */ 77209945Snwhitehorn long a_type; /* Entry type. */ 78209945Snwhitehorn union { 79209945Snwhitehorn long a_val; /* Integer value. */ 80209945Snwhitehorn void *a_ptr; /* Address. */ 81209945Snwhitehorn void (*a_fcn)(void); /* Function pointer (not used). */ 82209945Snwhitehorn } a_un; 83209945Snwhitehorn} Elf64_Auxinfo; 84209945Snwhitehorn 8570566Sobrien__ElfType(Auxinfo); 8670566Sobrien 8770566Sobrien/* Values for a_type. */ 8870566Sobrien#define AT_NULL 0 /* Terminates the vector. */ 8970566Sobrien#define AT_IGNORE 1 /* Ignored entry. */ 9070566Sobrien#define AT_EXECFD 2 /* File descriptor of program to load. */ 9170566Sobrien#define AT_PHDR 3 /* Program header of program already loaded. */ 9270566Sobrien#define AT_PHENT 4 /* Size of each program header entry. */ 9370566Sobrien#define AT_PHNUM 5 /* Number of program header entries. */ 9470566Sobrien#define AT_PAGESZ 6 /* Page size in bytes. */ 9570566Sobrien#define AT_BASE 7 /* Interpreter's base address. */ 9670566Sobrien#define AT_FLAGS 8 /* Flags (unused for PowerPC). */ 9770566Sobrien#define AT_ENTRY 9 /* Where interpreter should transfer control. */ 9870566Sobrien#define AT_DCACHEBSIZE 10 /* Data cache block size for the processor. */ 9970566Sobrien#define AT_ICACHEBSIZE 11 /* Instruction cache block size for the uP. */ 10070566Sobrien#define AT_UCACHEBSIZE 12 /* Cache block size, or `0' if cache not unified. */ 101189926Skib#define AT_EXECPATH 13 /* Path to the executable. */ 102211412Skib#define AT_CANARY 14 /* Canary for SSP */ 103211412Skib#define AT_CANARYLEN 15 /* Length of the canary. */ 104211412Skib#define AT_OSRELDATE 16 /* OSRELDATE. */ 105211412Skib#define AT_NCPUS 17 /* Number of CPUs. */ 106211412Skib#define AT_PAGESIZES 18 /* Pagesizes. */ 107211412Skib#define AT_PAGESIZESLEN 19 /* Number of pagesizes. */ 108217097Skib#define AT_STACKPROT 21 /* Initial stack protection. */ 109237753Skib#define AT_TIMEKEEP 22 /* Pointer to timehands. */ 11070566Sobrien 111237753Skib#define AT_COUNT 23 /* Count of defined aux entry types. */ 11270566Sobrien 11370566Sobrien/* 11470566Sobrien * Relocation types. 11570566Sobrien */ 11670566Sobrien 11770566Sobrien#define R_PPC_COUNT 37 /* Count of defined relocation types. */ 11870566Sobrien 11970566Sobrien /* Count of defined relocation types. */ 12070566Sobrien#define R_PPC_EMB_COUNT (R_PPC_EMB_RELSDA - R_PPC_EMB_NADDR32 + 1) 12170566Sobrien 12270566Sobrien/* Define "machine" characteristics */ 123209945Snwhitehorn#if __ELF_WORD_SIZE == 64 124209945Snwhitehorn#define ELF_TARG_CLASS ELFCLASS64 125209945Snwhitehorn#define ELF_TARG_DATA ELFDATA2MSB 126209945Snwhitehorn#define ELF_TARG_MACH EM_PPC64 127209945Snwhitehorn#define ELF_TARG_VER 1 128209945Snwhitehorn#else 12970566Sobrien#define ELF_TARG_CLASS ELFCLASS32 13070566Sobrien#define ELF_TARG_DATA ELFDATA2MSB 13170566Sobrien#define ELF_TARG_MACH EM_PPC 13270566Sobrien#define ELF_TARG_VER 1 133209945Snwhitehorn#endif 13470566Sobrien 135197933Skib#define ET_DYN_LOAD_ADDR 0x01010000 136197933Skib 13770566Sobrien#endif /* !_MACHINE_ELF_H_ */ 138