Raghu Gandham | 405b802 | 2012-07-25 18:16:42 -0700 | [diff] [blame] | 1 | /* $OpenBSD: exec.h,v 1.1 2004/10/18 19:05:36 grange Exp $ */ |
| 2 | |
| 3 | /* |
| 4 | * Copyright (c) 1996-2004 Per Fogelstrom, Opsycon AB |
| 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 ``AS IS'' AND ANY EXPRESS |
| 16 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 19 | * 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 | */ |
| 28 | |
| 29 | #ifndef _MIPS64_EXEC_H_ |
| 30 | #define _MIPS64_EXEC_H_ |
| 31 | |
| 32 | #define __LDPGSZ 4096 |
| 33 | |
| 34 | /* |
| 35 | * Define what exec "formats" we should handle. |
| 36 | */ |
| 37 | #define NATIVE_EXEC_ELF |
| 38 | #define NATIVE_ELFSIZE 64 |
| 39 | #define EXEC_SCRIPT |
| 40 | |
| 41 | /* |
| 42 | * If included from sys/exec.h define kernels ELF format. |
| 43 | */ |
| 44 | #ifdef __LP64__ |
| 45 | #define ARCH_ELFSIZE 64 |
| 46 | #define DB_ELFSIZE 64 |
| 47 | #define ELF_TARG_CLASS ELFCLASS64 |
| 48 | #else |
| 49 | #define ARCH_ELFSIZE 32 |
| 50 | #define DB_ELFSIZE 32 |
| 51 | #define ELF_TARG_CLASS ELFCLASS32 |
| 52 | #endif |
| 53 | |
| 54 | #if defined(__MIPSEB__) |
| 55 | #define ELF_TARG_DATA ELFDATA2MSB |
| 56 | #else |
| 57 | #define ELF_TARG_DATA ELFDATA2LSB |
| 58 | #endif |
| 59 | #define ELF_TARG_MACH EM_MIPS |
| 60 | |
| 61 | #define _NLIST_DO_ELF |
| 62 | |
| 63 | #if defined(_LP64) |
| 64 | #define _KERN_DO_ELF64 |
| 65 | #if defined(COMPAT_O32) |
| 66 | #define _KERN_DO_ELF |
| 67 | #endif |
| 68 | #else |
| 69 | #define _KERN_DO_ELF |
| 70 | #endif |
| 71 | |
| 72 | /* Information taken from MIPS ABI supplemental */ |
| 73 | |
| 74 | /* Architecture dependent Segment types - p_type */ |
| 75 | #define PT_MIPS_REGINFO 0x70000000 /* Register usage information */ |
| 76 | |
| 77 | /* Architecture dependent d_tag field for Elf32_Dyn. */ |
| 78 | #define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime Linker Interface ID */ |
| 79 | #define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */ |
| 80 | #define DT_MIPS_ICHECKSUM 0x70000003 /* Cksum of ext. str. and com. sizes */ |
| 81 | #define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */ |
| 82 | #define DT_MIPS_FLAGS 0x70000005 /* Flags */ |
| 83 | #define DT_MIPS_BASE_ADDRESS 0x70000006 /* Segment base address */ |
| 84 | #define DT_MIPS_CONFLICT 0x70000008 /* Adr of .conflict section */ |
| 85 | #define DT_MIPS_LIBLIST 0x70000009 /* Address of .liblist section */ |
| 86 | #define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local .GOT entries */ |
| 87 | #define DT_MIPS_CONFLICTNO 0x7000000b /* Number of .conflict entries */ |
| 88 | #define DT_MIPS_LIBLISTNO 0x70000010 /* Number of .liblist entries */ |
| 89 | #define DT_MIPS_SYMTABNO 0x70000011 /* Number of .dynsym entries */ |
| 90 | #define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */ |
| 91 | #define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in .dynsym */ |
| 92 | #define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */ |
| 93 | #define DT_MIPS_RLD_MAP 0x70000016 /* Address of debug map pointer */ |
| 94 | |
| 95 | #define DT_PROCNUM (DT_MIPS_RLD_MAP - DT_LOPROC + 1) |
| 96 | |
| 97 | /* |
| 98 | * Legal values for e_flags field of Elf32_Ehdr. |
| 99 | */ |
| 100 | #define EF_MIPS_NOREORDER 0x00000001 /* .noreorder was used */ |
| 101 | #define EF_MIPS_PIC 0x00000002 /* Contains PIC code */ |
| 102 | #define EF_MIPS_CPIC 0x00000004 /* Uses PIC calling sequence */ |
| 103 | #define EF_MIPS_ABI2 0x00000020 /* -n32 on Irix 6 */ |
| 104 | #define EF_MIPS_32BITMODE 0x00000100 /* 64 bit in 32 bit mode... */ |
| 105 | #define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */ |
| 106 | #define E_MIPS_ARCH_1 0x00000000 |
| 107 | #define E_MIPS_ARCH_2 0x10000000 |
| 108 | #define E_MIPS_ARCH_3 0x20000000 |
| 109 | #define E_MIPS_ARCH_4 0x30000000 |
| 110 | #define EF_MIPS_ABI 0x0000f000 /* ABI level */ |
| 111 | #define E_MIPS_ABI_NONE 0x00000000 /* ABI level not set */ |
| 112 | #define E_MIPS_ABI_O32 0x00001000 |
| 113 | #define E_MIPS_ABI_O64 0x00002000 |
| 114 | #define E_MIPS_ABI_EABI32 0x00004000 |
| 115 | #define E_MIPS_ABI_EABI64 0x00004000 |
| 116 | |
| 117 | /* |
| 118 | * Mips special sections. |
| 119 | */ |
| 120 | #define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */ |
| 121 | #define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */ |
| 122 | #define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */ |
| 123 | |
| 124 | /* |
| 125 | * Legal values for sh_type field of Elf32_Shdr. |
| 126 | */ |
| 127 | #define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */ |
| 128 | #define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */ |
| 129 | #define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */ |
| 130 | #define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */ |
| 131 | #define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information */ |
| 132 | #define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */ |
| 133 | |
| 134 | /* |
| 135 | * Legal values for sh_flags field of Elf32_Shdr. |
| 136 | */ |
| 137 | #define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */ |
| 138 | |
| 139 | #if 0 |
| 140 | /* |
| 141 | * Entries found in sections of type SHT_MIPS_GPTAB. |
| 142 | */ |
| 143 | typedef union { |
| 144 | struct { |
| 145 | Elf32_Word gt_current_g_value; /* -G val used in compilation */ |
| 146 | Elf32_Word gt_unused; /* Not used */ |
| 147 | } gt_header; /* First entry in section */ |
| 148 | struct { |
| 149 | Elf32_Word gt_g_value; /* If this val were used for -G */ |
| 150 | Elf32_Word gt_bytes; /* This many bytes would be used */ |
| 151 | } gt_entry; /* Subsequent entries in section */ |
| 152 | } Elf32_gptab; |
| 153 | |
| 154 | /* |
| 155 | * Entry found in sections of type SHT_MIPS_REGINFO. |
| 156 | */ |
| 157 | typedef struct { |
| 158 | Elf32_Word ri_gprmask; /* General registers used */ |
| 159 | Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */ |
| 160 | Elf32_Sword ri_gp_value; /* $gp register value */ |
| 161 | } Elf32_RegInfo; |
| 162 | #endif |
| 163 | |
| 164 | |
| 165 | /* |
| 166 | * Mips relocations. |
| 167 | */ |
| 168 | |
| 169 | #define R_MIPS_NONE 0 /* No reloc */ |
| 170 | #define R_MIPS_16 1 /* Direct 16 bit */ |
| 171 | #define R_MIPS_32 2 /* Direct 32 bit */ |
| 172 | #define R_MIPS_REL32 3 /* PC relative 32 bit */ |
| 173 | #define R_MIPS_26 4 /* Direct 26 bit shifted */ |
| 174 | #define R_MIPS_HI16 5 /* High 16 bit */ |
| 175 | #define R_MIPS_LO16 6 /* Low 16 bit */ |
| 176 | #define R_MIPS_GPREL16 7 /* GP relative 16 bit */ |
| 177 | #define R_MIPS_LITERAL 8 /* 16 bit literal entry */ |
| 178 | #define R_MIPS_GOT16 9 /* 16 bit GOT entry */ |
| 179 | #define R_MIPS_PC16 10 /* PC relative 16 bit */ |
| 180 | #define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ |
| 181 | #define R_MIPS_GPREL32 12 /* GP relative 32 bit */ |
| 182 | |
| 183 | #define R_MIPS_64 18 |
| 184 | |
| 185 | #define R_MIPS_REL32_64 ((R_MIPS_64 << 8) | R_MIPS_REL32) |
| 186 | |
| 187 | |
| 188 | #endif /* !_MIPS64_EXEC_H_ */ |