public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Ulf Hermann <ulf.hermann@qt.io>
To: <elfutils-devel@sourceware.org>
Subject: [PATCH] On non-linux systems, don't use native signal numbers
Date: Mon, 08 May 2017 16:22:00 -0000	[thread overview]
Message-ID: <2ec3c504-8706-010f-d8fd-078c2abea71e@qt.io> (raw)

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/readelf.c | 25 ++++++++++++++++++++-----
  1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/readelf.c b/src/readelf.c
index 6811ace..01d2a56 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -57,6 +57,21 @@
   #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;
@@ -9244,10 +9259,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))
@@ -9258,7 +9273,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)
-- 
2.8.1.windows.1

                 reply	other threads:[~2017-05-08 11:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2ec3c504-8706-010f-d8fd-078c2abea71e@qt.io \
    --to=ulf.hermann@qt.io \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).