| @@ -1,201 +1,203 @@ | | | @@ -1,201 +1,203 @@ |
1 | /* $NetBSD: elf_machdep.h,v 1.12 2009/12/14 00:46:04 matt Exp $ */ | | 1 | /* $NetBSD: elf_machdep.h,v 1.13 2009/12/14 03:20:27 mrg Exp $ */ |
2 | | | 2 | |
3 | #ifndef _MIPS_ELF_MACHDEP_H_ | | 3 | #ifndef _MIPS_ELF_MACHDEP_H_ |
4 | #define _MIPS_ELF_MACHDEP_H_ | | 4 | #define _MIPS_ELF_MACHDEP_H_ |
5 | | | 5 | |
6 | #if defined(ELFSIZE) | | 6 | #if defined(ELFSIZE) |
7 | #if ELFSIZE == 32 | | 7 | #if ELFSIZE == 32 |
8 | #define ELF32_MACHDEP_ID_CASES \ | | 8 | #define ELF32_MACHDEP_ID_CASES \ |
9 | case EM_MIPS: \ | | 9 | case EM_MIPS: \ |
10 | break; | | 10 | break; |
11 | | | 11 | |
12 | #define ELF32_MACHDEP_ID EM_MIPS | | 12 | #define ELF32_MACHDEP_ID EM_MIPS |
13 | #endif /* ELFSIZE == 32 */ | | 13 | #endif /* ELFSIZE == 32 */ |
14 | #if ELFSIZE == 64 | | 14 | #if ELFSIZE == 64 |
15 | #ifdef _LP64 | | 15 | #ifdef _LP64 |
16 | #define ELF64_MACHDEP_ID_CASES \ | | 16 | #define ELF64_MACHDEP_ID_CASES \ |
17 | case EM_MIPS: \ | | 17 | case EM_MIPS: \ |
18 | break; | | 18 | break; |
19 | #else | | 19 | #else |
20 | #define ELF64_MACHDEP_ID_CASES /* xxx */ | | 20 | #define ELF64_MACHDEP_ID_CASES /* xxx */ |
21 | #endif /* _LP64 */ | | 21 | #endif /* _LP64 */ |
22 | | | 22 | |
23 | #define ELF64_MACHDEP_ID EM_MIPS | | 23 | #define ELF64_MACHDEP_ID EM_MIPS |
24 | #endif /* ELFSIZE == 64 */ | | 24 | #endif /* ELFSIZE == 64 */ |
25 | #endif /* defined(ELFSIZE) */ | | 25 | #endif /* defined(ELFSIZE) */ |
26 | | | 26 | |
27 | #ifdef _LP64 | | 27 | #ifdef _LP64 |
28 | #define ARCH_ELFSIZE 64 /* MD native binary size */ | | 28 | #define ARCH_ELFSIZE 64 /* MD native binary size */ |
29 | #else | | 29 | #else |
30 | #define ARCH_ELFSIZE 32 /* MD native binary size */ | | 30 | #define ARCH_ELFSIZE 32 /* MD native binary size */ |
31 | #endif | | 31 | #endif |
32 | | | 32 | |
33 | /* mips relocs. */ | | 33 | /* mips relocs. */ |
34 | | | 34 | |
35 | #define R_MIPS_NONE 0 | | 35 | #define R_MIPS_NONE 0 |
36 | #define R_MIPS_16 1 | | 36 | #define R_MIPS_16 1 |
37 | #define R_MIPS_32 2 | | 37 | #define R_MIPS_32 2 |
38 | #define R_MIPS_REL32 3 | | 38 | #define R_MIPS_REL32 3 |
39 | #define R_MIPS_REL R_MIPS_REL32 | | 39 | #define R_MIPS_REL R_MIPS_REL32 |
40 | #define R_MIPS_26 4 | | 40 | #define R_MIPS_26 4 |
41 | #define R_MIPS_HI16 5 /* high 16 bits of symbol value */ | | 41 | #define R_MIPS_HI16 5 /* high 16 bits of symbol value */ |
42 | #define R_MIPS_LO16 6 /* low 16 bits of symbol value */ | | 42 | #define R_MIPS_LO16 6 /* low 16 bits of symbol value */ |
43 | #define R_MIPS_GPREL16 7 /* GP-relative reference */ | | 43 | #define R_MIPS_GPREL16 7 /* GP-relative reference */ |
44 | #define R_MIPS_LITERAL 8 /* Reference to literal section */ | | 44 | #define R_MIPS_LITERAL 8 /* Reference to literal section */ |
45 | #define R_MIPS_GOT16 9 /* Reference to global offset table */ | | 45 | #define R_MIPS_GOT16 9 /* Reference to global offset table */ |
46 | #define R_MIPS_GOT R_MIPS_GOT16 | | 46 | #define R_MIPS_GOT R_MIPS_GOT16 |
47 | #define R_MIPS_PC16 10 /* 16 bit PC relative reference */ | | 47 | #define R_MIPS_PC16 10 /* 16 bit PC relative reference */ |
48 | #define R_MIPS_CALL16 11 /* 16 bit call thru glbl offset tbl */ | | 48 | #define R_MIPS_CALL16 11 /* 16 bit call thru glbl offset tbl */ |
49 | #define R_MIPS_CALL R_MIPS_CALL16 | | 49 | #define R_MIPS_CALL R_MIPS_CALL16 |
50 | #define R_MIPS_GPREL32 12 | | 50 | #define R_MIPS_GPREL32 12 |
51 | | | 51 | |
52 | /* 13, 14, 15 are not defined at this point. */ | | 52 | /* 13, 14, 15 are not defined at this point. */ |
53 | #define R_MIPS_UNUSED1 13 | | 53 | #define R_MIPS_UNUSED1 13 |
54 | #define R_MIPS_UNUSED2 14 | | 54 | #define R_MIPS_UNUSED2 14 |
55 | #define R_MIPS_UNUSED3 15 | | 55 | #define R_MIPS_UNUSED3 15 |
56 | | | 56 | |
57 | /* | | 57 | /* |
58 | * The remaining relocs are apparently part of the 64-bit Irix ELF ABI. | | 58 | * The remaining relocs are apparently part of the 64-bit Irix ELF ABI. |
59 | */ | | 59 | */ |
60 | #define R_MIPS_SHIFT5 16 | | 60 | #define R_MIPS_SHIFT5 16 |
61 | #define R_MIPS_SHIFT6 17 | | 61 | #define R_MIPS_SHIFT6 17 |
62 | | | 62 | |
63 | #define R_MIPS_64 18 | | 63 | #define R_MIPS_64 18 |
64 | #define R_MIPS_GOT_DISP 19 | | 64 | #define R_MIPS_GOT_DISP 19 |
65 | #define R_MIPS_GOT_PAGE 20 | | 65 | #define R_MIPS_GOT_PAGE 20 |
66 | #define R_MIPS_GOT_OFST 21 | | 66 | #define R_MIPS_GOT_OFST 21 |
67 | #define R_MIPS_GOT_HI16 22 | | 67 | #define R_MIPS_GOT_HI16 22 |
68 | #define R_MIPS_GOT_LO16 23 | | 68 | #define R_MIPS_GOT_LO16 23 |
69 | #define R_MIPS_SUB 24 | | 69 | #define R_MIPS_SUB 24 |
70 | #define R_MIPS_INSERT_A 25 | | 70 | #define R_MIPS_INSERT_A 25 |
71 | #define R_MIPS_INSERT_B 26 | | 71 | #define R_MIPS_INSERT_B 26 |
72 | #define R_MIPS_DELETE 27 | | 72 | #define R_MIPS_DELETE 27 |
73 | #define R_MIPS_HIGHER 28 | | 73 | #define R_MIPS_HIGHER 28 |
74 | #define R_MIPS_HIGHEST 29 | | 74 | #define R_MIPS_HIGHEST 29 |
75 | #define R_MIPS_CALL_HI16 30 | | 75 | #define R_MIPS_CALL_HI16 30 |
76 | #define R_MIPS_CALL_LO16 31 | | 76 | #define R_MIPS_CALL_LO16 31 |
77 | #define R_MIPS_SCN_DISP 32 | | 77 | #define R_MIPS_SCN_DISP 32 |
78 | #define R_MIPS_REL16 33 | | 78 | #define R_MIPS_REL16 33 |
79 | #define R_MIPS_ADD_IMMEDIATE 34 | | 79 | #define R_MIPS_ADD_IMMEDIATE 34 |
80 | #define R_MIPS_PJUMP 35 | | 80 | #define R_MIPS_PJUMP 35 |
81 | #define R_MIPS_RELGOT 36 | | 81 | #define R_MIPS_RELGOT 36 |
82 | #define R_MIPS_JALR 37 | | 82 | #define R_MIPS_JALR 37 |
83 | /* TLS relocations */ | | 83 | /* TLS relocations */ |
84 | | | 84 | |
85 | #define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */ | | 85 | #define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */ |
86 | #define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */ | | 86 | #define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */ |
87 | #define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */ | | 87 | #define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */ |
88 | #define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */ | | 88 | #define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */ |
89 | #define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */ | | 89 | #define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */ |
90 | #define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */ | | 90 | #define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */ |
91 | #define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */ | | 91 | #define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */ |
92 | #define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */ | | 92 | #define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */ |
93 | #define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */ | | 93 | #define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */ |
94 | #define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */ | | 94 | #define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */ |
95 | #define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */ | | 95 | #define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */ |
96 | #define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */ | | 96 | #define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */ |
97 | #define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */ | | 97 | #define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */ |
98 | | | 98 | |
99 | #define R_MIPS_max 51 | | 99 | #define R_MIPS_max 51 |
100 | | | 100 | |
101 | #define R_TYPE(name) __CONCAT(R_MIPS_,name) | | 101 | #define R_TYPE(name) __CONCAT(R_MIPS_,name) |
102 | | | 102 | |
103 | #define R_MIPS16_min 100 | | 103 | #define R_MIPS16_min 100 |
104 | #define R_MIPS16_26 100 | | 104 | #define R_MIPS16_26 100 |
105 | #define R_MIPS16_GPREL 101 | | 105 | #define R_MIPS16_GPREL 101 |
106 | #define R_MIPS16_GOT16 102 | | 106 | #define R_MIPS16_GOT16 102 |
107 | #define R_MIPS16_CALL16 103 | | 107 | #define R_MIPS16_CALL16 103 |
108 | #define R_MIPS16_HI16 104 | | 108 | #define R_MIPS16_HI16 104 |
109 | #define R_MIPS16_LO16 105 | | 109 | #define R_MIPS16_LO16 105 |
110 | #define R_MIPS16_max 106 | | 110 | #define R_MIPS16_max 106 |
111 | | | 111 | |
112 | | | 112 | |
113 | /* mips dynamic tags */ | | 113 | /* mips dynamic tags */ |
114 | | | 114 | |
115 | #define DT_MIPS_RLD_VERSION 0x70000001 | | 115 | #define DT_MIPS_RLD_VERSION 0x70000001 |
116 | #define DT_MIPS_TIME_STAMP 0x70000002 | | 116 | #define DT_MIPS_TIME_STAMP 0x70000002 |
117 | #define DT_MIPS_ICHECKSUM 0x70000003 | | 117 | #define DT_MIPS_ICHECKSUM 0x70000003 |
118 | #define DT_MIPS_IVERSION 0x70000004 | | 118 | #define DT_MIPS_IVERSION 0x70000004 |
119 | #define DT_MIPS_FLAGS 0x70000005 | | 119 | #define DT_MIPS_FLAGS 0x70000005 |
120 | #define DT_MIPS_BASE_ADDRESS 0x70000006 | | 120 | #define DT_MIPS_BASE_ADDRESS 0x70000006 |
121 | #define DT_MIPS_CONFLICT 0x70000008 | | 121 | #define DT_MIPS_CONFLICT 0x70000008 |
122 | #define DT_MIPS_LIBLIST 0x70000009 | | 122 | #define DT_MIPS_LIBLIST 0x70000009 |
123 | #define DT_MIPS_CONFLICTNO 0x7000000b | | 123 | #define DT_MIPS_CONFLICTNO 0x7000000b |
124 | #define DT_MIPS_LOCAL_GOTNO 0x7000000a /* number of local got ents */ | | 124 | #define DT_MIPS_LOCAL_GOTNO 0x7000000a /* number of local got ents */ |
125 | #define DT_MIPS_LIBLISTNO 0x70000010 | | 125 | #define DT_MIPS_LIBLISTNO 0x70000010 |
126 | #define DT_MIPS_SYMTABNO 0x70000011 /* number of .dynsym entries */ | | 126 | #define DT_MIPS_SYMTABNO 0x70000011 /* number of .dynsym entries */ |
127 | #define DT_MIPS_UNREFEXTNO 0x70000012 | | 127 | #define DT_MIPS_UNREFEXTNO 0x70000012 |
128 | #define DT_MIPS_GOTSYM 0x70000013 /* first dynamic sym in got */ | | 128 | #define DT_MIPS_GOTSYM 0x70000013 /* first dynamic sym in got */ |
129 | #define DT_MIPS_HIPAGENO 0x70000014 | | 129 | #define DT_MIPS_HIPAGENO 0x70000014 |
130 | #define DT_MIPS_RLD_MAP 0x70000016 /* address of loader map */ | | 130 | #define DT_MIPS_RLD_MAP 0x70000016 /* address of loader map */ |
131 | | | 131 | |
132 | /* | | 132 | /* |
133 | * ELF Flags | | 133 | * ELF Flags |
134 | */ | | 134 | */ |
135 | #define EF_MIPS_PIC 0x00000002 /* Contains PIC code */ | | 135 | #define EF_MIPS_PIC 0x00000002 /* Contains PIC code */ |
136 | #define EF_MIPS_CPIC 0x00000004 /* STD PIC calling sequence */ | | 136 | #define EF_MIPS_CPIC 0x00000004 /* STD PIC calling sequence */ |
137 | #define EF_MIPS_ABI2 0x00000020 /* N32 */ | | 137 | #define EF_MIPS_ABI2 0x00000020 /* N32 */ |
138 | | | 138 | |
139 | #define EF_MIPS_ARCH_ASE 0x0f000000 /* Architectural extensions */ | | 139 | #define EF_MIPS_ARCH_ASE 0x0f000000 /* Architectural extensions */ |
140 | #define EF_MIPS_ARCH_MDMX 0x08000000 /* MDMX multimedia extension */ | | 140 | #define EF_MIPS_ARCH_MDMX 0x08000000 /* MDMX multimedia extension */ |
141 | #define EF_MIPS_ARCH_M16 0x04000000 /* MIPS-16 ISA extensions */ | | 141 | #define EF_MIPS_ARCH_M16 0x04000000 /* MIPS-16 ISA extensions */ |
142 | | | 142 | |
143 | #define EF_MIPS_ARCH 0xf0000000 /* Architecture field */ | | 143 | #define EF_MIPS_ARCH 0xf0000000 /* Architecture field */ |
144 | #define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code */ | | 144 | #define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code */ |
145 | #define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code */ | | 145 | #define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code */ |
146 | #define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code */ | | 146 | #define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code */ |
147 | #define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code */ | | 147 | #define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code */ |
148 | #define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code */ | | 148 | #define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code */ |
149 | #define EF_MIPS_ARCH_32 0x50000000 /* -mips32 code */ | | 149 | #define EF_MIPS_ARCH_32 0x50000000 /* -mips32 code */ |
150 | #define EF_MIPS_ARCH_64 0x60000000 /* -mips64 code */ | | 150 | #define EF_MIPS_ARCH_64 0x60000000 /* -mips64 code */ |
151 | #define EF_MIPS_ARCH_32R2 0x70000000 /* -mips32r2 code */ | | 151 | #define EF_MIPS_ARCH_32R2 0x70000000 /* -mips32r2 code */ |
152 | #define EF_MIPS_ARCH_64R4 0x80000000 /* -mips64r2 code */ | | 152 | #define EF_MIPS_ARCH_64R4 0x80000000 /* -mips64r2 code */ |
153 | | | 153 | |
154 | #define EF_MIPS_ABI 0x0000f000 | | 154 | #define EF_MIPS_ABI 0x0000f000 |
155 | #define EF_MIPS_ABI_O32 0x00001000 | | 155 | #define EF_MIPS_ABI_O32 0x00001000 |
156 | #define EF_MIPS_ABI_O64 0x00002000 | | 156 | #define EF_MIPS_ABI_O64 0x00002000 |
157 | #define EF_MIPS_ABI_EABI32 0x00003000 | | 157 | #define EF_MIPS_ABI_EABI32 0x00003000 |
158 | #define EF_MIPS_ABI_EABI64 0x00004000 | | 158 | #define EF_MIPS_ABI_EABI64 0x00004000 |
159 | | | 159 | |
160 | #if defined(__MIPSEB__) | | 160 | #if defined(__MIPSEB__) |
161 | #define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB | | 161 | #define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB |
162 | #define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB | | 162 | #define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB |
163 | #elif defined(__MIPSEL__) | | 163 | #elif defined(__MIPSEL__) |
164 | #define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB | | 164 | #define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB |
165 | #define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB | | 165 | #define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB |
166 | #elif !defined(HAVE_NBTOOL_CONFIG_H) | | 166 | #elif !defined(HAVE_NBTOOL_CONFIG_H) |
167 | #error neither __MIPSEL__ nor __MIPSEB__ are defined. | | 167 | #error neither __MIPSEL__ nor __MIPSEB__ are defined. |
168 | #endif | | 168 | #endif |
169 | | | 169 | |
170 | #ifdef _KERNEL | | 170 | #ifdef _KERNEL |
171 | #ifdef _KERNEL_OPT | | 171 | #ifdef _KERNEL_OPT |
172 | #include "opt_compat_netbsd.h" | | 172 | #include "opt_compat_netbsd.h" |
173 | #endif | | 173 | #endif |
174 | #ifdef COMPAT_16 | | 174 | #ifdef COMPAT_16 |
175 | /* | | 175 | /* |
176 | * Up to 1.6, the ELF dynamic loader (ld.elf_so) was not relocatable. | | 176 | * Up to 1.6, the ELF dynamic loader (ld.elf_so) was not relocatable. |
177 | * Tell the kernel ELF exec code not to try relocating the interpreter | | 177 | * Tell the kernel ELF exec code not to try relocating the interpreter |
178 | * for dynamically-linked ELF binaries. | | 178 | * for dynamically-linked ELF binaries. |
179 | */ | | 179 | */ |
180 | #define ELF_INTERP_NON_RELOCATABLE | | 180 | #define ELF_INTERP_NON_RELOCATABLE |
181 | #endif /* COMPAT_16 */ | | 181 | #endif /* COMPAT_16 */ |
182 | | | 182 | |
183 | /* | | 183 | /* |
184 | * We need to be able to include the ELF header so we can pick out the | | 184 | * We need to be able to include the ELF header so we can pick out the |
185 | * ABI being used. | | 185 | * ABI being used. |
186 | */ | | 186 | */ |
187 | #ifdef ELFSIZE | | 187 | #ifdef ELFSIZE |
188 | #define ELF_MD_PROBE_FUNC ELFNAME2(mips_netbsd,probe) | | 188 | #define ELF_MD_PROBE_FUNC ELFNAME2(mips_netbsd,probe) |
189 | #define ELF_MD_COREDUMP_SETUP ELFNAME2(coredump,setup) | | 189 | #define ELF_MD_COREDUMP_SETUP ELFNAME2(coredump,setup) |
190 | #endif | | 190 | #endif |
191 | | | 191 | |
| | | 192 | struct exec_package; |
| | | 193 | |
192 | int mips_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *, | | 194 | int mips_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *, |
193 | vaddr_t *); | | 195 | vaddr_t *); |
194 | void coredump_elf32_setup(struct lwp *, void *); | | 196 | void coredump_elf32_setup(struct lwp *, void *); |
195 | | | 197 | |
196 | int mips_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *, | | 198 | int mips_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *, |
197 | vaddr_t *); | | 199 | vaddr_t *); |
198 | void coredump_elf64_setup(struct lwp *, void *); | | 200 | void coredump_elf64_setup(struct lwp *, void *); |
199 | #endif /* _KERNEL */ | | 201 | #endif /* _KERNEL */ |
200 | | | 202 | |
201 | #endif /* _MIPS_ELF_MACHDEP_H_ */ | | 203 | #endif /* _MIPS_ELF_MACHDEP_H_ */ |