]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
On non-linux systems, don't use native signal numbers
authorUlf Hermann <ulf.hermann@qt.io>
Fri, 18 Aug 2017 15:03:50 +0000 (17:03 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 18 Aug 2017 21:35:47 +0000 (23:35 +0200)
We assume core files from linux systems, so we should use the linux
version of the signals when reading them. Other OS might have different
signal numbers.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
src/ChangeLog
src/readelf.c

index 54ba767e97d53bd9b65c2850666bef0fe82f30ea..8aa570518922baec1957fb6bad8d85fae3331073 100644 (file)
@@ -1,3 +1,7 @@
+2017-08-18  Ulf Hermann  <ulf.hermann@qt.io>
+
+       * readelf.c: Hardcode the signal numbers for non-linux systems.
+
 2017-07-26  Mark Wielaard  <mark@klomp.org>
 
        * readelf.c (print_debug_macro_section): Accept either version 4 or
index 73be474bab75adcc9abfe6979008b33aa30235f2..5e2f3fc283f80a91876a6351735921edc19db3ab 100644 (file)
 
 #include "../libdw/known-dwarf.h"
 
+#ifdef __linux__
+#define CORE_SIGILL  SIGILL
+#define CORE_SIGBUS  SIGBUS
+#define CORE_SIGFPE  SIGFPE
+#define CORE_SIGSEGV SIGSEGV
+#define CORE_SI_USER SI_USER
+#else
+/* We want the linux version of those as that is what shows up in the core files. */
+#define CORE_SIGILL  4  /* Illegal instruction (ANSI).  */
+#define CORE_SIGBUS  7  /* BUS error (4.2 BSD).  */
+#define CORE_SIGFPE  8  /* Floating-point exception (ANSI).  */
+#define CORE_SIGSEGV 11 /* Segmentation violation (ANSI).  */
+#define CORE_SI_USER 0  /* Sent by kill, sigsend.  */
+#endif
 
 /* Name and version of program.  */
 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
@@ -9335,10 +9349,10 @@ handle_siginfo_note (Elf *core, GElf_Word descsz, GElf_Off desc_pos)
   if (si_code > 0)
     switch (si_signo)
       {
-      case SIGILL:
-      case SIGFPE:
-      case SIGSEGV:
-      case SIGBUS:
+      case CORE_SIGILL:
+      case CORE_SIGFPE:
+      case CORE_SIGSEGV:
+      case CORE_SIGBUS:
        {
          uint64_t addr;
          if (! buf_read_ulong (core, &ptr, end, &addr))
@@ -9349,7 +9363,7 @@ handle_siginfo_note (Elf *core, GElf_Word descsz, GElf_Off desc_pos)
       default:
        ;
       }
-  else if (si_code == SI_USER)
+  else if (si_code == CORE_SI_USER)
     {
       int pid, uid;
       if (! buf_read_int (core, &ptr, end, &pid)