aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/sparc64/Kconfig8
-rw-r--r--arch/sparc64/kernel/Makefile1
-rw-r--r--arch/sparc64/kernel/binfmt_elf32.c136
-rw-r--r--include/asm-sparc64/elf.h59
4 files changed, 52 insertions, 152 deletions
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index a8c6366f05a1..565404ddcdc4 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -380,13 +380,7 @@ config COMPAT
380 bool 380 bool
381 depends on SPARC32_COMPAT 381 depends on SPARC32_COMPAT
382 default y 382 default y
383 383 select COMPAT_BINFMT_ELF
384config BINFMT_ELF32
385 bool "Kernel support for 32-bit ELF binaries"
386 depends on SPARC32_COMPAT
387 help
388 This allows you to run 32-bit Linux/ELF binaries on your Ultra.
389 Everybody wants this; say Y.
390 384
391config BINFMT_AOUT32 385config BINFMT_AOUT32
392 bool "Kernel support for 32-bit (ie. SunOS) a.out binaries" 386 bool "Kernel support for 32-bit (ie. SunOS) a.out binaries"
diff --git a/arch/sparc64/kernel/Makefile b/arch/sparc64/kernel/Makefile
index 4b78b24ef413..1bf5b187de49 100644
--- a/arch/sparc64/kernel/Makefile
+++ b/arch/sparc64/kernel/Makefile
@@ -21,7 +21,6 @@ obj-$(CONFIG_PCI) += ebus.o isa.o pci_common.o \
21obj-$(CONFIG_PCI_MSI) += pci_msi.o 21obj-$(CONFIG_PCI_MSI) += pci_msi.o
22obj-$(CONFIG_SMP) += smp.o trampoline.o hvtramp.o 22obj-$(CONFIG_SMP) += smp.o trampoline.o hvtramp.o
23obj-$(CONFIG_SPARC32_COMPAT) += sys32.o sys_sparc32.o signal32.o 23obj-$(CONFIG_SPARC32_COMPAT) += sys32.o sys_sparc32.o signal32.o
24obj-$(CONFIG_BINFMT_ELF32) += binfmt_elf32.o
25obj-$(CONFIG_BINFMT_AOUT32) += binfmt_aout32.o 24obj-$(CONFIG_BINFMT_AOUT32) += binfmt_aout32.o
26obj-$(CONFIG_MODULES) += module.o 25obj-$(CONFIG_MODULES) += module.o
27obj-$(CONFIG_US3_FREQ) += us3_cpufreq.o 26obj-$(CONFIG_US3_FREQ) += us3_cpufreq.o
diff --git a/arch/sparc64/kernel/binfmt_elf32.c b/arch/sparc64/kernel/binfmt_elf32.c
deleted file mode 100644
index d141300e76b7..000000000000
--- a/arch/sparc64/kernel/binfmt_elf32.c
+++ /dev/null
@@ -1,136 +0,0 @@
1/*
2 * binfmt_elf32.c: Support 32-bit Sparc ELF binaries on Ultra.
3 *
4 * Copyright (C) 1995, 1996, 1997, 1998, 2008 David S. Miller (davem@davemloft.net)
5 * Copyright (C) 1995, 1996, 1997, 1998 Jakub Jelinek (jj@ultra.linux.cz)
6 */
7
8#define ELF_ARCH EM_SPARC
9#define ELF_CLASS ELFCLASS32
10#define ELF_DATA ELFDATA2MSB;
11
12/* Format is:
13 * G0 --> G7
14 * O0 --> O7
15 * L0 --> L7
16 * I0 --> I7
17 * PSR, PC, nPC, Y, WIM, TBR
18 */
19typedef unsigned int elf_greg_t;
20#define ELF_NGREG 38
21typedef elf_greg_t elf_gregset_t[ELF_NGREG];
22
23typedef struct {
24 union {
25 unsigned int pr_regs[32];
26 unsigned long pr_dregs[16];
27 } pr_fr;
28 unsigned int __unused;
29 unsigned int pr_fsr;
30 unsigned char pr_qcnt;
31 unsigned char pr_q_entrysize;
32 unsigned char pr_en;
33 unsigned int pr_q[64];
34} elf_fpregset_t;
35
36/* UltraSparc extensions. Still unused, but will be eventually. */
37typedef struct {
38 unsigned int pr_type;
39 unsigned int pr_align;
40 union {
41 struct {
42 union {
43 unsigned int pr_regs[32];
44 unsigned long pr_dregs[16];
45 long double pr_qregs[8];
46 } pr_xfr;
47 } pr_v8p;
48 unsigned int pr_xfsr;
49 unsigned int pr_fprs;
50 unsigned int pr_xg[8];
51 unsigned int pr_xo[8];
52 unsigned long pr_tstate;
53 unsigned int pr_filler[8];
54 } pr_un;
55} elf_xregset_t;
56
57#define elf_check_arch(x) (((x)->e_machine == EM_SPARC) || ((x)->e_machine == EM_SPARC32PLUS))
58
59#define ELF_ET_DYN_BASE 0x70000000
60
61
62#include <asm/processor.h>
63#include <linux/module.h>
64#include <linux/elfcore.h>
65#include <linux/compat.h>
66
67#define elf_prstatus elf_prstatus32
68struct elf_prstatus32
69{
70 struct elf_siginfo pr_info; /* Info associated with signal */
71 short pr_cursig; /* Current signal */
72 unsigned int pr_sigpend; /* Set of pending signals */
73 unsigned int pr_sighold; /* Set of held signals */
74 pid_t pr_pid;
75 pid_t pr_ppid;
76 pid_t pr_pgrp;
77 pid_t pr_sid;
78 struct compat_timeval pr_utime; /* User time */
79 struct compat_timeval pr_stime; /* System time */
80 struct compat_timeval pr_cutime; /* Cumulative user time */
81 struct compat_timeval pr_cstime; /* Cumulative system time */
82 elf_gregset_t pr_reg; /* GP registers */
83 int pr_fpvalid; /* True if math co-processor being used. */
84};
85
86#define elf_prpsinfo elf_prpsinfo32
87struct elf_prpsinfo32
88{
89 char pr_state; /* numeric process state */
90 char pr_sname; /* char for pr_state */
91 char pr_zomb; /* zombie */
92 char pr_nice; /* nice val */
93 unsigned int pr_flag; /* flags */
94 u16 pr_uid;
95 u16 pr_gid;
96 pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
97 /* Lots missing */
98 char pr_fname[16]; /* filename of executable */
99 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
100};
101
102#include <linux/highuid.h>
103
104#undef NEW_TO_OLD_UID
105#undef NEW_TO_OLD_GID
106#define NEW_TO_OLD_UID(uid) ((uid) > 65535) ? (u16)overflowuid : (u16)(uid)
107#define NEW_TO_OLD_GID(gid) ((gid) > 65535) ? (u16)overflowgid : (u16)(gid)
108
109#include <linux/time.h>
110
111#undef cputime_to_timeval
112#define cputime_to_timeval cputime_to_compat_timeval
113static inline void
114cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
115{
116 unsigned long jiffies = cputime_to_jiffies(cputime);
117 value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
118 value->tv_sec = jiffies / HZ;
119}
120
121#undef start_thread
122#define start_thread start_thread32
123#define init_elf_binfmt init_elf32_binfmt
124
125MODULE_DESCRIPTION("Binary format loader for compatibility with 32bit SparcLinux binaries on the Ultra");
126MODULE_AUTHOR("Eric Youngdale, David S. Miller, Jakub Jelinek");
127
128#undef MODULE_DESCRIPTION
129#undef MODULE_AUTHOR
130
131#include <asm/a.out.h>
132
133#undef TASK_SIZE
134#define TASK_SIZE STACK_TOP32
135
136#include "../../../fs/binfmt_elf.c"
diff --git a/include/asm-sparc64/elf.h b/include/asm-sparc64/elf.h
index 272a65873f2e..11c8e68d712a 100644
--- a/include/asm-sparc64/elf.h
+++ b/include/asm-sparc64/elf.h
@@ -75,7 +75,6 @@
75/* 75/*
76 * These are used to set parameters in the core dumps. 76 * These are used to set parameters in the core dumps.
77 */ 77 */
78#ifndef ELF_ARCH
79#define ELF_ARCH EM_SPARCV9 78#define ELF_ARCH EM_SPARCV9
80#define ELF_CLASS ELFCLASS64 79#define ELF_CLASS ELFCLASS64
81#define ELF_DATA ELFDATA2MSB 80#define ELF_DATA ELFDATA2MSB
@@ -100,14 +99,59 @@ typedef struct {
100 unsigned long pr_gsr; 99 unsigned long pr_gsr;
101 unsigned long pr_fprs; 100 unsigned long pr_fprs;
102} elf_fpregset_t; 101} elf_fpregset_t;
103#endif 102
103/* Format of 32-bit elf_gregset_t is:
104 * G0 --> G7
105 * O0 --> O7
106 * L0 --> L7
107 * I0 --> I7
108 * PSR, PC, nPC, Y, WIM, TBR
109 */
110typedef unsigned int compat_elf_greg_t;
111#define COMPAT_ELF_NGREG 38
112typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
113
114typedef struct {
115 union {
116 unsigned int pr_regs[32];
117 unsigned long pr_dregs[16];
118 } pr_fr;
119 unsigned int __unused;
120 unsigned int pr_fsr;
121 unsigned char pr_qcnt;
122 unsigned char pr_q_entrysize;
123 unsigned char pr_en;
124 unsigned int pr_q[64];
125} compat_elf_fpregset_t;
126
127/* UltraSparc extensions. Still unused, but will be eventually. */
128typedef struct {
129 unsigned int pr_type;
130 unsigned int pr_align;
131 union {
132 struct {
133 union {
134 unsigned int pr_regs[32];
135 unsigned long pr_dregs[16];
136 long double pr_qregs[8];
137 } pr_xfr;
138 } pr_v8p;
139 unsigned int pr_xfsr;
140 unsigned int pr_fprs;
141 unsigned int pr_xg[8];
142 unsigned int pr_xo[8];
143 unsigned long pr_tstate;
144 unsigned int pr_filler[8];
145 } pr_un;
146} elf_xregset_t;
104 147
105/* 148/*
106 * This is used to ensure we don't load something for the wrong architecture. 149 * This is used to ensure we don't load something for the wrong architecture.
107 */ 150 */
108#ifndef elf_check_arch 151#define elf_check_arch(x) ((x)->e_machine == ELF_ARCH)
109#define elf_check_arch(x) ((x)->e_machine == ELF_ARCH) /* Might be EM_SPARCV9 or EM_SPARC */ 152#define compat_elf_check_arch(x) ((x)->e_machine == EM_SPARC || \
110#endif 153 (x)->e_machine == EM_SPARC32PLUS)
154#define compat_start_thread start_thread32
111 155
112#define USE_ELF_CORE_DUMP 156#define USE_ELF_CORE_DUMP
113#define ELF_EXEC_PAGESIZE PAGE_SIZE 157#define ELF_EXEC_PAGESIZE PAGE_SIZE
@@ -117,9 +161,8 @@ typedef struct {
117 the loader. We need to make sure that it is out of the way of the program 161 the loader. We need to make sure that it is out of the way of the program
118 that it will "exec", and that there is sufficient room for the brk. */ 162 that it will "exec", and that there is sufficient room for the brk. */
119 163
120#ifndef ELF_ET_DYN_BASE 164#define ELF_ET_DYN_BASE 0x0000010000000000UL
121#define ELF_ET_DYN_BASE 0x0000010000000000UL 165#define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
122#endif
123 166
124 167
125/* This yields a mask that user programs can use to figure out what 168/* This yields a mask that user programs can use to figure out what