Commit 7d2f551f authored by Al Viro's avatar Al Viro

restore 32bit aout coredump

just getting rid of bitrot
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 0f6ed63b
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/personality.h> #include <linux/personality.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/perf_event.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/pgalloc.h> #include <asm/pgalloc.h>
...@@ -33,14 +34,18 @@ ...@@ -33,14 +34,18 @@
#include <asm/ia32.h> #include <asm/ia32.h>
#undef WARN_OLD #undef WARN_OLD
#undef CORE_DUMP /* definitely broken */
static int load_aout_binary(struct linux_binprm *); static int load_aout_binary(struct linux_binprm *);
static int load_aout_library(struct file *); static int load_aout_library(struct file *);
#ifdef CORE_DUMP #ifdef CONFIG_COREDUMP
static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, static int aout_core_dump(struct coredump_params *);
unsigned long limit);
static unsigned long get_dr(int n)
{
struct perf_event *bp = current->thread.ptrace_bps[n];
return bp ? bp->hw.info.address : 0;
}
/* /*
* fill in the user structure for a core dump.. * fill in the user structure for a core dump..
...@@ -48,6 +53,7 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, ...@@ -48,6 +53,7 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
static void dump_thread32(struct pt_regs *regs, struct user32 *dump) static void dump_thread32(struct pt_regs *regs, struct user32 *dump)
{ {
u32 fs, gs; u32 fs, gs;
memset(dump, 0, sizeof(*dump));
/* changed the size calculations - should hopefully work better. lbt */ /* changed the size calculations - should hopefully work better. lbt */
dump->magic = CMAGIC; dump->magic = CMAGIC;
...@@ -57,15 +63,12 @@ static void dump_thread32(struct pt_regs *regs, struct user32 *dump) ...@@ -57,15 +63,12 @@ static void dump_thread32(struct pt_regs *regs, struct user32 *dump)
dump->u_dsize = ((unsigned long) dump->u_dsize = ((unsigned long)
(current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT; (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT;
dump->u_dsize -= dump->u_tsize; dump->u_dsize -= dump->u_tsize;
dump->u_ssize = 0; dump->u_debugreg[0] = get_dr(0);
dump->u_debugreg[0] = current->thread.debugreg0; dump->u_debugreg[1] = get_dr(1);
dump->u_debugreg[1] = current->thread.debugreg1; dump->u_debugreg[2] = get_dr(2);
dump->u_debugreg[2] = current->thread.debugreg2; dump->u_debugreg[3] = get_dr(3);
dump->u_debugreg[3] = current->thread.debugreg3;
dump->u_debugreg[4] = 0;
dump->u_debugreg[5] = 0;
dump->u_debugreg[6] = current->thread.debugreg6; dump->u_debugreg[6] = current->thread.debugreg6;
dump->u_debugreg[7] = current->thread.debugreg7; dump->u_debugreg[7] = current->thread.ptrace_dr7;
if (dump->start_stack < 0xc0000000) { if (dump->start_stack < 0xc0000000) {
unsigned long tmp; unsigned long tmp;
...@@ -74,24 +77,24 @@ static void dump_thread32(struct pt_regs *regs, struct user32 *dump) ...@@ -74,24 +77,24 @@ static void dump_thread32(struct pt_regs *regs, struct user32 *dump)
dump->u_ssize = tmp >> PAGE_SHIFT; dump->u_ssize = tmp >> PAGE_SHIFT;
} }
dump->regs.bx = regs->bx; dump->regs.ebx = regs->bx;
dump->regs.cx = regs->cx; dump->regs.ecx = regs->cx;
dump->regs.dx = regs->dx; dump->regs.edx = regs->dx;
dump->regs.si = regs->si; dump->regs.esi = regs->si;
dump->regs.di = regs->di; dump->regs.edi = regs->di;
dump->regs.bp = regs->bp; dump->regs.ebp = regs->bp;
dump->regs.ax = regs->ax; dump->regs.eax = regs->ax;
dump->regs.ds = current->thread.ds; dump->regs.ds = current->thread.ds;
dump->regs.es = current->thread.es; dump->regs.es = current->thread.es;
savesegment(fs, fs); savesegment(fs, fs);
dump->regs.fs = fs; dump->regs.fs = fs;
savesegment(gs, gs); savesegment(gs, gs);
dump->regs.gs = gs; dump->regs.gs = gs;
dump->regs.orig_ax = regs->orig_ax; dump->regs.orig_eax = regs->orig_ax;
dump->regs.ip = regs->ip; dump->regs.eip = regs->ip;
dump->regs.cs = regs->cs; dump->regs.cs = regs->cs;
dump->regs.flags = regs->flags; dump->regs.eflags = regs->flags;
dump->regs.sp = regs->sp; dump->regs.esp = regs->sp;
dump->regs.ss = regs->ss; dump->regs.ss = regs->ss;
#if 1 /* FIXME */ #if 1 /* FIXME */
...@@ -107,7 +110,7 @@ static struct linux_binfmt aout_format = { ...@@ -107,7 +110,7 @@ static struct linux_binfmt aout_format = {
.module = THIS_MODULE, .module = THIS_MODULE,
.load_binary = load_aout_binary, .load_binary = load_aout_binary,
.load_shlib = load_aout_library, .load_shlib = load_aout_library,
#ifdef CORE_DUMP #ifdef CONFIG_COREDUMP
.core_dump = aout_core_dump, .core_dump = aout_core_dump,
#endif #endif
.min_coredump = PAGE_SIZE .min_coredump = PAGE_SIZE
...@@ -122,7 +125,7 @@ static void set_brk(unsigned long start, unsigned long end) ...@@ -122,7 +125,7 @@ static void set_brk(unsigned long start, unsigned long end)
vm_brk(start, end - start); vm_brk(start, end - start);
} }
#ifdef CORE_DUMP #ifdef CONFIG_COREDUMP
/* /*
* These are the only things you should do on a core-file: use only these * These are the only things you should do on a core-file: use only these
* macros to write out all the necessary info. * macros to write out all the necessary info.
...@@ -131,14 +134,14 @@ static void set_brk(unsigned long start, unsigned long end) ...@@ -131,14 +134,14 @@ static void set_brk(unsigned long start, unsigned long end)
#include <linux/coredump.h> #include <linux/coredump.h>
#define DUMP_WRITE(addr, nr) \ #define DUMP_WRITE(addr, nr) \
if (!dump_write(file, (void *)(addr), (nr))) \ if (!dump_write(cprm->file, (void *)(addr), (nr))) \
goto end_coredump; goto end_coredump;
#define DUMP_SEEK(offset) \ #define DUMP_SEEK(offset) \
if (!dump_seek(file, offset)) \ if (!dump_seek(cprm->file, offset)) \
goto end_coredump; goto end_coredump;
#define START_DATA() (u.u_tsize << PAGE_SHIFT) #define START_DATA(u) (u.u_tsize << PAGE_SHIFT)
#define START_STACK(u) (u.start_stack) #define START_STACK(u) (u.start_stack)
/* /*
...@@ -151,8 +154,7 @@ static void set_brk(unsigned long start, unsigned long end) ...@@ -151,8 +154,7 @@ static void set_brk(unsigned long start, unsigned long end)
* dumping of the process results in another error.. * dumping of the process results in another error..
*/ */
static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, static int aout_core_dump(struct coredump_params *cprm)
unsigned long limit)
{ {
mm_segment_t fs; mm_segment_t fs;
int has_dumped = 0; int has_dumped = 0;
...@@ -164,19 +166,19 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, ...@@ -164,19 +166,19 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
has_dumped = 1; has_dumped = 1;
strncpy(dump.u_comm, current->comm, sizeof(current->comm)); strncpy(dump.u_comm, current->comm, sizeof(current->comm));
dump.u_ar0 = offsetof(struct user32, regs); dump.u_ar0 = offsetof(struct user32, regs);
dump.signal = signr; dump.signal = cprm->siginfo->si_signo;
dump_thread32(regs, &dump); dump_thread32(cprm->regs, &dump);
/* /*
* If the size of the dump file exceeds the rlimit, then see * If the size of the dump file exceeds the rlimit, then see
* what would happen if we wrote the stack, but not the data * what would happen if we wrote the stack, but not the data
* area. * area.
*/ */
if ((dump.u_dsize + dump.u_ssize + 1) * PAGE_SIZE > limit) if ((dump.u_dsize + dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
dump.u_dsize = 0; dump.u_dsize = 0;
/* Make sure we have enough room to write the stack and data areas. */ /* Make sure we have enough room to write the stack and data areas. */
if ((dump.u_ssize + 1) * PAGE_SIZE > limit) if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
dump.u_ssize = 0; dump.u_ssize = 0;
/* make sure we actually have a data and stack area to dump */ /* make sure we actually have a data and stack area to dump */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment