* better
[mascara-docs.git] / i386 / linux-2.3.21 / arch / mips / kernel / irixelf.c
blobcf5dd2ea323d1420160d815d4c5a9db84a7e3381
1 /* $Id: irixelf.c,v 1.17 1999/06/17 13:25:45 ralf Exp $
3 * irixelf.c: Code to load IRIX ELF executables which conform to
4 * the MIPS ABI.
6 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
8 * Based upon work which is:
9 * Copyright 1993, 1994: Eric Youngdale (ericy@cais.com).
12 #include <linux/module.h>
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/a.out.h>
20 #include <linux/errno.h>
21 #include <linux/init.h>
22 #include <linux/signal.h>
23 #include <linux/binfmts.h>
24 #include <linux/string.h>
25 #include <linux/fcntl.h>
26 #include <linux/ptrace.h>
27 #include <linux/malloc.h>
28 #include <linux/shm.h>
29 #include <linux/personality.h>
30 #include <linux/elfcore.h>
32 #include <asm/uaccess.h>
33 #include <asm/pgtable.h>
34 #include <asm/mipsregs.h>
35 #include <asm/prctl.h>
37 #include <linux/config.h>
39 #define DLINFO_ITEMS 12
41 #include <linux/elf.h>
43 #undef DEBUG_ELF
45 static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs);
46 static int load_irix_library(int fd);
47 static int irix_core_dump(long signr, struct pt_regs * regs);
48 extern int dump_fpu (elf_fpregset_t *);
50 static struct linux_binfmt irix_format = {
51 NULL,
52 #ifndef MODULE
53 NULL,
54 #else
55 &__this_module.usecount,
56 #endif
57 load_irix_binary, load_irix_library, irix_core_dump, PAGE_SIZE
60 #ifndef elf_addr_t
61 #define elf_addr_t unsigned long
62 #define elf_caddr_t char *
63 #endif
65 #ifdef DEBUG_ELF
66 /* Debugging routines. */
67 static char *get_elf_p_type(Elf32_Word p_type)
69 int i = (int) p_type;
71 switch(i) {
72 case PT_NULL: return("PT_NULL"); break;
73 case PT_LOAD: return("PT_LOAD"); break;
74 case PT_DYNAMIC: return("PT_DYNAMIC"); break;
75 case PT_INTERP: return("PT_INTERP"); break;
76 case PT_NOTE: return("PT_NOTE"); break;
77 case PT_SHLIB: return("PT_SHLIB"); break;
78 case PT_PHDR: return("PT_PHDR"); break;
79 case PT_LOPROC: return("PT_LOPROC/REGINFO"); break;
80 case PT_HIPROC: return("PT_HIPROC"); break;
81 default: return("PT_BOGUS"); break;
85 static void print_elfhdr(struct elfhdr *ehp)
87 int i;
89 printk("ELFHDR: e_ident<");
90 for(i = 0; i < (EI_NIDENT - 1); i++) printk("%x ", ehp->e_ident[i]);
91 printk("%x>\n", ehp->e_ident[i]);
92 printk(" e_type[%04x] e_machine[%04x] e_version[%08lx]\n",
93 (unsigned short) ehp->e_type, (unsigned short) ehp->e_machine,
94 (unsigned long) ehp->e_version);
95 printk(" e_entry[%08lx] e_phoff[%08lx] e_shoff[%08lx] "
96 "e_flags[%08lx]\n",
97 (unsigned long) ehp->e_entry, (unsigned long) ehp->e_phoff,
98 (unsigned long) ehp->e_shoff, (unsigned long) ehp->e_flags);
99 printk(" e_ehsize[%04x] e_phentsize[%04x] e_phnum[%04x]\n",
100 (unsigned short) ehp->e_ehsize, (unsigned short) ehp->e_phentsize,
101 (unsigned short) ehp->e_phnum);
102 printk(" e_shentsize[%04x] e_shnum[%04x] e_shstrndx[%04x]\n",
103 (unsigned short) ehp->e_shentsize, (unsigned short) ehp->e_shnum,
104 (unsigned short) ehp->e_shstrndx);
107 static void print_phdr(int i, struct elf_phdr *ep)
109 printk("PHDR[%d]: p_type[%s] p_offset[%08lx] p_vaddr[%08lx] "
110 "p_paddr[%08lx]\n", i, get_elf_p_type(ep->p_type),
111 (unsigned long) ep->p_offset, (unsigned long) ep->p_vaddr,
112 (unsigned long) ep->p_paddr);
113 printk(" p_filesz[%08lx] p_memsz[%08lx] p_flags[%08lx] "
114 "p_align[%08lx]\n", (unsigned long) ep->p_filesz,
115 (unsigned long) ep->p_memsz, (unsigned long) ep->p_flags,
116 (unsigned long) ep->p_align);
119 static void dump_phdrs(struct elf_phdr *ep, int pnum)
121 int i;
123 for(i = 0; i < pnum; i++, ep++) {
124 if((ep->p_type == PT_LOAD) ||
125 (ep->p_type == PT_INTERP) ||
126 (ep->p_type == PT_PHDR))
127 print_phdr(i, ep);
130 #endif /* (DEBUG_ELF) */
132 static void set_brk(unsigned long start, unsigned long end)
134 start = PAGE_ALIGN(start);
135 end = PAGE_ALIGN(end);
136 if (end <= start)
137 return;
138 do_brk(start, end - start);
142 /* We need to explicitly zero any fractional pages
143 * after the data section (i.e. bss). This would
144 * contain the junk from the file that should not
145 * be in memory.
147 static void padzero(unsigned long elf_bss)
149 unsigned long nbyte;
151 nbyte = elf_bss & (PAGE_SIZE-1);
152 if (nbyte) {
153 nbyte = PAGE_SIZE - nbyte;
154 clear_user((void *) elf_bss, nbyte);
158 unsigned long * create_irix_tables(char * p, int argc, int envc,
159 struct elfhdr * exec, unsigned int load_addr,
160 unsigned int interp_load_addr,
161 struct pt_regs *regs, struct elf_phdr *ephdr)
163 elf_caddr_t *argv;
164 elf_caddr_t *envp;
165 elf_addr_t *sp, *csp;
167 #ifdef DEBUG_ELF
168 printk("create_irix_tables: p[%p] argc[%d] envc[%d] "
169 "load_addr[%08x] interp_load_addr[%08x]\n",
170 p, argc, envc, load_addr, interp_load_addr);
171 #endif
172 sp = (elf_addr_t *) (~15UL & (unsigned long) p);
173 csp = sp;
174 csp -= exec ? DLINFO_ITEMS*2 : 2;
175 csp -= envc+1;
176 csp -= argc+1;
177 csp -= 1; /* argc itself */
178 if ((unsigned long)csp & 15UL) {
179 sp -= (16UL - ((unsigned long)csp & 15UL)) / sizeof(*sp);
183 * Put the ELF interpreter info on the stack
185 #define NEW_AUX_ENT(nr, id, val) \
186 __put_user ((id), sp+(nr*2)); \
187 __put_user ((val), sp+(nr*2+1)); \
189 sp -= 2;
190 NEW_AUX_ENT(0, AT_NULL, 0);
192 if(exec) {
193 sp -= 11*2;
195 NEW_AUX_ENT (0, AT_PHDR, load_addr + exec->e_phoff);
196 NEW_AUX_ENT (1, AT_PHENT, sizeof (struct elf_phdr));
197 NEW_AUX_ENT (2, AT_PHNUM, exec->e_phnum);
198 NEW_AUX_ENT (3, AT_PAGESZ, ELF_EXEC_PAGESIZE);
199 NEW_AUX_ENT (4, AT_BASE, interp_load_addr);
200 NEW_AUX_ENT (5, AT_FLAGS, 0);
201 NEW_AUX_ENT (6, AT_ENTRY, (elf_addr_t) exec->e_entry);
202 NEW_AUX_ENT (7, AT_UID, (elf_addr_t) current->uid);
203 NEW_AUX_ENT (8, AT_EUID, (elf_addr_t) current->euid);
204 NEW_AUX_ENT (9, AT_GID, (elf_addr_t) current->gid);
205 NEW_AUX_ENT (10, AT_EGID, (elf_addr_t) current->egid);
207 #undef NEW_AUX_ENT
209 sp -= envc+1;
210 envp = (elf_caddr_t *) sp;
211 sp -= argc+1;
212 argv = (elf_caddr_t *) sp;
214 __put_user((elf_addr_t)argc,--sp);
215 current->mm->arg_start = (unsigned long) p;
216 while (argc-->0) {
217 __put_user((elf_caddr_t)(unsigned long)p,argv++);
218 p += strlen_user(p);
220 __put_user(NULL, argv);
221 current->mm->arg_end = current->mm->env_start = (unsigned long) p;
222 while (envc-->0) {
223 __put_user((elf_caddr_t)(unsigned long)p,envp++);
224 p += strlen_user(p);
226 __put_user(NULL, envp);
227 current->mm->env_end = (unsigned long) p;
228 return sp;
232 /* This is much more generalized than the library routine read function,
233 * so we keep this separate. Technically the library read function
234 * is only provided so that we can read a.out libraries that have
235 * an ELF header.
237 static unsigned int load_irix_interp(struct elfhdr * interp_elf_ex,
238 struct dentry * interpreter_dentry,
239 unsigned int *interp_load_addr)
241 struct file * file;
242 struct elf_phdr *elf_phdata = NULL;
243 struct elf_phdr *eppnt;
244 unsigned int len;
245 unsigned int load_addr;
246 int elf_exec_fileno;
247 int elf_bss;
248 int retval;
249 unsigned int last_bss;
250 int error;
251 int i;
252 unsigned int k;
254 elf_bss = 0;
255 last_bss = 0;
256 error = load_addr = 0;
258 #ifdef DEBUG_ELF
259 print_elfhdr(interp_elf_ex);
260 #endif
262 /* First of all, some simple consistency checks */
263 if((interp_elf_ex->e_type != ET_EXEC &&
264 interp_elf_ex->e_type != ET_DYN) ||
265 !elf_check_arch(interp_elf_ex->e_machine) ||
266 (!interpreter_dentry->d_inode->i_op ||
267 !interpreter_dentry->d_inode->i_op->default_file_ops->mmap)) {
268 printk("IRIX interp has bad e_type %d\n", interp_elf_ex->e_type);
269 return 0xffffffff;
272 /* Now read in all of the header information */
273 if(sizeof(struct elf_phdr) * interp_elf_ex->e_phnum > PAGE_SIZE) {
274 printk("IRIX interp header bigger than a page (%d)\n",
275 (sizeof(struct elf_phdr) * interp_elf_ex->e_phnum));
276 return 0xffffffff;
279 elf_phdata = (struct elf_phdr *)
280 kmalloc(sizeof(struct elf_phdr) * interp_elf_ex->e_phnum,
281 GFP_KERNEL);
283 if(!elf_phdata) {
284 printk("Cannot kmalloc phdata for IRIX interp.\n");
285 return 0xffffffff;
288 /* If the size of this structure has changed, then punt, since
289 * we will be doing the wrong thing.
291 if(interp_elf_ex->e_phentsize != 32) {
292 printk("IRIX interp e_phentsize == %d != 32 ",
293 interp_elf_ex->e_phentsize);
294 kfree(elf_phdata);
295 return 0xffffffff;
298 retval = read_exec(interpreter_dentry, interp_elf_ex->e_phoff,
299 (char *) elf_phdata,
300 sizeof(struct elf_phdr) * interp_elf_ex->e_phnum, 1);
302 #ifdef DEBUG_ELF
303 dump_phdrs(elf_phdata, interp_elf_ex->e_phnum);
304 #endif
306 elf_exec_fileno = open_dentry(interpreter_dentry, O_RDONLY);
307 if (elf_exec_fileno < 0) {
308 printk("Could not open IRIX interp inode.\n");
309 kfree(elf_phdata);
310 return 0xffffffff;
313 file = fget(elf_exec_fileno);
315 eppnt = elf_phdata;
316 for(i=0; i<interp_elf_ex->e_phnum; i++, eppnt++) {
317 if(eppnt->p_type == PT_LOAD) {
318 int elf_type = MAP_PRIVATE | MAP_DENYWRITE;
319 int elf_prot = 0;
320 unsigned long vaddr = 0;
321 if (eppnt->p_flags & PF_R) elf_prot = PROT_READ;
322 if (eppnt->p_flags & PF_W) elf_prot |= PROT_WRITE;
323 if (eppnt->p_flags & PF_X) elf_prot |= PROT_EXEC;
324 elf_type |= MAP_FIXED;
325 vaddr = eppnt->p_vaddr;
327 #ifdef DEBUG_ELF
328 printk("INTERP do_mmap(%p, %08lx, %08lx, %08lx, %08lx, %08lx) ",
329 file, vaddr,
330 (unsigned long) (eppnt->p_filesz + (eppnt->p_vaddr & 0xfff)),
331 (unsigned long) elf_prot, (unsigned long) elf_type,
332 (unsigned long) (eppnt->p_offset & 0xfffff000));
333 #endif
334 error = do_mmap(file, vaddr,
335 eppnt->p_filesz + (eppnt->p_vaddr & 0xfff),
336 elf_prot, elf_type,
337 eppnt->p_offset & 0xfffff000);
339 if(error < 0 && error > -1024) {
340 printk("Aieee IRIX interp mmap error=%d\n", error);
341 break; /* Real error */
343 #ifdef DEBUG_ELF
344 printk("error=%08lx ", (unsigned long) error);
345 #endif
346 if(!load_addr && interp_elf_ex->e_type == ET_DYN) {
347 load_addr = error;
348 #ifdef DEBUG_ELF
349 printk("load_addr = error ");
350 #endif
353 /* Find the end of the file mapping for this phdr, and keep
354 * track of the largest address we see for this.
356 k = eppnt->p_vaddr + eppnt->p_filesz;
357 if(k > elf_bss) elf_bss = k;
359 /* Do the same thing for the memory mapping - between
360 * elf_bss and last_bss is the bss section.
362 k = eppnt->p_memsz + eppnt->p_vaddr;
363 if(k > last_bss) last_bss = k;
364 #ifdef DEBUG_ELF
365 printk("\n");
366 #endif
370 /* Now use mmap to map the library into memory. */
371 fput(file);
372 sys_close(elf_exec_fileno);
373 if(error < 0 && error > -1024) {
374 #ifdef DEBUG_ELF
375 printk("got error %d\n", error);
376 #endif
377 kfree(elf_phdata);
378 return 0xffffffff;
381 /* Now fill out the bss section. First pad the last page up
382 * to the page boundary, and then perform a mmap to make sure
383 * that there are zero-mapped pages up to and including the
384 * last bss page.
386 #ifdef DEBUG_ELF
387 printk("padzero(%08lx) ", (unsigned long) (elf_bss));
388 #endif
389 padzero(elf_bss);
390 len = (elf_bss + 0xfff) & 0xfffff000; /* What we have mapped so far */
392 #ifdef DEBUG_ELF
393 printk("last_bss[%08lx] len[%08lx]\n", (unsigned long) last_bss,
394 (unsigned long) len);
395 #endif
397 /* Map the last of the bss segment */
398 if (last_bss > len) {
399 do_brk(len, (last_bss - len));
401 kfree(elf_phdata);
403 *interp_load_addr = load_addr;
404 return ((unsigned int) interp_elf_ex->e_entry);
407 /* Check sanity of IRIX elf executable header. */
408 static int verify_binary(struct elfhdr *ehp, struct linux_binprm *bprm)
410 if (ehp->e_ident[0] != 0x7f || strncmp(&ehp->e_ident[1], "ELF", 3)) {
411 return -ENOEXEC;
414 /* First of all, some simple consistency checks */
415 if((ehp->e_type != ET_EXEC && ehp->e_type != ET_DYN) ||
416 !elf_check_arch(ehp->e_machine) ||
417 (!bprm->dentry->d_inode->i_op ||
418 !bprm->dentry->d_inode->i_op->default_file_ops ||
419 !bprm->dentry->d_inode->i_op->default_file_ops->mmap)) {
420 return -ENOEXEC;
423 /* Only support MIPS ARCH2 or greater IRIX binaries for now. */
424 if(!(ehp->e_flags & EF_MIPS_ARCH) && !(ehp->e_flags & 0x04)) {
425 return -ENOEXEC;
428 /* XXX Don't support N32 or 64bit binaries yet because they can
429 * XXX and do execute 64 bit instructions and expect all registers
430 * XXX to be 64 bit as well. We need to make the kernel save
431 * XXX all registers as 64bits on cpu's capable of this at
432 * XXX exception time plus frob the XTLB exception vector.
434 if((ehp->e_flags & 0x20)) {
435 return -ENOEXEC;
438 return 0; /* It's ok. */
441 #define IRIX_INTERP_PREFIX "/usr/gnemul/irix"
443 /* Look for an IRIX ELF interpreter. */
444 static inline int look_for_irix_interpreter(char **name,
445 struct dentry **interpreter_dentry,
446 struct elfhdr *interp_elf_ex,
447 struct elf_phdr *epp,
448 struct linux_binprm *bprm, int pnum)
450 mm_segment_t old_fs;
451 int i;
452 int retval = -EINVAL;
453 struct dentry *dentry = NULL;
455 *name = NULL;
456 for(i = 0; i < pnum; i++, epp++) {
457 if(epp->p_type != PT_INTERP)
458 continue;
460 /* It is illegal to have two interpreters for one executable. */
461 if(*name != NULL)
462 goto out;
464 *name = (char *) kmalloc((epp->p_filesz +
465 strlen(IRIX_INTERP_PREFIX)),
466 GFP_KERNEL);
467 if(!*name)
468 return -ENOMEM;
470 strcpy(*name, IRIX_INTERP_PREFIX);
471 retval = read_exec(bprm->dentry, epp->p_offset, (*name + 16),
472 epp->p_filesz, 1);
473 if(retval < 0)
474 goto out;
476 old_fs = get_fs(); set_fs(get_ds());
477 dentry = namei(*name);
478 set_fs(old_fs);
479 if(IS_ERR(dentry)) {
480 retval = PTR_ERR(dentry);
481 goto out;
483 retval = read_exec(dentry, 0, bprm->buf, 128, 1);
484 if(retval < 0)
485 goto dput_and_out;
487 *interp_elf_ex = *((struct elfhdr *) bprm->buf);
489 *interpreter_dentry = dentry;
490 return 0;
492 dput_and_out:
493 dput(dentry);
494 out:
495 kfree(*name);
496 return retval;
499 static inline int verify_irix_interpreter(struct elfhdr *ihp)
501 if(ihp->e_ident[0] != 0x7f || strncmp(&ihp->e_ident[1], "ELF", 3))
502 return -ELIBBAD;
503 return 0;
506 #define EXEC_MAP_FLAGS (MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE)
508 static inline void map_executable(struct file *fp, struct elf_phdr *epp, int pnum,
509 unsigned int *estack, unsigned int *laddr,
510 unsigned int *scode, unsigned int *ebss,
511 unsigned int *ecode, unsigned int *edata,
512 unsigned int *ebrk)
514 unsigned int tmp;
515 int i, prot;
517 for(i = 0; i < pnum; i++, epp++) {
518 if(epp->p_type != PT_LOAD)
519 continue;
521 /* Map it. */
522 prot = (epp->p_flags & PF_R) ? PROT_READ : 0;
523 prot |= (epp->p_flags & PF_W) ? PROT_WRITE : 0;
524 prot |= (epp->p_flags & PF_X) ? PROT_EXEC : 0;
525 (void) do_mmap(fp, (epp->p_vaddr & 0xfffff000),
526 (epp->p_filesz + (epp->p_vaddr & 0xfff)),
527 prot, EXEC_MAP_FLAGS,
528 (epp->p_offset & 0xfffff000));
530 /* Fixup location tracking vars. */
531 if((epp->p_vaddr & 0xfffff000) < *estack)
532 *estack = (epp->p_vaddr & 0xfffff000);
533 if(!*laddr)
534 *laddr = epp->p_vaddr - epp->p_offset;
535 if(epp->p_vaddr < *scode)
536 *scode = epp->p_vaddr;
538 tmp = epp->p_vaddr + epp->p_filesz;
539 if(tmp > *ebss)
540 *ebss = tmp;
541 if((epp->p_flags & PF_X) && *ecode < tmp)
542 *ecode = tmp;
543 if(*edata < tmp)
544 *edata = tmp;
546 tmp = epp->p_vaddr + epp->p_memsz;
547 if(tmp > *ebrk)
548 *ebrk = tmp;
553 static inline int map_interpreter(struct elf_phdr *epp, struct elfhdr *ihp,
554 struct dentry *identry, unsigned int *iladdr,
555 int pnum, mm_segment_t old_fs,
556 unsigned int *eentry)
558 int i;
560 *eentry = 0xffffffff;
561 for(i = 0; i < pnum; i++, epp++) {
562 if(epp->p_type != PT_INTERP)
563 continue;
565 /* We should have fielded this error elsewhere... */
566 if(*eentry != 0xffffffff)
567 return -1;
569 set_fs(old_fs);
570 *eentry = load_irix_interp(ihp, identry, iladdr);
571 old_fs = get_fs();
572 set_fs(get_ds());
574 dput(identry);
576 if(*eentry == 0xffffffff)
577 return -1;
579 return 0;
583 * IRIX maps a page at 0x200000 that holds information about the
584 * process and the system, here we map the page and fill the
585 * structure
587 void irix_map_prda_page (void)
589 unsigned long v;
590 struct prda *pp;
592 v = do_brk (PRDA_ADDRESS, PAGE_SIZE);
594 if (v < 0)
595 return;
597 pp = (struct prda *) v;
598 pp->prda_sys.t_pid = current->pid;
599 pp->prda_sys.t_prid = read_32bit_cp0_register (CP0_PRID);
600 pp->prda_sys.t_rpid = current->pid;
602 /* We leave the rest set to zero */
607 /* These are the functions used to load ELF style executables and shared
608 * libraries. There is no binary dependent code anywhere else.
610 static inline int do_load_irix_binary(struct linux_binprm * bprm,
611 struct pt_regs * regs)
613 struct elfhdr elf_ex, interp_elf_ex;
614 struct dentry *interpreter_dentry;
615 struct elf_phdr *elf_phdata, *elf_ihdr, *elf_ephdr;
616 unsigned int load_addr, elf_bss, elf_brk;
617 unsigned int elf_entry, interp_load_addr = 0;
618 unsigned int start_code, end_code, end_data, elf_stack;
619 int elf_exec_fileno, retval, has_interp, has_ephdr, size, i;
620 char *elf_interpreter;
621 struct file *file;
622 mm_segment_t old_fs;
624 load_addr = 0;
625 has_interp = has_ephdr = 0;
626 elf_ihdr = elf_ephdr = 0;
627 elf_ex = *((struct elfhdr *) bprm->buf);
629 if(verify_binary(&elf_ex, bprm))
630 return -ENOEXEC;
632 #ifdef DEBUG_ELF
633 print_elfhdr(&elf_ex);
634 #endif
636 /* Now read in all of the header information */
637 size = elf_ex.e_phentsize * elf_ex.e_phnum;
638 elf_phdata = (struct elf_phdr *) kmalloc(size, GFP_KERNEL);
639 if (elf_phdata == NULL)
640 return -ENOMEM;
642 retval = read_exec(bprm->dentry, elf_ex.e_phoff,
643 (char *) elf_phdata, size, 1);
644 if (retval < 0)
645 goto out_phdata;
647 #ifdef DEBUG_ELF
648 dump_phdrs(elf_phdata, elf_ex.e_phnum);
649 #endif
651 /* Set some things for later. */
652 for(i = 0; i < elf_ex.e_phnum; i++) {
653 switch(elf_phdata[i].p_type) {
654 case PT_INTERP:
655 has_interp = 1;
656 elf_ihdr = &elf_phdata[i];
657 break;
658 case PT_PHDR:
659 has_ephdr = 1;
660 elf_ephdr = &elf_phdata[i];
661 break;
664 #ifdef DEBUG_ELF
665 printk("\n");
666 #endif
668 elf_bss = 0;
669 elf_brk = 0;
670 retval = open_dentry(bprm->dentry, O_RDONLY);
671 if (retval < 0)
672 goto out_phdata;
673 file = fget(elf_exec_fileno = retval);
675 elf_stack = 0xffffffff;
676 elf_interpreter = NULL;
677 start_code = 0xffffffff;
678 end_code = 0;
679 end_data = 0;
681 retval = look_for_irix_interpreter(&elf_interpreter,
682 &interpreter_dentry,
683 &interp_elf_ex, elf_phdata, bprm,
684 elf_ex.e_phnum);
685 if(retval)
686 goto out_file;
688 if(elf_interpreter) {
689 retval = verify_irix_interpreter(&interp_elf_ex);
690 if(retval)
691 goto out_interp;
694 /* OK, we are done with that, now set up the arg stuff,
695 * and then start this sucker up.
697 retval = -E2BIG;
698 if (!bprm->sh_bang && !bprm->p)
699 goto out_interp;
701 /* Flush all traces of the currently running executable */
702 retval = flush_old_exec(bprm);
703 if (retval)
704 goto out_interp;
706 /* OK, This is the point of no return */
707 current->mm->end_data = 0;
708 current->mm->end_code = 0;
709 current->mm->mmap = NULL;
710 current->flags &= ~PF_FORKNOEXEC;
711 elf_entry = (unsigned int) elf_ex.e_entry;
713 /* Do this so that we can load the interpreter, if need be. We will
714 * change some of these later.
716 current->mm->rss = 0;
717 setup_arg_pages(bprm);
718 current->mm->start_stack = bprm->p;
720 /* At this point, we assume that the image should be loaded at
721 * fixed address, not at a variable address.
723 old_fs = get_fs();
724 set_fs(get_ds());
726 map_executable(file, elf_phdata, elf_ex.e_phnum, &elf_stack, &load_addr,
727 &start_code, &elf_bss, &end_code, &end_data, &elf_brk);
729 if(elf_interpreter) {
730 retval = map_interpreter(elf_phdata, &interp_elf_ex,
731 interpreter_dentry, &interp_load_addr,
732 elf_ex.e_phnum, old_fs, &elf_entry);
733 kfree(elf_interpreter);
734 if(retval) {
735 set_fs(old_fs);
736 printk("Unable to load IRIX ELF interpreter\n");
737 send_sig(SIGSEGV, current, 0);
738 retval = 0;
739 goto out_file;
743 set_fs(old_fs);
745 kfree(elf_phdata);
746 fput(file);
747 sys_close(elf_exec_fileno);
748 current->personality = PER_IRIX32;
750 if (current->exec_domain && current->exec_domain->module)
751 __MOD_DEC_USE_COUNT(current->exec_domain->module);
752 if (current->binfmt && current->binfmt->module)
753 __MOD_DEC_USE_COUNT(current->binfmt->module);
754 current->exec_domain = lookup_exec_domain(current->personality);
755 current->binfmt = &irix_format;
756 if (current->exec_domain && current->exec_domain->module)
757 __MOD_INC_USE_COUNT(current->exec_domain->module);
758 if (current->binfmt && current->binfmt->module)
759 __MOD_INC_USE_COUNT(current->binfmt->module);
761 compute_creds(bprm);
762 current->flags &= ~PF_FORKNOEXEC;
763 bprm->p = (unsigned long)
764 create_irix_tables((char *)bprm->p, bprm->argc, bprm->envc,
765 (elf_interpreter ? &elf_ex : NULL),
766 load_addr, interp_load_addr, regs, elf_ephdr);
767 current->mm->start_brk = current->mm->brk = elf_brk;
768 current->mm->end_code = end_code;
769 current->mm->start_code = start_code;
770 current->mm->end_data = end_data;
771 current->mm->start_stack = bprm->p;
773 /* Calling set_brk effectively mmaps the pages that we need for the
774 * bss and break sections.
776 set_brk(elf_bss, elf_brk);
779 * IRIX maps a page at 0x200000 which holds some system
780 * information. Programs depend on this.
782 irix_map_prda_page ();
784 padzero(elf_bss);
786 #ifdef DEBUG_ELF
787 printk("(start_brk) %lx\n" , (long) current->mm->start_brk);
788 printk("(end_code) %lx\n" , (long) current->mm->end_code);
789 printk("(start_code) %lx\n" , (long) current->mm->start_code);
790 printk("(end_data) %lx\n" , (long) current->mm->end_data);
791 printk("(start_stack) %lx\n" , (long) current->mm->start_stack);
792 printk("(brk) %lx\n" , (long) current->mm->brk);
793 #endif
795 #if 0 /* XXX No fucking way dude... */
796 /* Why this, you ask??? Well SVr4 maps page 0 as read-only,
797 * and some applications "depend" upon this behavior.
798 * Since we do not have the power to recompile these, we
799 * emulate the SVr4 behavior. Sigh.
801 (void) do_mmap(NULL, 0, 4096, PROT_READ | PROT_EXEC,
802 MAP_FIXED | MAP_PRIVATE, 0);
803 #endif
805 start_thread(regs, elf_entry, bprm->p);
806 if (current->flags & PF_PTRACED)
807 send_sig(SIGTRAP, current, 0);
808 return 0;
810 out_interp:
811 if(elf_interpreter) {
812 kfree(elf_interpreter);
814 out_file:
815 fput(file);
816 sys_close(elf_exec_fileno);
817 out_phdata:
818 kfree (elf_phdata);
819 return retval;
822 static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs)
824 int retval;
826 MOD_INC_USE_COUNT;
827 retval = do_load_irix_binary(bprm, regs);
828 MOD_DEC_USE_COUNT;
829 return retval;
832 /* This is really simpleminded and specialized - we are loading an
833 * a.out library that is given an ELF header.
835 static inline int do_load_irix_library(struct file *file)
837 struct elfhdr elf_ex;
838 struct elf_phdr *elf_phdata = NULL;
839 struct dentry *dentry;
840 struct inode *inode;
841 unsigned int len;
842 int elf_bss;
843 int retval;
844 unsigned int bss;
845 int error;
846 int i,j, k;
848 len = 0;
849 if (!file->f_op)
850 return -EACCES;
851 dentry = file->f_dentry;
852 inode = dentry->d_inode;
853 elf_bss = 0;
855 /* Seek to the beginning of the file. */
856 if (file->f_op->llseek) {
857 if ((error = file->f_op->llseek(file, 0, 0)) != 0)
858 return -ENOEXEC;
859 } else
860 file->f_pos = 0;
862 set_fs(KERNEL_DS);
863 error = file->f_op->read(file, (char *) &elf_ex, sizeof(elf_ex),
864 &file->f_pos);
865 set_fs(USER_DS);
866 if (error != sizeof(elf_ex))
867 return -ENOEXEC;
869 if (elf_ex.e_ident[0] != 0x7f ||
870 strncmp(&elf_ex.e_ident[1], "ELF",3) != 0)
871 return -ENOEXEC;
873 /* First of all, some simple consistency checks. */
874 if(elf_ex.e_type != ET_EXEC || elf_ex.e_phnum > 2 ||
875 !elf_check_arch(elf_ex.e_machine) ||
876 (!dentry->d_inode->i_op ||
877 !dentry->d_inode->i_op->default_file_ops->mmap))
878 return -ENOEXEC;
880 /* Now read in all of the header information. */
881 if(sizeof(struct elf_phdr) * elf_ex.e_phnum > PAGE_SIZE)
882 return -ENOEXEC;
884 elf_phdata = (struct elf_phdr *)
885 kmalloc(sizeof(struct elf_phdr) * elf_ex.e_phnum, GFP_KERNEL);
886 if (elf_phdata == NULL)
887 return -ENOMEM;
889 retval = read_exec(dentry, elf_ex.e_phoff, (char *) elf_phdata,
890 sizeof(struct elf_phdr) * elf_ex.e_phnum, 1);
892 j = 0;
893 for(i=0; i<elf_ex.e_phnum; i++)
894 if((elf_phdata + i)->p_type == PT_LOAD) j++;
896 if(j != 1) {
897 kfree(elf_phdata);
898 return -ENOEXEC;
901 while(elf_phdata->p_type != PT_LOAD) elf_phdata++;
903 /* Now use mmap to map the library into memory. */
904 error = do_mmap(file,
905 elf_phdata->p_vaddr & 0xfffff000,
906 elf_phdata->p_filesz + (elf_phdata->p_vaddr & 0xfff),
907 PROT_READ | PROT_WRITE | PROT_EXEC,
908 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE,
909 elf_phdata->p_offset & 0xfffff000);
911 k = elf_phdata->p_vaddr + elf_phdata->p_filesz;
912 if(k > elf_bss) elf_bss = k;
914 if (error != (elf_phdata->p_vaddr & 0xfffff000)) {
915 kfree(elf_phdata);
916 return error;
919 padzero(elf_bss);
921 len = (elf_phdata->p_filesz + elf_phdata->p_vaddr+ 0xfff) & 0xfffff000;
922 bss = elf_phdata->p_memsz + elf_phdata->p_vaddr;
923 if (bss > len)
924 do_brk(len, bss-len);
925 kfree(elf_phdata);
926 return 0;
929 static int load_irix_library(int fd)
931 int retval = -EACCES;
932 struct file *file;
934 MOD_INC_USE_COUNT;
935 file = fget(fd);
936 if (file) {
937 retval = do_load_irix_library(file);
938 fput(file);
940 MOD_DEC_USE_COUNT;
941 return retval;
944 /* Called through irix_syssgi() to map an elf image given an FD,
945 * a phdr ptr USER_PHDRP in userspace, and a count CNT telling how many
946 * phdrs there are in the USER_PHDRP array. We return the vaddr the
947 * first phdr was successfully mapped to.
949 unsigned long irix_mapelf(int fd, struct elf_phdr *user_phdrp, int cnt)
951 struct elf_phdr *hp;
952 struct file *filp;
953 int i, retval;
955 #ifdef DEBUG_ELF
956 printk("irix_mapelf: fd[%d] user_phdrp[%p] cnt[%d]\n",
957 fd, user_phdrp, cnt);
958 #endif
960 /* First get the verification out of the way. */
961 hp = user_phdrp;
962 retval = verify_area(VERIFY_READ, hp, (sizeof(struct elf_phdr) * cnt));
963 if(retval) {
964 #ifdef DEBUG_ELF
965 printk("irix_mapelf: verify_area fails!\n");
966 #endif
967 return retval;
970 #ifdef DEBUG_ELF
971 dump_phdrs(user_phdrp, cnt);
972 #endif
974 for(i = 0; i < cnt; i++, hp++)
975 if(hp->p_type != PT_LOAD) {
976 printk("irix_mapelf: One section is not PT_LOAD!\n");
977 return -ENOEXEC;
980 filp = fget(fd);
981 if (!filp)
982 return -EACCES;
983 if(!filp->f_op) {
984 printk("irix_mapelf: Bogon filp!\n");
985 fput(file);
986 return -EACCES;
989 hp = user_phdrp;
990 for(i = 0; i < cnt; i++, hp++) {
991 int prot;
993 prot = (hp->p_flags & PF_R) ? PROT_READ : 0;
994 prot |= (hp->p_flags & PF_W) ? PROT_WRITE : 0;
995 prot |= (hp->p_flags & PF_X) ? PROT_EXEC : 0;
996 retval = do_mmap(filp, (hp->p_vaddr & 0xfffff000),
997 (hp->p_filesz + (hp->p_vaddr & 0xfff)),
998 prot, (MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE),
999 (hp->p_offset & 0xfffff000));
1001 if(retval != (hp->p_vaddr & 0xfffff000)) {
1002 printk("irix_mapelf: do_mmap fails with %d!\n", retval);
1003 fput(file);
1004 return retval;
1008 #ifdef DEBUG_ELF
1009 printk("irix_mapelf: Success, returning %08lx\n", user_phdrp->p_vaddr);
1010 #endif
1011 fput(file);
1012 return user_phdrp->p_vaddr;
1016 * ELF core dumper
1018 * Modelled on fs/exec.c:aout_core_dump()
1019 * Jeremy Fitzhardinge <jeremy@sw.oz.au>
1022 /* These are the only things you should do on a core-file: use only these
1023 * functions to write out all the necessary info.
1025 static int dump_write(struct file *file, const void *addr, int nr)
1027 return file->f_op->write(file, addr, nr, &file->f_pos) == nr;
1030 static int dump_seek(struct file *file, off_t off)
1032 if (file->f_op->llseek) {
1033 if (file->f_op->llseek(file, off, 0) != off)
1034 return 0;
1035 } else
1036 file->f_pos = off;
1037 return 1;
1040 /* Decide whether a segment is worth dumping; default is yes to be
1041 * sure (missing info is worse than too much; etc).
1042 * Personally I'd include everything, and use the coredump limit...
1044 * I think we should skip something. But I am not sure how. H.J.
1046 static inline int maydump(struct vm_area_struct *vma)
1048 if (!(vma->vm_flags & (VM_READ|VM_WRITE|VM_EXEC)))
1049 return 0;
1050 #if 1
1051 if (vma->vm_flags & (VM_WRITE|VM_GROWSUP|VM_GROWSDOWN))
1052 return 1;
1053 if (vma->vm_flags & (VM_READ|VM_EXEC|VM_EXECUTABLE|VM_SHARED))
1054 return 0;
1055 #endif
1056 return 1;
1059 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
1061 /* An ELF note in memory. */
1062 struct memelfnote
1064 const char *name;
1065 int type;
1066 unsigned int datasz;
1067 void *data;
1070 static int notesize(struct memelfnote *en)
1072 int sz;
1074 sz = sizeof(struct elf_note);
1075 sz += roundup(strlen(en->name), 4);
1076 sz += roundup(en->datasz, 4);
1078 return sz;
1081 /* #define DEBUG */
1083 #define DUMP_WRITE(addr, nr) \
1084 do { if (!dump_write(file, (addr), (nr))) return 0; } while(0)
1085 #define DUMP_SEEK(off) \
1086 do { if (!dump_seek(file, (off))) return 0; } while(0)
1088 static int writenote(struct memelfnote *men, struct file *file)
1090 struct elf_note en;
1092 en.n_namesz = strlen(men->name);
1093 en.n_descsz = men->datasz;
1094 en.n_type = men->type;
1096 DUMP_WRITE(&en, sizeof(en));
1097 DUMP_WRITE(men->name, en.n_namesz);
1098 /* XXX - cast from long long to long to avoid need for libgcc.a */
1099 DUMP_SEEK(roundup((unsigned long)file->f_pos, 4)); /* XXX */
1100 DUMP_WRITE(men->data, men->datasz);
1101 DUMP_SEEK(roundup((unsigned long)file->f_pos, 4)); /* XXX */
1103 return 1;
1105 #undef DUMP_WRITE
1106 #undef DUMP_SEEK
1108 #define DUMP_WRITE(addr, nr) \
1109 if (!dump_write(file, (addr), (nr))) \
1110 goto end_coredump;
1111 #define DUMP_SEEK(off) \
1112 if (!dump_seek(file, (off))) \
1113 goto end_coredump;
1114 /* Actual dumper.
1116 * This is a two-pass process; first we find the offsets of the bits,
1117 * and then they are actually written out. If we run out of core limit
1118 * we just truncate.
1120 static int irix_core_dump(long signr, struct pt_regs * regs, struct file *file)
1122 int has_dumped = 0;
1123 mm_segment_t fs;
1124 int segs;
1125 int i;
1126 size_t size;
1127 struct vm_area_struct *vma;
1128 struct elfhdr elf;
1129 off_t offset = 0, dataoff;
1130 int limit = current->rlim[RLIMIT_CORE].rlim_cur;
1131 int numnote = 4;
1132 struct memelfnote notes[4];
1133 struct elf_prstatus prstatus; /* NT_PRSTATUS */
1134 elf_fpregset_t fpu; /* NT_PRFPREG */
1135 struct elf_prpsinfo psinfo; /* NT_PRPSINFO */
1137 #ifndef CONFIG_BINFMT_IRIX
1138 MOD_INC_USE_COUNT;
1139 #endif
1141 /* Count what's needed to dump, up to the limit of coredump size. */
1142 segs = 0;
1143 size = 0;
1144 for(vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) {
1145 if (maydump(vma))
1147 int sz = vma->vm_end-vma->vm_start;
1149 if (size+sz >= limit)
1150 break;
1151 else
1152 size += sz;
1155 segs++;
1157 #ifdef DEBUG
1158 printk("irix_core_dump: %d segs taking %d bytes\n", segs, size);
1159 #endif
1161 /* Set up header. */
1162 memcpy(elf.e_ident, ELFMAG, SELFMAG);
1163 elf.e_ident[EI_CLASS] = ELFCLASS32;
1164 elf.e_ident[EI_DATA] = ELFDATA2LSB;
1165 elf.e_ident[EI_VERSION] = EV_CURRENT;
1166 memset(elf.e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD);
1168 elf.e_type = ET_CORE;
1169 elf.e_machine = ELF_ARCH;
1170 elf.e_version = EV_CURRENT;
1171 elf.e_entry = 0;
1172 elf.e_phoff = sizeof(elf);
1173 elf.e_shoff = 0;
1174 elf.e_flags = 0;
1175 elf.e_ehsize = sizeof(elf);
1176 elf.e_phentsize = sizeof(struct elf_phdr);
1177 elf.e_phnum = segs+1; /* Include notes. */
1178 elf.e_shentsize = 0;
1179 elf.e_shnum = 0;
1180 elf.e_shstrndx = 0;
1182 fs = get_fs();
1183 set_fs(KERNEL_DS);
1185 has_dumped = 1;
1186 current->flags |= PF_DUMPCORE;
1188 DUMP_WRITE(&elf, sizeof(elf));
1189 offset += sizeof(elf); /* Elf header. */
1190 offset += (segs+1) * sizeof(struct elf_phdr); /* Program headers. */
1192 /* Set up the notes in similar form to SVR4 core dumps made
1193 * with info from their /proc.
1195 memset(&psinfo, 0, sizeof(psinfo));
1196 memset(&prstatus, 0, sizeof(prstatus));
1198 notes[0].name = "CORE";
1199 notes[0].type = NT_PRSTATUS;
1200 notes[0].datasz = sizeof(prstatus);
1201 notes[0].data = &prstatus;
1202 prstatus.pr_info.si_signo = prstatus.pr_cursig = signr;
1203 prstatus.pr_sigpend = current->signal.sig[0];
1204 prstatus.pr_sighold = current->blocked.sig[0];
1205 psinfo.pr_pid = prstatus.pr_pid = current->pid;
1206 psinfo.pr_ppid = prstatus.pr_ppid = current->p_pptr->pid;
1207 psinfo.pr_pgrp = prstatus.pr_pgrp = current->pgrp;
1208 psinfo.pr_sid = prstatus.pr_sid = current->session;
1209 prstatus.pr_utime.tv_sec = CT_TO_SECS(current->times.tms_utime);
1210 prstatus.pr_utime.tv_usec = CT_TO_USECS(current->times.tms_utime);
1211 prstatus.pr_stime.tv_sec = CT_TO_SECS(current->times.tms_stime);
1212 prstatus.pr_stime.tv_usec = CT_TO_USECS(current->times.tms_stime);
1213 prstatus.pr_cutime.tv_sec = CT_TO_SECS(current->times.tms_cutime);
1214 prstatus.pr_cutime.tv_usec = CT_TO_USECS(current->times.tms_cutime);
1215 prstatus.pr_cstime.tv_sec = CT_TO_SECS(current->times.tms_cstime);
1216 prstatus.pr_cstime.tv_usec = CT_TO_USECS(current->times.tms_cstime);
1217 if (sizeof(elf_gregset_t) != sizeof(struct pt_regs)) {
1218 printk("sizeof(elf_gregset_t) (%d) != sizeof(struct pt_regs) "
1219 "(%d)\n", sizeof(elf_gregset_t), sizeof(struct pt_regs));
1220 } else {
1221 *(struct pt_regs *)&prstatus.pr_reg = *regs;
1224 notes[1].name = "CORE";
1225 notes[1].type = NT_PRPSINFO;
1226 notes[1].datasz = sizeof(psinfo);
1227 notes[1].data = &psinfo;
1228 i = current->state ? ffz(~current->state) + 1 : 0;
1229 psinfo.pr_state = i;
1230 psinfo.pr_sname = (i < 0 || i > 5) ? '.' : "RSDZTD"[i];
1231 psinfo.pr_zomb = psinfo.pr_sname == 'Z';
1232 psinfo.pr_nice = current->priority-15;
1233 psinfo.pr_flag = current->flags;
1234 psinfo.pr_uid = current->uid;
1235 psinfo.pr_gid = current->gid;
1237 int i, len;
1239 set_fs(fs);
1241 len = current->mm->arg_end - current->mm->arg_start;
1242 len = len >= ELF_PRARGSZ ? ELF_PRARGSZ : len;
1243 copy_from_user(&psinfo.pr_psargs,
1244 (const char *)current->mm->arg_start, len);
1245 for(i = 0; i < len; i++)
1246 if (psinfo.pr_psargs[i] == 0)
1247 psinfo.pr_psargs[i] = ' ';
1248 psinfo.pr_psargs[len] = 0;
1250 set_fs(KERNEL_DS);
1252 strncpy(psinfo.pr_fname, current->comm, sizeof(psinfo.pr_fname));
1254 notes[2].name = "CORE";
1255 notes[2].type = NT_TASKSTRUCT;
1256 notes[2].datasz = sizeof(*current);
1257 notes[2].data = current;
1259 /* Try to dump the FPU. */
1260 prstatus.pr_fpvalid = dump_fpu (&fpu);
1261 if (!prstatus.pr_fpvalid) {
1262 numnote--;
1263 } else {
1264 notes[3].name = "CORE";
1265 notes[3].type = NT_PRFPREG;
1266 notes[3].datasz = sizeof(fpu);
1267 notes[3].data = &fpu;
1270 /* Write notes phdr entry. */
1272 struct elf_phdr phdr;
1273 int sz = 0;
1275 for(i = 0; i < numnote; i++)
1276 sz += notesize(&notes[i]);
1278 phdr.p_type = PT_NOTE;
1279 phdr.p_offset = offset;
1280 phdr.p_vaddr = 0;
1281 phdr.p_paddr = 0;
1282 phdr.p_filesz = sz;
1283 phdr.p_memsz = 0;
1284 phdr.p_flags = 0;
1285 phdr.p_align = 0;
1287 offset += phdr.p_filesz;
1288 DUMP_WRITE(&phdr, sizeof(phdr));
1291 /* Page-align dumped data. */
1292 dataoff = offset = roundup(offset, PAGE_SIZE);
1294 /* Write program headers for segments dump. */
1295 for(vma = current->mm->mmap, i = 0;
1296 i < segs && vma != NULL; vma = vma->vm_next) {
1297 struct elf_phdr phdr;
1298 size_t sz;
1300 i++;
1302 sz = vma->vm_end - vma->vm_start;
1304 phdr.p_type = PT_LOAD;
1305 phdr.p_offset = offset;
1306 phdr.p_vaddr = vma->vm_start;
1307 phdr.p_paddr = 0;
1308 phdr.p_filesz = maydump(vma) ? sz : 0;
1309 phdr.p_memsz = sz;
1310 offset += phdr.p_filesz;
1311 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
1312 if (vma->vm_flags & VM_WRITE) phdr.p_flags |= PF_W;
1313 if (vma->vm_flags & VM_EXEC) phdr.p_flags |= PF_X;
1314 phdr.p_align = PAGE_SIZE;
1316 DUMP_WRITE(&phdr, sizeof(phdr));
1319 for(i = 0; i < numnote; i++)
1320 if (!writenote(&notes[i], file))
1321 goto end_coredump;
1323 set_fs(fs);
1325 DUMP_SEEK(dataoff);
1327 for(i = 0, vma = current->mm->mmap;
1328 i < segs && vma != NULL;
1329 vma = vma->vm_next) {
1330 unsigned long addr = vma->vm_start;
1331 unsigned long len = vma->vm_end - vma->vm_start;
1333 if (!maydump(vma))
1334 continue;
1335 i++;
1336 #ifdef DEBUG
1337 printk("elf_core_dump: writing %08lx %lx\n", addr, len);
1338 #endif
1339 DUMP_WRITE((void *)addr, len);
1342 if ((off_t) file->f_pos != offset) {
1343 /* Sanity check. */
1344 printk("elf_core_dump: file->f_pos (%ld) != offset (%ld)\n",
1345 (off_t) file->f_pos, offset);
1348 end_coredump:
1349 set_fs(fs);
1350 #ifndef CONFIG_BINFMT_ELF
1351 MOD_DEC_USE_COUNT;
1352 #endif
1353 return has_dumped;
1356 int __init init_irix_binfmt(void)
1358 return register_binfmt(&irix_format);
1361 #ifdef MODULE
1363 int init_module(void)
1365 /* Install the COFF, ELF and XOUT loaders.
1366 * N.B. We *rely* on the table being the right size with the
1367 * right number of free slots...
1369 return init_irix_binfmt();
1373 void cleanup_module( void)
1375 /* Remove the IRIX ELF loaders. */
1376 unregister_binfmt(&irix_format);
1378 #endif