libdw: Parse new DWARF5 units and CU DIEs.
Parse DWARF5 units, add the unit_type to the Dwarf_CU and generalize some
code calculating the header length and getting at the first DIE of a unit.
Unit headers can have different sizes depending on the unit type.
Signed-off-by: Mark Wielaard <mark@klomp.org>
diff --git a/libdwfl/cu.c b/libdwfl/cu.c
index 7aa23b5..94bfad8 100644
--- a/libdwfl/cu.c
+++ b/libdwfl/cu.c
@@ -1,5 +1,5 @@
/* Keeping track of DWARF compilation units in libdwfl.
- Copyright (C) 2005-2010, 2015 Red Hat, Inc.
+ Copyright (C) 2005-2010, 2015, 2016, 2017 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -155,12 +155,7 @@
static inline Dwarf_Off
cudie_offset (const struct dwfl_cu *cu)
{
- /* These are real CUs, so there never is a type_sig8. Note
- initialization of dwkey.start and offset_size in intern_cu ()
- to see why this calculates the same value for both key and
- die.cu search items. */
- return DIE_OFFSET_FROM_CU_OFFSET (cu->die.cu->start, cu->die.cu->offset_size,
- 0);
+ return __libdw_first_die_off_from_cu (cu->die.cu);
}
static int
@@ -198,11 +193,8 @@
if (die == NULL)
return DWFL_E_LIBDW;
- struct Dwarf_CU dwkey;
struct dwfl_cu key;
- key.die.cu = &dwkey;
- dwkey.offset_size = 0;
- dwkey.start = cuoff - (3 * 0 - 4 + 3);
+ key.die.cu = die->cu;
struct dwfl_cu **found = tsearch (&key, &mod->lazy_cu_root, &compare_cukey);
if (unlikely (found == NULL))
return DWFL_E_NOMEM;