From ff8d659689b0aee56d115bdc0f24d68e61ce9a05 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 16 Nov 2007 15:19:09 +0000 Subject: 0.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 --- elfutils/libdw/libdw_findcu.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'elfutils/libdw/libdw_findcu.c') 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 , 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; -- cgit v1.2.1