From 7d6fe0a39f6ae5c516ffd63558e12b24297bf982 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 29 May 2018 23:49:21 +0200 Subject: libdw: Handle split Dwarf Dies in dwarf_die_addr_die. dwarf_die_addr_die can be used to turn an Dwarf_Die addr back into a full Dwarf_Die, just given the original Dwarf debug handle. This now also works for Dwarf_Dies which originated from a split Dwarf. Whenever a split Dwarf_CU is found the Dwarf it originated from is registered with the Dwarf that the skeleton Dwarf_CU came from. All registered split Dwarfs are then searched by dwarf_die_addr_die if the addr didn't match the main Dwarf or the alt Dwarf. One limitation in this implementation is that only DIEs that come from the main .debug_info in the .dwo are supported. Theoretically there could also be DIEs in an .debug_type or from other/multiple (comdat) sections. New tests are added for dwarf-4, dwarf-5, split-dwarf-4, split-dwarf-5 and version 4 and 5 dwo files. Signed-off-by: Mark Wielaard --- libdw/libdw_find_split_unit.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libdw/libdw_find_split_unit.c') diff --git a/libdw/libdw_find_split_unit.c b/libdw/libdw_find_split_unit.c index d6527e07..dc62e0d0 100644 --- a/libdw/libdw_find_split_unit.c +++ b/libdw/libdw_find_split_unit.c @@ -34,6 +34,7 @@ #include "libelfP.h" #include +#include #include #include #include @@ -84,6 +85,14 @@ __libdw_find_split_unit (Dwarf_CU *cu) if (split->unit_type == DW_UT_split_compile && cu->unit_id8 == split->unit_id8) { + if (tsearch (split->dbg, &cu->dbg->split_tree, + __libdw_finddbg_cb) == NULL) + { + /* Something went wrong. Don't link. */ + __libdw_seterrno (DWARF_E_NOMEM); + break; + } + /* Link skeleton and split compile units. */ __libdw_link_skel_split (cu, split); -- cgit v1.2.3