aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-02-08 07:19:28 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 12:22:30 -0500
commit7fa3031500ec9b0a7460c8c23751799006ffee74 (patch)
tree2a7e9202b35a39dc8217e95825263c0629e67e35 /include
parentb0b933c08bd5fd053bbba8ba6387f543be03d49f (diff)
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>
Diffstat (limited to 'include')
-rw-r--r--include/asm-alpha/a.out-core.h80
-rw-r--r--include/asm-arm/a.out-core.h49
-rw-r--r--include/asm-frv/a.out.h5
-rw-r--r--include/asm-generic/Kbuild.asm2
-rw-r--r--include/asm-m68k/a.out-core.h67
-rw-r--r--include/asm-sparc/a.out-core.h52
-rw-r--r--include/asm-sparc64/a.out-core.h31
-rw-r--r--include/asm-um/a.out-core.h27
-rw-r--r--include/asm-x86/a.out-core.h71
-rw-r--r--include/linux/a.out.h12
-rw-r--r--include/linux/kernel.h2
11 files changed, 390 insertions, 8 deletions
diff --git a/include/asm-alpha/a.out-core.h b/include/asm-alpha/a.out-core.h
new file mode 100644
index 000000000000..9e33e92e524c
--- /dev/null
+++ b/include/asm-alpha/a.out-core.h
@@ -0,0 +1,80 @@
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 */
22static 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 */
diff --git a/include/asm-arm/a.out-core.h b/include/asm-arm/a.out-core.h
new file mode 100644
index 000000000000..93d04acaa31f
--- /dev/null
+++ b/include/asm-arm/a.out-core.h
@@ -0,0 +1,49 @@
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 */
23static 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 */
diff --git a/include/asm-frv/a.out.h b/include/asm-frv/a.out.h
deleted file mode 100644
index dd3b7e5754c9..000000000000
--- a/include/asm-frv/a.out.h
+++ /dev/null
@@ -1,5 +0,0 @@
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 */
diff --git a/include/asm-generic/Kbuild.asm b/include/asm-generic/Kbuild.asm
index 57ba60635959..fd9dcfd91c39 100644
--- a/include/asm-generic/Kbuild.asm
+++ b/include/asm-generic/Kbuild.asm
@@ -1,4 +1,6 @@
1ifeq ($(wildcard include/asm-$(SRCARCH)/a.out.h),include/asm-$(SRCARCH)/a.out.h)
1unifdef-y += a.out.h 2unifdef-y += a.out.h
3endif
2unifdef-y += auxvec.h 4unifdef-y += auxvec.h
3unifdef-y += byteorder.h 5unifdef-y += byteorder.h
4unifdef-y += errno.h 6unifdef-y += errno.h
diff --git a/include/asm-m68k/a.out-core.h b/include/asm-m68k/a.out-core.h
new file mode 100644
index 000000000000..f6bfc1d63ff6
--- /dev/null
+++ b/include/asm-m68k/a.out-core.h
@@ -0,0 +1,67 @@
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 */
23static 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 */
diff --git a/include/asm-sparc/a.out-core.h b/include/asm-sparc/a.out-core.h
new file mode 100644
index 000000000000..e8fd338ed0b2
--- /dev/null
+++ b/include/asm-sparc/a.out-core.h
@@ -0,0 +1,52 @@
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 */
22static 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 */
diff --git a/include/asm-sparc64/a.out-core.h b/include/asm-sparc64/a.out-core.h
new file mode 100644
index 000000000000..3499b3c425ca
--- /dev/null
+++ b/include/asm-sparc64/a.out-core.h
@@ -0,0 +1,31 @@
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 */
22static 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 */
diff --git a/include/asm-um/a.out-core.h b/include/asm-um/a.out-core.h
new file mode 100644
index 000000000000..995643b18309
--- /dev/null
+++ b/include/asm-um/a.out-core.h
@@ -0,0 +1,27 @@
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 */
22static 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 */
diff --git a/include/asm-x86/a.out-core.h b/include/asm-x86/a.out-core.h
new file mode 100644
index 000000000000..d2b6e11d3e97
--- /dev/null
+++ b/include/asm-x86/a.out-core.h
@@ -0,0 +1,71 @@
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 */
24static 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 */
diff --git a/include/linux/a.out.h b/include/linux/a.out.h
index 82cd918f2ab7..208f4e8ed304 100644
--- a/include/linux/a.out.h
+++ b/include/linux/a.out.h
@@ -1,6 +1,8 @@
1#ifndef __A_OUT_GNU_H__ 1#ifndef __A_OUT_GNU_H__
2#define __A_OUT_GNU_H__ 2#define __A_OUT_GNU_H__
3 3
4#ifdef CONFIG_ARCH_SUPPORTS_AOUT
5
4#define __GNU_EXEC_MACROS__ 6#define __GNU_EXEC_MACROS__
5 7
6#ifndef __STRUCT_EXEC_OVERRIDE__ 8#ifndef __STRUCT_EXEC_OVERRIDE__
@@ -9,6 +11,8 @@
9 11
10#endif /* __STRUCT_EXEC_OVERRIDE__ */ 12#endif /* __STRUCT_EXEC_OVERRIDE__ */
11 13
14#ifndef __ASSEMBLY__
15
12/* these go in the N_MACHTYPE field */ 16/* these go in the N_MACHTYPE field */
13enum machine_type { 17enum machine_type {
14#if defined (M_OLDSUN2) 18#if defined (M_OLDSUN2)
@@ -272,5 +276,11 @@ struct relocation_info
272}; 276};
273#endif /* no N_RELOCATION_INFO_DECLARED. */ 277#endif /* no N_RELOCATION_INFO_DECLARED. */
274 278
275 279#endif /*__ASSEMBLY__ */
280#else /* CONFIG_ARCH_SUPPORTS_AOUT */
281#ifndef __ASSEMBLY__
282struct exec {
283};
284#endif
285#endif /* CONFIG_ARCH_SUPPORTS_AOUT */
276#endif /* __A_OUT_GNU_H__ */ 286#endif /* __A_OUT_GNU_H__ */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 9e01f376840a..568042290c0b 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -172,8 +172,6 @@ extern int kernel_text_address(unsigned long addr);
172struct pid; 172struct pid;
173extern struct pid *session_of_pgrp(struct pid *pgrp); 173extern struct pid *session_of_pgrp(struct pid *pgrp);
174 174
175extern void dump_thread(struct pt_regs *regs, struct user *dump);
176
177#ifdef CONFIG_PRINTK 175#ifdef CONFIG_PRINTK
178asmlinkage int vprintk(const char *fmt, va_list args) 176asmlinkage int vprintk(const char *fmt, va_list args)
179 __attribute__ ((format (printf, 1, 0))); 177 __attribute__ ((format (printf, 1, 0)));