1384740dcSRalf Baechle /* 2384740dcSRalf Baechle * This file is subject to the terms and conditions of the GNU General Public 3384740dcSRalf Baechle * License. See the file "COPYING" in the main directory of this archive 4384740dcSRalf Baechle * for more details. 5384740dcSRalf Baechle * 6384740dcSRalf Baechle * Much of this is taken from binutils and GNU libc ... 7384740dcSRalf Baechle */ 8384740dcSRalf Baechle #ifndef _ASM_ELF_H 9384740dcSRalf Baechle #define _ASM_ELF_H 10384740dcSRalf Baechle 1190cee759SPaul Burton #include <linux/fs.h> 1290cee759SPaul Burton #include <uapi/linux/elf.h> 13384740dcSRalf Baechle 149b26616cSMaciej W. Rozycki #include <asm/cpu-info.h> 159b26616cSMaciej W. Rozycki #include <asm/current.h> 169b26616cSMaciej W. Rozycki 17384740dcSRalf Baechle /* ELF header e_flags defines. */ 18384740dcSRalf Baechle /* MIPS architecture level. */ 19384740dcSRalf Baechle #define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ 20384740dcSRalf Baechle #define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ 21384740dcSRalf Baechle #define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ 22384740dcSRalf Baechle #define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ 23384740dcSRalf Baechle #define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ 24384740dcSRalf Baechle #define EF_MIPS_ARCH_32 0x50000000 /* MIPS32 code. */ 25384740dcSRalf Baechle #define EF_MIPS_ARCH_64 0x60000000 /* MIPS64 code. */ 26384740dcSRalf Baechle #define EF_MIPS_ARCH_32R2 0x70000000 /* MIPS32 R2 code. */ 27384740dcSRalf Baechle #define EF_MIPS_ARCH_64R2 0x80000000 /* MIPS64 R2 code. */ 28384740dcSRalf Baechle 29384740dcSRalf Baechle /* The ABI of a file. */ 30384740dcSRalf Baechle #define EF_MIPS_ABI_O32 0x00001000 /* O32 ABI. */ 31384740dcSRalf Baechle #define EF_MIPS_ABI_O64 0x00002000 /* O32 extended for 64 bit. */ 32384740dcSRalf Baechle 33384740dcSRalf Baechle #define PT_MIPS_REGINFO 0x70000000 34384740dcSRalf Baechle #define PT_MIPS_RTPROC 0x70000001 35384740dcSRalf Baechle #define PT_MIPS_OPTIONS 0x70000002 366cd96229SPaul Burton #define PT_MIPS_ABIFLAGS 0x70000003 37384740dcSRalf Baechle 38384740dcSRalf Baechle /* Flags in the e_flags field of the header */ 39384740dcSRalf Baechle #define EF_MIPS_NOREORDER 0x00000001 40384740dcSRalf Baechle #define EF_MIPS_PIC 0x00000002 41384740dcSRalf Baechle #define EF_MIPS_CPIC 0x00000004 42384740dcSRalf Baechle #define EF_MIPS_ABI2 0x00000020 43384740dcSRalf Baechle #define EF_MIPS_OPTIONS_FIRST 0x00000080 44384740dcSRalf Baechle #define EF_MIPS_32BITMODE 0x00000100 45597ce172SPaul Burton #define EF_MIPS_FP64 0x00000200 46384740dcSRalf Baechle #define EF_MIPS_ABI 0x0000f000 47384740dcSRalf Baechle #define EF_MIPS_ARCH 0xf0000000 48384740dcSRalf Baechle 49384740dcSRalf Baechle #define DT_MIPS_RLD_VERSION 0x70000001 50384740dcSRalf Baechle #define DT_MIPS_TIME_STAMP 0x70000002 51384740dcSRalf Baechle #define DT_MIPS_ICHECKSUM 0x70000003 52384740dcSRalf Baechle #define DT_MIPS_IVERSION 0x70000004 53384740dcSRalf Baechle #define DT_MIPS_FLAGS 0x70000005 54384740dcSRalf Baechle #define RHF_NONE 0x00000000 55384740dcSRalf Baechle #define RHF_HARDWAY 0x00000001 56384740dcSRalf Baechle #define RHF_NOTPOT 0x00000002 57384740dcSRalf Baechle #define RHF_SGI_ONLY 0x00000010 58384740dcSRalf Baechle #define DT_MIPS_BASE_ADDRESS 0x70000006 59384740dcSRalf Baechle #define DT_MIPS_CONFLICT 0x70000008 60384740dcSRalf Baechle #define DT_MIPS_LIBLIST 0x70000009 61384740dcSRalf Baechle #define DT_MIPS_LOCAL_GOTNO 0x7000000a 62384740dcSRalf Baechle #define DT_MIPS_CONFLICTNO 0x7000000b 63384740dcSRalf Baechle #define DT_MIPS_LIBLISTNO 0x70000010 64384740dcSRalf Baechle #define DT_MIPS_SYMTABNO 0x70000011 65384740dcSRalf Baechle #define DT_MIPS_UNREFEXTNO 0x70000012 66384740dcSRalf Baechle #define DT_MIPS_GOTSYM 0x70000013 67384740dcSRalf Baechle #define DT_MIPS_HIPAGENO 0x70000014 68384740dcSRalf Baechle #define DT_MIPS_RLD_MAP 0x70000016 69384740dcSRalf Baechle 70384740dcSRalf Baechle #define R_MIPS_NONE 0 71384740dcSRalf Baechle #define R_MIPS_16 1 72384740dcSRalf Baechle #define R_MIPS_32 2 73384740dcSRalf Baechle #define R_MIPS_REL32 3 74384740dcSRalf Baechle #define R_MIPS_26 4 75384740dcSRalf Baechle #define R_MIPS_HI16 5 76384740dcSRalf Baechle #define R_MIPS_LO16 6 77384740dcSRalf Baechle #define R_MIPS_GPREL16 7 78384740dcSRalf Baechle #define R_MIPS_LITERAL 8 79384740dcSRalf Baechle #define R_MIPS_GOT16 9 80384740dcSRalf Baechle #define R_MIPS_PC16 10 81384740dcSRalf Baechle #define R_MIPS_CALL16 11 82384740dcSRalf Baechle #define R_MIPS_GPREL32 12 83384740dcSRalf Baechle /* The remaining relocs are defined on Irix, although they are not 84384740dcSRalf Baechle in the MIPS ELF ABI. */ 85384740dcSRalf Baechle #define R_MIPS_UNUSED1 13 86384740dcSRalf Baechle #define R_MIPS_UNUSED2 14 87384740dcSRalf Baechle #define R_MIPS_UNUSED3 15 88384740dcSRalf Baechle #define R_MIPS_SHIFT5 16 89384740dcSRalf Baechle #define R_MIPS_SHIFT6 17 90384740dcSRalf Baechle #define R_MIPS_64 18 91384740dcSRalf Baechle #define R_MIPS_GOT_DISP 19 92384740dcSRalf Baechle #define R_MIPS_GOT_PAGE 20 93384740dcSRalf Baechle #define R_MIPS_GOT_OFST 21 94384740dcSRalf Baechle /* 95384740dcSRalf Baechle * The following two relocation types are specified in the MIPS ABI 96384740dcSRalf Baechle * conformance guide version 1.2 but not yet in the psABI. 97384740dcSRalf Baechle */ 98384740dcSRalf Baechle #define R_MIPS_GOTHI16 22 99384740dcSRalf Baechle #define R_MIPS_GOTLO16 23 100384740dcSRalf Baechle #define R_MIPS_SUB 24 101384740dcSRalf Baechle #define R_MIPS_INSERT_A 25 102384740dcSRalf Baechle #define R_MIPS_INSERT_B 26 103384740dcSRalf Baechle #define R_MIPS_DELETE 27 104384740dcSRalf Baechle #define R_MIPS_HIGHER 28 105384740dcSRalf Baechle #define R_MIPS_HIGHEST 29 106384740dcSRalf Baechle /* 107384740dcSRalf Baechle * The following two relocation types are specified in the MIPS ABI 108384740dcSRalf Baechle * conformance guide version 1.2 but not yet in the psABI. 109384740dcSRalf Baechle */ 110384740dcSRalf Baechle #define R_MIPS_CALLHI16 30 111384740dcSRalf Baechle #define R_MIPS_CALLLO16 31 112384740dcSRalf Baechle /* 113384740dcSRalf Baechle * This range is reserved for vendor specific relocations. 114384740dcSRalf Baechle */ 115384740dcSRalf Baechle #define R_MIPS_LOVENDOR 100 116384740dcSRalf Baechle #define R_MIPS_HIVENDOR 127 117384740dcSRalf Baechle 118384740dcSRalf Baechle #define SHN_MIPS_ACCOMON 0xff00 /* Allocated common symbols */ 119384740dcSRalf Baechle #define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */ 120384740dcSRalf Baechle #define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */ 121384740dcSRalf Baechle #define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */ 122384740dcSRalf Baechle #define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */ 123384740dcSRalf Baechle 124384740dcSRalf Baechle #define SHT_MIPS_LIST 0x70000000 125384740dcSRalf Baechle #define SHT_MIPS_CONFLICT 0x70000002 126384740dcSRalf Baechle #define SHT_MIPS_GPTAB 0x70000003 127384740dcSRalf Baechle #define SHT_MIPS_UCODE 0x70000004 128384740dcSRalf Baechle #define SHT_MIPS_DEBUG 0x70000005 129384740dcSRalf Baechle #define SHT_MIPS_REGINFO 0x70000006 130384740dcSRalf Baechle #define SHT_MIPS_PACKAGE 0x70000007 131384740dcSRalf Baechle #define SHT_MIPS_PACKSYM 0x70000008 132384740dcSRalf Baechle #define SHT_MIPS_RELD 0x70000009 133384740dcSRalf Baechle #define SHT_MIPS_IFACE 0x7000000b 134384740dcSRalf Baechle #define SHT_MIPS_CONTENT 0x7000000c 135384740dcSRalf Baechle #define SHT_MIPS_OPTIONS 0x7000000d 136384740dcSRalf Baechle #define SHT_MIPS_SHDR 0x70000010 137384740dcSRalf Baechle #define SHT_MIPS_FDESC 0x70000011 138384740dcSRalf Baechle #define SHT_MIPS_EXTSYM 0x70000012 139384740dcSRalf Baechle #define SHT_MIPS_DENSE 0x70000013 140384740dcSRalf Baechle #define SHT_MIPS_PDESC 0x70000014 141384740dcSRalf Baechle #define SHT_MIPS_LOCSYM 0x70000015 142384740dcSRalf Baechle #define SHT_MIPS_AUXSYM 0x70000016 143384740dcSRalf Baechle #define SHT_MIPS_OPTSYM 0x70000017 144384740dcSRalf Baechle #define SHT_MIPS_LOCSTR 0x70000018 145384740dcSRalf Baechle #define SHT_MIPS_LINE 0x70000019 146384740dcSRalf Baechle #define SHT_MIPS_RFDESC 0x7000001a 147384740dcSRalf Baechle #define SHT_MIPS_DELTASYM 0x7000001b 148384740dcSRalf Baechle #define SHT_MIPS_DELTAINST 0x7000001c 149384740dcSRalf Baechle #define SHT_MIPS_DELTACLASS 0x7000001d 150384740dcSRalf Baechle #define SHT_MIPS_DWARF 0x7000001e 151384740dcSRalf Baechle #define SHT_MIPS_DELTADECL 0x7000001f 152384740dcSRalf Baechle #define SHT_MIPS_SYMBOL_LIB 0x70000020 153384740dcSRalf Baechle #define SHT_MIPS_EVENTS 0x70000021 154384740dcSRalf Baechle #define SHT_MIPS_TRANSLATE 0x70000022 155384740dcSRalf Baechle #define SHT_MIPS_PIXIE 0x70000023 156384740dcSRalf Baechle #define SHT_MIPS_XLATE 0x70000024 157384740dcSRalf Baechle #define SHT_MIPS_XLATE_DEBUG 0x70000025 158384740dcSRalf Baechle #define SHT_MIPS_WHIRL 0x70000026 159384740dcSRalf Baechle #define SHT_MIPS_EH_REGION 0x70000027 160384740dcSRalf Baechle #define SHT_MIPS_XLATE_OLD 0x70000028 161384740dcSRalf Baechle #define SHT_MIPS_PDR_EXCEPTION 0x70000029 162384740dcSRalf Baechle 163384740dcSRalf Baechle #define SHF_MIPS_GPREL 0x10000000 164384740dcSRalf Baechle #define SHF_MIPS_MERGE 0x20000000 165384740dcSRalf Baechle #define SHF_MIPS_ADDR 0x40000000 166384740dcSRalf Baechle #define SHF_MIPS_STRING 0x80000000 167384740dcSRalf Baechle #define SHF_MIPS_NOSTRIP 0x08000000 168384740dcSRalf Baechle #define SHF_MIPS_LOCAL 0x04000000 169384740dcSRalf Baechle #define SHF_MIPS_NAMES 0x02000000 170384740dcSRalf Baechle #define SHF_MIPS_NODUPES 0x01000000 171384740dcSRalf Baechle 172384740dcSRalf Baechle #ifndef ELF_ARCH 173384740dcSRalf Baechle /* ELF register definitions */ 174384740dcSRalf Baechle #define ELF_NGREG 45 175384740dcSRalf Baechle #define ELF_NFPREG 33 176384740dcSRalf Baechle 177384740dcSRalf Baechle typedef unsigned long elf_greg_t; 178384740dcSRalf Baechle typedef elf_greg_t elf_gregset_t[ELF_NGREG]; 179384740dcSRalf Baechle 180384740dcSRalf Baechle typedef double elf_fpreg_t; 181384740dcSRalf Baechle typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; 182384740dcSRalf Baechle 1836cd96229SPaul Burton struct mips_elf_abiflags_v0 { 1846cd96229SPaul Burton uint16_t version; /* Version of flags structure */ 1856cd96229SPaul Burton uint8_t isa_level; /* The level of the ISA: 1-5, 32, 64 */ 1866cd96229SPaul Burton uint8_t isa_rev; /* The revision of ISA: 0 for MIPS V and below, 1876cd96229SPaul Burton 1-n otherwise */ 1886cd96229SPaul Burton uint8_t gpr_size; /* The size of general purpose registers */ 1896cd96229SPaul Burton uint8_t cpr1_size; /* The size of co-processor 1 registers */ 1906cd96229SPaul Burton uint8_t cpr2_size; /* The size of co-processor 2 registers */ 1916cd96229SPaul Burton uint8_t fp_abi; /* The floating-point ABI */ 1926cd96229SPaul Burton uint32_t isa_ext; /* Mask of processor-specific extensions */ 1936cd96229SPaul Burton uint32_t ases; /* Mask of ASEs used */ 1946cd96229SPaul Burton uint32_t flags1; /* Mask of general flags */ 1956cd96229SPaul Burton uint32_t flags2; 1966cd96229SPaul Burton }; 1976cd96229SPaul Burton 1986cd96229SPaul Burton #define MIPS_ABI_FP_ANY 0 /* FP ABI doesn't matter */ 1996cd96229SPaul Burton #define MIPS_ABI_FP_DOUBLE 1 /* -mdouble-float */ 2006cd96229SPaul Burton #define MIPS_ABI_FP_SINGLE 2 /* -msingle-float */ 2016cd96229SPaul Burton #define MIPS_ABI_FP_SOFT 3 /* -msoft-float */ 2026cd96229SPaul Burton #define MIPS_ABI_FP_OLD_64 4 /* -mips32r2 -mfp64 */ 2036cd96229SPaul Burton #define MIPS_ABI_FP_XX 5 /* -mfpxx */ 2046cd96229SPaul Burton #define MIPS_ABI_FP_64 6 /* -mips32r2 -mfp64 */ 2056cd96229SPaul Burton #define MIPS_ABI_FP_64A 7 /* -mips32r2 -mfp64 -mno-odd-spreg */ 2066cd96229SPaul Burton 207384740dcSRalf Baechle #ifdef CONFIG_32BIT 208384740dcSRalf Baechle 209384740dcSRalf Baechle /* 210597ce172SPaul Burton * In order to be sure that we don't attempt to execute an O32 binary which 211597ce172SPaul Burton * requires 64 bit FP (FR=1) on a system which does not support it we refuse 212597ce172SPaul Burton * to execute any binary which has bits specified by the following macro set 213597ce172SPaul Burton * in its ELF header flags. 214597ce172SPaul Burton */ 215597ce172SPaul Burton #ifdef CONFIG_MIPS_O32_FP64_SUPPORT 216597ce172SPaul Burton # define __MIPS_O32_FP64_MUST_BE_ZERO 0 217597ce172SPaul Burton #else 218597ce172SPaul Burton # define __MIPS_O32_FP64_MUST_BE_ZERO EF_MIPS_FP64 219597ce172SPaul Burton #endif 220597ce172SPaul Burton 221597ce172SPaul Burton /* 222384740dcSRalf Baechle * This is used to ensure we don't load something for the wrong architecture. 223384740dcSRalf Baechle */ 224384740dcSRalf Baechle #define elf_check_arch(hdr) \ 225384740dcSRalf Baechle ({ \ 226384740dcSRalf Baechle int __res = 1; \ 227384740dcSRalf Baechle struct elfhdr *__h = (hdr); \ 228384740dcSRalf Baechle \ 229384740dcSRalf Baechle if (__h->e_machine != EM_MIPS) \ 230384740dcSRalf Baechle __res = 0; \ 231384740dcSRalf Baechle if (__h->e_ident[EI_CLASS] != ELFCLASS32) \ 232384740dcSRalf Baechle __res = 0; \ 233384740dcSRalf Baechle if ((__h->e_flags & EF_MIPS_ABI2) != 0) \ 234384740dcSRalf Baechle __res = 0; \ 235384740dcSRalf Baechle if (((__h->e_flags & EF_MIPS_ABI) != 0) && \ 236384740dcSRalf Baechle ((__h->e_flags & EF_MIPS_ABI) != EF_MIPS_ABI_O32)) \ 237384740dcSRalf Baechle __res = 0; \ 238597ce172SPaul Burton if (__h->e_flags & __MIPS_O32_FP64_MUST_BE_ZERO) \ 239597ce172SPaul Burton __res = 0; \ 240384740dcSRalf Baechle \ 241384740dcSRalf Baechle __res; \ 242384740dcSRalf Baechle }) 243384740dcSRalf Baechle 244384740dcSRalf Baechle /* 245384740dcSRalf Baechle * These are used to set parameters in the core dumps. 246384740dcSRalf Baechle */ 247384740dcSRalf Baechle #define ELF_CLASS ELFCLASS32 248384740dcSRalf Baechle 249384740dcSRalf Baechle #endif /* CONFIG_32BIT */ 250384740dcSRalf Baechle 251384740dcSRalf Baechle #ifdef CONFIG_64BIT 252384740dcSRalf Baechle /* 253384740dcSRalf Baechle * This is used to ensure we don't load something for the wrong architecture. 254384740dcSRalf Baechle */ 255384740dcSRalf Baechle #define elf_check_arch(hdr) \ 256384740dcSRalf Baechle ({ \ 257384740dcSRalf Baechle int __res = 1; \ 258384740dcSRalf Baechle struct elfhdr *__h = (hdr); \ 259384740dcSRalf Baechle \ 260384740dcSRalf Baechle if (__h->e_machine != EM_MIPS) \ 261384740dcSRalf Baechle __res = 0; \ 262384740dcSRalf Baechle if (__h->e_ident[EI_CLASS] != ELFCLASS64) \ 263384740dcSRalf Baechle __res = 0; \ 264384740dcSRalf Baechle \ 265384740dcSRalf Baechle __res; \ 266384740dcSRalf Baechle }) 267384740dcSRalf Baechle 268384740dcSRalf Baechle /* 269384740dcSRalf Baechle * These are used to set parameters in the core dumps. 270384740dcSRalf Baechle */ 271384740dcSRalf Baechle #define ELF_CLASS ELFCLASS64 272384740dcSRalf Baechle 273384740dcSRalf Baechle #endif /* CONFIG_64BIT */ 274384740dcSRalf Baechle 275384740dcSRalf Baechle /* 276384740dcSRalf Baechle * These are used to set parameters in the core dumps. 277384740dcSRalf Baechle */ 278384740dcSRalf Baechle #ifdef __MIPSEB__ 279384740dcSRalf Baechle #define ELF_DATA ELFDATA2MSB 28008d9d1c4SDavid Daney #elif defined(__MIPSEL__) 281384740dcSRalf Baechle #define ELF_DATA ELFDATA2LSB 282384740dcSRalf Baechle #endif 283384740dcSRalf Baechle #define ELF_ARCH EM_MIPS 284384740dcSRalf Baechle 285384740dcSRalf Baechle #endif /* !defined(ELF_ARCH) */ 286384740dcSRalf Baechle 287384740dcSRalf Baechle struct mips_abi; 288384740dcSRalf Baechle 289384740dcSRalf Baechle extern struct mips_abi mips_abi; 290384740dcSRalf Baechle extern struct mips_abi mips_abi_32; 291384740dcSRalf Baechle extern struct mips_abi mips_abi_n32; 292384740dcSRalf Baechle 293384740dcSRalf Baechle #ifdef CONFIG_32BIT 294384740dcSRalf Baechle 29590cee759SPaul Burton #define SET_PERSONALITY2(ex, state) \ 296384740dcSRalf Baechle do { \ 2971c0d52b9SDavid Daney if (personality(current->personality) != PER_LINUX) \ 298384740dcSRalf Baechle set_personality(PER_LINUX); \ 299384740dcSRalf Baechle \ 30090cee759SPaul Burton mips_set_personality_fp(state); \ 30190cee759SPaul Burton \ 302384740dcSRalf Baechle current->thread.abi = &mips_abi; \ 3039b26616cSMaciej W. Rozycki \ 3049b26616cSMaciej W. Rozycki current->thread.fpu.fcr31 = current_cpu_data.fpu_csr31; \ 305384740dcSRalf Baechle } while (0) 306384740dcSRalf Baechle 307384740dcSRalf Baechle #endif /* CONFIG_32BIT */ 308384740dcSRalf Baechle 309384740dcSRalf Baechle #ifdef CONFIG_64BIT 310384740dcSRalf Baechle 311384740dcSRalf Baechle #ifdef CONFIG_MIPS32_N32 312384740dcSRalf Baechle #define __SET_PERSONALITY32_N32() \ 313384740dcSRalf Baechle do { \ 314384740dcSRalf Baechle set_thread_flag(TIF_32BIT_ADDR); \ 315384740dcSRalf Baechle current->thread.abi = &mips_abi_n32; \ 316384740dcSRalf Baechle } while (0) 317384740dcSRalf Baechle #else 318384740dcSRalf Baechle #define __SET_PERSONALITY32_N32() \ 319384740dcSRalf Baechle do { } while (0) 320384740dcSRalf Baechle #endif 321384740dcSRalf Baechle 322384740dcSRalf Baechle #ifdef CONFIG_MIPS32_O32 32390cee759SPaul Burton #define __SET_PERSONALITY32_O32(ex, state) \ 324384740dcSRalf Baechle do { \ 325384740dcSRalf Baechle set_thread_flag(TIF_32BIT_REGS); \ 326384740dcSRalf Baechle set_thread_flag(TIF_32BIT_ADDR); \ 327597ce172SPaul Burton \ 32890cee759SPaul Burton mips_set_personality_fp(state); \ 329597ce172SPaul Burton \ 330384740dcSRalf Baechle current->thread.abi = &mips_abi_32; \ 331384740dcSRalf Baechle } while (0) 332384740dcSRalf Baechle #else 33390cee759SPaul Burton #define __SET_PERSONALITY32_O32(ex, state) \ 334384740dcSRalf Baechle do { } while (0) 335384740dcSRalf Baechle #endif 336384740dcSRalf Baechle 337384740dcSRalf Baechle #ifdef CONFIG_MIPS32_COMPAT 33890cee759SPaul Burton #define __SET_PERSONALITY32(ex, state) \ 339384740dcSRalf Baechle do { \ 340384740dcSRalf Baechle if ((((ex).e_flags & EF_MIPS_ABI2) != 0) && \ 341384740dcSRalf Baechle ((ex).e_flags & EF_MIPS_ABI) == 0) \ 342384740dcSRalf Baechle __SET_PERSONALITY32_N32(); \ 343384740dcSRalf Baechle else \ 34490cee759SPaul Burton __SET_PERSONALITY32_O32(ex, state); \ 345384740dcSRalf Baechle } while (0) 346384740dcSRalf Baechle #else 34790cee759SPaul Burton #define __SET_PERSONALITY32(ex, state) do { } while (0) 348384740dcSRalf Baechle #endif 349384740dcSRalf Baechle 35090cee759SPaul Burton #define SET_PERSONALITY2(ex, state) \ 351384740dcSRalf Baechle do { \ 3521c0d52b9SDavid Daney unsigned int p; \ 3531c0d52b9SDavid Daney \ 354384740dcSRalf Baechle clear_thread_flag(TIF_32BIT_REGS); \ 355597ce172SPaul Burton clear_thread_flag(TIF_32BIT_FPREGS); \ 3564227a2d4SPaul Burton clear_thread_flag(TIF_HYBRID_FPREGS); \ 357384740dcSRalf Baechle clear_thread_flag(TIF_32BIT_ADDR); \ 358384740dcSRalf Baechle \ 359384740dcSRalf Baechle if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \ 36090cee759SPaul Burton __SET_PERSONALITY32(ex, state); \ 361384740dcSRalf Baechle else \ 362384740dcSRalf Baechle current->thread.abi = &mips_abi; \ 363384740dcSRalf Baechle \ 3649b26616cSMaciej W. Rozycki current->thread.fpu.fcr31 = current_cpu_data.fpu_csr31; \ 3659b26616cSMaciej W. Rozycki \ 3661c0d52b9SDavid Daney p = personality(current->personality); \ 3671c0d52b9SDavid Daney if (p != PER_LINUX32 && p != PER_LINUX) \ 368384740dcSRalf Baechle set_personality(PER_LINUX); \ 369384740dcSRalf Baechle } while (0) 370384740dcSRalf Baechle 371384740dcSRalf Baechle #endif /* CONFIG_64BIT */ 372384740dcSRalf Baechle 3736a9c001bSRalf Baechle #define CORE_DUMP_USE_REGSET 374384740dcSRalf Baechle #define ELF_EXEC_PAGESIZE PAGE_SIZE 375384740dcSRalf Baechle 376384740dcSRalf Baechle /* This yields a mask that user programs can use to figure out what 377384740dcSRalf Baechle instruction set this cpu supports. This could be done in userspace, 378384740dcSRalf Baechle but it's not easy, and we've already done it here. */ 379384740dcSRalf Baechle 380384740dcSRalf Baechle #define ELF_HWCAP (0) 381384740dcSRalf Baechle 382874fd3b5SDavid Daney /* 383874fd3b5SDavid Daney * This yields a string that ld.so will use to load implementation 384874fd3b5SDavid Daney * specific libraries for optimization. This is more specific in 385874fd3b5SDavid Daney * intent than poking at uname or /proc/cpuinfo. 386874fd3b5SDavid Daney */ 387384740dcSRalf Baechle 388874fd3b5SDavid Daney #define ELF_PLATFORM __elf_platform 389874fd3b5SDavid Daney extern const char *__elf_platform; 390384740dcSRalf Baechle 391384740dcSRalf Baechle /* 392384740dcSRalf Baechle * See comments in asm-alpha/elf.h, this is the same thing 393384740dcSRalf Baechle * on the MIPS. 394384740dcSRalf Baechle */ 395384740dcSRalf Baechle #define ELF_PLAT_INIT(_r, load_addr) do { \ 396384740dcSRalf Baechle _r->regs[1] = _r->regs[2] = _r->regs[3] = _r->regs[4] = 0; \ 397384740dcSRalf Baechle _r->regs[5] = _r->regs[6] = _r->regs[7] = _r->regs[8] = 0; \ 398384740dcSRalf Baechle _r->regs[9] = _r->regs[10] = _r->regs[11] = _r->regs[12] = 0; \ 399384740dcSRalf Baechle _r->regs[13] = _r->regs[14] = _r->regs[15] = _r->regs[16] = 0; \ 400384740dcSRalf Baechle _r->regs[17] = _r->regs[18] = _r->regs[19] = _r->regs[20] = 0; \ 401384740dcSRalf Baechle _r->regs[21] = _r->regs[22] = _r->regs[23] = _r->regs[24] = 0; \ 402384740dcSRalf Baechle _r->regs[25] = _r->regs[26] = _r->regs[27] = _r->regs[28] = 0; \ 403384740dcSRalf Baechle _r->regs[30] = _r->regs[31] = 0; \ 404384740dcSRalf Baechle } while (0) 405384740dcSRalf Baechle 406384740dcSRalf Baechle /* This is the location that an ET_DYN program is loaded if exec'ed. Typical 407384740dcSRalf Baechle use of this is to invoke "./ld.so someprog" to test out a new version of 408384740dcSRalf Baechle the loader. We need to make sure that it is out of the way of the program 409384740dcSRalf Baechle that it will "exec", and that there is sufficient room for the brk. */ 410384740dcSRalf Baechle 411384740dcSRalf Baechle #ifndef ELF_ET_DYN_BASE 412384740dcSRalf Baechle #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2) 413384740dcSRalf Baechle #endif 414384740dcSRalf Baechle 415c52d0d30SDavid Daney #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 416c52d0d30SDavid Daney struct linux_binprm; 417c52d0d30SDavid Daney extern int arch_setup_additional_pages(struct linux_binprm *bprm, 418c52d0d30SDavid Daney int uses_interp); 419652b14aaSDavid Daney 420652b14aaSDavid Daney struct mm_struct; 421652b14aaSDavid Daney extern unsigned long arch_randomize_brk(struct mm_struct *mm); 422652b14aaSDavid Daney #define arch_randomize_brk arch_randomize_brk 423652b14aaSDavid Daney 42490cee759SPaul Burton struct arch_elf_state { 42590cee759SPaul Burton int fp_abi; 42690cee759SPaul Burton int interp_fp_abi; 42746490b57SMarkos Chandras int overall_fp_mode; 42890cee759SPaul Burton }; 42990cee759SPaul Burton 43046490b57SMarkos Chandras #define MIPS_ABI_FP_UNKNOWN (-1) /* Unknown FP ABI (kernel internal) */ 43146490b57SMarkos Chandras 43290cee759SPaul Burton #define INIT_ARCH_ELF_STATE { \ 43346490b57SMarkos Chandras .fp_abi = MIPS_ABI_FP_UNKNOWN, \ 43446490b57SMarkos Chandras .interp_fp_abi = MIPS_ABI_FP_UNKNOWN, \ 43546490b57SMarkos Chandras .overall_fp_mode = -1, \ 43690cee759SPaul Burton } 43790cee759SPaul Burton 43890cee759SPaul Burton extern int arch_elf_pt_proc(void *ehdr, void *phdr, struct file *elf, 43990cee759SPaul Burton bool is_interp, struct arch_elf_state *state); 44090cee759SPaul Burton 44190cee759SPaul Burton extern int arch_check_elf(void *ehdr, bool has_interpreter, 44290cee759SPaul Burton struct arch_elf_state *state); 44390cee759SPaul Burton 44490cee759SPaul Burton extern void mips_set_personality_fp(struct arch_elf_state *state); 44590cee759SPaul Burton 446384740dcSRalf Baechle #endif /* _ASM_ELF_H */ 447