Commit 7fa3031500ec9b0a7460c8c23751799006ffee74

Authored by David Howells
Committed by Linus Torvalds
1 parent b0b933c08b

aout: suppress A.OUT library support if !CONFIG_ARCH_SUPPORTS_AOUT

Suppress A.OUT library support if CONFIG_ARCH_SUPPORTS_AOUT is not set.

Not all architectures support the A.OUT binfmt, so the ELF binfmt should not
be permitted to go looking for A.OUT libraries to load in such a case.  Not
only that, but under such conditions A.OUT core dumps are not produced either.

To make this work, this patch also does the following:

 (1) Makes the existence of the contents of linux/a.out.h contingent on
     CONFIG_ARCH_SUPPORTS_AOUT.

 (2) Renames dump_thread() to aout_dump_thread() as it's only called by A.OUT
     core dumping code.

 (3) Moves aout_dump_thread() into asm/a.out-core.h and makes it inline.  This
     is then included only where needed.  This means that this bit of arch
     code will be stored in the appropriate A.OUT binfmt module rather than
     the core kernel.

 (4) Drops A.OUT support for Blackfin (according to Mike Frysinger it's not
     needed) and FRV.

This patch depends on the previous patch to move STACK_TOP[_MAX] out of
asm/a.out.h and into asm/processor.h as they're required whether or not A.OUT
format is available.

[jdike@addtoit.com: uml: re-remove accidentally restored code]
Signed-off-by: David Howells <dhowells@redhat.com>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 25 changed files with 423 additions and 257 deletions Side-by-side Diff

arch/alpha/kernel/process.c
... ... @@ -318,68 +318,6 @@
318 318 }
319 319  
320 320 /*
321   - * Fill in the user structure for an ECOFF core dump.
322   - */
323   -void
324   -dump_thread(struct pt_regs * pt, struct user * dump)
325   -{
326   - /* switch stack follows right below pt_regs: */
327   - struct switch_stack * sw = ((struct switch_stack *) pt) - 1;
328   -
329   - dump->magic = CMAGIC;
330   - dump->start_code = current->mm->start_code;
331   - dump->start_data = current->mm->start_data;
332   - dump->start_stack = rdusp() & ~(PAGE_SIZE - 1);
333   - dump->u_tsize = ((current->mm->end_code - dump->start_code)
334   - >> PAGE_SHIFT);
335   - dump->u_dsize = ((current->mm->brk + PAGE_SIZE-1 - dump->start_data)
336   - >> PAGE_SHIFT);
337   - dump->u_ssize = (current->mm->start_stack - dump->start_stack
338   - + PAGE_SIZE-1) >> PAGE_SHIFT;
339   -
340   - /*
341   - * We store the registers in an order/format that is
342   - * compatible with DEC Unix/OSF/1 as this makes life easier
343   - * for gdb.
344   - */
345   - dump->regs[EF_V0] = pt->r0;
346   - dump->regs[EF_T0] = pt->r1;
347   - dump->regs[EF_T1] = pt->r2;
348   - dump->regs[EF_T2] = pt->r3;
349   - dump->regs[EF_T3] = pt->r4;
350   - dump->regs[EF_T4] = pt->r5;
351   - dump->regs[EF_T5] = pt->r6;
352   - dump->regs[EF_T6] = pt->r7;
353   - dump->regs[EF_T7] = pt->r8;
354   - dump->regs[EF_S0] = sw->r9;
355   - dump->regs[EF_S1] = sw->r10;
356   - dump->regs[EF_S2] = sw->r11;
357   - dump->regs[EF_S3] = sw->r12;
358   - dump->regs[EF_S4] = sw->r13;
359   - dump->regs[EF_S5] = sw->r14;
360   - dump->regs[EF_S6] = sw->r15;
361   - dump->regs[EF_A3] = pt->r19;
362   - dump->regs[EF_A4] = pt->r20;
363   - dump->regs[EF_A5] = pt->r21;
364   - dump->regs[EF_T8] = pt->r22;
365   - dump->regs[EF_T9] = pt->r23;
366   - dump->regs[EF_T10] = pt->r24;
367   - dump->regs[EF_T11] = pt->r25;
368   - dump->regs[EF_RA] = pt->r26;
369   - dump->regs[EF_T12] = pt->r27;
370   - dump->regs[EF_AT] = pt->r28;
371   - dump->regs[EF_SP] = rdusp();
372   - dump->regs[EF_PS] = pt->ps;
373   - dump->regs[EF_PC] = pt->pc;
374   - dump->regs[EF_GP] = pt->gp;
375   - dump->regs[EF_A0] = pt->r16;
376   - dump->regs[EF_A1] = pt->r17;
377   - dump->regs[EF_A2] = pt->r18;
378   - memcpy((char *)dump->regs + EF_SIZE, sw->fp, 32 * 8);
379   -}
380   -EXPORT_SYMBOL(dump_thread);
381   -
382   -/*
383 321 * Fill in the user structure for a ELF core dump.
384 322 */
385 323 void
arch/arm/kernel/process.c
... ... @@ -368,35 +368,6 @@
368 368 EXPORT_SYMBOL(dump_fpu);
369 369  
370 370 /*
371   - * fill in the user structure for a core dump..
372   - */
373   -void dump_thread(struct pt_regs * regs, struct user * dump)
374   -{
375   - struct task_struct *tsk = current;
376   -
377   - dump->magic = CMAGIC;
378   - dump->start_code = tsk->mm->start_code;
379   - dump->start_stack = regs->ARM_sp & ~(PAGE_SIZE - 1);
380   -
381   - dump->u_tsize = (tsk->mm->end_code - tsk->mm->start_code) >> PAGE_SHIFT;
382   - dump->u_dsize = (tsk->mm->brk - tsk->mm->start_data + PAGE_SIZE - 1) >> PAGE_SHIFT;
383   - dump->u_ssize = 0;
384   -
385   - dump->u_debugreg[0] = tsk->thread.debug.bp[0].address;
386   - dump->u_debugreg[1] = tsk->thread.debug.bp[1].address;
387   - dump->u_debugreg[2] = tsk->thread.debug.bp[0].insn.arm;
388   - dump->u_debugreg[3] = tsk->thread.debug.bp[1].insn.arm;
389   - dump->u_debugreg[4] = tsk->thread.debug.nsaved;
390   -
391   - if (dump->start_stack < 0x04000000)
392   - dump->u_ssize = (0x04000000 - dump->start_stack) >> PAGE_SHIFT;
393   -
394   - dump->regs = *regs;
395   - dump->u_fpvalid = dump_fpu (regs, &dump->u_fp);
396   -}
397   -EXPORT_SYMBOL(dump_thread);
398   -
399   -/*
400 371 * Shuffle the argument into the correct register before calling the
401 372 * thread function. r1 is the thread argument, r2 is the pointer to
402 373 * the thread function, and r3 points to the exit function.
arch/m68k/kernel/process.c
... ... @@ -316,53 +316,6 @@
316 316 EXPORT_SYMBOL(dump_fpu);
317 317  
318 318 /*
319   - * fill in the user structure for a core dump..
320   - */
321   -void dump_thread(struct pt_regs * regs, struct user * dump)
322   -{
323   - struct switch_stack *sw;
324   -
325   -/* changed the size calculations - should hopefully work better. lbt */
326   - dump->magic = CMAGIC;
327   - dump->start_code = 0;
328   - dump->start_stack = rdusp() & ~(PAGE_SIZE - 1);
329   - dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
330   - dump->u_dsize = ((unsigned long) (current->mm->brk +
331   - (PAGE_SIZE-1))) >> PAGE_SHIFT;
332   - dump->u_dsize -= dump->u_tsize;
333   - dump->u_ssize = 0;
334   -
335   - if (dump->start_stack < TASK_SIZE)
336   - dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;
337   -
338   - dump->u_ar0 = offsetof(struct user, regs);
339   - sw = ((struct switch_stack *)regs) - 1;
340   - dump->regs.d1 = regs->d1;
341   - dump->regs.d2 = regs->d2;
342   - dump->regs.d3 = regs->d3;
343   - dump->regs.d4 = regs->d4;
344   - dump->regs.d5 = regs->d5;
345   - dump->regs.d6 = sw->d6;
346   - dump->regs.d7 = sw->d7;
347   - dump->regs.a0 = regs->a0;
348   - dump->regs.a1 = regs->a1;
349   - dump->regs.a2 = regs->a2;
350   - dump->regs.a3 = sw->a3;
351   - dump->regs.a4 = sw->a4;
352   - dump->regs.a5 = sw->a5;
353   - dump->regs.a6 = sw->a6;
354   - dump->regs.d0 = regs->d0;
355   - dump->regs.orig_d0 = regs->orig_d0;
356   - dump->regs.stkadj = regs->stkadj;
357   - dump->regs.sr = regs->sr;
358   - dump->regs.pc = regs->pc;
359   - dump->regs.fmtvec = (regs->format << 12) | regs->vector;
360   - /* dump floating point stuff */
361   - dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp);
362   -}
363   -EXPORT_SYMBOL(dump_thread);
364   -
365   -/*
366 319 * sys_execve() executes a new program.
367 320 */
368 321 asmlinkage int sys_execve(char __user *name, char __user * __user *argv, char __user * __user *envp)
arch/sparc/kernel/process.c
... ... @@ -567,38 +567,6 @@
567 567 }
568 568  
569 569 /*
570   - * fill in the user structure for a core dump..
571   - */
572   -void dump_thread(struct pt_regs * regs, struct user * dump)
573   -{
574   - unsigned long first_stack_page;
575   -
576   - dump->magic = SUNOS_CORE_MAGIC;
577   - dump->len = sizeof(struct user);
578   - dump->regs.psr = regs->psr;
579   - dump->regs.pc = regs->pc;
580   - dump->regs.npc = regs->npc;
581   - dump->regs.y = regs->y;
582   - /* fuck me plenty */
583   - memcpy(&dump->regs.regs[0], &regs->u_regs[1], (sizeof(unsigned long) * 15));
584   - dump->uexec = current->thread.core_exec;
585   - dump->u_tsize = (((unsigned long) current->mm->end_code) -
586   - ((unsigned long) current->mm->start_code)) & ~(PAGE_SIZE - 1);
587   - dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1)));
588   - dump->u_dsize -= dump->u_tsize;
589   - dump->u_dsize &= ~(PAGE_SIZE - 1);
590   - first_stack_page = (regs->u_regs[UREG_FP] & ~(PAGE_SIZE - 1));
591   - dump->u_ssize = (TASK_SIZE - first_stack_page) & ~(PAGE_SIZE - 1);
592   - memcpy(&dump->fpu.fpstatus.fregs.regs[0], &current->thread.float_regs[0], (sizeof(unsigned long) * 32));
593   - dump->fpu.fpstatus.fsr = current->thread.fsr;
594   - dump->fpu.fpstatus.flags = dump->fpu.fpstatus.extra = 0;
595   - dump->fpu.fpstatus.fpq_count = current->thread.fpqdepth;
596   - memcpy(&dump->fpu.fpstatus.fpq[0], &current->thread.fpqueue[0],
597   - ((sizeof(unsigned long) * 2) * 16));
598   - dump->sigcode = 0;
599   -}
600   -
601   -/*
602 570 * fill in the fpu structure for a core dump.
603 571 */
604 572 int dump_fpu (struct pt_regs * regs, elf_fpregset_t * fpregs)
arch/sparc/kernel/sparc_ksyms.c
... ... @@ -214,8 +214,6 @@
214 214 EXPORT_SYMBOL(svr4_setcontext);
215 215 EXPORT_SYMBOL(svr4_getcontext);
216 216  
217   -EXPORT_SYMBOL(dump_thread);
218   -
219 217 /* prom symbols */
220 218 EXPORT_SYMBOL(idprom);
221 219 EXPORT_SYMBOL(prom_root_node);
arch/sparc64/kernel/binfmt_aout32.c
... ... @@ -32,6 +32,7 @@
32 32 #include <asm/uaccess.h>
33 33 #include <asm/pgalloc.h>
34 34 #include <asm/mmu_context.h>
  35 +#include <asm/a.out-core.h>
35 36  
36 37 static int load_aout32_binary(struct linux_binprm *, struct pt_regs * regs);
37 38 static int load_aout32_library(struct file*);
... ... @@ -101,7 +102,7 @@
101 102 current->flags |= PF_DUMPCORE;
102 103 strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm));
103 104 dump.signal = signr;
104   - dump_thread(regs, &dump);
  105 + aout_dump_thread(regs, &dump);
105 106  
106 107 /* If the size of the dump file exceeds the rlimit, then see what would happen
107 108 if we wrote the stack, but not the data area. */
arch/sparc64/kernel/process.c
... ... @@ -725,17 +725,6 @@
725 725 return retval;
726 726 }
727 727  
728   -/*
729   - * fill in the user structure for a core dump..
730   - */
731   -void dump_thread(struct pt_regs * regs, struct user * dump)
732   -{
733   - /* Only should be used for SunOS and ancient a.out
734   - * SparcLinux binaries... Not worth implementing.
735   - */
736   - memset(dump, 0, sizeof(struct user));
737   -}
738   -
739 728 typedef struct {
740 729 union {
741 730 unsigned int pr_regs[32];
arch/um/kernel/ksyms.c
... ... @@ -60,7 +60,6 @@
60 60 EXPORT_SYMBOL(os_rcv_fd);
61 61 EXPORT_SYMBOL(run_helper);
62 62 EXPORT_SYMBOL(start_thread);
63   -EXPORT_SYMBOL(dump_thread);
64 63  
65 64 #ifdef CONFIG_SMP
66 65  
arch/um/kernel/process.c
... ... @@ -258,10 +258,6 @@
258 258 default_idle();
259 259 }
260 260  
261   -void dump_thread(struct pt_regs *regs, struct user *u)
262   -{
263   -}
264   -
265 261 int __cant_sleep(void) {
266 262 return in_atomic() || irqs_disabled() || in_interrupt();
267 263 /* Is in_interrupt() really needed? */
arch/x86/kernel/process_32.c
... ... @@ -539,55 +539,6 @@
539 539 return err;
540 540 }
541 541  
542   -/*
543   - * fill in the user structure for a core dump..
544   - */
545   -void dump_thread(struct pt_regs * regs, struct user * dump)
546   -{
547   - u16 gs;
548   -
549   -/* changed the size calculations - should hopefully work better. lbt */
550   - dump->magic = CMAGIC;
551   - dump->start_code = 0;
552   - dump->start_stack = regs->sp & ~(PAGE_SIZE - 1);
553   - dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
554   - dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT;
555   - dump->u_dsize -= dump->u_tsize;
556   - dump->u_ssize = 0;
557   - dump->u_debugreg[0] = current->thread.debugreg0;
558   - dump->u_debugreg[1] = current->thread.debugreg1;
559   - dump->u_debugreg[2] = current->thread.debugreg2;
560   - dump->u_debugreg[3] = current->thread.debugreg3;
561   - dump->u_debugreg[4] = 0;
562   - dump->u_debugreg[5] = 0;
563   - dump->u_debugreg[6] = current->thread.debugreg6;
564   - dump->u_debugreg[7] = current->thread.debugreg7;
565   -
566   - if (dump->start_stack < TASK_SIZE)
567   - dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;
568   -
569   - dump->regs.bx = regs->bx;
570   - dump->regs.cx = regs->cx;
571   - dump->regs.dx = regs->dx;
572   - dump->regs.si = regs->si;
573   - dump->regs.di = regs->di;
574   - dump->regs.bp = regs->bp;
575   - dump->regs.ax = regs->ax;
576   - dump->regs.ds = (u16)regs->ds;
577   - dump->regs.es = (u16)regs->es;
578   - dump->regs.fs = (u16)regs->fs;
579   - savesegment(gs,gs);
580   - dump->regs.orig_ax = regs->orig_ax;
581   - dump->regs.ip = regs->ip;
582   - dump->regs.cs = (u16)regs->cs;
583   - dump->regs.flags = regs->flags;
584   - dump->regs.sp = regs->sp;
585   - dump->regs.ss = (u16)regs->ss;
586   -
587   - dump->u_fpvalid = dump_fpu (regs, &dump->i387);
588   -}
589   -EXPORT_SYMBOL(dump_thread);
590   -
591 542 #ifdef CONFIG_SECCOMP
592 543 static void hard_disable_TSC(void)
593 544 {
... ... @@ -61,7 +61,8 @@
61 61  
62 62 config BINFMT_AOUT
63 63 tristate "Kernel support for a.out and ECOFF binaries"
64   - depends on X86_32 || ALPHA || ARM || M68K || SPARC32
  64 + depends on ARCH_SUPPORTS_AOUT && \
  65 + (X86_32 || ALPHA || ARM || M68K || SPARC32)
65 66 ---help---
66 67 A.out (Assembler.OUTput) is a set of formats for libraries and
67 68 executables used in the earliest versions of UNIX. Linux used
... ... @@ -28,6 +28,7 @@
28 28 #include <asm/system.h>
29 29 #include <asm/uaccess.h>
30 30 #include <asm/cacheflush.h>
  31 +#include <asm/a.out-core.h>
31 32  
32 33 static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs);
33 34 static int load_aout_library(struct file*);
... ... @@ -118,7 +119,7 @@
118 119 dump.u_ar0 = offsetof(struct user, regs);
119 120 #endif
120 121 dump.signal = signr;
121   - dump_thread(regs, &dump);
  122 + aout_dump_thread(regs, &dump);
122 123  
123 124 /* If the size of the dump file exceeds the rlimit, then see what would happen
124 125 if we wrote the stack, but not the data area. */
... ... @@ -513,6 +513,7 @@
513 513 return error;
514 514 }
515 515  
  516 +#ifdef CONFIG_ARCH_SUPPORTS_AOUT
516 517 static unsigned long load_aout_interp(struct exec *interp_ex,
517 518 struct file *interpreter)
518 519 {
... ... @@ -558,6 +559,14 @@
558 559 out:
559 560 return elf_entry;
560 561 }
  562 +#else
  563 +/* dummy extern - the function should never be called if !CONFIG_AOUT_BINFMT */
  564 +static inline unsigned long load_aout_interp(struct exec *interp_ex,
  565 + struct file *interpreter)
  566 +{
  567 + return -ELIBACC;
  568 +}
  569 +#endif
561 570  
562 571 /*
563 572 * These are the functions used to load ELF style executables and shared
564 573  
... ... @@ -565,9 +574,15 @@
565 574 */
566 575  
567 576 #define INTERPRETER_NONE 0
568   -#define INTERPRETER_AOUT 1
569 577 #define INTERPRETER_ELF 2
570 578  
  579 +#ifdef CONFIG_ARCH_SUPPORTS_AOUT
  580 +#define INTERPRETER_AOUT 1
  581 +#define IS_AOUT_INTERP(x) ((x) == INTERPRETER_AOUT)
  582 +#else
  583 +#define IS_AOUT_INTERP(x) (0)
  584 +#endif
  585 +
571 586 #ifndef STACK_RND_MASK
572 587 #define STACK_RND_MASK (0x7ff >> (PAGE_SHIFT - 12)) /* 8MB of VA */
573 588 #endif
... ... @@ -775,6 +790,7 @@
775 790 /* Some simple consistency checks for the interpreter */
776 791 if (elf_interpreter) {
777 792 static int warn;
  793 +#ifdef CONFIG_ARCH_SUPPORTS_AOUT
778 794 interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT;
779 795  
780 796 /* Now figure out which format our binary is */
781 797  
... ... @@ -782,11 +798,13 @@
782 798 (N_MAGIC(loc->interp_ex) != ZMAGIC) &&
783 799 (N_MAGIC(loc->interp_ex) != QMAGIC))
784 800 interpreter_type = INTERPRETER_ELF;
785   -
  801 +#else
  802 + interpreter_type = INTERPRETER_ELF;
  803 +#endif
786 804 if (memcmp(loc->interp_elf_ex.e_ident, ELFMAG, SELFMAG) != 0)
787 805 interpreter_type &= ~INTERPRETER_ELF;
788 806  
789   - if (interpreter_type == INTERPRETER_AOUT && warn < 10) {
  807 + if (IS_AOUT_INTERP(interpreter_type) && warn < 10) {
790 808 printk(KERN_WARNING "a.out ELF interpreter %s is "
791 809 "deprecated and will not be supported "
792 810 "after Linux 2.6.25\n", elf_interpreter);
... ... @@ -815,7 +833,7 @@
815 833  
816 834 /* OK, we are done with that, now set up the arg stuff,
817 835 and then start this sucker up */
818   - if ((!bprm->sh_bang) && (interpreter_type == INTERPRETER_AOUT)) {
  836 + if (IS_AOUT_INTERP(interpreter_type) && !bprm->sh_bang) {
819 837 char *passed_p = passed_fileno;
820 838 sprintf(passed_fileno, "%d", elf_exec_fileno);
821 839  
... ... @@ -1004,7 +1022,7 @@
1004 1022 }
1005 1023  
1006 1024 if (elf_interpreter) {
1007   - if (interpreter_type == INTERPRETER_AOUT) {
  1025 + if (IS_AOUT_INTERP(interpreter_type)) {
1008 1026 elf_entry = load_aout_interp(&loc->interp_ex,
1009 1027 interpreter);
1010 1028 } else {
... ... @@ -1045,7 +1063,7 @@
1045 1063  
1046 1064 kfree(elf_phdata);
1047 1065  
1048   - if (interpreter_type != INTERPRETER_AOUT)
  1066 + if (!IS_AOUT_INTERP(interpreter_type))
1049 1067 sys_close(elf_exec_fileno);
1050 1068  
1051 1069 set_binfmt(&elf_format);
1052 1070  
... ... @@ -1061,14 +1079,14 @@
1061 1079 compute_creds(bprm);
1062 1080 current->flags &= ~PF_FORKNOEXEC;
1063 1081 retval = create_elf_tables(bprm, &loc->elf_ex,
1064   - (interpreter_type == INTERPRETER_AOUT),
  1082 + IS_AOUT_INTERP(interpreter_type),
1065 1083 load_addr, interp_load_addr);
1066 1084 if (retval < 0) {
1067 1085 send_sig(SIGKILL, current, 0);
1068 1086 goto out;
1069 1087 }
1070 1088 /* N.B. passed_fileno might not be initialized? */
1071   - if (interpreter_type == INTERPRETER_AOUT)
  1089 + if (IS_AOUT_INTERP(interpreter_type))
1072 1090 current->mm->arg_start += strlen(passed_fileno) + 1;
1073 1091 current->mm->end_code = end_code;
1074 1092 current->mm->start_code = start_code;
... ... @@ -1166,7 +1166,7 @@
1166 1166 {
1167 1167 int try,retval;
1168 1168 struct linux_binfmt *fmt;
1169   -#ifdef __alpha__
  1169 +#if defined(__alpha__) && defined(CONFIG_ARCH_SUPPORTS_AOUT)
1170 1170 /* handle /sbin/loader.. */
1171 1171 {
1172 1172 struct exec * eh = (struct exec *) bprm->buf;
include/asm-alpha/a.out-core.h
  1 +/* a.out coredump register dumper
  2 + *
  3 + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4 + * Written by David Howells (dhowells@redhat.com)
  5 + *
  6 + * This program is free software; you can redistribute it and/or
  7 + * modify it under the terms of the GNU General Public Licence
  8 + * as published by the Free Software Foundation; either version
  9 + * 2 of the Licence, or (at your option) any later version.
  10 + */
  11 +
  12 +#ifndef _ASM_A_OUT_CORE_H
  13 +#define _ASM_A_OUT_CORE_H
  14 +
  15 +#ifdef __KERNEL__
  16 +
  17 +#include <linux/user.h>
  18 +
  19 +/*
  20 + * Fill in the user structure for an ECOFF core dump.
  21 + */
  22 +static inline void aout_dump_thread(struct pt_regs *pt, struct user *dump)
  23 +{
  24 + /* switch stack follows right below pt_regs: */
  25 + struct switch_stack * sw = ((struct switch_stack *) pt) - 1;
  26 +
  27 + dump->magic = CMAGIC;
  28 + dump->start_code = current->mm->start_code;
  29 + dump->start_data = current->mm->start_data;
  30 + dump->start_stack = rdusp() & ~(PAGE_SIZE - 1);
  31 + dump->u_tsize = ((current->mm->end_code - dump->start_code)
  32 + >> PAGE_SHIFT);
  33 + dump->u_dsize = ((current->mm->brk + PAGE_SIZE-1 - dump->start_data)
  34 + >> PAGE_SHIFT);
  35 + dump->u_ssize = (current->mm->start_stack - dump->start_stack
  36 + + PAGE_SIZE-1) >> PAGE_SHIFT;
  37 +
  38 + /*
  39 + * We store the registers in an order/format that is
  40 + * compatible with DEC Unix/OSF/1 as this makes life easier
  41 + * for gdb.
  42 + */
  43 + dump->regs[EF_V0] = pt->r0;
  44 + dump->regs[EF_T0] = pt->r1;
  45 + dump->regs[EF_T1] = pt->r2;
  46 + dump->regs[EF_T2] = pt->r3;
  47 + dump->regs[EF_T3] = pt->r4;
  48 + dump->regs[EF_T4] = pt->r5;
  49 + dump->regs[EF_T5] = pt->r6;
  50 + dump->regs[EF_T6] = pt->r7;
  51 + dump->regs[EF_T7] = pt->r8;
  52 + dump->regs[EF_S0] = sw->r9;
  53 + dump->regs[EF_S1] = sw->r10;
  54 + dump->regs[EF_S2] = sw->r11;
  55 + dump->regs[EF_S3] = sw->r12;
  56 + dump->regs[EF_S4] = sw->r13;
  57 + dump->regs[EF_S5] = sw->r14;
  58 + dump->regs[EF_S6] = sw->r15;
  59 + dump->regs[EF_A3] = pt->r19;
  60 + dump->regs[EF_A4] = pt->r20;
  61 + dump->regs[EF_A5] = pt->r21;
  62 + dump->regs[EF_T8] = pt->r22;
  63 + dump->regs[EF_T9] = pt->r23;
  64 + dump->regs[EF_T10] = pt->r24;
  65 + dump->regs[EF_T11] = pt->r25;
  66 + dump->regs[EF_RA] = pt->r26;
  67 + dump->regs[EF_T12] = pt->r27;
  68 + dump->regs[EF_AT] = pt->r28;
  69 + dump->regs[EF_SP] = rdusp();
  70 + dump->regs[EF_PS] = pt->ps;
  71 + dump->regs[EF_PC] = pt->pc;
  72 + dump->regs[EF_GP] = pt->gp;
  73 + dump->regs[EF_A0] = pt->r16;
  74 + dump->regs[EF_A1] = pt->r17;
  75 + dump->regs[EF_A2] = pt->r18;
  76 + memcpy((char *)dump->regs + EF_SIZE, sw->fp, 32 * 8);
  77 +}
  78 +
  79 +#endif /* __KERNEL__ */
  80 +#endif /* _ASM_A_OUT_CORE_H */
include/asm-arm/a.out-core.h
  1 +/* a.out coredump register dumper
  2 + *
  3 + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4 + * Written by David Howells (dhowells@redhat.com)
  5 + *
  6 + * This program is free software; you can redistribute it and/or
  7 + * modify it under the terms of the GNU General Public Licence
  8 + * as published by the Free Software Foundation; either version
  9 + * 2 of the Licence, or (at your option) any later version.
  10 + */
  11 +
  12 +#ifndef _ASM_A_OUT_CORE_H
  13 +#define _ASM_A_OUT_CORE_H
  14 +
  15 +#ifdef __KERNEL__
  16 +
  17 +#include <linux/user.h>
  18 +#include <linux/elfcore.h>
  19 +
  20 +/*
  21 + * fill in the user structure for an a.out core dump
  22 + */
  23 +static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
  24 +{
  25 + struct task_struct *tsk = current;
  26 +
  27 + dump->magic = CMAGIC;
  28 + dump->start_code = tsk->mm->start_code;
  29 + dump->start_stack = regs->ARM_sp & ~(PAGE_SIZE - 1);
  30 +
  31 + dump->u_tsize = (tsk->mm->end_code - tsk->mm->start_code) >> PAGE_SHIFT;
  32 + dump->u_dsize = (tsk->mm->brk - tsk->mm->start_data + PAGE_SIZE - 1) >> PAGE_SHIFT;
  33 + dump->u_ssize = 0;
  34 +
  35 + dump->u_debugreg[0] = tsk->thread.debug.bp[0].address;
  36 + dump->u_debugreg[1] = tsk->thread.debug.bp[1].address;
  37 + dump->u_debugreg[2] = tsk->thread.debug.bp[0].insn.arm;
  38 + dump->u_debugreg[3] = tsk->thread.debug.bp[1].insn.arm;
  39 + dump->u_debugreg[4] = tsk->thread.debug.nsaved;
  40 +
  41 + if (dump->start_stack < 0x04000000)
  42 + dump->u_ssize = (0x04000000 - dump->start_stack) >> PAGE_SHIFT;
  43 +
  44 + dump->regs = *regs;
  45 + dump->u_fpvalid = dump_fpu (regs, &dump->u_fp);
  46 +}
  47 +
  48 +#endif /* __KERNEL__ */
  49 +#endif /* _ASM_A_OUT_CORE_H */
include/asm-frv/a.out.h
1   -/*
2   - * FRV doesn't do AOUT format. This header file should be removed as
3   - * soon as fs/exec.c and fs/proc/kcore.c and the archs that require
4   - * them to include linux/a.out.h are fixed.
5   - */
include/asm-generic/Kbuild.asm
  1 +ifeq ($(wildcard include/asm-$(SRCARCH)/a.out.h),include/asm-$(SRCARCH)/a.out.h)
1 2 unifdef-y += a.out.h
  3 +endif
2 4 unifdef-y += auxvec.h
3 5 unifdef-y += byteorder.h
4 6 unifdef-y += errno.h
include/asm-m68k/a.out-core.h
  1 +/* a.out coredump register dumper
  2 + *
  3 + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4 + * Written by David Howells (dhowells@redhat.com)
  5 + *
  6 + * This program is free software; you can redistribute it and/or
  7 + * modify it under the terms of the GNU General Public Licence
  8 + * as published by the Free Software Foundation; either version
  9 + * 2 of the Licence, or (at your option) any later version.
  10 + */
  11 +
  12 +#ifndef _ASM_A_OUT_CORE_H
  13 +#define _ASM_A_OUT_CORE_H
  14 +
  15 +#ifdef __KERNEL__
  16 +
  17 +#include <linux/user.h>
  18 +#include <linux/elfcore.h>
  19 +
  20 +/*
  21 + * fill in the user structure for an a.out core dump
  22 + */
  23 +static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
  24 +{
  25 + struct switch_stack *sw;
  26 +
  27 +/* changed the size calculations - should hopefully work better. lbt */
  28 + dump->magic = CMAGIC;
  29 + dump->start_code = 0;
  30 + dump->start_stack = rdusp() & ~(PAGE_SIZE - 1);
  31 + dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
  32 + dump->u_dsize = ((unsigned long) (current->mm->brk +
  33 + (PAGE_SIZE-1))) >> PAGE_SHIFT;
  34 + dump->u_dsize -= dump->u_tsize;
  35 + dump->u_ssize = 0;
  36 +
  37 + if (dump->start_stack < TASK_SIZE)
  38 + dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;
  39 +
  40 + dump->u_ar0 = offsetof(struct user, regs);
  41 + sw = ((struct switch_stack *)regs) - 1;
  42 + dump->regs.d1 = regs->d1;
  43 + dump->regs.d2 = regs->d2;
  44 + dump->regs.d3 = regs->d3;
  45 + dump->regs.d4 = regs->d4;
  46 + dump->regs.d5 = regs->d5;
  47 + dump->regs.d6 = sw->d6;
  48 + dump->regs.d7 = sw->d7;
  49 + dump->regs.a0 = regs->a0;
  50 + dump->regs.a1 = regs->a1;
  51 + dump->regs.a2 = regs->a2;
  52 + dump->regs.a3 = sw->a3;
  53 + dump->regs.a4 = sw->a4;
  54 + dump->regs.a5 = sw->a5;
  55 + dump->regs.a6 = sw->a6;
  56 + dump->regs.d0 = regs->d0;
  57 + dump->regs.orig_d0 = regs->orig_d0;
  58 + dump->regs.stkadj = regs->stkadj;
  59 + dump->regs.sr = regs->sr;
  60 + dump->regs.pc = regs->pc;
  61 + dump->regs.fmtvec = (regs->format << 12) | regs->vector;
  62 + /* dump floating point stuff */
  63 + dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp);
  64 +}
  65 +
  66 +#endif /* __KERNEL__ */
  67 +#endif /* _ASM_A_OUT_CORE_H */
include/asm-sparc/a.out-core.h
  1 +/* a.out coredump register dumper
  2 + *
  3 + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4 + * Written by David Howells (dhowells@redhat.com)
  5 + *
  6 + * This program is free software; you can redistribute it and/or
  7 + * modify it under the terms of the GNU General Public Licence
  8 + * as published by the Free Software Foundation; either version
  9 + * 2 of the Licence, or (at your option) any later version.
  10 + */
  11 +
  12 +#ifndef _ASM_A_OUT_CORE_H
  13 +#define _ASM_A_OUT_CORE_H
  14 +
  15 +#ifdef __KERNEL__
  16 +
  17 +#include <linux/user.h>
  18 +
  19 +/*
  20 + * fill in the user structure for an a.out core dump
  21 + */
  22 +static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
  23 +{
  24 + unsigned long first_stack_page;
  25 +
  26 + dump->magic = SUNOS_CORE_MAGIC;
  27 + dump->len = sizeof(struct user);
  28 + dump->regs.psr = regs->psr;
  29 + dump->regs.pc = regs->pc;
  30 + dump->regs.npc = regs->npc;
  31 + dump->regs.y = regs->y;
  32 + /* fuck me plenty */
  33 + memcpy(&dump->regs.regs[0], &regs->u_regs[1], (sizeof(unsigned long) * 15));
  34 + dump->uexec = current->thread.core_exec;
  35 + dump->u_tsize = (((unsigned long) current->mm->end_code) -
  36 + ((unsigned long) current->mm->start_code)) & ~(PAGE_SIZE - 1);
  37 + dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1)));
  38 + dump->u_dsize -= dump->u_tsize;
  39 + dump->u_dsize &= ~(PAGE_SIZE - 1);
  40 + first_stack_page = (regs->u_regs[UREG_FP] & ~(PAGE_SIZE - 1));
  41 + dump->u_ssize = (TASK_SIZE - first_stack_page) & ~(PAGE_SIZE - 1);
  42 + memcpy(&dump->fpu.fpstatus.fregs.regs[0], &current->thread.float_regs[0], (sizeof(unsigned long) * 32));
  43 + dump->fpu.fpstatus.fsr = current->thread.fsr;
  44 + dump->fpu.fpstatus.flags = dump->fpu.fpstatus.extra = 0;
  45 + dump->fpu.fpstatus.fpq_count = current->thread.fpqdepth;
  46 + memcpy(&dump->fpu.fpstatus.fpq[0], &current->thread.fpqueue[0],
  47 + ((sizeof(unsigned long) * 2) * 16));
  48 + dump->sigcode = 0;
  49 +}
  50 +
  51 +#endif /* __KERNEL__ */
  52 +#endif /* _ASM_A_OUT_CORE_H */
include/asm-sparc64/a.out-core.h
  1 +/* a.out coredump register dumper
  2 + *
  3 + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4 + * Written by David Howells (dhowells@redhat.com)
  5 + *
  6 + * This program is free software; you can redistribute it and/or
  7 + * modify it under the terms of the GNU General Public Licence
  8 + * as published by the Free Software Foundation; either version
  9 + * 2 of the Licence, or (at your option) any later version.
  10 + */
  11 +
  12 +#ifndef _ASM_A_OUT_CORE_H
  13 +#define _ASM_A_OUT_CORE_H
  14 +
  15 +#ifdef __KERNEL__
  16 +
  17 +#include <linux/user.h>
  18 +
  19 +/*
  20 + * fill in the user structure for an a.out core dump
  21 + */
  22 +static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
  23 +{
  24 + /* Only should be used for SunOS and ancient a.out
  25 + * SparcLinux binaries... Not worth implementing.
  26 + */
  27 + memset(dump, 0, sizeof(struct user));
  28 +}
  29 +
  30 +#endif /* __KERNEL__ */
  31 +#endif /* _ASM_A_OUT_CORE_H */
include/asm-um/a.out-core.h
  1 +/* a.out coredump register dumper
  2 + *
  3 + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4 + * Written by David Howells (dhowells@redhat.com)
  5 + *
  6 + * This program is free software; you can redistribute it and/or
  7 + * modify it under the terms of the GNU General Public Licence
  8 + * as published by the Free Software Foundation; either version
  9 + * 2 of the Licence, or (at your option) any later version.
  10 + */
  11 +
  12 +#ifndef __UM_A_OUT_CORE_H
  13 +#define __UM_A_OUT_CORE_H
  14 +
  15 +#ifdef __KERNEL__
  16 +
  17 +#include <linux/user.h>
  18 +
  19 +/*
  20 + * fill in the user structure for an a.out core dump
  21 + */
  22 +static inline void aout_dump_thread(struct pt_regs *regs, struct user *u)
  23 +{
  24 +}
  25 +
  26 +#endif /* __KERNEL__ */
  27 +#endif /* __UM_A_OUT_CORE_H */
include/asm-x86/a.out-core.h
  1 +/* a.out coredump register dumper
  2 + *
  3 + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4 + * Written by David Howells (dhowells@redhat.com)
  5 + *
  6 + * This program is free software; you can redistribute it and/or
  7 + * modify it under the terms of the GNU General Public Licence
  8 + * as published by the Free Software Foundation; either version
  9 + * 2 of the Licence, or (at your option) any later version.
  10 + */
  11 +
  12 +#ifndef _ASM_A_OUT_CORE_H
  13 +#define _ASM_A_OUT_CORE_H
  14 +
  15 +#ifdef __KERNEL__
  16 +#ifdef CONFIG_X86_32
  17 +
  18 +#include <linux/user.h>
  19 +#include <linux/elfcore.h>
  20 +
  21 +/*
  22 + * fill in the user structure for an a.out core dump
  23 + */
  24 +static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
  25 +{
  26 + u16 gs;
  27 +
  28 +/* changed the size calculations - should hopefully work better. lbt */
  29 + dump->magic = CMAGIC;
  30 + dump->start_code = 0;
  31 + dump->start_stack = regs->sp & ~(PAGE_SIZE - 1);
  32 + dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
  33 + dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT;
  34 + dump->u_dsize -= dump->u_tsize;
  35 + dump->u_ssize = 0;
  36 + dump->u_debugreg[0] = current->thread.debugreg0;
  37 + dump->u_debugreg[1] = current->thread.debugreg1;
  38 + dump->u_debugreg[2] = current->thread.debugreg2;
  39 + dump->u_debugreg[3] = current->thread.debugreg3;
  40 + dump->u_debugreg[4] = 0;
  41 + dump->u_debugreg[5] = 0;
  42 + dump->u_debugreg[6] = current->thread.debugreg6;
  43 + dump->u_debugreg[7] = current->thread.debugreg7;
  44 +
  45 + if (dump->start_stack < TASK_SIZE)
  46 + dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;
  47 +
  48 + dump->regs.bx = regs->bx;
  49 + dump->regs.cx = regs->cx;
  50 + dump->regs.dx = regs->dx;
  51 + dump->regs.si = regs->si;
  52 + dump->regs.di = regs->di;
  53 + dump->regs.bp = regs->bp;
  54 + dump->regs.ax = regs->ax;
  55 + dump->regs.ds = (u16)regs->ds;
  56 + dump->regs.es = (u16)regs->es;
  57 + dump->regs.fs = (u16)regs->fs;
  58 + savesegment(gs,gs);
  59 + dump->regs.orig_ax = regs->orig_ax;
  60 + dump->regs.ip = regs->ip;
  61 + dump->regs.cs = (u16)regs->cs;
  62 + dump->regs.flags = regs->flags;
  63 + dump->regs.sp = regs->sp;
  64 + dump->regs.ss = (u16)regs->ss;
  65 +
  66 + dump->u_fpvalid = dump_fpu (regs, &dump->i387);
  67 +}
  68 +
  69 +#endif /* CONFIG_X86_32 */
  70 +#endif /* __KERNEL__ */
  71 +#endif /* _ASM_A_OUT_CORE_H */
include/linux/a.out.h
1 1 #ifndef __A_OUT_GNU_H__
2 2 #define __A_OUT_GNU_H__
3 3  
  4 +#ifdef CONFIG_ARCH_SUPPORTS_AOUT
  5 +
4 6 #define __GNU_EXEC_MACROS__
5 7  
6 8 #ifndef __STRUCT_EXEC_OVERRIDE__
... ... @@ -9,6 +11,8 @@
9 11  
10 12 #endif /* __STRUCT_EXEC_OVERRIDE__ */
11 13  
  14 +#ifndef __ASSEMBLY__
  15 +
12 16 /* these go in the N_MACHTYPE field */
13 17 enum machine_type {
14 18 #if defined (M_OLDSUN2)
... ... @@ -272,6 +276,12 @@
272 276 };
273 277 #endif /* no N_RELOCATION_INFO_DECLARED. */
274 278  
275   -
  279 +#endif /*__ASSEMBLY__ */
  280 +#else /* CONFIG_ARCH_SUPPORTS_AOUT */
  281 +#ifndef __ASSEMBLY__
  282 +struct exec {
  283 +};
  284 +#endif
  285 +#endif /* CONFIG_ARCH_SUPPORTS_AOUT */
276 286 #endif /* __A_OUT_GNU_H__ */
include/linux/kernel.h
... ... @@ -172,8 +172,6 @@
172 172 struct pid;
173 173 extern struct pid *session_of_pgrp(struct pid *pgrp);
174 174  
175   -extern void dump_thread(struct pt_regs *regs, struct user *dump);
176   -
177 175 #ifdef CONFIG_PRINTK
178 176 asmlinkage int vprintk(const char *fmt, va_list args)
179 177 __attribute__ ((format (printf, 1, 0)));