]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
backends: Add x32_corenote.c
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 12 Mar 2015 21:51:42 +0000 (14:51 -0700)
committerMark Wielaard <mjw@redhat.com>
Wed, 1 Apr 2015 18:45:13 +0000 (20:45 +0200)
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>
backends/ChangeLog
backends/Makefile.am
backends/linux-core-note.c
backends/x32_corenote.c [new file with mode: 0644]
backends/x86_64_corenote.c
backends/x86_64_init.c

index 0a47b75ec33aec1871cee26dee2391725df64f6f..8d9ecc1c414d1e4a08be7a0abce15b14362fda07 100644 (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
index 687c089d35802cbf384cb89cc50228e02305e580..21d7bd24da3eaa5582580bea1d421d55849e1ad7 100644 (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)
index e3c0109822f75e48946f52d3be1a0c3585c0660b..db82e85e7e44c8f5c6ca1cfba275b8479c4bba4e 100644 (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
 #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'),
diff --git a/backends/x32_corenote.c b/backends/x32_corenote.c
new file mode 100644 (file)
index 0000000..bd6560d
--- /dev/null
@@ -0,0 +1,2 @@
+#define BITS 32
+#include "x86_64_corenote.c"
index f9d8db452e79c86a18e295b12553a58c806209e3..1bacc60f5c294f20fb57c80803b9de4ab851eb68 100644 (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
 #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
index b885558b0b64738dffae44b16415c0b7cf2b617d..273eabbf2ec180152348d411e48d3fd921adb04c 100644 (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);