summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2010-05-20 17:30:53 -0700
committerRoland McGrath <roland@redhat.com>2010-05-20 17:37:00 -0700
commit9ba051c71c42f172971bb2a6c1c1595a33a73131 (patch)
treeb29990ce2234658cefc2bf9dce868de9718a1731
parent844f20f64770e9ed4177aa7285c9b96a11ec7547 (diff)
make check ok after mergeupstream/roland/notes
-rw-r--r--libdwfl/Makefile.am4
-rw-r--r--libdwfl/core-file-register-map.c12
-rw-r--r--libdwfl/dwfl_module.c4
-rw-r--r--libdwfl/libdwfl.h5
-rw-r--r--libdwfl/register-map.c17
-rw-r--r--libelf/Makefile.am2
-rw-r--r--libelf/elf_begin.c2
-rw-r--r--libelf/gelf_getdata_rawchunk.c94
-rw-r--r--libelf/libelfP.h6
-rw-r--r--tests/coreregs.c18
10 files changed, 29 insertions, 135 deletions
diff --git a/libdwfl/Makefile.am b/libdwfl/Makefile.am
index fa5395f5..c06a5d25 100644
--- a/libdwfl/Makefile.am
+++ b/libdwfl/Makefile.am
@@ -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 \
diff --git a/libdwfl/core-file-register-map.c b/libdwfl/core-file-register-map.c
index 9e3af781..ef1829ac 100644
--- a/libdwfl/core-file-register-map.c
+++ b/libdwfl/core-file-register-map.c
@@ -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;
diff --git a/libdwfl/dwfl_module.c b/libdwfl/dwfl_module.c
index de2fa5a9..f7e3e34d 100644
--- a/libdwfl/dwfl_module.c
+++ b/libdwfl/dwfl_module.c
@@ -104,10 +104,6 @@ __libdwfl_module_free (Dwfl_Module *mod)
if (mod->build_id_bits != NULL)
free (mod->build_id_bits);
-
- if (mod->build_id_bits != NULL)
- free (mod->build_id_bits);
-
if (mod->cb_data != NULL)
free (mod->cb_data);
free (mod->name);
diff --git a/libdwfl/libdwfl.h b/libdwfl/libdwfl.h
index bd28f064..e98b797f 100644
--- a/libdwfl/libdwfl.h
+++ b/libdwfl/libdwfl.h
@@ -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.
diff --git a/libdwfl/register-map.c b/libdwfl/register-map.c
index ad150519..c4e0f226 100644
--- a/libdwfl/register-map.c
+++ b/libdwfl/register-map.c
@@ -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;
diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index 9c7e7762..c8c09e86 100644
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -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 \
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index 80507e5d..a7eeffd1 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -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
index dba492fb..00000000
--- a/libelf/gelf_getdata_rawchunk.c
+++ /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;
-}
diff --git a/libelf/libelfP.h b/libelf/libelfP.h
index 613a7d95..24cad2d1 100644
--- a/libelf/libelfP.h
+++ b/libelf/libelfP.h
@@ -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);
diff --git a/tests/coreregs.c b/tests/coreregs.c
index 0683a3d3..a147735a 100644
--- a/tests/coreregs.c
+++ b/tests/coreregs.c
@@ -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