summaryrefslogtreecommitdiff
path: root/elfutils/libdw/libdw_findcu.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2007-11-16 15:19:09 +0000
committerDmitry V. Levin <ldv@altlinux.org>2007-11-16 15:19:09 +0000
commitff8d659689b0aee56d115bdc0f24d68e61ce9a05 (patch)
treece6311e3afa4851d0dc087bfed63ce4bda2dce62 /elfutils/libdw/libdw_findcu.c
parent965679e2f32d58a7052caf2b81666d0049ba41f8 (diff)
downloadelfutils-ff8d659689b0aee56d115bdc0f24d68e61ce9a05.tar.gz
0.131-10.131-1
- Update to 0.131 - libdw: DW_FORM_ref_addr support; dwarf_formref entry point now deprecated; bug fixes for oddly-formatted DWARF - libdwfl: bug fixes in offline archive support, symbol table handling; apply partial relocations for dwfl_module_address_section on ET_REL - libebl: powerpc backend support for Altivec registers
Diffstat (limited to 'elfutils/libdw/libdw_findcu.c')
-rw-r--r--elfutils/libdw/libdw_findcu.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/elfutils/libdw/libdw_findcu.c b/elfutils/libdw/libdw_findcu.c
index e6259d49..afff6d3a 100644
--- a/elfutils/libdw/libdw_findcu.c
+++ b/elfutils/libdw/libdw_findcu.c
@@ -1,5 +1,5 @@
/* Find CU for given offset.
- Copyright (C) 2003, 2004, 2005 Red Hat, Inc.
+ Copyright (C) 2003, 2004, 2005, 2007 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -97,6 +97,7 @@ __libdw_findcu (dbg, start)
if (start < dbg->next_cu_offset)
{
+ invalid:
__libdw_seterrno (DWARF_E_INVALID_DWARF);
return NULL;
}
@@ -115,6 +116,15 @@ __libdw_findcu (dbg, start)
/* No more entries. */
return NULL;
+ /* XXX We need the version number but dwarf_nextcu swallows it. */
+ const char *bytes = (dbg->sectiondata[IDX_debug_info]->d_buf + oldoff
+ + (2 * offset_size - 4));
+ uint16_t version = read_2ubyte_unaligned (dbg, bytes);
+
+ /* We only know how to handle the DWARF version 2 and 3 formats. */
+ if (unlikely (version != 2) && unlikely (version != 3))
+ goto invalid;
+
/* Create an entry for this CU. */
struct Dwarf_CU *newp = libdw_typed_alloc (dbg, struct Dwarf_CU);
@@ -123,6 +133,7 @@ __libdw_findcu (dbg, start)
newp->end = dbg->next_cu_offset;
newp->address_size = address_size;
newp->offset_size = offset_size;
+ newp->version = version;
Dwarf_Abbrev_Hash_init (&newp->abbrev_hash, 41);
newp->orig_abbrev_offset = newp->last_abbrev_offset = abbrev_offset;
newp->lines = NULL;