backends: Add x32_corenote.c

This patch adds x32_corenote.c to support x32 coredump.  X32 coredump is
a hybrid between ia32 coredump and x86-64 coredump.  The exact formats
are described in bfd/hosts/x86-64linux.h in GNU binutils source tree.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
H.J. Lu
2015-03-12 14:51:42 -07:00
committed by Mark Wielaard
parent 7f61734779
commit 28ce4e89d3
6 changed files with 92 additions and 11 deletions
+32
View File
@@ -1,3 +1,35 @@
2015-04-01 H.J. Lu <hjl.tools@gmail.com>
* Makefile.am (x86_64_SRCS): Add x32_corenote.c.
* linux-core-note.c (PR_REG): New.
(PRPSINFO_UID_T): Likewise.
(ALIGN_PRPSINFO_UID_T): Likewise.
(TYPE_PRPSINFO_UID_T): Likewise.
(PRPSINFO_GID_T): Likewise.
(ALIGN_PRPSINFO_GID_T): Likewise.
(TYPE_PRPSINFO_GID_T): Likewise.
(pr_reg): Replace ULONG with PR_REG.
(pr_uid): Replace UID_T with PRPSINFO_UID_T.
(uid): Likewise.
(pr_gid): Replace GID_T with PRPSINFO_GID_T.
(gid): Likewise.
* x32_corenote.c: New file.
* x86_64_corenote.c (BITS): New. Support x32.
(BACKEND): Support x32.
(ULONG): Likewise.
(ALIGN_ULONG): Likewise.
(TYPE_ULONG): Likewise.
(PRPSINFO_UID_T): New.
(ALIGN_PRPSINFO_UID_T): Likewise.
(TYPE_PRPSINFO_UID_T): Likewise.
(PRPSINFO_GID_T): Likewise.
(ALIGN_PRPSINFO_GID_T): Likewise.
(TYPE_PRPSINFO_GID_T): Likewise.
(PR_REG): Likewise.
(ALIGN_PR_REG): Likewise.
* x86_64_init.c (x32_core_note): New.
(x86_64_init): Set eh->core_note to x32_core_note for x32.
2015-03-23 Mark Wielaard <mjw@redhat.com>
* aarch64_symbol.c (aarch64_check_special_symbol): Accept
+1 -1
View File
@@ -58,7 +58,7 @@ am_libebl_sh_pic_a_OBJECTS = $(sh_SRCS:.c=.os)
x86_64_SRCS = x86_64_init.c x86_64_symbol.c x86_64_corenote.c x86_64_cfi.c \
x86_64_retval.c x86_64_regs.c i386_auxv.c x86_64_syscall.c \
x86_64_initreg.c
x86_64_initreg.c x32_corenote.c
cpu_x86_64 = ../libcpu/libcpu_x86_64.a
libebl_x86_64_pic_a_SOURCES = $(x86_64_SRCS)
am_libebl_x86_64_pic_a_OBJECTS = $(x86_64_SRCS:.c=.os)
+19 -5
View File
@@ -1,5 +1,6 @@
/* Common core note type descriptions for Linux.
Copyright (C) 2007-2010 Red Hat, Inc.
Copyright (C) H.J. Lu <hjl.tools@gmail.com>, 2015.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -42,9 +43,22 @@
#define INT int32_t
#define ALIGN_INT 4
#define TYPE_INT ELF_T_SWORD
#ifndef PR_REG
# define PR_REG ULONG
#endif
#ifndef ALIGN_PR_REG
# define ALIGN_PR_REG ALIGN_ULONG
#endif
#ifndef PRPSINFO_UID_T
# define PRPSINFO_UID_T UID_T
# define ALIGN_PRPSINFO_UID_T ALIGN_UID_T
# define TYPE_PRPSINFO_UID_T TYPE_UID_T
#endif
#ifndef PRPSINFO_GID_T
# define PRPSINFO_GID_T GID_T
# define ALIGN_PRPSINFO_GID_T ALIGN_GID_T
# define TYPE_PRPSINFO_GID_T TYPE_GID_T
#endif
#define FIELD(type, name) type name __attribute__ ((aligned (ALIGN_##type)))
@@ -86,7 +100,7 @@ struct EBLHOOK(prstatus)
struct EBLHOOK(timeval) pr_cstime;
struct
{
FIELD (ULONG, pr_reg[PRSTATUS_REGS_SIZE / sizeof (ULONG)]);
FIELD (PR_REG, pr_reg[PRSTATUS_REGS_SIZE / sizeof (PR_REG)]);
}
#ifdef ALIGN_PR_REG
__attribute__ ((aligned (ALIGN_PR_REG)))
@@ -105,8 +119,8 @@ struct EBLHOOK(prpsinfo)
FIELD (CHAR, pr_zomb);
FIELD (CHAR, pr_nice);
FIELD (ULONG, pr_flag);
FIELD (UID_T, pr_uid);
FIELD (GID_T, pr_gid);
FIELD (PRPSINFO_UID_T, pr_uid);
FIELD (PRPSINFO_GID_T, pr_gid);
FIELD (PID_T, pr_pid);
FIELD (PID_T, pr_ppid);
FIELD (PID_T, pr_pgrp);
@@ -170,8 +184,8 @@ static const Ebl_Core_Item prpsinfo_items[] =
FIELD (state, CHAR, zomb, 'd'),
FIELD (state, CHAR, nice, 'd'),
FIELD (state, ULONG, flag, 'x'),
FIELD (identity, UID_T, uid, 'd'),
FIELD (identity, GID_T, gid, 'd'),
FIELD (identity, PRPSINFO_UID_T, uid, 'd'),
FIELD (identity, PRPSINFO_GID_T, gid, 'd'),
FIELD (identity, PID_T, pid, 'd'),
FIELD (identity, PID_T, ppid, 'd'),
FIELD (identity, PID_T, pgrp, 'd'),
+2
View File
@@ -0,0 +1,2 @@
#define BITS 32
#include "x86_64_corenote.c"
+31 -4
View File
@@ -1,5 +1,6 @@
/* x86-64 specific core note handling.
Copyright (C) 2005, 2007, 2008 Red Hat, Inc.
Copyright (C) H.J. Lu <hjl.tools@gmail.com>, 2015.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -36,7 +37,13 @@
#include <stdio.h>
#include <sys/time.h>
#define BACKEND x86_64_
#ifndef BITS
# define BITS 64
# define BACKEND x86_64_
#else
# define BITS 32
# define BACKEND x32_
#endif
#include "libebl_CPU.h"
@@ -77,15 +84,35 @@ static const Ebl_Register_Location prstatus_regs[] =
};
#define PRSTATUS_REGS_SIZE (27 * 8)
#define ULONG uint64_t
#if BITS == 32
# define ULONG uint32_t
# define ALIGN_ULONG 4
# define TYPE_ULONG ELF_T_WORD
# define PRPSINFO_UID_T uint16_t
# define ALIGN_PRPSINFO_UID_T 2
# define TYPE_PRPSINFO_UID_T ELF_T_HALF
# define PRPSINFO_GID_T uint16_t
# define ALIGN_PRPSINFO_GID_T 2
# define TYPE_PRPSINFO_GID_T ELF_T_HALF
#else
# define ULONG uint64_t
# define ALIGN_ULONG 8
# define TYPE_ULONG ELF_T_XWORD
# define PRPSINFO_UID_T uint32_t
# define ALIGN_PRPSINFO_UID_T 4
# define TYPE_PRPSINFO_UID_T TYPE_UID_T
# define PRPSINFO_GID_T uint32_t
# define ALIGN_PRPSINFO_GID_T 4
# define TYPE_PRPSINFO_GID_T TYPE_GID_T
#endif
#define PR_REG uint64_t
#define ALIGN_PR_REG 8
#define PID_T int32_t
#define UID_T uint32_t
#define GID_T uint32_t
#define ALIGN_ULONG 8
#define ALIGN_PID_T 4
#define ALIGN_UID_T 4
#define ALIGN_GID_T 4
#define TYPE_ULONG ELF_T_XWORD
#define TYPE_PID_T ELF_T_SWORD
#define TYPE_UID_T ELF_T_SWORD
#define TYPE_GID_T ELF_T_SWORD
+7 -1
View File
@@ -1,5 +1,6 @@
/* Initialization of x86-64 specific backend library.
Copyright (C) 2002-2009, 2013 Red Hat, Inc.
Copyright (C) H.J. Lu <hjl.tools@gmail.com>, 2015.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -38,6 +39,8 @@
/* This defines the common reloc hooks based on x86_64_reloc.def. */
#include "common-reloc.c"
extern __typeof (EBLHOOK (core_note)) x32_core_note attribute_hidden;
const char *
x86_64_init (elf, machine, eh, ehlen)
Elf *elf __attribute__ ((unused));
@@ -53,7 +56,10 @@ x86_64_init (elf, machine, eh, ehlen)
eh->name = "AMD x86-64";
x86_64_init_reloc (eh);
HOOK (eh, reloc_simple_type);
HOOK (eh, core_note);
if (eh->class == ELFCLASS32)
eh->core_note = x32_core_note;
else
HOOK (eh, core_note);
HOOK (eh, return_value_location);
HOOK (eh, register_info);
HOOK (eh, syscall_abi);