]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
backends: Use ebl->class consistently in sparc backend.
authorMark Wielaard <mjw@redhat.com>
Thu, 3 Sep 2015 10:50:54 +0000 (12:50 +0200)
committerMark Wielaard <mjw@redhat.com>
Thu, 3 Sep 2015 10:50:54 +0000 (12:50 +0200)
sparc_init would check the ELF class to register to correct core_note
handler. But sparc_register_info would check the ELF machine to determine
whether the register set was 32 or 64 bits. This caused some confusion
and assertion failures in readelf when printing core notes where the
sparc machine and class didn't seem to match up. Check the ELF class
in both sparc_unit and sparc_register_info to give consistent results.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
backends/ChangeLog
backends/sparc_regs.c

index c95e80f1200bf61072ea8ab1fb7f993418c0ac3b..4accedcb389deb49990c9e9d6525153389f2bdd8 100644 (file)
@@ -1,3 +1,7 @@
+2015-09-03  Mark Wielaard  <mjw@redhat.com>
+
+       * sparc_regs.c (sparc_register_info): Use ebl->class not ebl->machine.
+
 2015-06-26  Pino Toscano  <toscano.pino@tiscali.it>
 
        * i386_initreg.c: Reduce scope of some includes to match their usage.
index f9709bb30c8894f205b86309ca7be00799c1f7cd..2bddcf435b4bb50d28b1380e2d2fe85490e7ab73 100644 (file)
@@ -1,5 +1,5 @@
 /* Register names and numbers for SPARC DWARF.
-   Copyright (C) 2005, 2006 Red Hat, Inc.
+   Copyright (C) 2005, 2006, 2015 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -42,8 +42,8 @@ sparc_register_info (Ebl *ebl,
                     const char **prefix, const char **setname,
                     int *bits, int *type)
 {
-  const int nfp = 32 + (ebl->machine == EM_SPARC ? 0 : 16);
-  const int nspec = ebl->machine == EM_SPARC ? 8 : 6;
+  const int nfp = 32 + (ebl->class == ELFCLASS32 ? 0 : 16);
+  const int nspec = ebl->class == ELFCLASS32 ? 8 : 6;
 
   if (name == NULL)
     return 32 + nfp + nspec;
@@ -51,7 +51,7 @@ sparc_register_info (Ebl *ebl,
   if (regno < 0 || regno >= 32 + nfp + nspec || namelen < 6)
     return -1;
 
-  *bits = ebl->machine == EM_SPARC ? 32 : 64;
+  *bits = ebl->class == ELFCLASS32 ? 32 : 64;
   *type = DW_ATE_signed;
 
   *prefix = "%";
@@ -66,9 +66,9 @@ sparc_register_info (Ebl *ebl,
        };
       *setname = "control";
       *type = DW_ATE_unsigned;
-      if ((ebl->machine != EM_SPARC ? 0 : 4) + 1 - (unsigned int) regno <= 1)
+      if ((ebl->class == ELFCLASS64 ? 0 : 4) + 1 - (unsigned int) regno <= 1)
        *type = DW_ATE_address;
-      return stpncpy (name, names[ebl->machine != EM_SPARC][regno],
+      return stpncpy (name, names[ebl->class == ELFCLASS64][regno],
                      namelen) + 1 - name;
     }