1144513Simp/*	$OpenBSD: exec.h,v 1.10 2022/10/28 15:07:25 kettenis Exp $	*/
2144513Simp
3144513Simp/*
4144513Simp * Copyright (c) 1996-2004 Per Fogelstrom, Opsycon AB
5144513Simp *
6144513Simp * 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	16384
33
34#define	ARCH_ELFSIZE 64
35#define ELF_TARG_CLASS  ELFCLASS64
36
37#if defined(__MIPSEB__)
38#define ELF_TARG_DATA		ELFDATA2MSB
39#else
40#define ELF_TARG_DATA		ELFDATA2LSB
41#endif
42#define ELF_TARG_MACH		EM_MIPS
43
44/* Information taken from MIPS ABI supplement */
45
46/* Architecture dependent Segment types - p_type */
47#define PT_MIPS_REGINFO 0x70000000      /* Register usage information */
48
49/* Architecture dependent d_tag field for Elf32_Dyn.  */
50#define DT_MIPS_RLD_VERSION  0x70000001 /* Runtime Linker Interface ID */
51#define DT_MIPS_TIME_STAMP   0x70000002 /* Timestamp */
52#define DT_MIPS_ICHECKSUM    0x70000003 /* Cksum of ext. str. and com. sizes */
53#define DT_MIPS_IVERSION     0x70000004 /* Version string (string tbl index) */
54#define DT_MIPS_FLAGS        0x70000005 /* Flags */
55#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Segment base address */
56#define DT_MIPS_CONFLICT     0x70000008 /* Adr of .conflict section */
57#define DT_MIPS_LIBLIST      0x70000009 /* Address of .liblist section */
58#define DT_MIPS_LOCAL_GOTNO  0x7000000a /* Number of local .GOT entries */
59#define DT_MIPS_CONFLICTNO   0x7000000b /* Number of .conflict entries */
60#define DT_MIPS_LIBLISTNO    0x70000010 /* Number of .liblist entries */
61#define DT_MIPS_SYMTABNO     0x70000011 /* Number of .dynsym entries */
62#define DT_MIPS_UNREFEXTNO   0x70000012 /* First external DYNSYM */
63#define DT_MIPS_GOTSYM       0x70000013 /* First GOT entry in .dynsym */
64#define DT_MIPS_HIPAGENO     0x70000014 /* Number of GOT page table entries */
65#define DT_MIPS_RLD_MAP      0x70000016 /* Address of debug map pointer */
66#define DT_MIPS_RLD_MAP_REL  0x70000035 /* Relative address of debug map ptr */
67
68#define DT_PROCNUM (DT_MIPS_RLD_MAP_REL - DT_LOPROC + 1)
69
70/*
71 * Legal values for e_flags field of Elf32_Ehdr.
72 */
73#define EF_MIPS_NOREORDER	0x00000001	/* .noreorder was used */
74#define EF_MIPS_PIC		0x00000002	/* Contains PIC code */
75#define EF_MIPS_CPIC		0x00000004	/* Uses PIC calling sequence */
76#define	EF_MIPS_ABI2		0x00000020	/* -n32 on Irix 6 */
77#define	EF_MIPS_32BITMODE	0x00000100	/* 64 bit in 32 bit mode... */
78#define EF_MIPS_ARCH		0xf0000000	/* MIPS architecture level */
79#define	E_MIPS_ARCH_1		0x00000000
80#define	E_MIPS_ARCH_2		0x10000000
81#define	E_MIPS_ARCH_3		0x20000000
82#define	E_MIPS_ARCH_4		0x30000000
83#define	EF_MIPS_ABI		0x0000f000	/* ABI level */
84#define	E_MIPS_ABI_NONE		0x00000000	/* ABI level not set */
85#define	E_MIPS_ABI_O32		0x00001000
86#define	E_MIPS_ABI_O64		0x00002000
87#define	E_MIPS_ABI_EABI32	0x00004000
88#define	E_MIPS_ABI_EABI64	0x00004000
89
90/*
91 * Mips special sections.
92 */
93#define	SHN_MIPS_ACOMMON	0xff00		/* Allocated common symbols */
94#define	SHN_MIPS_SCOMMON	0xff03		/* Small common symbols */
95#define	SHN_MIPS_SUNDEFINED	0xff04		/* Small undefined symbols */
96
97/*
98 * Legal values for sh_type field of Elf32_Shdr.
99 */
100#define	SHT_MIPS_LIBLIST  0x70000000	/* Shared objects used in link */
101#define	SHT_MIPS_CONFLICT 0x70000002	/* Conflicting symbols */
102#define	SHT_MIPS_GPTAB    0x70000003	/* Global data area sizes */
103#define	SHT_MIPS_UCODE    0x70000004	/* Reserved for SGI/MIPS compilers */
104#define	SHT_MIPS_DEBUG    0x70000005	/* MIPS ECOFF debugging information */
105#define	SHT_MIPS_REGINFO  0x70000006	/* Register usage information */
106
107/*
108 * Legal values for sh_flags field of Elf32_Shdr.
109 */
110#define	SHF_MIPS_GPREL	0x10000000	/* Must be part of global data area */
111
112#if 0
113/*
114 * Entries found in sections of type SHT_MIPS_GPTAB.
115 */
116typedef union {
117	struct {
118		Elf32_Word gt_current_g_value;	/* -G val used in compilation */
119		Elf32_Word gt_unused;	/* Not used */
120	} gt_header;			/* First entry in section */
121	struct {
122		Elf32_Word gt_g_value;	/* If this val were used for -G */
123		Elf32_Word gt_bytes;	/* This many bytes would be used */
124	} gt_entry;			/* Subsequent entries in section */
125} Elf32_gptab;
126
127/*
128 * Entry found in sections of type SHT_MIPS_REGINFO.
129 */
130typedef struct {
131	Elf32_Word	ri_gprmask;	/* General registers used */
132	Elf32_Word	ri_cprmask[4];	/* Coprocessor registers used */
133	Elf32_Sword	ri_gp_value;	/* $gp register value */
134} Elf32_RegInfo;
135#endif
136
137#endif	/* !_MIPS64_EXEC_H_ */
138