2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Support for o32 Linux/MIPS ELF binaries.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999, 2001 Ralf Baechle
|
|
|
|
* Copyright (C) 1999, 2001 Silicon Graphics, Inc.
|
|
|
|
*
|
|
|
|
* Heavily inspired by the 32-bit Sparc compat code which is
|
|
|
|
* Copyright (C) 1995, 1996, 1997, 1998 David S. Miller (davem@redhat.com)
|
2013-01-22 19:59:30 +08:00
|
|
|
* Copyright (C) 1995, 1996, 1997, 1998 Jakub Jelinek (jj@ultra.linux.cz)
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define ELF_ARCH EM_MIPS
|
|
|
|
#define ELF_CLASS ELFCLASS32
|
|
|
|
#ifdef __MIPSEB__
|
|
|
|
#define ELF_DATA ELFDATA2MSB;
|
|
|
|
#else /* __MIPSEL__ */
|
|
|
|
#define ELF_DATA ELFDATA2LSB;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* ELF register definitions */
|
|
|
|
#define ELF_NGREG 45
|
|
|
|
#define ELF_NFPREG 33
|
|
|
|
|
|
|
|
typedef unsigned int elf_greg_t;
|
|
|
|
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
|
|
|
|
|
|
|
|
typedef double elf_fpreg_t;
|
|
|
|
typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
|
|
|
|
|
2013-11-22 21:12:07 +08:00
|
|
|
/*
|
|
|
|
* In order to be sure that we don't attempt to execute an O32 binary which
|
|
|
|
* requires 64 bit FP (FR=1) on a system which does not support it we refuse
|
|
|
|
* to execute any binary which has bits specified by the following macro set
|
|
|
|
* in its ELF header flags.
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_MIPS_O32_FP64_SUPPORT
|
|
|
|
# define __MIPS_O32_FP64_MUST_BE_ZERO 0
|
|
|
|
#else
|
|
|
|
# define __MIPS_O32_FP64_MUST_BE_ZERO EF_MIPS_FP64
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* This is used to ensure we don't load something for the wrong architecture.
|
|
|
|
*/
|
|
|
|
#define elf_check_arch(hdr) \
|
|
|
|
({ \
|
|
|
|
int __res = 1; \
|
|
|
|
struct elfhdr *__h = (hdr); \
|
|
|
|
\
|
|
|
|
if (__h->e_machine != EM_MIPS) \
|
|
|
|
__res = 0; \
|
|
|
|
if (__h->e_ident[EI_CLASS] != ELFCLASS32) \
|
|
|
|
__res = 0; \
|
|
|
|
if ((__h->e_flags & EF_MIPS_ABI2) != 0) \
|
|
|
|
__res = 0; \
|
|
|
|
if (((__h->e_flags & EF_MIPS_ABI) != 0) && \
|
|
|
|
((__h->e_flags & EF_MIPS_ABI) != EF_MIPS_ABI_O32)) \
|
2013-11-22 21:12:07 +08:00
|
|
|
__res = 0; \
|
|
|
|
if (__h->e_flags & __MIPS_O32_FP64_MUST_BE_ZERO) \
|
2005-04-17 06:20:36 +08:00
|
|
|
__res = 0; \
|
|
|
|
\
|
|
|
|
__res; \
|
|
|
|
})
|
|
|
|
|
2012-11-22 10:34:03 +08:00
|
|
|
#ifdef CONFIG_KVM_GUEST
|
|
|
|
#define TASK32_SIZE 0x3fff8000UL
|
|
|
|
#else
|
2005-04-17 06:20:36 +08:00
|
|
|
#define TASK32_SIZE 0x7fff8000UL
|
2012-11-22 10:34:03 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
#undef ELF_ET_DYN_BASE
|
2013-01-22 19:59:30 +08:00
|
|
|
#define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <asm/processor.h>
|
2009-07-01 09:35:39 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/elfcore.h>
|
|
|
|
#include <linux/compat.h>
|
2008-05-01 19:34:31 +08:00
|
|
|
#include <linux/math64.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define elf_prstatus elf_prstatus32
|
|
|
|
struct elf_prstatus32
|
|
|
|
{
|
|
|
|
struct elf_siginfo pr_info; /* Info associated with signal */
|
|
|
|
short pr_cursig; /* Current signal */
|
|
|
|
unsigned int pr_sigpend; /* Set of pending signals */
|
|
|
|
unsigned int pr_sighold; /* Set of held signals */
|
|
|
|
pid_t pr_pid;
|
|
|
|
pid_t pr_ppid;
|
|
|
|
pid_t pr_pgrp;
|
|
|
|
pid_t pr_sid;
|
2013-01-22 19:59:30 +08:00
|
|
|
struct compat_timeval pr_utime; /* User time */
|
|
|
|
struct compat_timeval pr_stime; /* System time */
|
2005-04-17 06:20:36 +08:00
|
|
|
struct compat_timeval pr_cutime;/* Cumulative user time */
|
|
|
|
struct compat_timeval pr_cstime;/* Cumulative system time */
|
|
|
|
elf_gregset_t pr_reg; /* GP registers */
|
|
|
|
int pr_fpvalid; /* True if math co-processor being used. */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define elf_prpsinfo elf_prpsinfo32
|
|
|
|
struct elf_prpsinfo32
|
|
|
|
{
|
|
|
|
char pr_state; /* numeric process state */
|
|
|
|
char pr_sname; /* char for pr_state */
|
|
|
|
char pr_zomb; /* zombie */
|
|
|
|
char pr_nice; /* nice val */
|
|
|
|
unsigned int pr_flag; /* flags */
|
|
|
|
__kernel_uid_t pr_uid;
|
|
|
|
__kernel_gid_t pr_gid;
|
|
|
|
pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
|
|
|
|
/* Lots missing */
|
|
|
|
char pr_fname[16]; /* filename of executable */
|
2013-01-22 19:59:30 +08:00
|
|
|
char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define elf_caddr_t u32
|
|
|
|
#define init_elf_binfmt init_elf32_binfmt
|
|
|
|
|
|
|
|
#define jiffies_to_timeval jiffies_to_compat_timeval
|
2005-01-26 10:21:06 +08:00
|
|
|
static inline void
|
2005-04-17 06:20:36 +08:00
|
|
|
jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
|
|
|
|
{
|
|
|
|
/*
|
2008-02-03 22:54:53 +08:00
|
|
|
* Convert jiffies to nanoseconds and separate with
|
2005-04-17 06:20:36 +08:00
|
|
|
* one divide.
|
|
|
|
*/
|
2005-09-04 06:56:17 +08:00
|
|
|
u64 nsec = (u64)jiffies * TICK_NSEC;
|
2008-05-01 19:34:31 +08:00
|
|
|
u32 rem;
|
|
|
|
value->tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
|
2006-02-21 00:25:06 +08:00
|
|
|
value->tv_usec = rem / NSEC_PER_USEC;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("Binary format loader for compatibility with o32 Linux/MIPS binaries");
|
|
|
|
MODULE_AUTHOR("Ralf Baechle (ralf@linux-mips.org)");
|
|
|
|
|
|
|
|
#undef MODULE_DESCRIPTION
|
|
|
|
#undef MODULE_AUTHOR
|
|
|
|
|
2005-01-26 10:22:22 +08:00
|
|
|
#undef TASK_SIZE
|
|
|
|
#define TASK_SIZE TASK_SIZE32
|
|
|
|
|
MIPS: Compat: Fix cputime_to_timeval() arguments in compat binfmt_elf.
cputime_to_timeval() takes a struct timeval *as its second argument but
a struct compat_timeval * will be passed resulting in:
CC arch/mips/kernel/binfmt_elfn32.o
In file included from arch/mips/kernel/binfmt_elfn32.c:122:0:
arch/mips/kernel/../../../fs/binfmt_elf.c: In function ‘fill_prstatus’:
arch/mips/kernel/../../../fs/binfmt_elf.c:1330:3: warning: passing argument 2 of ‘cputime_to_timeval’ from incompatible pointer type [enabled by default]
In file included from include/asm-generic/cputime.h:12:0,
from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/cputime.h:4,
from include/linux/sched.h:28,
from include/linux/ptrace.h:5,
from include/uapi/linux/elfcore.h:7,
from include/linux/elfcore.h:7,
from arch/mips/kernel/binfmt_elfn32.c:55:
include/asm-generic/cputime_nsecs.h:92:91: note: expected ‘struct timeval *’ but argument is of type ‘struct compat_timeval *’
In file included from arch/mips/kernel/binfmt_elfn32.c:122:0:
arch/mips/kernel/../../../fs/binfmt_elf.c:1331:3: warning: passing argument 2 of ‘cputime_to_timeval’ from incompatible pointer type [enabled by default]
In file included from include/asm-generic/cputime.h:12:0,
from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/cputime.h:4,
from include/linux/sched.h:28,
from include/linux/ptrace.h:5,
from include/uapi/linux/elfcore.h:7,
from include/linux/elfcore.h:7,
from arch/mips/kernel/binfmt_elfn32.c:55:
include/asm-generic/cputime_nsecs.h:92:91: note: expected ‘struct timeval *’ but argument is of type ‘struct compat_timeval *’
In file included from arch/mips/kernel/binfmt_elfn32.c:122:0:
arch/mips/kernel/../../../fs/binfmt_elf.c:1336:3: warning: passing argument 2 of ‘cputime_to_timeval’ from incompatible pointer type [enabled by default]
In file included from include/asm-generic/cputime.h:12:0,
from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/cputime.h:4,
from include/linux/sched.h:28,
from include/linux/ptrace.h:5,
from include/uapi/linux/elfcore.h:7,
from include/linux/elfcore.h:7,
from arch/mips/kernel/binfmt_elfn32.c:55:
include/asm-generic/cputime_nsecs.h:92:91: note: expected ‘struct timeval *’ but argument is of type ‘struct compat_timeval *’
In file included from arch/mips/kernel/binfmt_elfn32.c:122:0:
arch/mips/kernel/../../../fs/binfmt_elf.c:1337:3: warning: passing argument 2 of ‘cputime_to_timeval’ from incompatible pointer type [enabled by default]
In file included from include/asm-generic/cputime.h:12:0,
from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/cputime.h:4,
from include/linux/sched.h:28,
from include/linux/ptrace.h:5,
from include/uapi/linux/elfcore.h:7,
from include/linux/elfcore.h:7,
from arch/mips/kernel/binfmt_elfn32.c:55:
include/asm-generic/cputime_nsecs.h:92:91: note: expected ‘struct timeval *’ but argument is of type ‘struct compat_timeval *’
In file included from arch/mips/kernel/binfmt_elfn32.c:122:0:
arch/mips/kernel/../../../fs/binfmt_elf.c:1339:2: warning: passing argument 2 of ‘cputime_to_timeval’ from incompatible pointer type [enabled by default]
In file included from include/asm-generic/cputime.h:12:0,
from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/cputime.h:4,
from include/linux/sched.h:28,
from include/linux/ptrace.h:5,
from include/uapi/linux/elfcore.h:7,
from include/linux/elfcore.h:7,
from arch/mips/kernel/binfmt_elfn32.c:55:
include/asm-generic/cputime_nsecs.h:92:91: note: expected ‘struct timeval *’ but argument is of type ‘struct compat_timeval *’
In file included from arch/mips/kernel/binfmt_elfn32.c:122:0:
arch/mips/kernel/../../../fs/binfmt_elf.c:1340:2: warning: passing argument 2 of ‘cputime_to_timeval’ from incompatible pointer type [enabled by default]
In file included from include/asm-generic/cputime.h:12:0,
from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/cputime.h:4,
from include/linux/sched.h:28,
from include/linux/ptrace.h:5,
from include/uapi/linux/elfcore.h:7,
from include/linux/elfcore.h:7,
from arch/mips/kernel/binfmt_elfn32.c:55:
include/asm-generic/cputime_nsecs.h:92:91: note: expected ‘struct timeval *’ but argument is of type ‘struct compat_timeval *’
AS arch/mips/kernel/scall64-n32.o
CC arch/mips/kernel/signal_n32.o
CC arch/mips/kernel/binfmt_elfo32.o
In file included from arch/mips/kernel/binfmt_elfo32.c:165:0:
arch/mips/kernel/../../../fs/binfmt_elf.c: In function ‘fill_prstatus’:
arch/mips/kernel/../../../fs/binfmt_elf.c:1330:3: warning: passing argument 2 of ‘cputime_to_timeval’ from incompatible pointer type [enabled by default]
In file included from include/asm-generic/cputime.h:12:0,
from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/cputime.h:4,
from include/linux/sched.h:28,
from include/linux/ptrace.h:5,
from include/uapi/linux/elfcore.h:7,
from include/linux/elfcore.h:7,
from arch/mips/kernel/binfmt_elfo32.c:78:
include/asm-generic/cputime_nsecs.h:92:91: note: expected ‘struct timeval *’ but argument is of type ‘struct compat_timeval *’
In file included from arch/mips/kernel/binfmt_elfo32.c:165:0:
arch/mips/kernel/../../../fs/binfmt_elf.c:1331:3: warning: passing argument 2 of ‘cputime_to_timeval’ from incompatible pointer type [enabled by default]
In file included from include/asm-generic/cputime.h:12:0,
from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/cputime.h:4,
from include/linux/sched.h:28,
from include/linux/ptrace.h:5,
from include/uapi/linux/elfcore.h:7,
from include/linux/elfcore.h:7,
from arch/mips/kernel/binfmt_elfo32.c:78:
include/asm-generic/cputime_nsecs.h:92:91: note: expected ‘struct timeval *’ but argument is of type ‘struct compat_timeval *’
In file included from arch/mips/kernel/binfmt_elfo32.c:165:0:
arch/mips/kernel/../../../fs/binfmt_elf.c:1336:3: warning: passing argument 2 of ‘cputime_to_timeval’ from incompatible pointer type [enabled by default]
In file included from include/asm-generic/cputime.h:12:0,
from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/cputime.h:4,
from include/linux/sched.h:28,
from include/linux/ptrace.h:5,
from include/uapi/linux/elfcore.h:7,
from include/linux/elfcore.h:7,
from arch/mips/kernel/binfmt_elfo32.c:78:
include/asm-generic/cputime_nsecs.h:92:91: note: expected ‘struct timeval *’ but argument is of type ‘struct compat_timeval *’
In file included from arch/mips/kernel/binfmt_elfo32.c:165:0:
arch/mips/kernel/../../../fs/binfmt_elf.c:1337:3: warning: passing argument 2 of ‘cputime_to_timeval’ from incompatible pointer type [enabled by default]
In file included from include/asm-generic/cputime.h:12:0,
from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/cputime.h:4,
from include/linux/sched.h:28,
from include/linux/ptrace.h:5,
from include/uapi/linux/elfcore.h:7,
from include/linux/elfcore.h:7,
from arch/mips/kernel/binfmt_elfo32.c:78:
include/asm-generic/cputime_nsecs.h:92:91: note: expected ‘struct timeval *’ but argument is of type ‘struct compat_timeval *’
In file included from arch/mips/kernel/binfmt_elfo32.c:165:0:
arch/mips/kernel/../../../fs/binfmt_elf.c:1339:2: warning: passing argument 2 of ‘cputime_to_timeval’ from incompatible pointer type [enabled by default]
In file included from include/asm-generic/cputime.h:12:0,
from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/cputime.h:4,
from include/linux/sched.h:28,
from include/linux/ptrace.h:5,
from include/uapi/linux/elfcore.h:7,
from include/linux/elfcore.h:7,
from arch/mips/kernel/binfmt_elfo32.c:78:
include/asm-generic/cputime_nsecs.h:92:91: note: expected ‘struct timeval *’ but argument is of type ‘struct compat_timeval *’
In file included from arch/mips/kernel/binfmt_elfo32.c:165:0:
arch/mips/kernel/../../../fs/binfmt_elf.c:1340:2: warning: passing argument 2 of ‘cputime_to_timeval’ from incompatible pointer type [enabled by default]
In file included from include/asm-generic/cputime.h:12:0,
from /home/ralf/src/linux/linux-mips/arch/mips/include/asm/cputime.h:4,
from include/linux/sched.h:28,
from include/linux/ptrace.h:5,
from include/uapi/linux/elfcore.h:7,
from include/linux/elfcore.h:7,
from arch/mips/kernel/binfmt_elfo32.c:78:
include/asm-generic/cputime_nsecs.h:92:91: note: expected ‘struct timeval *’ but argument is of type ‘struct compat_timeval *’
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2013-05-29 06:48:10 +08:00
|
|
|
#undef cputime_to_timeval
|
|
|
|
#define cputime_to_timeval cputime_to_compat_timeval
|
|
|
|
static __inline__ void
|
|
|
|
cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
|
|
|
|
{
|
|
|
|
unsigned long jiffies = cputime_to_jiffies(cputime);
|
|
|
|
|
|
|
|
value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
|
|
|
|
value->tv_sec = jiffies / HZ;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include "../../../fs/binfmt_elf.c"
|