aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/include/asm/elf.h
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2016-05-13 02:21:40 -0400
committerRalf Baechle <ralf@linux-mips.org>2016-05-13 09:30:25 -0400
commitc9babb1926852d88ebee3c27f2b8bac848560c0e (patch)
treebfa74272fe3443722c9ca338d801e1251c9c03cf /arch/mips/include/asm/elf.h
parent4a60ad51d660200adcb8bfecda472f0179ff22ec (diff)
MIPS: ELF: Unify ABI classification macros
Remove a duplicate o32 `elf_check_arch' implementation, move all macro variants to <asm/elf.h> and define them unconditionally under indvidual names, substituting alias `elf_check_arch' definitions in variant code. Signed-off-by: Maciej W. Rozycki <macro@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/13245/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/include/asm/elf.h')
-rw-r--r--arch/mips/include/asm/elf.h91
1 files changed, 60 insertions, 31 deletions
diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
index 68705a0a8014..f5f45717968e 100644
--- a/arch/mips/include/asm/elf.h
+++ b/arch/mips/include/asm/elf.h
@@ -214,25 +214,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
214/* 214/*
215 * This is used to ensure we don't load something for the wrong architecture. 215 * This is used to ensure we don't load something for the wrong architecture.
216 */ 216 */
217#define elf_check_arch(hdr) \ 217#define elf_check_arch elfo32_check_arch
218({ \
219 int __res = 1; \
220 struct elfhdr *__h = (hdr); \
221 \
222 if (!mips_elf_check_machine(__h)) \
223 __res = 0; \
224 if (__h->e_ident[EI_CLASS] != ELFCLASS32) \
225 __res = 0; \
226 if ((__h->e_flags & EF_MIPS_ABI2) != 0) \
227 __res = 0; \
228 if (((__h->e_flags & EF_MIPS_ABI) != 0) && \
229 ((__h->e_flags & EF_MIPS_ABI) != EF_MIPS_ABI_O32)) \
230 __res = 0; \
231 if (__h->e_flags & __MIPS_O32_FP64_MUST_BE_ZERO) \
232 __res = 0; \
233 \
234 __res; \
235})
236 218
237/* 219/*
238 * These are used to set parameters in the core dumps. 220 * These are used to set parameters in the core dumps.
@@ -245,18 +227,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
245/* 227/*
246 * This is used to ensure we don't load something for the wrong architecture. 228 * This is used to ensure we don't load something for the wrong architecture.
247 */ 229 */
248#define elf_check_arch(hdr) \ 230#define elf_check_arch elfn64_check_arch
249({ \
250 int __res = 1; \
251 struct elfhdr *__h = (hdr); \
252 \
253 if (!mips_elf_check_machine(__h)) \
254 __res = 0; \
255 if (__h->e_ident[EI_CLASS] != ELFCLASS64) \
256 __res = 0; \
257 \
258 __res; \
259})
260 231
261/* 232/*
262 * These are used to set parameters in the core dumps. 233 * These are used to set parameters in the core dumps.
@@ -294,6 +265,64 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
294#define vmcore_elf32_check_arch mips_elf_check_machine 265#define vmcore_elf32_check_arch mips_elf_check_machine
295#define vmcore_elf64_check_arch mips_elf_check_machine 266#define vmcore_elf64_check_arch mips_elf_check_machine
296 267
268/*
269 * Return non-zero if HDR identifies an o32 ELF binary.
270 */
271#define elfo32_check_arch(hdr) \
272({ \
273 int __res = 1; \
274 struct elfhdr *__h = (hdr); \
275 \
276 if (!mips_elf_check_machine(__h)) \
277 __res = 0; \
278 if (__h->e_ident[EI_CLASS] != ELFCLASS32) \
279 __res = 0; \
280 if ((__h->e_flags & EF_MIPS_ABI2) != 0) \
281 __res = 0; \
282 if (((__h->e_flags & EF_MIPS_ABI) != 0) && \
283 ((__h->e_flags & EF_MIPS_ABI) != EF_MIPS_ABI_O32)) \
284 __res = 0; \
285 if (__h->e_flags & __MIPS_O32_FP64_MUST_BE_ZERO) \
286 __res = 0; \
287 \
288 __res; \
289})
290
291/*
292 * Return non-zero if HDR identifies an n64 ELF binary.
293 */
294#define elfn64_check_arch(hdr) \
295({ \
296 int __res = 1; \
297 struct elfhdr *__h = (hdr); \
298 \
299 if (!mips_elf_check_machine(__h)) \
300 __res = 0; \
301 if (__h->e_ident[EI_CLASS] != ELFCLASS64) \
302 __res = 0; \
303 \
304 __res; \
305})
306
307/*
308 * Return non-zero if HDR identifies an n32 ELF binary.
309 */
310#define elfn32_check_arch(hdr) \
311({ \
312 int __res = 1; \
313 struct elfhdr *__h = (hdr); \
314 \
315 if (!mips_elf_check_machine(__h)) \
316 __res = 0; \
317 if (__h->e_ident[EI_CLASS] != ELFCLASS32) \
318 __res = 0; \
319 if (((__h->e_flags & EF_MIPS_ABI2) == 0) || \
320 ((__h->e_flags & EF_MIPS_ABI) != 0)) \
321 __res = 0; \
322 \
323 __res; \
324})
325
297struct mips_abi; 326struct mips_abi;
298 327
299extern struct mips_abi mips_abi; 328extern struct mips_abi mips_abi;