]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
.
authorJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 12 Nov 2012 15:24:43 +0000 (16:24 +0100)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 12 Nov 2012 15:24:43 +0000 (16:24 +0100)
backends/core-get-pc.c
libdwfl/dwfl_frame_state.c
libelf/Makefile.am
libelf/gelf_convert.c [deleted file]
libelf/libelf.h
libelf/libelf.map

index 5cb19518f127397d8619f848c943f84255a9a1ef..164876ca989da2e1b1a8ae440b6c378259ab747f 100644 (file)
@@ -61,25 +61,23 @@ core_get_pc (Elf *core, Dwarf_Addr *core_pc, unsigned pc_offset)
          switch (bits)
          {
            case 32:;
-             Elf32_Word val32;
-             reg_desc = gelf_convert (core, ELF_T_WORD, ELF_T_WORD, &val32,
-                                      reg_desc);
-             /* NULL REG_DESC is caught below.  */
+             uint32_t val32 = *(const uint32_t *) reg_desc;
+             reg_desc += sizeof (val32);
+             val32 = (elf_getident (core, NULL)[EI_DATA] == ELFDATA2MSB
+                      ? be32toh (val32) : le32toh (val32));
              /* Do a host width conversion.  */
              val = val32;
              break;
            case 64:;
-             Elf64_Xword val64;
-             reg_desc = gelf_convert (core, ELF_T_XWORD, ELF_T_XWORD, &val64,
-                                      reg_desc);
-             /* NULL REG_DESC is caught below.  */
+             uint64_t val64 = *(const uint64_t *) reg_desc;
+             reg_desc += sizeof (val64);
+             val64 = (elf_getident (core, NULL)[EI_DATA] == ELFDATA2MSB
+                      ? be64toh (val64) : le64toh (val64));
              val = val64;
              break;
            default:
              abort ();
          }
-         if (reg_desc == NULL)
-           continue;
          *core_pc = val;
          return true;
        }
index ee8048ee3f095aa5b14f3bd3a43273d8962f2548..1cc18f77077de3888bbd8e0f424eaf797e4487d4 100644 (file)
@@ -528,18 +528,17 @@ dwfl_frame_state_core (Dwfl *dwfl, const char *corefile)
              for (item = items; item < items + nitems; item++)
                if (strcmp (item->name, "pid") == 0)
                  break;
-             Elf32_Sword val32s;
-             if (item == items + nitems
-                 || gelf_convert (core, ELF_T_SWORD, item->type, &val32s,
-                                  desc + item->offset)
-                    == NULL)
+             if (item == items + nitems)
                {
                  process_free (process);
                  __libdwfl_seterrno (DWFL_E_BADELF);
                  return NULL;
                }
-             pid_t tid = val32s;
-             eu_static_assert (sizeof val32s <= sizeof tid);
+             uint32_t val32 = *(const uint32_t *) (desc + item->offset);
+             val32 = (elf_getident (core, NULL)[EI_DATA] == ELFDATA2MSB
+                       ? be32toh (val32) : le32toh (val32));
+             pid_t tid = (int32_t) val32;
+             eu_static_assert (sizeof val32 <= sizeof tid);
              if (thread)
                {
                  /* Delay initialization of THREAD till all notes for it have
@@ -588,30 +587,22 @@ dwfl_frame_state_core (Dwfl *dwfl, const char *corefile)
                  switch (regloc->bits)
                  {
                    case 32:;
-                     Elf32_Word val32;
-                     reg_desc = gelf_convert (core, ELF_T_WORD, ELF_T_WORD,
-                                              &val32, reg_desc);
-                     /* NULL REG_DESC is caught below.  */
+                     uint32_t val32 = *(const uint32_t *) reg_desc;
+                     val32 = (elf_getident (core, NULL)[EI_DATA] == ELFDATA2MSB
+                              ? be32toh (val32) : le32toh (val32));
                      /* Do a host width conversion.  */
                      val = val32;
                      break;
                    case 64:;
-                     Elf64_Xword val64;
-                     reg_desc = gelf_convert (core, ELF_T_XWORD, ELF_T_XWORD,
-                                              &val64, reg_desc);
-                     /* NULL REG_DESC is caught below.  */
+                     uint64_t val64 = *(const uint64_t *) reg_desc;
+                     val64 = (elf_getident (core, NULL)[EI_DATA] == ELFDATA2MSB
+                              ? be64toh (val64) : le64toh (val64));
                      assert (sizeof (*state->regs) == sizeof (val64));
                      val = val64;
                      break;
                    default:
                      abort ();
                  }
-                 if (reg_desc == NULL)
-                   {
-                     process_free (process);
-                     __libdwfl_seterrno (DWFL_E_BADELF);
-                     return NULL;
-                   }
                  /* Registers not valid for CFI are just ignored.  */
                  dwfl_frame_state_reg_set (state, regno, val);
                  reg_desc += regloc->pad;
index c4458f1826c8e51026a9bfd636a900f836c8b380..5903ea8685c1a5388a6e82466fcb09f1edeb87b4 100644 (file)
@@ -90,7 +90,7 @@ libelf_a_SOURCES = elf_version.c elf_hash.c elf_error.c elf_fill.c \
                   elf32_offscn.c elf64_offscn.c gelf_offscn.c \
                   elf_getaroff.c \
                   elf_gnu_hash.c \
-                  elf_scnshndx.c gelf_convert.c
+                  elf_scnshndx.c
 
 if !MUDFLAP
 libelf_pic_a_SOURCES =
diff --git a/libelf/gelf_convert.c b/libelf/gelf_convert.c
deleted file mode 100644 (file)
index 5396d37..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Convert DATA from ELF to VALUE in host memory.
-   Copyright (C) 2012 Red Hat, Inc.
-   This file is part of elfutils.
-
-   This file is free software; you can redistribute it and/or modify
-   it under the terms of either
-
-     * the GNU Lesser General Public License as published by the Free
-       Software Foundation; either version 3 of the License, or (at
-       your option) any later version
-
-   or
-
-     * the GNU General Public License as published by the Free
-       Software Foundation; either version 2 of the License, or (at
-       your option) any later version
-
-   or both in parallel, as here.
-
-   elfutils is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received copies of the GNU General Public License and
-   the GNU Lesser General Public License along with this program.  If
-   not, see <http://www.gnu.org/licenses/>.  */
-
-#include "libelfP.h"
-
-const void *
-gelf_convert (Elf *elf, Elf_Type valuetype, Elf_Type datatype, void *value,
-             const void *data)
-{
-  Elf_Data valuedata =
-    {
-      .d_type = valuetype,
-      .d_buf = value,
-      .d_size = gelf_fsize (elf, valuetype, 1, EV_CURRENT),
-      .d_version = EV_CURRENT,
-    };
-  Elf_Data indata =
-    {
-      .d_type = datatype,
-      .d_buf = (void *) data,
-      .d_size = valuedata.d_size,
-      .d_version = EV_CURRENT,
-    };
-
-  Elf_Data *d = gelf_xlatetom (elf, &valuedata, &indata,
-                              elf_getident (elf, NULL)[EI_DATA]);
-  if (d == NULL)
-    return NULL;
-
-  return data + indata.d_size;
-}
index 28db23e4114c60d6f8a1ad87b21777642e756a9d..5a2b3af856e0c65e7afe9c5cc23b12058827cac3 100644 (file)
@@ -383,12 +383,6 @@ extern unsigned long int elf_hash (const char *__string)
 extern unsigned long int elf_gnu_hash (const char *__string)
        __attribute__ ((__pure__));
 
-/* Convert DATA from ELF to VALUE in host memory.  Return NULL on error,
-   otherwise th updated DATA pointer.  */
-extern const void *gelf_convert (Elf *elf, Elf_Type valuetype,
-                                Elf_Type datatype, void *value,
-                                const void *data);
-
 
 /* Compute simple checksum from permanent parts of the ELF file.  */
 extern long int elf32_checksum (Elf *__elf);
index 93d25a3d58e3aa7c3f13dfa32f68be6aa68956a4..de6d912a1aa1187e47196e8bf203728c5459a6ef 100644 (file)
@@ -138,8 +138,3 @@ ELFUTILS_1.6 {
   global:
     elf_getphdrnum;
 } ELFUTILS_1.5;
-
-ELFUTILS_0.155 {
-  global:
-    gelf_convert;
-} ELFUTILS_1.6;