linux/arch/mips/include/asm/elfcore-compat.h
Al Viro 0bb87f051e mips compat: switch to compat_binfmt_elf.c
Like amd64, mips has two 32bit ABIs - o32 and n32.  Unlike amd64,
it does not use compat_binfmt_elf.c for either of those; each
of those ABIs has a binfmt handler of its own, both very similar
to fs/compat_binfmt_elf.c.  And the same technics as we use on
amd64 can be used to make fs/compat_binfmt_elf.c handle both.
	* merge elfo32_check_arch() with elfn32_check_arch(),
make that serve as compat_elf_check_arch().  Note that
SET_PERSONALITY2() is already the same for all ABI variants -
it looks at the elf header to choose the flags to set.
	* add asm/elfcore-compat.h, using the bigger (n32) variant
of elf32_prstatus as compat_elf_prstatus there.
	* make PRSTATUS_SIZE() and SET_PR_FPVALID() choose the
right layout, same as done for amd64.  test_thread_flag(TIF_32BIT_REGS)
is used as the predicate.

Voila - we are rid of binfmt_elf{n,o}32.c; fs/compat_binfmt_elf.c is
used, same as for all other ELF-supporting 64bit architectures that
need 32bit compat.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2021-01-06 08:42:49 -05:00

30 lines
841 B
C

#ifndef _ASM_MIPS_ELFCORE_COMPAT_H
#define _ASM_MIPS_ELFCORE_COMPAT_H
/*
* On mips we have two 32bit ABIs - o32 and n32. The latter
* has bigger registers, so we use it for compat_elf_regset_t.
* The former uses o32_elf_prstatus and PRSTATUS_SIZE/SET_PR_FPVALID
* are used to choose the size and location of ->pr_fpvalid of
* the layout actually used.
*/
typedef elf_gregset_t compat_elf_gregset_t;
struct o32_elf_prstatus
{
struct compat_elf_prstatus_common common;
unsigned int pr_reg[ELF_NGREG];
compat_int_t pr_fpvalid;
};
#define PRSTATUS_SIZE \
(!test_thread_flag(TIF_32BIT_REGS) \
? sizeof(struct compat_elf_prstatus) \
: sizeof(struct o32_elf_prstatus))
#define SET_PR_FPVALID(S) \
(*(!test_thread_flag(TIF_32BIT_REGS) \
? &(S)->pr_fpvalid \
: &((struct o32_elf_prstatus *)(S))->pr_fpvalid) = 1)
#endif