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
---
libdw/ChangeLog | 7 ++
libdw/dwarf_attr_integrate.c | 15 -
libdw/dwarf_hasattr_integrate.c | 16 -
libdw/libdwP.h | 2 +-
tests/ChangeLog | 9 +++
tests/Makefile.am| 11 ++--
tests/attr-integrate-skel.c | 109 +++
tests/run-attr-integrate-skel.sh | 52 +++
8 files changed, 214 insertions(+), 7 deletions(-)
create mode 100644 tests/attr-integrate-skel.c
create mode 100755 tests/run-attr-integrate-skel.sh
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index a87a7092..c22811ec 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,10 @@
+2018-05-17 Mark Wielaard
+
+ * 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-15 Mark Wielaard
* Makefile.am (libdw_a_SOURCES): Add libdw_find_split_unit.c.
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 60572276..08d144ba 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -892,7 +892,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.
diff --git a/tests/ChangeLog b/tests/ChangeLog
index b865ad54..05e8f26c 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,12 @@
+2018-05-17 Mark Wielaard
+
+ * Makefile.am (check_PROGRAMS): Add attr-integrate-skel.
+ (TESTS): Add run-attr-integrate-skel.
+ (EXTRA_DIST): Likewise.
+ (attr_integrate_skel_LDADD): New variable.
+ * attr-integrate-skel.c: New test.
+ * run-attr-integrate-skel.sh: New test runner.
+
2018-05-16 Mark Wielaard
* Makefile.am (check_PROGRAMS): Add get-units-split.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 07165d84..05a5441b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to create Makefile.in
##
-## Copyright (C) 1996-2017 Red Hat, Inc.
+## Copyright (C) 1996-2018 Red Hat, Inc.
## This file is part of elfutils.
##
## This file is free software; you can redistribute it and/or modify
@@ -56,7 +56,7 @@ check_PROGRAMS = arextract arsymtest newfile saridx scnnames
sectiondump \