diff options
author | Mark Wielaard <mark@klomp.org> | 2018-05-14 23:58:25 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2018-05-20 10:38:17 +0200 |
commit | 3d4998a9edd9f88b46662b3584de89ecd8f2f4c8 (patch) | |
tree | 1e162090152f5af68e78dc5fe42ee4d590aa6a47 /libdw | |
parent | 38ab84547a045386cc056422d37a7a7582c8afb9 (diff) | |
download | elfutils-3d4998a9edd9f88b46662b3584de89ecd8f2f4c8.tar.gz |
libdw: Search skeleton DIE for split compile unit DIE attributes.
dwarf_attr_integrate and dwarf_hasattr_integrate should also search
for attributes from the skeleton DIE in case the given DIE is a split
compile unit DIE. Split compile unit DIEs inherit various attributes
from their skeleton unit DIE in DWARF5.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdw')
-rw-r--r-- | libdw/ChangeLog | 7 | ||||
-rw-r--r-- | libdw/dwarf_attr_integrate.c | 15 | ||||
-rw-r--r-- | libdw/dwarf_hasattr_integrate.c | 16 | ||||
-rw-r--r-- | libdw/libdwP.h | 2 |
4 files changed, 37 insertions, 3 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog index fffe0cc9..c91d9ff2 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,10 @@ +2018-05-17 Mark Wielaard <mark@klomp.org> + + * dwarf_attr_integrate.c (dwarf_attr_integrate): Handle split_compile + unit DIE, search skeleton_compile unit DIE. + * dwarf_hasattr_integrate.c (dwarf_hasattr_integrate): Likewise. + * libdwP.h (is_cudie): Check cu is not NULL. + 2018-05-19 Mark Wielaard <mark@klomp.org> * libdwP.h (__libdw_find_split_unit): Mark as internal_function. diff --git a/libdw/dwarf_attr_integrate.c b/libdw/dwarf_attr_integrate.c index 812d74b9..748d988d 100644 --- a/libdw/dwarf_attr_integrate.c +++ b/libdw/dwarf_attr_integrate.c @@ -1,5 +1,5 @@ /* Return specific DWARF attribute of a DIE, integrating indirections. - Copyright (C) 2005 Red Hat, Inc. + Copyright (C) 2005, 2018 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -55,6 +55,19 @@ dwarf_attr_integrate (Dwarf_Die *die, unsigned int search_name, } while (die != NULL); + /* Not NULL if it didn't have abstract_origin and specification + attributes. If it is a split CU then see if the skeleton + has it. */ + if (die != NULL && is_cudie (die) + && die->cu->unit_type == DW_UT_split_compile) + { + Dwarf_CU *skel_cu = __libdw_find_split_unit (die->cu); + if (skel_cu != NULL) + { + Dwarf_Die skel_die = CUDIE (skel_cu); + return INTUSE(dwarf_attr) (&skel_die, search_name, result); + } + } return NULL; } INTDEF (dwarf_attr_integrate) diff --git a/libdw/dwarf_hasattr_integrate.c b/libdw/dwarf_hasattr_integrate.c index 2d5348cf..4d4b4c54 100644 --- a/libdw/dwarf_hasattr_integrate.c +++ b/libdw/dwarf_hasattr_integrate.c @@ -1,5 +1,5 @@ /* Check whether DIE has specific attribute, integrating DW_AT_abstract_origin. - Copyright (C) 2005 Red Hat, Inc. + Copyright (C) 2005, 2018 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -55,5 +55,19 @@ dwarf_hasattr_integrate (Dwarf_Die *die, unsigned int search_name) } while (die != NULL); + /* Not NULL if it didn't have abstract_origin and specification + attributes. If it is a split CU then see if the skeleton + has it. */ + if (die != NULL && is_cudie (die) + && die->cu->unit_type == DW_UT_split_compile) + { + Dwarf_CU *skel_cu = __libdw_find_split_unit (die->cu); + if (skel_cu != NULL) + { + Dwarf_Die skel_die = CUDIE (skel_cu); + return INTUSE(dwarf_hasattr) (&skel_die, search_name); + } + } + return 0; } diff --git a/libdw/libdwP.h b/libdw/libdwP.h index db14b689..cffe6ce7 100644 --- a/libdw/libdwP.h +++ b/libdw/libdwP.h @@ -893,7 +893,7 @@ cu_sec_idx (struct Dwarf_CU *cu) static inline bool is_cudie (Dwarf_Die *cudie) { - return CUDIE (cudie->cu).addr == cudie->addr; + return cudie->cu != NULL && CUDIE (cudie->cu).addr == cudie->addr; } /* Read up begin/end pair and increment read pointer. |