]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
make check ok after merge roland/notes
authorRoland McGrath <roland@redhat.com>
Fri, 21 May 2010 00:30:53 +0000 (17:30 -0700)
committerRoland McGrath <roland@redhat.com>
Fri, 21 May 2010 00:37:00 +0000 (17:37 -0700)
libdwfl/Makefile.am
libdwfl/core-file-register-map.c
libdwfl/dwfl_module.c
libdwfl/libdwfl.h
libdwfl/register-map.c
libelf/Makefile.am
libelf/elf_begin.c
libelf/gelf_getdata_rawchunk.c [deleted file]
libelf/libelfP.h
tests/coreregs.c

index fa5395f5aa9e66b1f142d0a73491e082290946cc..c06a5d257eb9234284cfa422285efb09ad2a8e2f 100644 (file)
@@ -48,9 +48,7 @@ libdwfl_a_SOURCES = dwfl_begin.c dwfl_end.c dwfl_error.c dwfl_version.c \
                    argp-std.c find-debuginfo.c \
                    dwfl_build_id_find_elf.c \
                    dwfl_build_id_find_debuginfo.c \
-                   dwfl_build_id_find_elf.c \
-                   dwfl_build_id_find_debuginfo.c \
-                   linux-kernel-modules.c linux-proc-maps.c core-file.c \
+                   linux-kernel-modules.c linux-proc-maps.c \
                    dwfl_addrmodule.c dwfl_addrdwarf.c \
                    cu.c dwfl_module_nextcu.c dwfl_nextcu.c dwfl_cumodule.c \
                    dwfl_module_addrdie.c dwfl_addrdie.c \
index 9e3af78101d52e0e55ba14c0aebce148fbaf3504..ef1829aca1fa90953abb4f52fe0cd7220e62117a 100644 (file)
@@ -1,5 +1,5 @@
 /* Examine a core file for notes describing register data.
-   Copyright (C) 2007 Red Hat, Inc.
+   Copyright (C) 2007-2010 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -83,8 +83,8 @@ handle_note (Dwfl *dwfl, Elf *core, const GElf_Phdr *phdr,
             Dwfl_Register_Map *map, int *setno,
             GElf_Off *start, GElf_Off *end)
 {
-  Elf_Data *data = gelf_getdata_rawchunk (core, phdr->p_offset, phdr->p_filesz,
-                                         ELF_T_NHDR);
+  Elf_Data *data = elf_getdata_rawchunk (core, phdr->p_offset, phdr->p_filesz,
+                                        ELF_T_NHDR);
   if (data == NULL)
     return -1;
 
@@ -111,7 +111,7 @@ handle_note (Dwfl *dwfl, Elf *core, const GElf_Phdr *phdr,
        }
 
       result = dwfl_register_map_populate (map, dwfl, *setno,
-                                          nhdr.n_type, 0, nhdr.n_descsz);
+                                          &nhdr, data->d_buf + name_offset);
       if (result < 0)
        break;
       if (result > 0)
@@ -202,8 +202,8 @@ dwfl_core_file_read_note (dwfl, map, offset, limit,
   *ident_pos = 0;
   *ident_type = ELF_T_NUM;
 
-  Elf_Data *data = gelf_getdata_rawchunk (core, offset, limit - offset,
-                                         ELF_T_NHDR);
+  Elf_Data *data = elf_getdata_rawchunk (core, offset, limit - offset,
+                                        ELF_T_NHDR);
   if (data == NULL)
     return -1;
 
index de2fa5a93ceabdcb37ac013a478a1b3716feb6e3..f7e3e34de24f757cae1fc2a30395ab3baca2a238 100644 (file)
@@ -101,10 +101,6 @@ __libdwfl_module_free (Dwfl_Module *mod)
     free_file (&mod->debug);
   free_file (&mod->main);
 
-  if (mod->build_id_bits != NULL)
-    free (mod->build_id_bits);
-
-
   if (mod->build_id_bits != NULL)
     free (mod->build_id_bits);
 
index bd28f064749231ebc090fd15f4d27399d7e053a1..e98b797f8d66dae10743c52802b90272b9fd9593 100644 (file)
@@ -602,9 +602,8 @@ extern void dwfl_register_map_end (Dwfl_Register_Map *);
 
 extern int dwfl_register_map_populate (Dwfl_Register_Map *map, Dwfl *ref,
                                       int setno,
-                                      GElf_Word n_type,
-                                      GElf_Word offset,
-                                      GElf_Word size);
+                                      const GElf_Nhdr *nhdr,
+                                      const char *n_name);
 
 /* Look up a DWARF register number in the given register map.
 
index ad15051926fdbdfec054a8ff0aa02c824a9bd1c2..c4e0f22660e72bd72ccff851d7e0acc06a0cef7e 100644 (file)
@@ -1,5 +1,5 @@
 /* Handle register maps.
-   Copyright (C) 2007 Red Hat, Inc.
+   Copyright (C) 2007-2010 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -110,14 +110,15 @@ expand_map (Dwfl_Register_Map *map, int first, int limit)
 }
 
 int
-dwfl_register_map_populate (map, ref, setno, type, offset, size)
+dwfl_register_map_populate (map, ref, setno, nhdr, n_name)
      Dwfl_Register_Map *map;
      Dwfl *ref;
      int setno;
-     GElf_Word type;
-     GElf_Word offset;
-     GElf_Word size;
+     const GElf_Nhdr *nhdr;
+     const char *n_name;
 {
+  size_t offset = 0; // XXX &pr_reg for non-core caller? get from backend?
+
   if (map == NULL || ref == NULL)
     return -1;
 
@@ -138,8 +139,8 @@ dwfl_register_map_populate (map, ref, setno, type, offset, size)
   const Ebl_Register_Location *reglocs;
   const Ebl_Core_Item *items;
   GElf_Word regs_offset;
-  int result = ebl_core_note (ebl, type, offset + size, &regs_offset,
-                             &nregloc, &reglocs, &nitem, &items);
+  int result = ebl_core_note (ebl, nhdr, n_name,
+                             &regs_offset, &nregloc, &reglocs, &nitem, &items);
   if (result < 0)
     {
       __libdwfl_seterrno (DWFL_E_LIBEBL);
@@ -244,7 +245,7 @@ dwfl_register_map_populate (map, ref, setno, type, offset, size)
          map->types = memset (types, 0xff, setno * sizeof types[0]);
        }
 
-      map->types[setno] = type;
+      map->types[setno] = nhdr->n_type;
     }
 
   return result;
index 9c7e7762fa27e26fc7ca9929cb835db87f5618fa..c8c09e862df21dd69f97fc99a7f358b34701b863 100644 (file)
@@ -81,7 +81,7 @@ libelf_a_SOURCES = elf_version.c elf_hash.c elf_error.c elf_fill.c \
                   gelf_update_verdaux.c \
                   elf_getphdrnum.c elf_getshdrnum.c elf_getshdrstrndx.c \
                   gelf_checksum.c elf32_checksum.c elf64_checksum.c \
-                  gelf_getdata_memory.c gelf_getdata_rawchunk.c \
+                  gelf_getdata_memory.c \
                   libelf_crc32.c libelf_next_prime.c \
                   elf_clone.c \
                   gelf_begin_embedded.c \
index 80507e5d1b6e3ae8833bc0417e7ae1bbfd16c9dd..a7eeffd148b107054259867f6d7d0d7c28c59f9e 100644 (file)
@@ -1045,7 +1045,7 @@ elf_begin (fildes, cmd, ref)
       }
 
     /* Duplicate the descriptor.  */
-    return dup_elf (fildes, cmd, ref);
+    return __libelf_dup_elf (fildes, cmd, ref, 0, 0);
   }
 
   switch (cmd)
diff --git a/libelf/gelf_getdata_rawchunk.c b/libelf/gelf_getdata_rawchunk.c
deleted file mode 100644 (file)
index dba492f..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Return converted data from raw chunk of ELF file.
-   Copyright (C) 2007 Red Hat, Inc.
-   This file is part of Red Hat elfutils.
-
-   Red Hat elfutils is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by the
-   Free Software Foundation; version 2 of the License.
-
-   Red Hat 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 a copy of the GNU General Public License along
-   with Red Hat elfutils; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
-
-   In addition, as a special exception, Red Hat, Inc. gives You the
-   additional right to link the code of Red Hat elfutils with code licensed
-   under any Open Source Initiative certified open source license
-   (http://www.opensource.org/licenses/index.php) which requires the
-   distribution of source code with any binary distribution and to
-   distribute linked combinations of the two.  Non-GPL Code permitted under
-   this exception must only link to the code of Red Hat elfutils through
-   those well defined interfaces identified in the file named EXCEPTION
-   found in the source code files (the "Approved Interfaces").  The files
-   of Non-GPL Code may instantiate templates or use macros or inline
-   functions from the Approved Interfaces without causing the resulting
-   work to be covered by the GNU General Public License.  Only Red Hat,
-   Inc. may make changes or additions to the list of Approved Interfaces.
-   Red Hat's grant of this exception is conditioned upon your not adding
-   any new exceptions.  If you wish to add a new Approved Interface or
-   exception, please contact Red Hat.  You must obey the GNU General Public
-   License in all respects for all of the Red Hat elfutils code and other
-   code used in conjunction with Red Hat elfutils except the Non-GPL Code
-   covered by this exception.  If you modify this file, you may extend this
-   exception to your version of the file, but you are not obligated to do
-   so.  If you do not wish to provide this exception without modification,
-   you must delete this exception statement from your version and license
-   this file solely under the GPL without exception.
-
-   Red Hat elfutils is an included package of the Open Invention Network.
-   An included package of the Open Invention Network is a package for which
-   Open Invention Network licensees cross-license their patents.  No patent
-   license is granted, either expressly or impliedly, by designation as an
-   included package.  Should you wish to participate in the Open Invention
-   Network licensing program, please visit www.openinventionnetwork.com
-   <http://www.openinventionnetwork.com>.  */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <assert.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include "libelfP.h"
-
-Elf_Data *
-gelf_getdata_rawchunk (elf, offset, size, type)
-     Elf *elf;
-     GElf_Off offset;
-     GElf_Word size;
-     Elf_Type type;
-{
-  /* Get the raw bytes from the file.  */
-  char *rawchunk = INTUSE(gelf_rawchunk) (elf, offset, size);
-  if (rawchunk == NULL)
-    return NULL;
-
-  /* We'll reuse the buffer if we didn't map the file directly.  */
-  bool alloced = (rawchunk < (char *) elf->map_address + elf->start_offset
-                 || rawchunk >= ((char *) elf->map_address + elf->start_offset
-                                 + elf->maximum_size));
-
-  Elf_Data *data = INTUSE(gelf_getdata_memory) (elf, rawchunk, size, type,
-                                               alloced ? rawchunk : NULL);
-
-  if (data != NULL)
-    {
-      Elf_Data_Chunk *chunk = (Elf_Data_Chunk *) data;
-      if (alloced)
-       {
-         /* It should have been converted in place.
-            elf_end will free our original RAWCHUNK pointer.  */
-         assert (chunk->dummy_scn.flags == 0);
-         chunk->dummy_scn.flags = ELF_F_MALLOCED;
-       }
-    }
-  else if (alloced)
-    free (rawchunk);
-
-  return data;
-}
index 613a7d955e2650fe0e1a91377791874eedf78347..24cad2d1fdf9222598938c939e80fe2aa6965bb0 100644 (file)
@@ -288,6 +288,7 @@ struct Elf
      for the archive. */
   Elf *parent;
   Elf *next;             /* Used in list of archive descriptors.  */
+  Elf *children;       /* List of all descriptors pointing to this one. */
 
   /* What kind of file is underneath (ELF file, archive...).  */
   Elf_Kind kind;
@@ -316,9 +317,6 @@ struct Elf
   /* Reference counting for the descriptor.  */
   int ref_count;
 
-  struct Elf *next;             /* Used in list of archive descriptors.  */
-  struct Elf *children;        /* List of all descriptors pointing to this one. */
-
   /* Lock to handle multithreaded programs.  */
   rwlock_define (,lock);
 
@@ -599,8 +597,6 @@ extern GElf_Sym *__gelf_getsym_internal (Elf_Data *__data, int __ndx,
 extern uint32_t __libelf_crc32 (uint32_t crc, unsigned char *buf, size_t len)
      attribute_hidden;
 
-INTDECL (gelf_rawchunk);
-INTDECL (gelf_freechunk);
 INTDECL (gelf_getdata_memory);
 
 
index 0683a3d34f87eb88ee52d5c66b94212ccfc03505..a147735a0f0970910897a924dc8297a73e3315ea 100644 (file)
@@ -1,5 +1,5 @@
 /* Test program for libdwfl core file handling.
-   Copyright (C) 2007 Red Hat, Inc.
+   Copyright (C) 2007-2010 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -173,7 +173,7 @@ handle_thread (Dwfl *dwfl, Elf *core, Dwfl_Register_Map *map,
               int nsets, GElf_Off offsets[], GElf_Word sizes[],
               int idset, GElf_Word idpos, Elf_Type idtype)
 {
-  void *sets[nsets];
+  Elf_Data *sets[nsets];
   memset (sets, 0, sizeof sets);
   inline int establish (int setno)
     {
@@ -181,7 +181,9 @@ handle_thread (Dwfl *dwfl, Elf *core, Dwfl_Register_Map *map,
        {
          if (sizes[setno] == 0)
            return 1;
-         sets[setno] = gelf_rawchunk (core, offsets[setno], sizes[setno]);
+         sets[setno] = elf_getdata_rawchunk (core,
+                                             offsets[setno], sizes[setno],
+                                             ELF_T_BYTE);
          if (sets[setno] == NULL)
            return -1;
        }
@@ -201,7 +203,7 @@ handle_thread (Dwfl *dwfl, Elf *core, Dwfl_Register_Map *map,
          int result = establish (setno);
          if (result == 0)
            handle_register_data (dwfl, core, regno, regname, bits, type,
-                                 sets[setno] + offset);
+                                 sets[setno]->d_buf + offset);
          else if (result < 0)
            error (2, 0, "gelf_rawchunk: %s", elf_errmsg (-1));
        }
@@ -217,7 +219,7 @@ handle_thread (Dwfl *dwfl, Elf *core, Dwfl_Register_Map *map,
        error (2, 0, "gelf_rawchunk: %s", elf_errmsg (-1));
       assert (result == 0);
 
-      handle_thread_identifier (core, idtype, sets[idset] + idpos);
+      handle_thread_identifier (core, idtype, sets[idset]->d_buf + idpos);
     }
 
   Dwfl_Module *mod = dwfl->modulelist; /* XXX */
@@ -226,10 +228,6 @@ handle_thread (Dwfl *dwfl, Elf *core, Dwfl_Register_Map *map,
     mod = mod->next;
   int result = dwfl_module_register_names (mod, &handle_register, NULL);
   assert (result == 0);
-
-  for (int i = 0; i < nsets; ++i)
-    if (sets[i] != NULL)
-      gelf_freechunk (core, sets[i]);
 }
 
 static void
@@ -282,7 +280,7 @@ find_registers (Dwfl *dwfl, Elf *core)
 static const Dwfl_Callbacks corefile_callbacks =
   {
     .find_debuginfo = INTUSE(dwfl_standard_find_debuginfo),
-    .find_elf = INTUSE(dwfl_core_file_find_elf),
+    .find_elf = INTUSE(dwfl_build_id_find_elf),
   };
 
 static void