1 /*- 2 * Copyright (c) 2001 David E. O'Brien 3 * Copyright (c) 1996-1997 John D. Polstra. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 * $FreeBSD$ 28 */ 29 30 #ifndef _MACHINE_ELF_H_ 31 #define _MACHINE_ELF_H_ 1 32 33 /* 34 * EABI ELF definitions for the PowerPC architecture. 35 * See "PowerPC Embedded Application Binary Interface, 32-Bit Impliementation" 36 * [ppc-eabi-1995-01.pdf] for details. 37 */ 38 39 #include <sys/elf32.h> /* Definitions common to all 32 bit architectures. */ 40 41 #define __ELF_WORD_SIZE 32 /* Used by <sys/elf_generic.h> */ 42 #include <sys/elf_generic.h> 43 44 #define ELF_ARCH EM_PPC 45 46 #define ELF_MACHINE_OK(x) ((x) == EM_PPC) 47 48 /* 49 * Auxiliary vector entries for passing information to the interpreter. 50 * 51 * The PowerPC supplement to the SVR4 ABI specification names this "auxv_t", 52 * but POSIX lays claim to all symbols ending with "_t". 53 */ 54 55 typedef struct { /* Auxiliary vector entry on initial stack */ 56 int a_type; /* Entry type. */ 57 union { 58 long a_val; /* Integer value. */ 59 void *a_ptr; /* Address. */ 60 void (*a_fcn)(void); /* Function pointer (not used). */ 61 } a_un; 62 } Elf32_Auxinfo; 63 64 __ElfType(Auxinfo); 65 66 /* Values for a_type. */ 67 #define AT_NULL 0 /* Terminates the vector. */ 68 #define AT_IGNORE 1 /* Ignored entry. */ 69 #define AT_EXECFD 2 /* File descriptor of program to load. */ 70 #define AT_PHDR 3 /* Program header of program already loaded. */ 71 #define AT_PHENT 4 /* Size of each program header entry. */ 72 #define AT_PHNUM 5 /* Number of program header entries. */ 73 #define AT_PAGESZ 6 /* Page size in bytes. */ 74 #define AT_BASE 7 /* Interpreter's base address. */ 75 #define AT_FLAGS 8 /* Flags (unused for PowerPC). */ 76 #define AT_ENTRY 9 /* Where interpreter should transfer control. */ 77 #define AT_DCACHEBSIZE 10 /* Data cache block size for the processor. */ 78 #define AT_ICACHEBSIZE 11 /* Instruction cache block size for the uP. */ 79 #define AT_UCACHEBSIZE 12 /* Cache block size, or `0' if cache not unified. */ 80 81 #define AT_COUNT 13 /* Count of defined aux entry types. */ 82 83 /* Used in John Polstra's testbed stuff. */ 84 #define AT_DEBUG 14 /* Debugging level. */ 85 86 /* 87 * Relocation types. 88 */ 89 90 #define R_PPC_NONE 0 /* No relocation. */ 91 #define R_PPC_ADDR32 1 92 #define R_PPC_ADDR24 2 93 #define R_PPC_ADDR16 3 94 #define R_PPC_ADDR16_LO 4 95 #define R_PPC_ADDR16_HI 5 96 #define R_PPC_ADDR16_HA 6 97 #define R_PPC_ADDR14 7 98 #define R_PPC_ADDR14_BRTAKEN 8 99 #define R_PPC_ADDR14_BRNTAKEN 9 100 #define R_PPC_REL24 10 101 #define R_PPC_REL14 11 102 #define R_PPC_REL14_BRTAKEN 12 103 #define R_PPC_REL14_BRNTAKEN 13 104 #define R_PPC_GOT16 14 105 #define R_PPC_GOT16_LO 15 106 #define R_PPC_GOT16_HI 16 107 #define R_PPC_GOT16_HA 17 108 #define R_PPC_PLTREL24 18 109 #define R_PPC_COPY 19 110 #define R_PPC_GLOB_DAT 20 111 #define R_PPC_JMP_SLOT 21 112 #define R_PPC_RELATIVE 22 113 #define R_PPC_LOCAL24PC 23 114 #define R_PPC_UADDR32 24 115 #define R_PPC_UADDR16 25 116 #define R_PPC_REL32 26 117 #define R_PPC_PLT32 27 118 #define R_PPC_PLTREL32 28 119 #define R_PPC_PLT16_LO 29 120 #define R_PPC_PLT16_HI 30 121 #define R_PPC_PLT16_HA 31 122 #define R_PPC_SDAREL16 32 123 #define R_PPC_SECTOFF 33 124 #define R_PPC_SECTOFF_LO 34 125 #define R_PPC_SECTOFF_HI 35 126 #define R_PPC_SECTOFF_HA 36 127 128 #define R_PPC_COUNT 37 /* Count of defined relocation types. */ 129 130 /* 131 * The remaining relocs are from the Embedded ELF ABI, and are not in the 132 * SVR4 ELF ABI. 133 */ 134 135 #define R_PPC_EMB_NADDR32 101 136 #define R_PPC_EMB_NADDR16 102 137 #define R_PPC_EMB_NADDR16_LO 103 138 #define R_PPC_EMB_NADDR16_HI 104 139 #define R_PPC_EMB_NADDR16_HA 105 140 #define R_PPC_EMB_SDAI16 106 141 #define R_PPC_EMB_SDA2I16 107 142 #define R_PPC_EMB_SDA2REL 108 143 #define R_PPC_EMB_SDA21 109 144 #define R_PPC_EMB_MRKREF 110 145 #define R_PPC_EMB_RELSEC16 111 146 #define R_PPC_EMB_RELST_LO 112 147 #define R_PPC_EMB_RELST_HI 113 148 #define R_PPC_EMB_RELST_HA 114 149 #define R_PPC_EMB_BIT_FLD 115 150 #define R_PPC_EMB_RELSDA 116 151 152 /* Count of defined relocation types. */ 153 #define R_PPC_EMB_COUNT (R_PPC_EMB_RELSDA - R_PPC_EMB_NADDR32 + 1) 154 155 /* Define "machine" characteristics */ 156 #define ELF_TARG_CLASS ELFCLASS32 157 #define ELF_TARG_DATA ELFDATA2MSB 158 #define ELF_TARG_MACH EM_PPC 159 #define ELF_TARG_VER 1 160 161 #ifdef _KERNEL 162 163 /* 164 * On the PowerPC we load the dynamic linker where a userland call 165 * to mmap(0, ...) would put it. The rationale behind this 166 * calculation is that it leaves room for the heap to grow to 167 * its maximum allowed size. 168 */ 169 #define ELF_RTLD_ADDR(vmspace) \ 170 (round_page((vm_offset_t)(vmspace)->vm_daddr + maxdsiz)) 171 172 #endif /* _KERNEL */ 173 #endif /* !_MACHINE_ELF_H_ */ 174