2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Support for o32 Linux/MIPS ELF binaries.
|
2016-08-22 02:58:13 +07:00
|
|
|
* Author: Ralf Baechle (ralf@linux-mips.org)
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
|
|
|
* 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 18:59:30 +07:00
|
|
|
* Copyright (C) 1995, 1996, 1997, 1998 Jakub Jelinek (jj@ultra.linux.cz)
|
2005-04-17 05:20:36 +07: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];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is used to ensure we don't load something for the wrong architecture.
|
|
|
|
*/
|
2016-05-13 13:21:40 +07:00
|
|
|
#define elf_check_arch elfo32_check_arch
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-11-22 09:34:03 +07:00
|
|
|
#ifdef CONFIG_KVM_GUEST
|
|
|
|
#define TASK32_SIZE 0x3fff8000UL
|
|
|
|
#else
|
2005-04-17 05:20:36 +07:00
|
|
|
#define TASK32_SIZE 0x7fff8000UL
|
2012-11-22 09:34:03 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
#undef ELF_ET_DYN_BASE
|
2013-01-22 18:59:30 +07:00
|
|
|
#define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#include <asm/processor.h>
|
2009-07-01 08:35:39 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/elfcore.h>
|
|
|
|
#include <linux/compat.h>
|
2008-05-01 18:34:31 +07:00
|
|
|
#include <linux/math64.h>
|
2005-04-17 05:20:36 +07: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 18:59:30 +07:00
|
|
|
struct compat_timeval pr_utime; /* User time */
|
|
|
|
struct compat_timeval pr_stime; /* System time */
|
2005-04-17 05:20:36 +07: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 18:59:30 +07:00
|
|
|
char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define elf_caddr_t u32
|
|
|
|
#define init_elf_binfmt init_elf32_binfmt
|
|
|
|
|
|
|
|
#define jiffies_to_timeval jiffies_to_compat_timeval
|
2005-01-26 09:21:06 +07:00
|
|
|
static inline void
|
2005-04-17 05:20:36 +07:00
|
|
|
jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
|
|
|
|
{
|
|
|
|
/*
|
2008-02-03 21:54:53 +07:00
|
|
|
* Convert jiffies to nanoseconds and separate with
|
2005-04-17 05:20:36 +07:00
|
|
|
* one divide.
|
|
|
|
*/
|
2005-09-04 05:56:17 +07:00
|
|
|
u64 nsec = (u64)jiffies * TICK_NSEC;
|
2008-05-01 18:34:31 +07:00
|
|
|
u32 rem;
|
|
|
|
value->tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
|
2006-02-20 23:25:06 +07:00
|
|
|
value->tv_usec = rem / NSEC_PER_USEC;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-01-26 09:22:22 +07:00
|
|
|
#undef TASK_SIZE
|
|
|
|
#define TASK_SIZE TASK_SIZE32
|
|
|
|
|
2017-01-31 10:09:27 +07:00
|
|
|
#undef ns_to_timeval
|
|
|
|
#define ns_to_timeval ns_to_compat_timeval
|
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 05:48:10 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#include "../../../fs/binfmt_elf.c"
|