Path: blob/master/arch/mips/kernel/binfmt_elfn32.c
10817 views
/*1* Support for n32 Linux/MIPS ELF binaries.2*3* Copyright (C) 1999, 2001 Ralf Baechle4* Copyright (C) 1999, 2001 Silicon Graphics, Inc.5*6* Heavily inspired by the 32-bit Sparc compat code which is7* Copyright (C) 1995, 1996, 1997, 1998 David S. Miller ([email protected])8* Copyright (C) 1995, 1996, 1997, 1998 Jakub Jelinek ([email protected])9*/1011#define ELF_ARCH EM_MIPS12#define ELF_CLASS ELFCLASS3213#ifdef __MIPSEB__14#define ELF_DATA ELFDATA2MSB;15#else /* __MIPSEL__ */16#define ELF_DATA ELFDATA2LSB;17#endif1819/* ELF register definitions */20#define ELF_NGREG 4521#define ELF_NFPREG 332223typedef unsigned long elf_greg_t;24typedef elf_greg_t elf_gregset_t[ELF_NGREG];2526typedef double elf_fpreg_t;27typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];2829/*30* This is used to ensure we don't load something for the wrong architecture.31*/32#define elf_check_arch(hdr) \33({ \34int __res = 1; \35struct elfhdr *__h = (hdr); \36\37if (__h->e_machine != EM_MIPS) \38__res = 0; \39if (__h->e_ident[EI_CLASS] != ELFCLASS32) \40__res = 0; \41if (((__h->e_flags & EF_MIPS_ABI2) == 0) || \42((__h->e_flags & EF_MIPS_ABI) != 0)) \43__res = 0; \44\45__res; \46})4748#define TASK32_SIZE 0x7fff8000UL49#undef ELF_ET_DYN_BASE50#define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)5152#include <asm/processor.h>53#include <linux/module.h>54#include <linux/elfcore.h>55#include <linux/compat.h>56#include <linux/math64.h>5758#define elf_prstatus elf_prstatus3259struct elf_prstatus3260{61struct elf_siginfo pr_info; /* Info associated with signal */62short pr_cursig; /* Current signal */63unsigned int pr_sigpend; /* Set of pending signals */64unsigned int pr_sighold; /* Set of held signals */65pid_t pr_pid;66pid_t pr_ppid;67pid_t pr_pgrp;68pid_t pr_sid;69struct compat_timeval pr_utime; /* User time */70struct compat_timeval pr_stime; /* System time */71struct compat_timeval pr_cutime;/* Cumulative user time */72struct compat_timeval pr_cstime;/* Cumulative system time */73elf_gregset_t pr_reg; /* GP registers */74int pr_fpvalid; /* True if math co-processor being used. */75};7677#define elf_prpsinfo elf_prpsinfo3278struct elf_prpsinfo3279{80char pr_state; /* numeric process state */81char pr_sname; /* char for pr_state */82char pr_zomb; /* zombie */83char pr_nice; /* nice val */84unsigned int pr_flag; /* flags */85__kernel_uid_t pr_uid;86__kernel_gid_t pr_gid;87pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;88/* Lots missing */89char pr_fname[16]; /* filename of executable */90char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */91};9293#define elf_caddr_t u3294#define init_elf_binfmt init_elfn32_binfmt9596#define jiffies_to_timeval jiffies_to_compat_timeval97static __inline__ void98jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)99{100/*101* Convert jiffies to nanoseconds and separate with102* one divide.103*/104u64 nsec = (u64)jiffies * TICK_NSEC;105u32 rem;106value->tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);107value->tv_usec = rem / NSEC_PER_USEC;108}109110#define ELF_CORE_EFLAGS EF_MIPS_ABI2111112MODULE_DESCRIPTION("Binary format loader for compatibility with n32 Linux/MIPS binaries");113MODULE_AUTHOR("Ralf Baechle ([email protected])");114115#undef MODULE_DESCRIPTION116#undef MODULE_AUTHOR117118#undef TASK_SIZE119#define TASK_SIZE TASK_SIZE32120121#include "../../../fs/binfmt_elf.c"122123124