aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHelge Deller <deller@gmx.de>2015-02-17 09:41:51 -0500
committerHelge Deller <deller@gmx.de>2015-02-17 10:29:36 -0500
commit35e88d5c22e1916c819b5a8756aed2f09a4aba18 (patch)
treef719b3b7f1e0de1c6ff58d72f6c8a8477c6d4831
parent3d66b810eb7b6ad2e3eb47f03f28c3aba239f508 (diff)
fs/binfmt_som: Drop kernel support for HP-UX SOM binaries
The parisc arch has been the only user of HP-UX SOM binaries. Support for HP-UX executables was never finished and since we now drop support for the HP-UX compat layer anyway, it does not makes sense to keep the BINFMT_SOM support. Cc: linux-fsdevel@vger.kernel.org Cc: linux-parisc@vger.kernel.org Signed-off-by: Helge Deller <deller@gmx.de>
-rw-r--r--fs/Kconfig.binfmt7
-rw-r--r--fs/Makefile1
-rw-r--r--fs/binfmt_som.c299
-rw-r--r--include/uapi/linux/Kbuild1
-rw-r--r--include/uapi/linux/som.h154
5 files changed, 0 insertions, 462 deletions
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
index c055d56ec63d..270c48148f79 100644
--- a/fs/Kconfig.binfmt
+++ b/fs/Kconfig.binfmt
@@ -149,13 +149,6 @@ config BINFMT_EM86
149 later load the module when you want to use a Linux/Intel binary. The 149 later load the module when you want to use a Linux/Intel binary. The
150 module will be called binfmt_em86. If unsure, say Y. 150 module will be called binfmt_em86. If unsure, say Y.
151 151
152config BINFMT_SOM
153 tristate "Kernel support for SOM binaries"
154 depends on PARISC && HPUX
155 help
156 SOM is a binary executable format inherited from HP/UX. Say
157 Y here to be able to load and execute SOM binaries directly.
158
159config BINFMT_MISC 152config BINFMT_MISC
160 tristate "Kernel support for MISC binaries" 153 tristate "Kernel support for MISC binaries"
161 ---help--- 154 ---help---
diff --git a/fs/Makefile b/fs/Makefile
index bedff48e8fdc..b7e0cfe3af2f 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -37,7 +37,6 @@ obj-$(CONFIG_BINFMT_SCRIPT) += binfmt_script.o
37obj-$(CONFIG_BINFMT_ELF) += binfmt_elf.o 37obj-$(CONFIG_BINFMT_ELF) += binfmt_elf.o
38obj-$(CONFIG_COMPAT_BINFMT_ELF) += compat_binfmt_elf.o 38obj-$(CONFIG_COMPAT_BINFMT_ELF) += compat_binfmt_elf.o
39obj-$(CONFIG_BINFMT_ELF_FDPIC) += binfmt_elf_fdpic.o 39obj-$(CONFIG_BINFMT_ELF_FDPIC) += binfmt_elf_fdpic.o
40obj-$(CONFIG_BINFMT_SOM) += binfmt_som.o
41obj-$(CONFIG_BINFMT_FLAT) += binfmt_flat.o 40obj-$(CONFIG_BINFMT_FLAT) += binfmt_flat.o
42 41
43obj-$(CONFIG_FS_MBCACHE) += mbcache.o 42obj-$(CONFIG_FS_MBCACHE) += mbcache.o
diff --git a/fs/binfmt_som.c b/fs/binfmt_som.c
deleted file mode 100644
index 4e00ed68d4a6..000000000000
--- a/fs/binfmt_som.c
+++ /dev/null
@@ -1,299 +0,0 @@
1/*
2 * linux/fs/binfmt_som.c
3 *
4 * These are the functions used to load SOM format executables as used
5 * by HP-UX.
6 *
7 * Copyright 1999 Matthew Wilcox <willy@bofh.ai>
8 * based on binfmt_elf which is
9 * Copyright 1993, 1994: Eric Youngdale (ericy@cais.com).
10 */
11
12#include <linux/module.h>
13
14#include <linux/fs.h>
15#include <linux/stat.h>
16#include <linux/sched.h>
17#include <linux/mm.h>
18#include <linux/mman.h>
19#include <linux/errno.h>
20#include <linux/signal.h>
21#include <linux/binfmts.h>
22#include <linux/som.h>
23#include <linux/string.h>
24#include <linux/file.h>
25#include <linux/fcntl.h>
26#include <linux/ptrace.h>
27#include <linux/slab.h>
28#include <linux/shm.h>
29#include <linux/personality.h>
30#include <linux/init.h>
31
32#include <asm/uaccess.h>
33#include <asm/pgtable.h>
34
35
36#include <linux/elf.h>
37
38static int load_som_binary(struct linux_binprm * bprm);
39static int load_som_library(struct file *);
40
41/*
42 * If we don't support core dumping, then supply a NULL so we
43 * don't even try.
44 */
45#if 0
46static int som_core_dump(struct coredump_params *cprm);
47#else
48#define som_core_dump NULL
49#endif
50
51#define SOM_PAGESTART(_v) ((_v) & ~(unsigned long)(SOM_PAGESIZE-1))
52#define SOM_PAGEOFFSET(_v) ((_v) & (SOM_PAGESIZE-1))
53#define SOM_PAGEALIGN(_v) (((_v) + SOM_PAGESIZE - 1) & ~(SOM_PAGESIZE - 1))
54
55static struct linux_binfmt som_format = {
56 .module = THIS_MODULE,
57 .load_binary = load_som_binary,
58 .load_shlib = load_som_library,
59 .core_dump = som_core_dump,
60 .min_coredump = SOM_PAGESIZE
61};
62
63/*
64 * create_som_tables() parses the env- and arg-strings in new user
65 * memory and creates the pointer tables from them, and puts their
66 * addresses on the "stack", returning the new stack pointer value.
67 */
68static void create_som_tables(struct linux_binprm *bprm)
69{
70 char **argv, **envp;
71 int argc = bprm->argc;
72 int envc = bprm->envc;
73 unsigned long p;
74 unsigned long *sp;
75
76 /* Word-align the stack pointer */
77 sp = (unsigned long *)((bprm->p + 3) & ~3);
78
79 envp = (char **) sp;
80 sp += envc + 1;
81 argv = (char **) sp;
82 sp += argc + 1;
83
84 __put_user((unsigned long) envp,++sp);
85 __put_user((unsigned long) argv,++sp);
86
87 __put_user(argc, ++sp);
88
89 bprm->p = (unsigned long) sp;
90
91 p = current->mm->arg_start;
92 while (argc-- > 0) {
93 __put_user((char *)p,argv++);
94 p += strlen_user((char *)p);
95 }
96 __put_user(NULL, argv);
97 current->mm->arg_end = current->mm->env_start = p;
98 while (envc-- > 0) {
99 __put_user((char *)p,envp++);
100 p += strlen_user((char *)p);
101 }
102 __put_user(NULL, envp);
103 current->mm->env_end = p;
104}
105
106static int check_som_header(struct som_hdr *som_ex)
107{
108 int *buf = (int *)som_ex;
109 int i, ck;
110
111 if (som_ex->system_id != SOM_SID_PARISC_1_0 &&
112 som_ex->system_id != SOM_SID_PARISC_1_1 &&
113 som_ex->system_id != SOM_SID_PARISC_2_0)
114 return -ENOEXEC;
115
116 if (som_ex->a_magic != SOM_EXEC_NONSHARE &&
117 som_ex->a_magic != SOM_EXEC_SHARE &&
118 som_ex->a_magic != SOM_EXEC_DEMAND)
119 return -ENOEXEC;
120
121 if (som_ex->version_id != SOM_ID_OLD &&
122 som_ex->version_id != SOM_ID_NEW)
123 return -ENOEXEC;
124
125 ck = 0;
126 for (i=0; i<32; i++)
127 ck ^= buf[i];
128 if (ck != 0)
129 return -ENOEXEC;
130
131 return 0;
132}
133
134static int map_som_binary(struct file *file,
135 const struct som_exec_auxhdr *hpuxhdr)
136{
137 unsigned long code_start, code_size, data_start, data_size;
138 unsigned long bss_start, som_brk;
139 int retval;
140 int prot = PROT_READ | PROT_EXEC;
141 int flags = MAP_FIXED|MAP_PRIVATE|MAP_DENYWRITE|MAP_EXECUTABLE;
142
143 mm_segment_t old_fs = get_fs();
144 set_fs(get_ds());
145
146 code_start = SOM_PAGESTART(hpuxhdr->exec_tmem);
147 code_size = SOM_PAGEALIGN(hpuxhdr->exec_tsize);
148 current->mm->start_code = code_start;
149 current->mm->end_code = code_start + code_size;
150 retval = vm_mmap(file, code_start, code_size, prot,
151 flags, SOM_PAGESTART(hpuxhdr->exec_tfile));
152 if (retval < 0 && retval > -1024)
153 goto out;
154
155 data_start = SOM_PAGESTART(hpuxhdr->exec_dmem);
156 data_size = SOM_PAGEALIGN(hpuxhdr->exec_dsize);
157 current->mm->start_data = data_start;
158 current->mm->end_data = bss_start = data_start + data_size;
159 retval = vm_mmap(file, data_start, data_size,
160 prot | PROT_WRITE, flags,
161 SOM_PAGESTART(hpuxhdr->exec_dfile));
162 if (retval < 0 && retval > -1024)
163 goto out;
164
165 som_brk = bss_start + SOM_PAGEALIGN(hpuxhdr->exec_bsize);
166 current->mm->start_brk = current->mm->brk = som_brk;
167 retval = vm_mmap(NULL, bss_start, som_brk - bss_start,
168 prot | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, 0);
169 if (retval > 0 || retval < -1024)
170 retval = 0;
171out:
172 set_fs(old_fs);
173 return retval;
174}
175
176
177/*
178 * These are the functions used to load SOM executables and shared
179 * libraries. There is no binary dependent code anywhere else.
180 */
181
182static int
183load_som_binary(struct linux_binprm * bprm)
184{
185 int retval;
186 unsigned int size;
187 unsigned long som_entry;
188 struct som_hdr *som_ex;
189 struct som_exec_auxhdr *hpuxhdr;
190 struct pt_regs *regs = current_pt_regs();
191
192 /* Get the exec-header */
193 som_ex = (struct som_hdr *) bprm->buf;
194
195 retval = check_som_header(som_ex);
196 if (retval != 0)
197 goto out;
198
199 /* Now read in the auxiliary header information */
200
201 retval = -ENOMEM;
202 size = som_ex->aux_header_size;
203 if (size > SOM_PAGESIZE)
204 goto out;
205 hpuxhdr = kmalloc(size, GFP_KERNEL);
206 if (!hpuxhdr)
207 goto out;
208
209 retval = kernel_read(bprm->file, som_ex->aux_header_location,
210 (char *) hpuxhdr, size);
211 if (retval != size) {
212 if (retval >= 0)
213 retval = -EIO;
214 goto out_free;
215 }
216
217 /* Flush all traces of the currently running executable */
218 retval = flush_old_exec(bprm);
219 if (retval)
220 goto out_free;
221
222 /* OK, This is the point of no return */
223 current->personality = PER_HPUX;
224 setup_new_exec(bprm);
225
226 /* Set the task size for HP-UX processes such that
227 * the gateway page is outside the address space.
228 * This can be fixed later, but for now, this is much
229 * easier.
230 */
231
232 current->thread.task_size = 0xc0000000;
233
234 /* Set map base to allow enough room for hp-ux heap growth */
235
236 current->thread.map_base = 0x80000000;
237
238 retval = map_som_binary(bprm->file, hpuxhdr);
239 if (retval < 0)
240 goto out_free;
241
242 som_entry = hpuxhdr->exec_entry;
243 kfree(hpuxhdr);
244
245 set_binfmt(&som_format);
246 install_exec_creds(bprm);
247 setup_arg_pages(bprm, STACK_TOP, EXSTACK_DEFAULT);
248
249 create_som_tables(bprm);
250
251 current->mm->start_stack = bprm->p;
252
253#if 0
254 printk("(start_brk) %08lx\n" , (unsigned long) current->mm->start_brk);
255 printk("(end_code) %08lx\n" , (unsigned long) current->mm->end_code);
256 printk("(start_code) %08lx\n" , (unsigned long) current->mm->start_code);
257 printk("(end_data) %08lx\n" , (unsigned long) current->mm->end_data);
258 printk("(start_stack) %08lx\n" , (unsigned long) current->mm->start_stack);
259 printk("(brk) %08lx\n" , (unsigned long) current->mm->brk);
260#endif
261
262 map_hpux_gateway_page(current,current->mm);
263
264 start_thread_som(regs, som_entry, bprm->p);
265 return 0;
266
267 /* error cleanup */
268out_free:
269 kfree(hpuxhdr);
270out:
271 return retval;
272}
273
274static int load_som_library(struct file *f)
275{
276/* No lib support in SOM yet. gizza chance.. */
277 return -ENOEXEC;
278}
279 /* Install the SOM loader.
280 * N.B. We *rely* on the table being the right size with the
281 * right number of free slots...
282 */
283
284static int __init init_som_binfmt(void)
285{
286 register_binfmt(&som_format);
287 return 0;
288}
289
290static void __exit exit_som_binfmt(void)
291{
292 /* Remove the SOM loader. */
293 unregister_binfmt(&som_format);
294}
295
296core_initcall(init_som_binfmt);
297module_exit(exit_som_binfmt);
298
299MODULE_LICENSE("GPL");
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index 7b8141bf59a7..68ceb97c458c 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -370,7 +370,6 @@ header-y += snmp.h
370header-y += sock_diag.h 370header-y += sock_diag.h
371header-y += socket.h 371header-y += socket.h
372header-y += sockios.h 372header-y += sockios.h
373header-y += som.h
374header-y += sonet.h 373header-y += sonet.h
375header-y += sonypi.h 374header-y += sonypi.h
376header-y += soundcard.h 375header-y += soundcard.h
diff --git a/include/uapi/linux/som.h b/include/uapi/linux/som.h
deleted file mode 100644
index 166594e4e7be..000000000000
--- a/include/uapi/linux/som.h
+++ /dev/null
@@ -1,154 +0,0 @@
1#ifndef _LINUX_SOM_H
2#define _LINUX_SOM_H
3
4/* File format definition for SOM executables / shared libraries */
5
6/* we need struct timespec */
7#include <linux/time.h>
8
9#define SOM_PAGESIZE 4096
10
11/* this is the SOM header */
12struct som_hdr {
13 short system_id; /* magic number - system */
14 short a_magic; /* magic number - file type */
15 unsigned int version_id; /* versiod ID: YYMMDDHH */
16 struct timespec file_time; /* system clock */
17 unsigned int entry_space; /* space for entry point */
18 unsigned int entry_subspace; /* subspace for entry point */
19 unsigned int entry_offset; /* offset of entry point */
20 unsigned int aux_header_location; /* auxiliary header location */
21 unsigned int aux_header_size; /* auxiliary header size */
22 unsigned int som_length; /* length of entire SOM */
23 unsigned int presumed_dp; /* compiler's DP value */
24 unsigned int space_location; /* space dictionary location */
25 unsigned int space_total; /* number of space entries */
26 unsigned int subspace_location; /* subspace entries location */
27 unsigned int subspace_total; /* number of subspace entries */
28 unsigned int loader_fixup_location; /* MPE/iX loader fixup */
29 unsigned int loader_fixup_total; /* number of fixup records */
30 unsigned int space_strings_location; /* (sub)space names */
31 unsigned int space_strings_size; /* size of strings area */
32 unsigned int init_array_location; /* reserved */
33 unsigned int init_array_total; /* reserved */
34 unsigned int compiler_location; /* module dictionary */
35 unsigned int compiler_total; /* number of modules */
36 unsigned int symbol_location; /* symbol dictionary */
37 unsigned int symbol_total; /* number of symbols */
38 unsigned int fixup_request_location; /* fixup requests */
39 unsigned int fixup_request_total; /* number of fixup requests */
40 unsigned int symbol_strings_location;/* module & symbol names area */
41 unsigned int symbol_strings_size; /* size of strings area */
42 unsigned int unloadable_sp_location; /* unloadable spaces location */
43 unsigned int unloadable_sp_size; /* size of data */
44 unsigned int checksum;
45};
46
47/* values for system_id */
48
49#define SOM_SID_PARISC_1_0 0x020b
50#define SOM_SID_PARISC_1_1 0x0210
51#define SOM_SID_PARISC_2_0 0x0214
52
53/* values for a_magic */
54
55#define SOM_LIB_EXEC 0x0104
56#define SOM_RELOCATABLE 0x0106
57#define SOM_EXEC_NONSHARE 0x0107
58#define SOM_EXEC_SHARE 0x0108
59#define SOM_EXEC_DEMAND 0x010B
60#define SOM_LIB_DYN 0x010D
61#define SOM_LIB_SHARE 0x010E
62#define SOM_LIB_RELOC 0x0619
63
64/* values for version_id. Decimal not hex, yes. Grr. */
65
66#define SOM_ID_OLD 85082112
67#define SOM_ID_NEW 87102412
68
69struct aux_id {
70 unsigned int mandatory :1; /* the linker must understand this */
71 unsigned int copy :1; /* Must be copied by the linker */
72 unsigned int append :1; /* Must be merged by the linker */
73 unsigned int ignore :1; /* Discard section if unknown */
74 unsigned int reserved :12;
75 unsigned int type :16; /* Header type */
76 unsigned int length; /* length of _following_ data */
77};
78
79/* The Exec Auxiliary Header. Called The HP-UX Header within HP apparently. */
80struct som_exec_auxhdr {
81 struct aux_id som_auxhdr;
82 int exec_tsize; /* Text size in bytes */
83 int exec_tmem; /* Address to load text at */
84 int exec_tfile; /* Location of text in file */
85 int exec_dsize; /* Data size in bytes */
86 int exec_dmem; /* Address to load data at */
87 int exec_dfile; /* Location of data in file */
88 int exec_bsize; /* Uninitialised data (bss) */
89 int exec_entry; /* Address to start executing */
90 int exec_flags; /* loader flags */
91 int exec_bfill; /* initialisation value for bss */
92};
93
94/* Oh, the things people do to avoid casts. Shame it'll break with gcc's
95 * new aliasing rules really.
96 */
97union name_pt {
98 char * n_name;
99 unsigned int n_strx;
100};
101
102/* The Space Dictionary */
103struct space_dictionary_record {
104 union name_pt name; /* index to subspace name */
105 unsigned int is_loadable :1; /* loadable */
106 unsigned int is_defined :1; /* defined within file */
107 unsigned int is_private :1; /* not sharable */
108 unsigned int has_intermediate_code :1; /* contains intermediate code */
109 unsigned int is_tspecific :1; /* thread specific */
110 unsigned int reserved :11; /* for future expansion */
111 unsigned int sort_key :8; /* for linker */
112 unsigned int reserved2 :8; /* for future expansion */
113
114 int space_number; /* index */
115 int subspace_index; /* index into subspace dict */
116 unsigned int subspace_quantity; /* number of subspaces */
117 int loader_fix_index; /* for loader */
118 unsigned int loader_fix_quantity; /* for loader */
119 int init_pointer_index; /* data pointer array index */
120 unsigned int init_pointer_quantity; /* number of data pointers */
121};
122
123/* The Subspace Dictionary */
124struct subspace_dictionary_record {
125 int space_index;
126 unsigned int access_control_bits :7;
127 unsigned int memory_resident :1;
128 unsigned int dup_common :1;
129 unsigned int is_common :1;
130 unsigned int quadrant :2;
131 unsigned int initially_frozen :1;
132 unsigned int is_first :1;
133 unsigned int code_only :1;
134 unsigned int sort_key :8;
135 unsigned int replicate_init :1;
136 unsigned int continuation :1;
137 unsigned int is_tspecific :1;
138 unsigned int is_comdat :1;
139 unsigned int reserved :4;
140
141 int file_loc_init_value;
142 unsigned int initialization_length;
143 unsigned int subspace_start;
144 unsigned int subspace_length;
145
146 unsigned int reserved2 :5;
147 unsigned int alignment :27;
148
149 union name_pt name;
150 int fixup_request_index;
151 unsigned int fixup_request_quantity;
152};
153
154#endif /* _LINUX_SOM_H */