Commit f2485a2d authored by Al Viro's avatar Al Viro
Browse files

elf_prstatus: collect the common part (everything before pr_reg) into a struct



Preparations to doing i386 compat elf_prstatus sanely - rather than duplicating
the beginning of compat_elf_prstatus, take these fields into a separate
structure (compat_elf_prstatus_common), so that it could be reused.  Due to
the incestous relationship between binfmt_elf.c and compat_binfmt_elf.c we
need the same shape change done to native struct elf_prstatus, gathering the
fields prior to pr_reg into a new structure (struct elf_prstatus_common).

Fortunately, offset of pr_reg is always a multiple of 16 with no padding
right before it, so it's possible to turn all the stuff prior to it into
a single member without disturbing the layout.

[build fix from Geert Uytterhoeven folded in]

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 8a00dd00
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ crash_save_this_cpu(void)

	elf_greg_t *dst = (elf_greg_t *)&(prstatus->pr_reg);
	memset(prstatus, 0, sizeof(*prstatus));
	prstatus->pr_pid = current->pid;
	prstatus->common.pr_pid = current->pid;

	ia64_dump_cpu_regs(dst);
	cfm = dst[43];
+6 −1
Original line number Diff line number Diff line
@@ -44,7 +44,8 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
#include <linux/math64.h>

#define elf_prstatus elf_prstatus32
struct elf_prstatus32
#define elf_prstatus_common elf_prstatus32_common
struct elf_prstatus32_common
{
	struct elf_siginfo pr_info;	/* Info associated with signal */
	short	pr_cursig;		/* Current signal */
@@ -58,6 +59,10 @@ struct elf_prstatus32
	struct old_timeval32 pr_stime; /* System time */
	struct old_timeval32 pr_cutime;/* Cumulative user time */
	struct old_timeval32 pr_cstime;/* Cumulative system time */
};
struct elf_prstatus32
{
	struct elf_prstatus32_common common:
	elf_gregset_t pr_reg;	/* GP registers */
	int pr_fpvalid;		/* True if math co-processor being used.  */
};
+5 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
#include <linux/math64.h>

#define elf_prstatus elf_prstatus32
struct elf_prstatus32
struct elf_prstatus32_common
{
	struct elf_siginfo pr_info;	/* Info associated with signal */
	short	pr_cursig;		/* Current signal */
@@ -63,6 +63,10 @@ struct elf_prstatus32
	struct old_timeval32 pr_stime; /* System time */
	struct old_timeval32 pr_cutime;/* Cumulative user time */
	struct old_timeval32 pr_cstime;/* Cumulative system time */
};
struct elf_prstatus32
{
	struct elf_prstatus32_common common:
	elf_gregset_t pr_reg;	/* GP registers */
	int pr_fpvalid;		/* True if math co-processor being used.  */
};
+3 −3
Original line number Diff line number Diff line
@@ -119,8 +119,8 @@ static void fill_prstatus(struct elf_prstatus *prstatus, int pir,
	 * As a PIR value could also be '0', add an offset of '100'
	 * to every PIR to avoid misinterpretations in GDB.
	 */
	prstatus->pr_pid  = cpu_to_be32(100 + pir);
	prstatus->pr_ppid = cpu_to_be32(1);
	prstatus->common.pr_pid  = cpu_to_be32(100 + pir);
	prstatus->common.pr_ppid = cpu_to_be32(1);

	/*
	 * Indicate SIGUSR1 for crash initiated from kernel.
@@ -130,7 +130,7 @@ static void fill_prstatus(struct elf_prstatus *prstatus, int pir,
		short sig;

		sig = kernel_initiated ? SIGUSR1 : SIGTERM;
		prstatus->pr_cursig = cpu_to_be16(sig);
		prstatus->common.pr_cursig = cpu_to_be16(sig);
	}
}

+1 −1
Original line number Diff line number Diff line
@@ -365,7 +365,7 @@ static void *fill_cpu_elf_notes(void *ptr, int cpu, struct save_area *sa)
	memcpy(&nt_prstatus.pr_reg.gprs, sa->gprs, sizeof(sa->gprs));
	memcpy(&nt_prstatus.pr_reg.psw, sa->psw, sizeof(sa->psw));
	memcpy(&nt_prstatus.pr_reg.acrs, sa->acrs, sizeof(sa->acrs));
	nt_prstatus.pr_pid = cpu;
	nt_prstatus.common.pr_pid = cpu;
	/* Prepare fpregset (floating point) note */
	memset(&nt_fpregset, 0, sizeof(nt_fpregset));
	memcpy(&nt_fpregset.fpc, &sa->fpc, sizeof(sa->fpc));
Loading