public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/14] elfutils: DWARF package (.dwp) file support
@ 2023-09-27 18:20 Omar Sandoval
  2023-09-27 18:20 ` [PATCH 01/14] libdw: Make try_split_file static Omar Sandoval
                   ` (16 more replies)
  0 siblings, 17 replies; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:20 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

Hi,

This patch series adds support for DWARF package files to libdw and the
elfutils tools. It supports the GNU DebugFission format for DWARF 4 [1]
and the format standardized in DWARF 5 (section 7.3.5 "DWARF Package
Files"). It supports both automatically opening the .dwp file for a
skeleton unit and examining the .dwp file alone, just like for .dwo
files.

Patch 1 is a trivial cleanup I found while developing this. Patches 2-6
are fixes for unrelated bugs in split DWARF and/or DWARF 5 that I
encountered while adding test cases for this series. I didn't add test
cases explicitly for those fixes because they are covered by the dwp
tests later in the series.

The actual dwp support is in patches 7-10 and 13, including test cases.
Patches 11 and 12 enable testing macro information in dwp files. Patch
14 adds support and tests for an LLVM extension to the dwp format.

More details in the individual commit messages.

Thanks!
Omar

P.S. drgn's dwp branch [2] demonstrates how the new
dwarf_cu_dwp_section_info function will be used. With this patch series,
drgn's test suite passes against a Linux kernel build using .dwp.

1: https://gcc.gnu.org/wiki/DebugFissionDWP
2: https://github.com/osandov/drgn/tree/dwp

Omar Sandoval (14):
  libdw: Make try_split_file static
  libdw: Handle split DWARF in dwarf_entrypc
  libdw: Handle DW_AT_ranges in split DWARF 5 skeleton in dwarf_ranges
  libdw: Handle other string forms in dwarf_macro_param2
  libdw: Fix dwarf_macro_getsrcfiles for DWARF 5
  libdw: Handle split DWARF in dwarf_macro_getsrcfiles
  libdw: Recognize .debug_[ct]u_index sections in dwarf_elf_begin
  libdw: Parse DWARF package file index sections
  libdw, libdwfl: Save original path of ELF file
  libdw: Try .dwp file in __libdw_find_split_unit()
  tests: Handle DW_MACRO_{define,undef}_{strx,sup} in dwarf-getmacros
  tests: Optionally dump all units in dwarf-getmacros
  libdw: Apply DWARF package file section offsets where appropriate
  libdw: Handle overflowed DW_SECT_INFO offsets in DWARF package file
    indexes

 libdw/ChangeLog                               |   72 +
 libdw/Makefile.am                             |    2 +-
 libdw/dwarf_begin_elf.c                       |   88 +-
 libdw/dwarf_cu_dwp_section_info.c             |  529 ++++++
 libdw/dwarf_end.c                             |   27 +-
 libdw/dwarf_entrypc.c                         |   12 +-
 libdw/dwarf_error.c                           |    1 +
 libdw/dwarf_getlocation.c                     |    6 +
 libdw/dwarf_getmacros.c                       |   54 +-
 libdw/dwarf_macro_getsrcfiles.c               |    8 +-
 libdw/dwarf_macro_param2.c                    |   21 +-
 libdw/dwarf_ranges.c                          |    4 +-
 libdw/libdw.h                                 |   23 +
 libdw/libdw.map                               |    5 +
 libdw/libdwP.h                                |  112 +-
 libdw/libdw_find_split_unit.c                 |   77 +-
 libdw/libdw_findcu.c                          |    8 +
 libdwfl/ChangeLog                             |    9 +
 libdwfl/dwfl_module.c                         |    2 +-
 libdwfl/dwfl_module_getdwarf.c                |   11 +-
 libdwfl/libdwflP.h                            |    2 +-
 libdwfl/offline.c                             |    4 +-
 tests/.gitignore                              |    1 +
 tests/ChangeLog                               |   36 +
 tests/Makefile.am                             |   15 +-
 tests/cu-dwp-section-info.c                   |   74 +
 tests/dwarf-getmacros.c                       |   55 +-
 tests/run-all-dwarf-ranges.sh                 |  114 ++
 tests/run-cu-dwp-section-info.sh              |  168 ++
 tests/run-dwarf-getmacros.sh                  | 1412 +++++++++++++++++
 tests/run-get-units-split.sh                  |   18 +
 tests/run-large-elf-file.sh                   |  174 ++
 tests/run-varlocs.sh                          |  126 +-
 tests/testfile-dwp-4-cu-index-overflow.bz2    |  Bin 0 -> 4490 bytes
 .../testfile-dwp-4-cu-index-overflow.dwp.bz2  |  Bin 0 -> 5584 bytes
 tests/testfile-dwp-4-strict.bz2               |  Bin 0 -> 4169 bytes
 tests/testfile-dwp-4-strict.dwp.bz2           |  Bin 0 -> 6871 bytes
 tests/testfile-dwp-4.bz2                      |  Bin 0 -> 4194 bytes
 tests/testfile-dwp-4.dwp.bz2                  |  Bin 0 -> 10098 bytes
 tests/testfile-dwp-5-cu-index-overflow.bz2    |  Bin 0 -> 4544 bytes
 .../testfile-dwp-5-cu-index-overflow.dwp.bz2  |  Bin 0 -> 5790 bytes
 tests/testfile-dwp-5.bz2                      |  Bin 0 -> 4223 bytes
 tests/testfile-dwp-5.dwp.bz2                  |  Bin 0 -> 10313 bytes
 tests/testfile-dwp-cu-index-overflow.source   |   86 +
 tests/testfile-dwp.source                     |  102 ++
 45 files changed, 3337 insertions(+), 121 deletions(-)
 create mode 100644 libdw/dwarf_cu_dwp_section_info.c
 create mode 100644 tests/cu-dwp-section-info.c
 create mode 100755 tests/run-cu-dwp-section-info.sh
 create mode 100755 tests/testfile-dwp-4-cu-index-overflow.bz2
 create mode 100644 tests/testfile-dwp-4-cu-index-overflow.dwp.bz2
 create mode 100755 tests/testfile-dwp-4-strict.bz2
 create mode 100644 tests/testfile-dwp-4-strict.dwp.bz2
 create mode 100755 tests/testfile-dwp-4.bz2
 create mode 100644 tests/testfile-dwp-4.dwp.bz2
 create mode 100755 tests/testfile-dwp-5-cu-index-overflow.bz2
 create mode 100644 tests/testfile-dwp-5-cu-index-overflow.dwp.bz2
 create mode 100755 tests/testfile-dwp-5.bz2
 create mode 100644 tests/testfile-dwp-5.dwp.bz2
 create mode 100644 tests/testfile-dwp-cu-index-overflow.source
 create mode 100644 tests/testfile-dwp.source

-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 01/14] libdw: Make try_split_file static
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
@ 2023-09-27 18:20 ` Omar Sandoval
  2023-10-03 16:09   ` Mark Wielaard
  2023-09-27 18:20 ` [PATCH 02/14] libdw: Handle split DWARF in dwarf_entrypc Omar Sandoval
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:20 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

It's only used in libdw_find_split_unit.c.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libdw/ChangeLog               | 4 ++++
 libdw/libdw_find_split_unit.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 406310ef..0014aeb1 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,7 @@
+2023-09-27  Omar Sandoval  <osandov@fb.com>
+
+	* libdw_find_split_unit.c (try_split_file): Make static.
+
 2023-02-22  Mark Wielaard  <mark@klomp.org>
 
 	* dwarf_getscopes.c (origin_match): Don't free a->scopes.
diff --git a/libdw/libdw_find_split_unit.c b/libdw/libdw_find_split_unit.c
index a22e7bc9..533f8072 100644
--- a/libdw/libdw_find_split_unit.c
+++ b/libdw/libdw_find_split_unit.c
@@ -41,7 +41,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-void
+static void
 try_split_file (Dwarf_CU *cu, const char *dwo_path)
 {
   int split_fd = open (dwo_path, O_RDONLY);
-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 02/14] libdw: Handle split DWARF in dwarf_entrypc
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
  2023-09-27 18:20 ` [PATCH 01/14] libdw: Make try_split_file static Omar Sandoval
@ 2023-09-27 18:20 ` Omar Sandoval
  2023-10-03 16:10   ` Mark Wielaard
  2023-09-27 18:20 ` [PATCH 03/14] libdw: Handle DW_AT_ranges in split DWARF 5 skeleton in dwarf_ranges Omar Sandoval
                   ` (14 subsequent siblings)
  16 siblings, 1 reply; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:20 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

If a DIE has no DW_AT_entry_pc attribute, dwarf_entrypc looks for
DW_AT_low_pc in that DIE.  But for a split compilation unit DIE,
DW_AT_low_pc is in the corresponding skeleton DIE, so this fails.
dwarf_lowpc already handles this fallback, so use it instead.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libdw/ChangeLog       |  1 +
 libdw/dwarf_entrypc.c | 12 +++++-------
 tests/ChangeLog       |  4 ++++
 tests/run-varlocs.sh  | 14 +++++++-------
 4 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 0014aeb1..af74ce0d 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,6 +1,7 @@
 2023-09-27  Omar Sandoval  <osandov@fb.com>
 
 	* libdw_find_split_unit.c (try_split_file): Make static.
+	* dwarf_entrypc.c (dwarf_entrypc): Call dwarf_lowpc.
 
 2023-02-22  Mark Wielaard  <mark@klomp.org>
 
diff --git a/libdw/dwarf_entrypc.c b/libdw/dwarf_entrypc.c
index 0ef3b0ea..543567d4 100644
--- a/libdw/dwarf_entrypc.c
+++ b/libdw/dwarf_entrypc.c
@@ -37,12 +37,10 @@
 int
 dwarf_entrypc (Dwarf_Die *die, Dwarf_Addr *return_addr)
 {
-  Dwarf_Attribute attr_mem;
-
-  return INTUSE(dwarf_formaddr) (INTUSE(dwarf_attr) (die, DW_AT_entry_pc,
-						     &attr_mem)
-				 ?: INTUSE(dwarf_attr) (die, DW_AT_low_pc,
-							&attr_mem),
-				 return_addr);
+  Dwarf_Attribute attr_mem, *attr;
+  if ((attr = INTUSE(dwarf_attr) (die, DW_AT_entry_pc, &attr_mem)) != NULL)
+    return INTUSE(dwarf_formaddr) (attr, return_addr);
+  else
+    return INTUSE(dwarf_lowpc) (die, return_addr);
 }
 INTDEF(dwarf_entrypc)
diff --git a/tests/ChangeLog b/tests/ChangeLog
index d816873c..f934c114 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2023-09-27  Omar Sandoval  <osandov@fb.com>
+
+	* run-varlocs.sh: Add entry PC to split units.
+
 2023-04-21  Frank Ch. Eigler <fche@redhat.com>
 
 	* run-debuginfod-IXr.sh: New test.
diff --git a/tests/run-varlocs.sh b/tests/run-varlocs.sh
index b2621776..cbbcf6c7 100755
--- a/tests/run-varlocs.sh
+++ b/tests/run-varlocs.sh
@@ -206,7 +206,7 @@ testfiles testfilesplitranges5.debug
 testfiles testfile-ranges-hello5.dwo testfile-ranges-world5.dwo
 testrun_compare ${abs_top_builddir}/tests/varlocs --debug -e testfilesplitranges5.debug <<\EOF
 module 'testfilesplitranges5.debug'
-[14] CU 'hello.c'
+[14] CU 'hello.c'@0
   [1d] function 'no_say'@401160
     frame_base: {call_frame_cfa {...}}
     [33] parameter 'prefix'
@@ -236,7 +236,7 @@ module 'testfilesplitranges5.debug'
     [111] parameter 'count'
       [401150,401160) {reg4}
 module 'testfilesplitranges5.debug'
-[14] CU 'world.c'
+[14] CU 'world.c'@401180
   [1d] function 'no_main'@4011d0
     frame_base: {call_frame_cfa {...}}
     [35] parameter 'argc'
@@ -282,7 +282,7 @@ testfiles testfilesplitranges4.debug
 testfiles testfile-ranges-hello.dwo testfile-ranges-world.dwo
 testrun_compare ${abs_top_builddir}/tests/varlocs --debug -e testfilesplitranges4.debug <<\EOF
 module 'testfilesplitranges4.debug'
-[b] CU 'hello.c'
+[b] CU 'hello.c'@0
   [18] function 'no_say'@4004f0
     frame_base: {call_frame_cfa {...}}
     [2f] parameter 'prefix'
@@ -310,7 +310,7 @@ module 'testfilesplitranges4.debug'
     [102] parameter 'count'
       [4004e0,4004f0) {reg4}
 module 'testfilesplitranges4.debug'
-[b] CU 'world.c'
+[b] CU 'world.c'@400500
   [18] function 'no_main'@400550
     frame_base: {call_frame_cfa {...}}
     [2f] parameter 'argc'
@@ -373,7 +373,7 @@ EOF
 testfiles testfile-addrx_constx-5 addrx_constx-5.dwo
 testrun_compare ${abs_top_builddir}/tests/varlocs --exprlocs -e testfile-addrx_constx-5 <<\EOF
 module 'testfile-addrx_constx-5'
-[14] CU 'addrx_constx.c'
+[14] CU 'addrx_constx.c'@0
   producer (strx)
   language (data1)
   name (strx)
@@ -467,7 +467,7 @@ EOF
 testfiles testfile-addrx_constx-4 addrx_constx-4.dwo
 testrun_compare ${abs_top_builddir}/tests/varlocs --exprlocs -e testfile-addrx_constx-4 <<\EOF
 module 'testfile-addrx_constx-4'
-[b] CU 'addrx_constx.c'
+[b] CU 'addrx_constx.c'@0
   producer (GNU_str_index)
   language (data1)
   name (GNU_str_index)
@@ -565,7 +565,7 @@ testfiles splitdwarf4-not-split4.dwo
 
 testrun_compare ${abs_top_builddir}/tests/varlocs --debug -e testfile-splitdwarf4-not-split4.debug <<\EOF
 module 'testfile-splitdwarf4-not-split4.debug'
-[b] CU 'splitdwarf4-not-split4.c'
+[b] CU 'splitdwarf4-not-split4.c'@0
   [18] function 'main'@401050
     frame_base: {call_frame_cfa {...}}
     [30] parameter 'argc'
-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 03/14] libdw: Handle DW_AT_ranges in split DWARF 5 skeleton in dwarf_ranges
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
  2023-09-27 18:20 ` [PATCH 01/14] libdw: Make try_split_file static Omar Sandoval
  2023-09-27 18:20 ` [PATCH 02/14] libdw: Handle split DWARF in dwarf_entrypc Omar Sandoval
@ 2023-09-27 18:20 ` Omar Sandoval
  2023-10-03 16:10   ` Mark Wielaard
  2023-09-27 18:20 ` [PATCH 04/14] libdw: Handle other string forms in dwarf_macro_param2 Omar Sandoval
                   ` (13 subsequent siblings)
  16 siblings, 1 reply; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:20 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

When commit 879f3a4f99df ("libdw: Handle .debug_rnglists in
dwarf_ranges.") added support for split DWARF 5 in 2018, GCC put all
range lists for split DWARF in the .debug_rnglists section of the
skeleton file (similarly to GNU DebugFission, which puts all range lists
in .debug_ranges in the skeleton file).

In 2021, after a discussion on the dwarf-discuss mailing list [1], GCC
changed this to match Clang's behavior.  Now, ranges are in
.debug_rnglists.dwo in the split file, _except_ for one: the skeleton
unit DIE has a DW_AT_ranges attribute, and its ranges are in
.debug_rnglists in the skeleton file.  See GCC commit 4b33c5aaab9e
("dwarf2out: Fix up ranges for -gdwarf-5 -gsplit-dwarf [PR99490]") and
the Issue 210310.1 clarifying the DWARF standard [2].

Unfortunately, this confuses dwarf_ranges, which always uses
.debug_rnglists.dwo if it exists.  Fix it by special casing the unit
DIE: its range lists should be in .debug_rnglists if that exists, and
.debug_rnglists.dwo otherwise.

1: https://lists.dwarfstd.org/pipermail/dwarf-discuss/2021-March/002009.html
2: https://dwarfstd.org/issues/210310.1.html

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libdw/ChangeLog      | 2 ++
 libdw/dwarf_ranges.c | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index af74ce0d..e84432f6 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -2,6 +2,8 @@
 
 	* libdw_find_split_unit.c (try_split_file): Make static.
 	* dwarf_entrypc.c (dwarf_entrypc): Call dwarf_lowpc.
+	* dwarf_ranges.c (dwarf_ranges): Use skeleton ranges section for
+	skeleton units.
 
 2023-02-22  Mark Wielaard  <mark@klomp.org>
 
diff --git a/libdw/dwarf_ranges.c b/libdw/dwarf_ranges.c
index 520f9ffe..b853e4b9 100644
--- a/libdw/dwarf_ranges.c
+++ b/libdw/dwarf_ranges.c
@@ -489,10 +489,10 @@ dwarf_ranges (Dwarf_Die *die, ptrdiff_t offset, Dwarf_Addr *basep,
 
   size_t secidx = (cu->version < 5 ? IDX_debug_ranges : IDX_debug_rnglists);
   const Elf_Data *d = cu->dbg->sectiondata[secidx];
-  if (d == NULL && cu->unit_type == DW_UT_split_compile)
+  if (cu->unit_type == DW_UT_split_compile && (d == NULL || is_cudie (die)))
     {
       Dwarf_CU *skel = __libdw_find_split_unit (cu);
-      if (skel != NULL)
+      if (skel != NULL && skel->dbg->sectiondata[secidx] != NULL)
 	{
 	  cu = skel;
 	  d = cu->dbg->sectiondata[secidx];
-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 04/14] libdw: Handle other string forms in dwarf_macro_param2
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
                   ` (2 preceding siblings ...)
  2023-09-27 18:20 ` [PATCH 03/14] libdw: Handle DW_AT_ranges in split DWARF 5 skeleton in dwarf_ranges Omar Sandoval
@ 2023-09-27 18:20 ` Omar Sandoval
  2023-10-03 16:11   ` Mark Wielaard
  2023-09-27 18:20 ` [PATCH 05/14] libdw: Fix dwarf_macro_getsrcfiles for DWARF 5 Omar Sandoval
                   ` (12 subsequent siblings)
  16 siblings, 1 reply; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:20 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

dwarf_getmacros handles the additional macro string forms added by DWARF
5, but dwarf_macro_param2 doesn't.  Update it with the list of all
string forms allowed in .debug_macro.  In particular, GCC and Clang
generate DW_MACRO_define_strx and DW_MACRO_undef_strx, which
dwarf_macro_param2 couldn't handle.

Fixes: cdf865b890c2 ("readelf, libdw: Handle DWARF5 .debug_macro.")
Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libdw/ChangeLog            |  3 +++
 libdw/dwarf_macro_param2.c | 21 +++++++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index e84432f6..7528c093 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -4,6 +4,9 @@
 	* dwarf_entrypc.c (dwarf_entrypc): Call dwarf_lowpc.
 	* dwarf_ranges.c (dwarf_ranges): Use skeleton ranges section for
 	skeleton units.
+	* dwarf_macro_param2.c (dwarf_macro_param2): Change form condition to
+	switch statement and add DW_FORM_line_strp, DW_FORM_strp_sup,
+	DW_FORM_strx, and DW_FORM_strx[1-4].
 
 2023-02-22  Mark Wielaard  <mark@klomp.org>
 
diff --git a/libdw/dwarf_macro_param2.c b/libdw/dwarf_macro_param2.c
index cc902c99..f12e6f9a 100644
--- a/libdw/dwarf_macro_param2.c
+++ b/libdw/dwarf_macro_param2.c
@@ -44,12 +44,21 @@ dwarf_macro_param2 (Dwarf_Macro *macro, Dwarf_Word *paramp, const char **strp)
   if (dwarf_macro_param (macro, 1, &param) != 0)
     return -1;
 
-  if (param.form == DW_FORM_string
-      || param.form == DW_FORM_strp)
+  switch (param.form)
     {
-      *strp = dwarf_formstring (&param);
-      return 0;
+      /* String forms allowed by libdw_valid_user_form.  */
+      case DW_FORM_line_strp:
+      case DW_FORM_string:
+      case DW_FORM_strp:
+      case DW_FORM_strp_sup:
+      case DW_FORM_strx:
+      case DW_FORM_strx1:
+      case DW_FORM_strx2:
+      case DW_FORM_strx3:
+      case DW_FORM_strx4:
+	*strp = dwarf_formstring (&param);
+	return 0;
+      default:
+	return dwarf_formudata (&param, paramp);
     }
-  else
-    return dwarf_formudata (&param, paramp);
 }
-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 05/14] libdw: Fix dwarf_macro_getsrcfiles for DWARF 5
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
                   ` (3 preceding siblings ...)
  2023-09-27 18:20 ` [PATCH 04/14] libdw: Handle other string forms in dwarf_macro_param2 Omar Sandoval
@ 2023-09-27 18:20 ` Omar Sandoval
  2023-10-03 21:29   ` Mark Wielaard
  2023-09-27 18:20 ` [PATCH 06/14] libdw: Handle split DWARF in dwarf_macro_getsrcfiles Omar Sandoval
                   ` (11 subsequent siblings)
  16 siblings, 1 reply; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:20 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

Dwarf_Macro_Op_Table::is_64bit conflates the address size and the offset
size: for .debug_macinfo, it is initialized based on the compilation
unit's address size, but for .debug_macro, it is initialized based on
the macro unit's offset size.  is_64bit is used to determine the address
size to pass to __libdw_getsrclines.  For a 64-bit architecture using
DWARF 5 with 32-bit offsets (the common case), this fails because
read_srclines checks that the given address size matches the address
size from the line number program header.

Fix it by splitting is_64bit into separate address_size and offset_size
members.

Fixes: fb90bf3f84b5 ("Support .debug_macro")
Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libdw/ChangeLog                 | 11 +++++++++++
 libdw/dwarf_getmacros.c         | 17 ++++++++++++++---
 libdw/dwarf_macro_getsrcfiles.c |  3 +--
 libdw/libdwP.h                  |  3 ++-
 4 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 7528c093..d3f36cc8 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -7,6 +7,17 @@
 	* dwarf_macro_param2.c (dwarf_macro_param2): Change form condition to
 	switch statement and add DW_FORM_line_strp, DW_FORM_strp_sup,
 	DW_FORM_strx, and DW_FORM_strx[1-4].
+	* dwarf_getmacros.c (get_macinfo_table): Replace assignment of
+	table->is_64bit with assignments of table->address_size and
+	table->offset_size.
+	(get_table_for_offset): Ditto.
+	(read_macros): Get fake CU offset_size from table->offset_size instead
+	of table->is_64bit.
+	* dwarf_macro_getsrcfiles.c (dwarf_macro_getsrcfiles): Get
+	address_size for __libdw_getsrclines from table->address_size instead
+	of table->is_64bit.
+	* libdwP.h (Dwarf_Macro_Op_Table): Replace is_64bit with address_size
+	and offset_size.
 
 2023-02-22  Mark Wielaard  <mark@klomp.org>
 
diff --git a/libdw/dwarf_getmacros.c b/libdw/dwarf_getmacros.c
index fd929669..b7d98af4 100644
--- a/libdw/dwarf_getmacros.c
+++ b/libdw/dwarf_getmacros.c
@@ -134,7 +134,8 @@ get_macinfo_table (Dwarf *dbg, Dwarf_Word macoff, Dwarf_Die *cudie)
   table->offset = macoff;
   table->sec_index = IDX_debug_macinfo;
   table->line_offset = line_offset;
-  table->is_64bit = cudie->cu->address_size == 8;
+  table->address_size = cudie->cu->address_size;
+  table->offset_size = cudie->cu->offset_size;
   table->comp_dir = __libdw_getcompdir (cudie);
 
   return table;
@@ -182,6 +183,15 @@ get_table_for_offset (Dwarf *dbg, Dwarf_Word macoff,
 	  return NULL;
     }
 
+  uint8_t address_size;
+  if (cudie != NULL)
+    address_size = cudie->cu->address_size;
+  else
+    {
+      char *ident = elf_getident (dbg->elf, NULL);
+      address_size = ident[EI_CLASS] == ELFCLASS32 ? 4 : 8;
+    }
+
   /* """The macinfo entry types defined in this standard may, but
      might not, be described in the table""".
 
@@ -258,7 +268,8 @@ get_table_for_offset (Dwarf *dbg, Dwarf_Word macoff,
     .line_offset = line_offset,
     .header_len = readp - startp,
     .version = version,
-    .is_64bit = is_64bit,
+    .address_size = address_size,
+    .offset_size = is_64bit ? 8 : 4,
 
     /* NULL if CUDIE is NULL or DW_AT_comp_dir is absent.  */
     .comp_dir = __libdw_getcompdir (cudie),
@@ -368,7 +379,7 @@ read_macros (Dwarf *dbg, int sec_index,
 	.dbg = dbg,
 	.sec_idx = sec_index,
 	.version = table->version,
-	.offset_size = table->is_64bit ? 8 : 4,
+	.offset_size = table->offset_size,
 	.str_off_base = str_offsets_base_off (dbg, (cudie != NULL
 						    ? cudie->cu: NULL)),
 	.startp = (void *) startp + offset,
diff --git a/libdw/dwarf_macro_getsrcfiles.c b/libdw/dwarf_macro_getsrcfiles.c
index 3b1794b1..4e8deeeb 100644
--- a/libdw/dwarf_macro_getsrcfiles.c
+++ b/libdw/dwarf_macro_getsrcfiles.c
@@ -72,8 +72,7 @@ dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro,
 	 will be broken.  */
 
       if (__libdw_getsrclines (dbg, line_offset, table->comp_dir,
-			       table->is_64bit ? 8 : 4,
-			       NULL, &table->files) < 0)
+			       table->address_size, NULL, &table->files) < 0)
 	table->files = (void *) -1;
     }
 
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 5cbdc279..c3fe9f93 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -526,7 +526,8 @@ typedef struct
   Dwarf_Half header_len;
 
   uint16_t version;
-  bool is_64bit;
+  uint8_t address_size;
+  uint8_t offset_size;
   uint8_t sec_index;	/* IDX_debug_macro or IDX_debug_macinfo.  */
 
   /* Shows where in TABLE each opcode is defined.  Since opcode 0 is
-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 06/14] libdw: Handle split DWARF in dwarf_macro_getsrcfiles
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
                   ` (4 preceding siblings ...)
  2023-09-27 18:20 ` [PATCH 05/14] libdw: Fix dwarf_macro_getsrcfiles for DWARF 5 Omar Sandoval
@ 2023-09-27 18:20 ` Omar Sandoval
  2023-10-03 21:49   ` Mark Wielaard
  2023-09-27 18:20 ` [PATCH 07/14] libdw: Recognize .debug_[ct]u_index sections in dwarf_elf_begin Omar Sandoval
                   ` (10 subsequent siblings)
  16 siblings, 1 reply; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:20 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

Macro information references file names from the line number information
table, which is tricky in split DWARF for a couple of reasons.

First, the line number information for a macro unit comes from the
.debug_line.dwo section in the split file, not the .debug_line section
in the skeleton file.  This was not specified in the GNU DebugFission
design document [1] or the DWARF 5 standard, but it is how GCC and Clang
behave in practice and was clarified in DWARF standard issue
200602.1 [2] for the upcoming DWARF 6 standard.

dwarf_macro_getsrcfiles uses the line number information from whichever
Dwarf handle it was passed.  This is error-prone, since the most natural
thing to do is to pass the skeleton Dwarf handle.  Fix this by storing
the appropriate Dwarf handle in Dwarf_Macro_Op_Table and using that one.

Second, for .debug_macinfo.dwo in GNU DebugFission (generated by gcc
-gdwarf-4 -gstrict-dwarf -gsplit-dwarf), the offset into .debug_line.dwo
is implicitly 0.  Again, this isn't in any specification, but it's how
GCC behaves in practice (Clang never generates macro information for
DWARF 4 split DWARF).  Make get_macinfo_table default to 0 for split
DWARF when it can't find DW_AT_stmt_list.

1: https://gcc.gnu.org/wiki/DebugFission
2: https://dwarfstd.org/issues/200602.1.html

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libdw/ChangeLog                 |  8 +++++---
 libdw/dwarf_getmacros.c         | 11 +++++++++--
 libdw/dwarf_macro_getsrcfiles.c |  5 ++++-
 libdw/libdwP.h                  |  2 ++
 4 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index d3f36cc8..be1e40bc 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -9,15 +9,17 @@
 	DW_FORM_strx, and DW_FORM_strx[1-4].
 	* dwarf_getmacros.c (get_macinfo_table): Replace assignment of
 	table->is_64bit with assignments of table->address_size and
-	table->offset_size.
+	table->offset_size.  Assume default DW_AT_stmt_list of 0 for split
+	DWARF.  Set table->dbg.
 	(get_table_for_offset): Ditto.
 	(read_macros): Get fake CU offset_size from table->offset_size instead
 	of table->is_64bit.
 	* dwarf_macro_getsrcfiles.c (dwarf_macro_getsrcfiles): Get
 	address_size for __libdw_getsrclines from table->address_size instead
-	of table->is_64bit.
+	of table->is_64bit.  Get dbg for __libdw_getsrclines from table->dbg
+	instead of dbg parameter, which is now unused.
 	* libdwP.h (Dwarf_Macro_Op_Table): Replace is_64bit with address_size
-	and offset_size.
+	and offset_size.  Add dbg.
 
 2023-02-22  Mark Wielaard  <mark@klomp.org>
 
diff --git a/libdw/dwarf_getmacros.c b/libdw/dwarf_getmacros.c
index b7d98af4..a3a78884 100644
--- a/libdw/dwarf_getmacros.c
+++ b/libdw/dwarf_getmacros.c
@@ -124,13 +124,19 @@ get_macinfo_table (Dwarf *dbg, Dwarf_Word macoff, Dwarf_Die *cudie)
     = INTUSE(dwarf_attr) (cudie, DW_AT_stmt_list, &attr_mem);
   Dwarf_Off line_offset = (Dwarf_Off) -1;
   if (attr != NULL)
-    if (unlikely (INTUSE(dwarf_formudata) (attr, &line_offset) != 0))
-      return NULL;
+    {
+      if (unlikely (INTUSE(dwarf_formudata) (attr, &line_offset) != 0))
+	return NULL;
+    }
+  else if (cudie->cu->unit_type == DW_UT_split_compile
+	   && dbg->sectiondata[IDX_debug_line] != NULL)
+    line_offset = 0;
 
   Dwarf_Macro_Op_Table *table = libdw_alloc (dbg, Dwarf_Macro_Op_Table,
 					     macinfo_data_size, 1);
   memcpy (table, macinfo_data, macinfo_data_size);
 
+  table->dbg = dbg;
   table->offset = macoff;
   table->sec_index = IDX_debug_macinfo;
   table->line_offset = line_offset;
@@ -263,6 +269,7 @@ get_table_for_offset (Dwarf *dbg, Dwarf_Word macoff,
 					     macop_table_size, 1);
 
   *table = (Dwarf_Macro_Op_Table) {
+    .dbg = dbg,
     .offset = macoff,
     .sec_index = IDX_debug_macro,
     .line_offset = line_offset,
diff --git a/libdw/dwarf_macro_getsrcfiles.c b/libdw/dwarf_macro_getsrcfiles.c
index 4e8deeeb..11c587af 100644
--- a/libdw/dwarf_macro_getsrcfiles.c
+++ b/libdw/dwarf_macro_getsrcfiles.c
@@ -36,6 +36,9 @@ int
 dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro,
 			 Dwarf_Files **files, size_t *nfiles)
 {
+  /* This was needed before Dwarf_Macro_Op_Table stored the Dwarf handle.  */
+  (void)dbg;
+
   /* macro is declared NN */
   Dwarf_Macro_Op_Table *const table = macro->table;
   if (table->files == NULL)
@@ -71,7 +74,7 @@ dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro,
 	 the same unit through dwarf_getsrcfiles, and the file names
 	 will be broken.  */
 
-      if (__libdw_getsrclines (dbg, line_offset, table->comp_dir,
+      if (__libdw_getsrclines (table->dbg, line_offset, table->comp_dir,
 			       table->address_size, NULL, &table->files) < 0)
 	table->files = (void *) -1;
     }
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index c3fe9f93..77959b3b 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -508,6 +508,8 @@ typedef struct
 /* Prototype table.  */
 typedef struct
 {
+  Dwarf *dbg;
+
   /* Offset of .debug_macro section.  */
   Dwarf_Off offset;
 
-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 07/14] libdw: Recognize .debug_[ct]u_index sections in dwarf_elf_begin
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
                   ` (5 preceding siblings ...)
  2023-09-27 18:20 ` [PATCH 06/14] libdw: Handle split DWARF in dwarf_macro_getsrcfiles Omar Sandoval
@ 2023-09-27 18:20 ` Omar Sandoval
  2023-11-01 14:03   ` Mark Wielaard
  2023-09-27 18:20 ` [PATCH 08/14] libdw: Parse DWARF package file index sections Omar Sandoval
                   ` (9 subsequent siblings)
  16 siblings, 1 reply; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:20 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

DWARF package (.dwp) files have a .debug_cu_index section and,
optionally, a .debug_tu_index section.  Add them to the list of DWARF
sections.

Unfortunately, it's not that simple: the other debug sections in a dwp
file have names ending with .dwo, which confuses the checks introduced
by commit 5b21e70216b8 ("libdw: dwarf_elf_begin should use either plain,
dwo or lto DWARF sections.").  So, we also have to special case
.debug_cu_index and .debug_tu_index in scn_dwarf_type and check_section
to treat them as TYPE_DWO sections.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libdw/ChangeLog         |  8 +++++++
 libdw/dwarf_begin_elf.c | 53 +++++++++++++++++++++--------------------
 libdw/libdwP.h          |  2 ++
 3 files changed, 37 insertions(+), 26 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index be1e40bc..52327688 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -20,6 +20,14 @@
 	instead of dbg parameter, which is now unused.
 	* libdwP.h (Dwarf_Macro_Op_Table): Replace is_64bit with address_size
 	and offset_size.  Add dbg.
+	Add IDX_debug_cu_index and IDX_debug_tu_index.
+	* dwarf_begin_elf.c (dwarf_scnnames): Add IDX_debug_cu_index and
+	IDX_debug_tu_index.
+	(scn_to_string_section_idx): Ditto.
+	(scn_dwarf_type): Check for .debug_cu_index, .debug_tu_index,
+	.zdebug_cu_index, and .zdebug_tu_index.
+	(check_section): Change .dwo suffix matching to account for
+	.debug_cu_index and .debug_tu_index.
 
 2023-02-22  Mark Wielaard  <mark@klomp.org>
 
diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index 92d76d24..7936d343 100644
--- a/libdw/dwarf_begin_elf.c
+++ b/libdw/dwarf_begin_elf.c
@@ -67,6 +67,8 @@ static const char dwarf_scnnames[IDX_last][19] =
   [IDX_debug_macro] = ".debug_macro",
   [IDX_debug_ranges] = ".debug_ranges",
   [IDX_debug_rnglists] = ".debug_rnglists",
+  [IDX_debug_cu_index] = ".debug_cu_index",
+  [IDX_debug_tu_index] = ".debug_tu_index",
   [IDX_gnu_debugaltlink] = ".gnu_debugaltlink"
 };
 #define ndwarf_scnnames (sizeof (dwarf_scnnames) / sizeof (dwarf_scnnames[0]))
@@ -92,6 +94,8 @@ static const enum string_section_index scn_to_string_section_idx[IDX_last] =
   [IDX_debug_macro] = STR_SCN_IDX_last,
   [IDX_debug_ranges] = STR_SCN_IDX_last,
   [IDX_debug_rnglists] = STR_SCN_IDX_last,
+  [IDX_debug_cu_index] = STR_SCN_IDX_last,
+  [IDX_debug_tu_index] = STR_SCN_IDX_last,
   [IDX_gnu_debugaltlink] = STR_SCN_IDX_last
 };
 
@@ -109,6 +113,11 @@ scn_dwarf_type (Dwarf *result, size_t shstrndx, Elf_Scn *scn)
     {
       if (startswith (scnname, ".gnu.debuglto_.debug"))
 	return TYPE_GNU_LTO;
+      else if (strcmp (scnname, ".debug_cu_index") == 0
+	       || strcmp (scnname, ".debug_tu_index") == 0
+	       || strcmp (scnname, ".zdebug_cu_index") == 0
+	       || strcmp (scnname, ".zdebug_tu_index") == 0)
+	return TYPE_DWO;
       else if (startswith (scnname, ".debug_") || startswith (scnname, ".zdebug_"))
 	{
 	  size_t len = strlen (scnname);
@@ -173,42 +182,34 @@ check_section (Dwarf *result, size_t shstrndx, Elf_Scn *scn, bool inscngrp)
   bool gnu_compressed = false;
   for (cnt = 0; cnt < ndwarf_scnnames; ++cnt)
     {
+      /* .debug_cu_index and .debug_tu_index don't have a .dwo suffix,
+	 but they are for DWO.  */
+      if (result->type != TYPE_DWO
+	  && (cnt == IDX_debug_cu_index || cnt == IDX_debug_tu_index))
+	continue;
+      bool need_dot_dwo =
+	(result->type == TYPE_DWO
+	 && cnt != IDX_debug_cu_index
+	 && cnt != IDX_debug_tu_index);
       size_t dbglen = strlen (dwarf_scnnames[cnt]);
       size_t scnlen = strlen (scnname);
       if (strncmp (scnname, dwarf_scnnames[cnt], dbglen) == 0
-	  && (dbglen == scnlen
-	      || (scnlen == dbglen + 4
+	  && ((!need_dot_dwo && dbglen == scnlen)
+	      || (need_dot_dwo
+		  && scnlen == dbglen + 4
 		  && strstr (scnname, ".dwo") == scnname + dbglen)))
-	{
-	  if (dbglen == scnlen)
-	    {
-	      if (result->type == TYPE_PLAIN)
-		break;
-	    }
-	  else if (result->type == TYPE_DWO)
-	    break;
-	}
+	break;
       else if (scnname[0] == '.' && scnname[1] == 'z'
 	       && (strncmp (&scnname[2], &dwarf_scnnames[cnt][1],
 			    dbglen - 1) == 0
-		   && (scnlen == dbglen + 1
-		       || (scnlen == dbglen + 5
+		   && ((!need_dot_dwo && scnlen == dbglen + 1)
+		       || (need_dot_dwo
+			   && scnlen == dbglen + 5
 			   && strstr (scnname,
 				      ".dwo") == scnname + dbglen + 1))))
 	{
-	  if (scnlen == dbglen + 1)
-	    {
-	      if (result->type == TYPE_PLAIN)
-		{
-		  gnu_compressed = true;
-		  break;
-		}
-	    }
-	  else if (result->type <= TYPE_DWO)
-	    {
-	      gnu_compressed = true;
-	      break;
-	    }
+	  gnu_compressed = true;
+	  break;
 	}
       else if (scnlen > 14 /* .gnu.debuglto_ prefix. */
 	       && startswith (scnname, ".gnu.debuglto_")
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 77959b3b..0c44d40c 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -82,6 +82,8 @@ enum
     IDX_debug_macro,
     IDX_debug_ranges,
     IDX_debug_rnglists,
+    IDX_debug_cu_index,
+    IDX_debug_tu_index,
     IDX_gnu_debugaltlink,
     IDX_last
   };
-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 08/14] libdw: Parse DWARF package file index sections
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
                   ` (6 preceding siblings ...)
  2023-09-27 18:20 ` [PATCH 07/14] libdw: Recognize .debug_[ct]u_index sections in dwarf_elf_begin Omar Sandoval
@ 2023-09-27 18:20 ` Omar Sandoval
  2023-11-01 23:07   ` Mark Wielaard
  2023-09-27 18:20 ` [PATCH 09/14] libdw, libdwfl: Save original path of ELF file Omar Sandoval
                   ` (8 subsequent siblings)
  16 siblings, 1 reply; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:20 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

The .debug_cu_index and .debug_tu_index sections in DWARF package files
are basically hash tables mapping a unit's 8 byte signature to an offset
and size in each section used by that unit [1].  Add support for parsing
and doing lookups in the index sections.

We look up a unit in the index when we intern it and cache its hash
table row in Dwarf_CU.  Then, a new function, dwarf_cu_dwp_section_info,
can be used to look up the section offsets and sizes for a unit.  This
will mostly be used internally in libdw, but it will also be needed in
static inline functions shared with eu-readelf.  Additionally, making it
public it makes dwp support much easier for external tools that do their
own low-level parsing of DWARF information, like drgn [2].

1: https://gcc.gnu.org/wiki/DebugFissionDWP#Format_of_the_CU_and_TU_Index_Sections
2: https://github.com/osandov/drgn

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libdw/ChangeLog                     |  18 +-
 libdw/Makefile.am                   |   2 +-
 libdw/dwarf_cu_dwp_section_info.c   | 371 ++++++++++++++++++++++++++++
 libdw/dwarf_end.c                   |   3 +
 libdw/dwarf_error.c                 |   1 +
 libdw/libdw.h                       |  23 ++
 libdw/libdw.map                     |   5 +
 libdw/libdwP.h                      |  36 +++
 libdw/libdw_findcu.c                |   8 +
 tests/.gitignore                    |   1 +
 tests/ChangeLog                     |  13 +
 tests/Makefile.am                   |  11 +-
 tests/cu-dwp-section-info.c         |  74 ++++++
 tests/run-cu-dwp-section-info.sh    | 168 +++++++++++++
 tests/testfile-dwp-4-strict.bz2     | Bin 0 -> 4169 bytes
 tests/testfile-dwp-4-strict.dwp.bz2 | Bin 0 -> 6871 bytes
 tests/testfile-dwp-4.bz2            | Bin 0 -> 4194 bytes
 tests/testfile-dwp-4.dwp.bz2        | Bin 0 -> 10098 bytes
 tests/testfile-dwp-5.bz2            | Bin 0 -> 4223 bytes
 tests/testfile-dwp-5.dwp.bz2        | Bin 0 -> 10313 bytes
 tests/testfile-dwp.source           | 102 ++++++++
 21 files changed, 831 insertions(+), 5 deletions(-)
 create mode 100644 libdw/dwarf_cu_dwp_section_info.c
 create mode 100644 tests/cu-dwp-section-info.c
 create mode 100755 tests/run-cu-dwp-section-info.sh
 create mode 100755 tests/testfile-dwp-4-strict.bz2
 create mode 100644 tests/testfile-dwp-4-strict.dwp.bz2
 create mode 100755 tests/testfile-dwp-4.bz2
 create mode 100644 tests/testfile-dwp-4.dwp.bz2
 create mode 100755 tests/testfile-dwp-5.bz2
 create mode 100644 tests/testfile-dwp-5.dwp.bz2
 create mode 100644 tests/testfile-dwp.source

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 52327688..1d229094 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -20,7 +20,14 @@
 	instead of dbg parameter, which is now unused.
 	* libdwP.h (Dwarf_Macro_Op_Table): Replace is_64bit with address_size
 	and offset_size.  Add dbg.
-	Add IDX_debug_cu_index and IDX_debug_tu_index.
+	(Dwarf): Add cu_index and tu_index.
+	(Dwarf_CU): Add dwp_row.
+	(Dwarf_Package_Index): New type.
+	(DW_SECT_TYPES): New macro.
+	(__libdw_dwp_find_unit): New declaration.
+	(dwarf_cu_dwp_section_info): New INTDECL.
+	Add IDX_debug_cu_index and IDX_debug_tu_index.  Add
+	DWARF_E_UNKNOWN_SECTION.
 	* dwarf_begin_elf.c (dwarf_scnnames): Add IDX_debug_cu_index and
 	IDX_debug_tu_index.
 	(scn_to_string_section_idx): Ditto.
@@ -28,6 +35,15 @@
 	.zdebug_cu_index, and .zdebug_tu_index.
 	(check_section): Change .dwo suffix matching to account for
 	.debug_cu_index and .debug_tu_index.
+	* Makefile.am (libdw_a_SOURCES): Add dwarf_cu_dwp_section_info.c.
+	* dwarf_end.c (dwarf_end): Free dwarf->cu_index and dwarf->tu_index.
+	* dwarf_error.c (errmsgs): Add DWARF_E_UNKNOWN_SECTION.
+	* libdw.h (dwarf_cu_dwp_section_info): New declaration.
+	* libdw.map (ELFUTILS_0.190): Add dwarf_cu_dwp_section_info.
+	* libdw_findcu.c (__libdw_intern_next_unit): Call
+	__libdw_dwp_find_unit, and use it to adjust abbrev_offset and assign
+	newp->dwp_row.
+	* dwarf_cu_dwp_section_info.c: New file.
 
 2023-02-22  Mark Wielaard  <mark@klomp.org>
 
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index e548f38c..5363c02a 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -93,7 +93,7 @@ libdw_a_SOURCES = dwarf_begin.c dwarf_begin_elf.c dwarf_end.c dwarf_getelf.c \
 		  dwarf_cu_die.c dwarf_peel_type.c dwarf_default_lower_bound.c \
 		  dwarf_die_addr_die.c dwarf_get_units.c \
 		  libdw_find_split_unit.c dwarf_cu_info.c \
-		  dwarf_next_lines.c
+		  dwarf_next_lines.c dwarf_cu_dwp_section_info.c
 
 if MAINTAINER_MODE
 BUILT_SOURCES = $(srcdir)/known-dwarf.h
diff --git a/libdw/dwarf_cu_dwp_section_info.c b/libdw/dwarf_cu_dwp_section_info.c
new file mode 100644
index 00000000..6766fb9a
--- /dev/null
+++ b/libdw/dwarf_cu_dwp_section_info.c
@@ -0,0 +1,371 @@
+/* Read DWARF package file index sections.
+   Copyright (c) Meta Platforms, Inc. and affiliates.
+   This file is part of elfutils.
+
+   This file is free software; you can redistribute it and/or modify
+   it under the terms of either
+
+     * the GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 3 of the License, or (at
+       your option) any later version
+
+   or
+
+     * the GNU General Public License as published by the Free
+       Software Foundation; either version 2 of the License, or (at
+       your option) any later version
+
+   or both in parallel, as here.
+
+   elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "libdwP.h"
+
+static Dwarf_Package_Index *
+__libdw_read_package_index (Dwarf *dbg, bool tu)
+{
+  Elf_Data *data;
+  if (tu)
+    data = dbg->sectiondata[IDX_debug_tu_index];
+  else
+    data = dbg->sectiondata[IDX_debug_cu_index];
+
+  /* We need at least 16 bytes for the header.  */
+  if (data == NULL || data->d_size < 16)
+    {
+    invalid:
+      __libdw_seterrno (DWARF_E_INVALID_DWARF);
+      return NULL;
+    }
+
+  const unsigned char *datap = data->d_buf;
+  const unsigned char *endp = datap + data->d_size;
+  uint16_t version;
+  /* In GNU DebugFission for DWARF 4, the version is 2 as a uword.  In the
+     standardized DWARF 5 format, it is a uhalf followed by a padding uhalf.
+     Check for both.  */
+  if (read_4ubyte_unaligned (dbg, datap) == 2)
+    version = 2;
+  else
+    {
+      version = read_2ubyte_unaligned (dbg, datap);
+      if (version != 5)
+	{
+	  __libdw_seterrno (DWARF_E_VERSION);
+	  return NULL;
+	}
+    }
+  datap += 4;
+  uint32_t section_count = read_4ubyte_unaligned_inc (dbg, datap);
+  uint32_t unit_count = read_4ubyte_unaligned_inc (dbg, datap);
+  uint32_t slot_count = read_4ubyte_unaligned_inc (dbg, datap);
+
+  /* The specification has a stricter requirement that
+     slot_count > 3 * unit_count / 2, but this is enough for us.  */
+  if (slot_count < unit_count)
+    goto invalid;
+
+  /* After the header, the section must contain:
+
+       8 byte signature per hash table slot
+     + 4 byte index per hash table slot
+     + Section offset table with 1 header row, 1 row per unit, 1 column per
+       section, 4 bytes per field
+     + Section size table with 1 row per unit, 1 column per section, 4 bytes
+       per field
+
+     We have to be careful about overflow when checking this.  */
+  const unsigned char *hash_table = datap;
+  if ((size_t) (endp - hash_table) < (uint64_t) slot_count * 12)
+    goto invalid;
+  const unsigned char *indices = hash_table + (size_t) slot_count * 8;
+  const unsigned char *sections = indices + (size_t) slot_count * 4;
+  if ((size_t) (endp - sections) < (uint64_t) section_count * 4)
+    goto invalid;
+  const unsigned char *section_offsets = sections + (size_t) section_count * 4;
+  if ((uint64_t) unit_count * section_count > UINT64_MAX / 8
+      || ((size_t) (endp - section_offsets)
+	  < (uint64_t) unit_count * section_count * 8))
+    goto invalid;
+  const unsigned char *section_sizes
+    = section_offsets + (uint64_t) unit_count * section_count * 4;
+
+  Dwarf_Package_Index *index = malloc (sizeof (*index));
+  if (index == NULL)
+    {
+      __libdw_seterrno (DWARF_E_NOMEM);
+      return NULL;
+    }
+
+  index->dbg = dbg;
+  /* Set absent sections to UINT32_MAX.  */
+  memset (index->sections, 0xff, sizeof (index->sections));
+  for (size_t i = 0; i < section_count; i++)
+    {
+      uint32_t section = read_4ubyte_unaligned (dbg, sections + i * 4);
+      /* 2 is DW_SECT_TYPES in version 2 and reserved in version 5.  We ignore
+         it for version 5.
+	 5 is DW_SECT_LOC in version 2 and DW_SECT_LOCLISTS in version 5.  We
+	 use the same index for both.
+	 7 is DW_SECT_MACINFO in version 2 and DW_SECT_MACRO in version 5.  We
+	 use the same index for both.
+	 8 is DW_SECT_MACRO in version 2 and DW_SECT_RNGLISTS in version 5.  We
+	 use the same index for version 2's DW_SECT_MACRO as version 2's
+	 DW_SECT_MACINFO/version 5's DW_SECT_MACRO.
+	 We ignore unknown sections.  */
+      if (section == 0)
+	continue;
+      if (version == 2)
+	{
+	  if (section > 8)
+	    continue;
+	  else if (section == 8)
+	    section = DW_SECT_MACRO;
+	}
+      else if (section == 2
+	       || (section
+		   > sizeof (index->sections) / sizeof (index->sections[0])))
+	continue;
+      index->sections[section - 1] = i;
+    }
+
+  /* DW_SECT_INFO (or DW_SECT_TYPES for DWARF 4 type units) and DW_SECT_ABBREV
+     are required.  */
+  if (((!tu || dbg->sectiondata[IDX_debug_types] == NULL)
+       && index->sections[DW_SECT_INFO - 1] == UINT32_MAX)
+      || (tu && dbg->sectiondata[IDX_debug_types] != NULL
+	  && index->sections[DW_SECT_TYPES - 1] == UINT32_MAX)
+      || index->sections[DW_SECT_ABBREV - 1] == UINT32_MAX)
+    {
+      free (index);
+      __libdw_seterrno (DWARF_E_INVALID_DWARF);
+      return NULL;
+    }
+
+  index->section_count = section_count;
+  index->unit_count = unit_count;
+  index->slot_count = slot_count;
+  index->last_unit_found = 0;
+  index->hash_table = hash_table;
+  index->indices = indices;
+  index->section_offsets = section_offsets;
+  index->section_sizes = section_sizes;
+
+  return index;
+}
+
+static Dwarf_Package_Index *
+__libdw_package_index (Dwarf *dbg, bool tu)
+{
+  if (tu && dbg->tu_index != NULL)
+    return dbg->tu_index;
+  else if (!tu && dbg->cu_index != NULL)
+    return dbg->cu_index;
+
+  Dwarf_Package_Index *index = __libdw_read_package_index (dbg, tu);
+  if (index == NULL)
+    return NULL;
+
+  if (tu)
+    dbg->tu_index = index;
+  else
+    dbg->cu_index = index;
+  return index;
+}
+
+static int
+__libdw_dwp_unit_row (Dwarf_Package_Index *index, uint64_t unit_id,
+		      uint32_t *unit_rowp)
+{
+  if (index == NULL)
+    return -1;
+
+  uint32_t hash = unit_id;
+  uint32_t hash2 = (unit_id >> 32) | 1;
+  /* Only check each slot once.  */
+  for (uint32_t n = index->slot_count; n-- > 0; )
+    {
+      size_t slot = hash & (index->slot_count - 1);
+      uint64_t sig = read_8ubyte_unaligned (index->dbg,
+					    index->hash_table + slot * 8);
+      if (sig == unit_id)
+	{
+	  uint32_t row = read_4ubyte_unaligned (index->dbg,
+						index->indices + slot * 4);
+	  if (row > index->unit_count)
+	    {
+	      __libdw_seterrno (DWARF_E_INVALID_DWARF);
+	      return -1;
+	    }
+	  *unit_rowp = row;
+	  return 0;
+	}
+      else if (sig == 0
+	       && read_4ubyte_unaligned (index->dbg,
+					 index->indices + slot * 4) == 0)
+	break;
+      hash += hash2;
+    }
+  *unit_rowp = 0;
+  return 0;
+}
+
+static int
+__libdw_dwp_section_info (Dwarf_Package_Index *index, uint32_t unit_row,
+			  unsigned int section, Dwarf_Off *offsetp,
+			  Dwarf_Off *sizep)
+{
+  if (index == NULL)
+    return -1;
+  if (unit_row == 0)
+    {
+      __libdw_seterrno (DWARF_E_INVALID_DWARF);
+      return -1;
+    }
+  if (index->sections[section - 1] == UINT32_MAX)
+    {
+      if (offsetp != NULL)
+	*offsetp = 0;
+      if (sizep != NULL)
+	*sizep = 0;
+      return 0;
+    }
+  size_t i = (size_t)(unit_row - 1) * index->section_count
+	     + index->sections[section - 1];
+  if (offsetp != NULL)
+    *offsetp = read_4ubyte_unaligned (index->dbg,
+				      index->section_offsets + i * 4);
+  if (sizep != NULL)
+    *sizep = read_4ubyte_unaligned (index->dbg,
+				    index->section_sizes + i * 4);
+  return 0;
+}
+
+int
+internal_function
+__libdw_dwp_find_unit (Dwarf *dbg, bool debug_types, Dwarf_Off off,
+		       uint16_t version, uint8_t unit_type, uint64_t unit_id8,
+		       uint32_t *unit_rowp, Dwarf_Off *abbrev_offsetp)
+{
+  if (version >= 5
+      && unit_type != DW_UT_split_compile && unit_type != DW_UT_split_type)
+    {
+    not_dwp:
+      *unit_rowp = 0;
+      *abbrev_offsetp = 0;
+      return 0;
+    }
+  bool tu = unit_type == DW_UT_split_type || debug_types;
+  if (dbg->sectiondata[tu ? IDX_debug_tu_index : IDX_debug_cu_index] == NULL)
+    goto not_dwp;
+  Dwarf_Package_Index *index = __libdw_package_index (dbg, tu);
+  if (index == NULL)
+    return -1;
+
+  /* This is always called for ascending offsets.  The most obvious way for a
+     producer to generate the section offset table is sorted by offset; both
+     GNU dwp and llvm-dwp do this.  In this common case, we can avoid the full
+     lookup.  */
+  if (index->last_unit_found < index->unit_count)
+    {
+      Dwarf_Off offset, size;
+      if (__libdw_dwp_section_info (index, index->last_unit_found + 1,
+				    debug_types ? DW_SECT_TYPES : DW_SECT_INFO,
+				    &offset, &size) != 0)
+	return -1;
+      if (offset <= off && off - offset < size)
+	{
+	  *unit_rowp = ++index->last_unit_found;
+	  goto done;
+	}
+      else
+	/* The units are not sorted. Don't try again.  */
+	index->last_unit_found = index->unit_count;
+    }
+
+  if (version >= 5 || debug_types)
+    {
+      /* In DWARF 5 and in type units, the unit signature is available in the
+         unit header.  */
+      if (__libdw_dwp_unit_row (index, unit_id8, unit_rowp) != 0)
+	return -1;
+    }
+  else
+    {
+      /* In DWARF 4 compilation units, the unit signature is an attribute.  We
+	 can't parse attributes in the split unit until we get the abbreviation
+	 table offset from the package index, which is a chicken-and-egg
+	 problem.  We could get the signature from the skeleton unit, but that
+	 may not be available.
+
+	 Instead, we resort to a linear scan through the section offset table.
+	 Finding all units is therefore quadratic in the number of units.
+	 However, this will likely never be needed in practice because of the
+	 sorted fast path above.  If this ceases to be the case, we can try to
+	 plumb through the skeleton unit's signature when it is available, or
+	 build a sorted lookup table for binary search.  */
+      if (index->sections[DW_SECT_INFO - 1] == UINT32_MAX)
+	{
+	  __libdw_seterrno (DWARF_E_INVALID_DWARF);
+	  return -1;
+	}
+      for (uint32_t i = 0; i < index->unit_count; i++)
+	{
+	  Dwarf_Off offset, size;
+	  __libdw_dwp_section_info (index, i + 1, DW_SECT_INFO, &offset,
+				    &size);
+	  if (offset <= off && off - offset < size)
+	    {
+	      *unit_rowp = i + 1;
+	      goto done;
+	    }
+	}
+      __libdw_seterrno (DWARF_E_INVALID_DWARF);
+      return -1;
+    }
+
+ done:
+  return __libdw_dwp_section_info (index, *unit_rowp, DW_SECT_ABBREV,
+				   abbrev_offsetp, NULL);
+}
+
+int
+dwarf_cu_dwp_section_info (Dwarf_CU *cu, unsigned int section,
+			   Dwarf_Off *offsetp, Dwarf_Off *sizep)
+{
+  if (cu == NULL)
+    return -1;
+  if (section < DW_SECT_INFO || section > DW_SECT_RNGLISTS)
+    {
+      __libdw_seterrno (DWARF_E_UNKNOWN_SECTION);
+      return -1;
+    }
+  if (cu->dwp_row == 0)
+    {
+      if (offsetp != NULL)
+	*offsetp = 0;
+      if (sizep != NULL)
+	*sizep = 0;
+      return 0;
+    }
+  else
+    {
+      Dwarf_Package_Index *index
+	= cu->unit_type == DW_UT_split_compile
+	? cu->dbg->cu_index : cu->dbg->tu_index;
+      return __libdw_dwp_section_info (index, cu->dwp_row, section, offsetp,
+				       sizep);
+    }
+}
+INTDEF(dwarf_cu_dwp_section_info)
diff --git a/libdw/dwarf_end.c b/libdw/dwarf_end.c
index 8dd075cf..18a419ce 100644
--- a/libdw/dwarf_end.c
+++ b/libdw/dwarf_end.c
@@ -77,6 +77,9 @@ dwarf_end (Dwarf *dwarf)
 {
   if (dwarf != NULL)
     {
+      free (dwarf->tu_index);
+      free (dwarf->cu_index);
+
       if (dwarf->cfi != NULL)
 	/* Clean up the CFI cache.  */
 	__libdw_destroy_frame_cache (dwarf->cfi);
diff --git a/libdw/dwarf_error.c b/libdw/dwarf_error.c
index 46ea16b3..0123cfa2 100644
--- a/libdw/dwarf_error.c
+++ b/libdw/dwarf_error.c
@@ -102,6 +102,7 @@ static const char *errmsgs[] =
     [DWARF_E_NOT_CUDIE] = N_("not a CU (unit) DIE"),
     [DWARF_E_UNKNOWN_LANGUAGE] = N_("unknown language code"),
     [DWARF_E_NO_DEBUG_ADDR] = N_(".debug_addr section missing"),
+    [DWARF_E_UNKNOWN_SECTION] = N_("unknown section"),
   };
 #define nerrmsgs (sizeof (errmsgs) / sizeof (errmsgs[0]))
 
diff --git a/libdw/libdw.h b/libdw/libdw.h
index 64d1689a..545ad043 100644
--- a/libdw/libdw.h
+++ b/libdw/libdw.h
@@ -1081,6 +1081,29 @@ extern int dwarf_frame_register (Dwarf_Frame *frame, int regno,
   __nonnull_attribute__ (3, 4, 5);
 
 
+/* Return offset and/or size of CU's contribution to SECTION in a DWARF package
+   file.
+
+   If CU is not from a DWARF package file, the file does not have SECTION, or CU
+   does not contribute to SECTION, then *SIZEP is set to 0.
+
+   SECTION is a DW_SECT section identifier.  Note that the original GNU DWARF
+   package file extension for DWARF 4 used slightly different section
+   identifiers.  This function uses the standardized section identifiers and
+   maps the GNU DWARF 4 identifiers to their standard DWARF 5 analogues:
+   DW_SECT_LOCLISTS (5) refers to .debug_locs.dwo for DWARF 4.
+   DW_SECT_MACRO (7) refers to .debug_macinfo.dwo for DWARF 4 or
+   .debug_macro.dwo for the GNU .debug_macro extension for DWARF 4 (section
+   identifier 8 is DW_SECT_RNGLISTS in DWARF 5, NOT DW_SECT_MACRO like in the
+   GNU extension.)
+   .debug_types.dwo does not have a DWARF 5 equivalent, so this function accepts
+   the original DW_SECT_TYPES (2).
+
+   Returns 0 for success or -1 for errors.  OFFSETP and SIZEP may be NULL.  */
+extern int dwarf_cu_dwp_section_info (Dwarf_CU *cu, unsigned int section,
+				      Dwarf_Off *offsetp, Dwarf_Off *sizep);
+
+
 /* Return error code of last failing function call.  This value is kept
    separately for each thread.  */
 extern int dwarf_errno (void);
diff --git a/libdw/libdw.map b/libdw/libdw.map
index 5331ad45..2104b007 100644
--- a/libdw/libdw.map
+++ b/libdw/libdw.map
@@ -373,3 +373,8 @@ ELFUTILS_0.188 {
     dwfl_frame_reg;
     dwfl_report_offline_memory;
 } ELFUTILS_0.186;
+
+ELFUTILS_0.190 {
+  global:
+    dwarf_cu_dwp_section_info;
+} ELFUTILS_0.188;
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 0c44d40c..13ca58ce 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -147,6 +147,7 @@ enum
   DWARF_E_NOT_CUDIE,
   DWARF_E_UNKNOWN_LANGUAGE,
   DWARF_E_NO_DEBUG_ADDR,
+  DWARF_E_UNKNOWN_SECTION,
 };
 
 
@@ -227,6 +228,11 @@ struct Dwarf
   /* Cached info from the CFI section.  */
   struct Dwarf_CFI_s *cfi;
 
+  /* DWARF package file CU index section.  */
+  struct Dwarf_Package_Index_s *cu_index;
+  /* DWARF package file TU index section.  */
+  struct Dwarf_Package_Index_s *tu_index;
+
   /* Fake loc CU.  Used when synthesizing attributes for Dwarf_Ops that
      came from a location list entry in dwarf_getlocation_attr.
      Depending on version this is the .debug_loc or .debug_loclists
@@ -339,6 +345,26 @@ struct Dwarf_Aranges_s
   } info[0];
 };
 
+/* DWARF package file unit index.  */
+typedef struct Dwarf_Package_Index_s
+{
+  Dwarf *dbg;
+  uint32_t section_count;
+  uint32_t unit_count;
+  uint32_t slot_count;
+  /* Mapping from DW_SECT_* - 1 to column number in the section tables, or
+     UINT32_MAX if not present.  */
+  uint32_t sections[DW_SECT_RNGLISTS];
+  /* Row number of last unit found in the index.  */
+  uint32_t last_unit_found;
+  const unsigned char *hash_table;
+  const unsigned char *indices;
+  const unsigned char *section_offsets;
+  const unsigned char *section_sizes;
+} Dwarf_Package_Index;
+
+/* Used in GNU DebugFission for DWARF 4.  Reserved in DWARF 5.  */
+#define DW_SECT_TYPES 2
 
 /* CU representation.  */
 struct Dwarf_CU
@@ -346,6 +372,8 @@ struct Dwarf_CU
   Dwarf *dbg;
   Dwarf_Off start;
   Dwarf_Off end;
+  /* Row number of this unit in DWARF package file index.  */
+  uint32_t dwp_row;
   uint8_t address_size;
   uint8_t offset_size;
   uint16_t version;
@@ -680,6 +708,13 @@ extern struct Dwarf *__libdw_find_split_dbg_addr (Dwarf *dbg, void *addr)
 extern struct Dwarf_CU *__libdw_find_split_unit (Dwarf_CU *cu)
      internal_function;
 
+/* Find a unit in a DWARF package file for __libdw_intern_next_unit.  */
+extern int __libdw_dwp_find_unit (Dwarf *dbg, bool debug_types, Dwarf_Off off,
+				  uint16_t version, uint8_t unit_type,
+				  uint64_t unit_id8, uint32_t *unit_rowp,
+				  Dwarf_Off *abbrev_offsetp)
+     __nonnull_attribute__ (1, 7, 8) internal_function;
+
 /* Get abbreviation with given code.  */
 extern Dwarf_Abbrev *__libdw_findabbrev (struct Dwarf_CU *cu,
 					 unsigned int code)
@@ -1380,6 +1415,7 @@ INTDECL (dwarf_attr_integrate)
 INTDECL (dwarf_begin)
 INTDECL (dwarf_begin_elf)
 INTDECL (dwarf_child)
+INTDECL (dwarf_cu_dwp_section_info)
 INTDECL (dwarf_default_lower_bound)
 INTDECL (dwarf_dieoffset)
 INTDECL (dwarf_diename)
diff --git a/libdw/libdw_findcu.c b/libdw/libdw_findcu.c
index ed744231..6c7dcfb5 100644
--- a/libdw/libdw_findcu.c
+++ b/libdw/libdw_findcu.c
@@ -143,6 +143,13 @@ __libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
   if (unlikely (*offsetp > data->d_size))
     *offsetp = data->d_size;
 
+  uint32_t dwp_row;
+  Dwarf_Off dwp_abbrev_offset;
+  if (__libdw_dwp_find_unit (dbg, debug_types, oldoff, version, unit_type,
+			     unit_id8, &dwp_row, &dwp_abbrev_offset) != 0)
+    return NULL;
+  abbrev_offset += dwp_abbrev_offset;
+
   /* Create an entry for this CU.  */
   struct Dwarf_CU *newp = libdw_typed_alloc (dbg, struct Dwarf_CU);
 
@@ -150,6 +157,7 @@ __libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
   newp->sec_idx = sec_idx;
   newp->start = oldoff;
   newp->end = *offsetp;
+  newp->dwp_row = dwp_row;
   newp->address_size = address_size;
   newp->offset_size = offset_size;
   newp->version = version;
diff --git a/tests/.gitignore b/tests/.gitignore
index b9aa22ba..e9a61a2d 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -28,6 +28,7 @@
 /backtrace-dwarf
 /buildid
 /core-dump-backtrace.lock
+/cu-dwp-section-info
 /debugaltlink
 /debuginfod_build_id_find
 /debuglink
diff --git a/tests/ChangeLog b/tests/ChangeLog
index f934c114..687a9f32 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,6 +1,19 @@
 2023-09-27  Omar Sandoval  <osandov@fb.com>
 
 	* run-varlocs.sh: Add entry PC to split units.
+	* Makefile.am (check_PROGRAMS): Add cu-dwp-section-info.
+	(TESTS): Add run-cu-dwp-section-info.sh
+	(EXTRA_DIST): Add run-cu-dwp-section-info.sh and new test files.
+	(cu_dwp_section_info_LDADD): New variable.
+	* cu-dwp-section-info.c: New test.
+	* run-cu-dwp-section-info.sh: New test.
+	* testfile-dwp-4-strict.bz2: New test file.
+	* testfile-dwp-4-strict.dwp.bz2: New test file.
+	* testfile-dwp-4.bz2: New test file.
+	* testfile-dwp-4.dwp.bz2: New test file.
+	* testfile-dwp-5.bz2: New test file.
+	* testfile-dwp-5.dwp.bz2: New test file.
+	* testfile-dwp.source: New file.
 
 2023-04-21  Frank Ch. Eigler <fche@redhat.com>
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 32b18e6e..0938882b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -62,7 +62,7 @@ check_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
 		  dwelf_elf_e_machine_string \
 		  getphdrnum leb128 read_unaligned \
 		  msg_tst system-elf-libelf-test system-elf-gelf-test \
-		  nvidia_extended_linemap_libdw \
+		  nvidia_extended_linemap_libdw cu-dwp-section-info \
 		  $(asm_TESTS)
 
 asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
@@ -211,7 +211,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \
 	$(asm_TESTS) run-disasm-bpf.sh run-low_high_pc-dw-form-indirect.sh \
 	run-nvidia-extended-linemap-libdw.sh run-nvidia-extended-linemap-readelf.sh \
 	run-readelf-dw-form-indirect.sh run-strip-largealign.sh \
-	run-readelf-Dd.sh
+	run-readelf-Dd.sh run-cu-dwp-section-info.sh
 
 if !BIARCH
 export ELFUTILS_DISABLE_BIARCH = 1
@@ -629,7 +629,11 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
 	     run-nvidia-extended-linemap-libdw.sh run-nvidia-extended-linemap-readelf.sh \
 	     testfile_nvidia_linemap.bz2 \
 	     testfile-largealign.o.bz2 run-strip-largealign.sh \
-	     run-funcretval++11.sh
+	     run-funcretval++11.sh \
+	     testfile-dwp-4.bz2 testfile-dwp-4.dwp.bz2 \
+	     testfile-dwp-4-strict.bz2 testfile-dwp-4-strict.dwp.bz2 \
+	     testfile-dwp-5.bz2 testfile-dwp-5.dwp.bz2 testfile-dwp.source \
+	     run-cu-dwp-section-info.sh
 
 
 if USE_VALGRIND
@@ -804,6 +808,7 @@ getphdrnum_LDADD = $(libelf) $(libdw)
 leb128_LDADD = $(libelf) $(libdw)
 read_unaligned_LDADD = $(libelf) $(libdw)
 nvidia_extended_linemap_libdw_LDADD = $(libelf) $(libdw)
+cu_dwp_section_info_LDADD = $(libdw)
 
 # We want to test the libelf headers against the system elf.h header.
 # Don't include any -I CPPFLAGS. Except when we install our own elf.h.
diff --git a/tests/cu-dwp-section-info.c b/tests/cu-dwp-section-info.c
new file mode 100644
index 00000000..e92f35b6
--- /dev/null
+++ b/tests/cu-dwp-section-info.c
@@ -0,0 +1,74 @@
+/* Test program for dwarf_cu_dwp_section_info
+   Copyright (c) Meta Platforms, Inc. and affiliates.
+   This file is part of elfutils.
+
+   This file is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdio.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dwarf.h>
+#include ELFUTILS_HEADER(dw)
+
+int
+main (int argc, char *argv[])
+{
+  for (int i = 1; i < argc; i++)
+    {
+      printf ("file: %s\n", argv[i]);
+      int fd = open (argv[i], O_RDONLY);
+      Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
+      if (dbg == NULL)
+	{
+	  printf ("%s not usable: %s\n", argv[i], dwarf_errmsg (-1));
+	  return -1;
+	}
+
+      Dwarf_CU *cu = NULL;
+      while (dwarf_get_units (dbg, cu, &cu, NULL, NULL, NULL, NULL) == 0)
+	{
+#define SECTION_INFO(section) do {					\
+	    printf (#section ": ");					\
+	    Dwarf_Off offset, size;					\
+	    if (dwarf_cu_dwp_section_info (cu, DW_SECT_##section,	\
+					   &offset, &size) == 0)	\
+	      printf ("0x%" PRIx64 " 0x%" PRIx64 "\n", offset, size);	\
+	    else							\
+	      printf ("%s\n", dwarf_errmsg (-1));			\
+	  } while (0)
+	  SECTION_INFO (INFO);
+#define DW_SECT_TYPES 2
+	  SECTION_INFO (TYPES);
+	  SECTION_INFO (ABBREV);
+	  SECTION_INFO (LINE);
+	  SECTION_INFO (LOCLISTS);
+	  SECTION_INFO (STR_OFFSETS);
+	  SECTION_INFO (MACRO);
+	  SECTION_INFO (RNGLISTS);
+	  printf ("\n");
+	}
+
+      dwarf_end (dbg);
+      close (fd);
+    }
+
+  return 0;
+}
diff --git a/tests/run-cu-dwp-section-info.sh b/tests/run-cu-dwp-section-info.sh
new file mode 100755
index 00000000..f8596f2c
--- /dev/null
+++ b/tests/run-cu-dwp-section-info.sh
@@ -0,0 +1,168 @@
+#! /bin/sh
+# Copyright (c) Meta Platforms, Inc. and affiliates.
+# This file is part of elfutils.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# elfutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. $srcdir/test-subr.sh
+
+# See testfile-dwp.source.
+testfiles testfile-dwp-5.dwp testfile-dwp-4.dwp testfile-dwp-4-strict.dwp
+
+testrun_compare ${abs_builddir}/cu-dwp-section-info testfile-dwp-5.dwp << EOF
+file: testfile-dwp-5.dwp
+INFO: 0x0 0x70
+TYPES: 0x0 0x0
+ABBREV: 0x0 0x160
+LINE: 0x0 0x7f
+LOCLISTS: 0x0 0xdb
+STR_OFFSETS: 0x0 0x75c
+MACRO: 0x0 0x6c6
+RNGLISTS: 0x0 0x22
+
+INFO: 0x70 0x108
+TYPES: 0x0 0x0
+ABBREV: 0x0 0x160
+LINE: 0x0 0x7f
+LOCLISTS: 0x0 0xdb
+STR_OFFSETS: 0x0 0x75c
+MACRO: 0x0 0x6c6
+RNGLISTS: 0x0 0x22
+
+INFO: 0x178 0x6e
+TYPES: 0x0 0x0
+ABBREV: 0x160 0xca
+LINE: 0x7f 0x7f
+LOCLISTS: 0x0 0x0
+STR_OFFSETS: 0x75c 0x758
+MACRO: 0x6c6 0x6c5
+RNGLISTS: 0x0 0x0
+
+INFO: 0x1e6 0x78
+TYPES: 0x0 0x0
+ABBREV: 0x160 0xca
+LINE: 0x7f 0x7f
+LOCLISTS: 0x0 0x0
+STR_OFFSETS: 0x75c 0x758
+MACRO: 0x6c6 0x6c5
+RNGLISTS: 0x0 0x0
+
+INFO: 0x25e 0x193
+TYPES: 0x0 0x0
+ABBREV: 0x22a 0x18a
+LINE: 0xfe 0x81
+LOCLISTS: 0xdb 0xc9
+STR_OFFSETS: 0xeb4 0x77c
+MACRO: 0xd8b 0x6c6
+RNGLISTS: 0x22 0x43
+
+EOF
+
+testrun_compare ${abs_builddir}/cu-dwp-section-info testfile-dwp-4.dwp << EOF
+file: testfile-dwp-4.dwp
+INFO: 0x0 0x11e
+TYPES: 0x0 0x0
+ABBREV: 0x0 0x172
+LINE: 0x0 0x52
+LOCLISTS: 0x0 0x11b
+STR_OFFSETS: 0x0 0x754
+MACRO: 0x0 0x6c7
+RNGLISTS: 0x0 0x0
+
+INFO: 0x11e 0x76
+TYPES: 0x0 0x0
+ABBREV: 0x172 0xd7
+LINE: 0x52 0x52
+LOCLISTS: 0x0 0x0
+STR_OFFSETS: 0x754 0x750
+MACRO: 0x6c7 0x6c6
+RNGLISTS: 0x0 0x0
+
+INFO: 0x194 0x1c5
+TYPES: 0x0 0x0
+ABBREV: 0x249 0x19e
+LINE: 0xa4 0x53
+LOCLISTS: 0x11b 0xf1
+STR_OFFSETS: 0xea4 0x774
+MACRO: 0xd8d 0x6c7
+RNGLISTS: 0x0 0x0
+
+INFO: 0x0 0x0
+TYPES: 0x0 0x6f
+ABBREV: 0x0 0x172
+LINE: 0x0 0x52
+LOCLISTS: 0x0 0x11b
+STR_OFFSETS: 0x0 0x754
+MACRO: 0x0 0x6c7
+RNGLISTS: 0x0 0x0
+
+INFO: 0x0 0x0
+TYPES: 0x6f 0x6d
+ABBREV: 0x172 0xd7
+LINE: 0x52 0x52
+LOCLISTS: 0x0 0x0
+STR_OFFSETS: 0x754 0x750
+MACRO: 0x6c7 0x6c6
+RNGLISTS: 0x0 0x0
+
+EOF
+
+testrun_compare ${abs_builddir}/cu-dwp-section-info testfile-dwp-4-strict.dwp << EOF
+file: testfile-dwp-4-strict.dwp
+INFO: 0x0 0x105
+TYPES: 0x0 0x0
+ABBREV: 0x0 0x15f
+LINE: 0x0 0x52
+LOCLISTS: 0x0 0xe2
+STR_OFFSETS: 0x0 0x24
+MACRO: 0x0 0x38e4
+RNGLISTS: 0x0 0x0
+
+INFO: 0x105 0x72
+TYPES: 0x0 0x0
+ABBREV: 0x15f 0xd3
+LINE: 0x52 0x52
+LOCLISTS: 0x0 0x0
+STR_OFFSETS: 0x24 0x20
+MACRO: 0x38e4 0x38db
+RNGLISTS: 0x0 0x0
+
+INFO: 0x177 0x17b
+TYPES: 0x0 0x0
+ABBREV: 0x232 0x157
+LINE: 0xa4 0x53
+LOCLISTS: 0xe2 0xb1
+STR_OFFSETS: 0x44 0x44
+MACRO: 0x71bf 0x38f5
+RNGLISTS: 0x0 0x0
+
+INFO: 0x0 0x0
+TYPES: 0x0 0x6e
+ABBREV: 0x0 0x15f
+LINE: 0x0 0x52
+LOCLISTS: 0x0 0xe2
+STR_OFFSETS: 0x0 0x24
+MACRO: 0x0 0x38e4
+RNGLISTS: 0x0 0x0
+
+INFO: 0x0 0x0
+TYPES: 0x6e 0x6b
+ABBREV: 0x15f 0xd3
+LINE: 0x52 0x52
+LOCLISTS: 0x0 0x0
+STR_OFFSETS: 0x24 0x20
+MACRO: 0x38e4 0x38db
+RNGLISTS: 0x0 0x0
+
+EOF
diff --git a/tests/testfile-dwp-4-strict.bz2 b/tests/testfile-dwp-4-strict.bz2
new file mode 100755
index 0000000000000000000000000000000000000000..4f419c07d45aea608e02da002e8c09bc35b3553b
GIT binary patch
literal 4169
zcmV-P5Vr3^T4*^jL0KkKS?l7w2>=>zfB*mg|NsC0|NsC0|NsB*|Nrhk>Fs?-|9$`e
zZp?pw@BQEpe)+iVPBzSvd3tYQL>mutsobk0dyaaM)74v6W)(>1wvOSE5Salc%6T+R
zP3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0gEDJ%IhR@GKMU^21Dy>U*x15k2s#<n)Q(?qt^{sCkXuBcY(2ztLk;ukS
TiAwT$ul!xf6yZWcuZr*_TcUC^

literal 0
HcmV?d00001

diff --git a/tests/testfile-dwp-4-strict.dwp.bz2 b/tests/testfile-dwp-4-strict.dwp.bz2
new file mode 100644
index 0000000000000000000000000000000000000000..8cc1bbe2a8042bd06c9119c276326371261afbe0
GIT binary patch
literal 6871
zcmY*-dpHwp`2W^=H)&=<&CFp4A#EC)V{CHhb?UIS(qWE`cgb<cp=r#SNe7WKyd|TY
z5=oIW(MHNSgqEDoht#+C`~Cg%yRZBDJlB2y^E}smf9}t7JrD6b-4JVWPW|+`o|T{F
zfb(L%|FgNv|GWGzY%ekjqCbAdha?!-YF;E}CDGJ)E9_Cgd2vn6e`)f&Sl%Z9yUYP6
zPlyBdXo)+i{3WF&mQN<zSeOGed1v}S<^bTClX32r(v|~u(x<%~yRYB3`*{88>5r>e
z$<`#{E&GD&S*KU63+O9R+#V}VmZcmH)NM*qZI4VaHD6V<w=R%4c1HP~D@ffQByHZt
zOD9=8mdZ27Lhpm6m3yReTIpC2NmUup_V_*)D*=GJV1eoCQSmwMf;L`GkC-qA!LeiS
z;d;dh+;NB~UK$tR-eZ@M!C{GEGFWZt=8Xb9y1PK&6-^gFN$M8St++<I9ujIUXl(`P
zc|EqXBbfthPbiy5Ia+#Ow|+W(fBIpxo;`>zwUq<<h@%7Obl?_O$VJk@Y&#YJ0L%fz
ztL)m7BW;e{N29x^yX)D-EhS5;EvgTwTsw8`Ok@H`-SOkc0Y`h1d5^R=qyPYZ_~dDh
zd$93k!s+I(#V=L1tZ$QJDqGT~Y*j4xYxhRfKfOXa74cr1&o`UCt5kbUCA@Uw{MRUq
zsoaiww)?&;Ph!@2)6fqD^I9=+9&+9El~qD^;*O^gYcJOD4LH^6&0P(3kSdg7^L~t3
zeK=!Er7NPE9%_JXyt_xHnUS`xOu))4LbTMO#WR>(l{1mI0f`UDDr<X$r+jrmA+a6k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h?>8?2c@7r*?3F+T1!s1ml2$I0h!es7&H|<;
z>6qB1{%v!*lr`Ev8$`00TlME0xmp)Ks<gKY%{(fD8EBzM^i9I+VU&tcfIo|Xu6b|*
z)uMArqnc&Be5t|R$Qqv)2QhWz4?Uk}45%rulze1}FnBEfL@EuSD$fDAHv!p+@J1R|
zY<MpZ+@1__2i9SHhWva+B^#$ffQ?b>oAB@G?z$*JZ0K}IX;_%Ku@zkconZ(&(#?&I
z_cR7}URrktJqf=07p!m5<U<mv2ptClR>|&74OER=v(DZgWMX{sg6YC{;JTP0K`n=y
zV&|1?`cj@bVr2x@WVT>ynDZ1HBVL@1RLbG(<cwymWP>wz)RV#$mq&vMwihowo)$Jz
zpMW1w$NRiGYwTOxEFN^McPidvvOffe@!Rh42TXf4b{T}={S<^_Pk)Gng^m%AFM_8|
zelO{Xa8`Np$kCX8oifbFtzv80*9o~+*?>Sl5?*Sg88*`r>DE0pVd&j+#r!es(}zo%
zw9#gx`@G!-bH481m$nFhREB((zVh{L<g2#|QyY*%<L<!tg{SQF{=flaswpv<KBRyG
zoBsKASmG5JF@B-V95bfAjw_5#UF`jOdYr#PZuzjLXR5e7jM$9Ys6+pt6JRjMhDly4
zusQ8>-ID2*K(X7dY~8!_du}f1OT3W|WqHKWkw%lYjXL6RrKM>VTFb9piVZ2d9mHf1
zlb9nu(_5O&fyfli>jDdJ)3~SI>syj%_GHR@_%J9PVIA{)wMbg&S&`0baY*A)u+wJ=
u-EDD=rUKAknm=t6Mb4u-*IS@BqPEeT77ryQqhr5xClY*l=qKMdJ^u&wK)Buj

literal 0
HcmV?d00001

diff --git a/tests/testfile-dwp-4.bz2 b/tests/testfile-dwp-4.bz2
new file mode 100755
index 0000000000000000000000000000000000000000..ece5817bd88a5cf195bdaa109f8f41a8d4595093
GIT binary patch
literal 4194
zcmV-o5S{NrT4*^jL0KkKS*>Kw-T)eo|NsC0|NsC0|NsC0|NsB*|M&hsZ*A>F|NZ~(
zXUu>9@BQEpkA1^+KHj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j}XBeZTweZm}KABnTm@H%yhSu*HcKDhvS3lUbuu5cQ~q*522^Z!D?@
s$6ikdcCrUi6OA4WkulnKm}Cqwy$-<F!wz&<mv8vHk}1N3g=;2u@MT|o8~^|S

literal 0
HcmV?d00001

diff --git a/tests/testfile-dwp-4.dwp.bz2 b/tests/testfile-dwp-4.dwp.bz2
new file mode 100644
index 0000000000000000000000000000000000000000..1a63b42d987cf1f64f8c994f8f16b7a5d0af029b
GIT binary patch
literal 10098
zcmV-&Cym%bT4*^jL0KkKS<b(?jQ}$-fB*mg|NsC0|NsC0|NsC0|NsC0|NsC0|NsC0
z|NsC0|Nr1A>R)ZEp8x;_z5p@kJAeQezz;wGJ!bJl019pIyY20+yUkuk<Llm?zVCJL
z`YoCPr`@aRyLveQ#7Jh!mO-JWN=b^K9ggQXD?n&6km{8vGKh($A*jrwDd@vN83w0<
zWjxY)6+Z@(0&Pr6dV5n7CZ2;yg*=!EGCdk-X*{L^CX6Sj%#+a?V^e9UdYPp4GJ2TM
zhMuMqY8w+%PbuWaMFvPiO-Zz6GI=J7eyQpW1Juy<F%77CjT$rn0MjOor~^YssL*Mk
z^%^vKO$`7Ck^lf{>Um870iXbA(V?IK4Lv{rG{`{+BT18LO;dYGl0p86qaf31G<tbS
z`jP4CPfbr#(rlB;ew5Q~Q)I~6rqmi50qOt%00xFZiI4!%kOn}|4FRE}CTeM?qI)WS
zR1l<*2+&mVs%;u4w5N)DQKp(qo{8#uo>8`_G-y3Rqtp!=Jw|{44^Z@hq2z#QXnKGE
z05s6h10ZRk>S*-<3`eK{(9i%jsR){Bk(!wrM%pGO7z8FNjQ|0rgFy6*L7?)DGepE`
zri_{ffY4}qfHD9802u%SKxhG=8fl;!X{LsNM4*8I00=S)dJ(EU>ZZ}OhNH@CjT333
zO*D;^#;2%yfs;+OCYe1lfr1Q=QIN#RlL%yFdW@N-f*K4)n@Ab}JwV9Q^+qF1AoQB<
za%;lU-g?0{n++bkq1jQ}0{vF8T-ge*Swhm51`+66M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NDL@sw15gOHCAjxYDNHSgK+M%VNqcYh-OzJ2Ds~#og$K0xl;rPVH^k%mTbbR6bhmj
zFKZZD;p{qq{2ngXe{O;LP$Nf)jSc-&I-o<P?{@hx>){^hk_8-t69?lYAtF|643odx
z9or+;p!ZGP9#Hs5Vg=2BjgG*W9n+Ignndz!EfJdUC~tx33%bIl8MPcHHz=+RAA3>6
z3O4Yth>djtuxbEJHX|q`lEP|Ov@PF+_F6-2@V0SnE2_d4C?x`7h4FWSPK+97GpnCQ
z?9O{{(~`YjB=hjekOK|)<ZU<IJ9@2mb3@!iZlIqBW&m<(1MOZ@2S-_V8JVS+tAH;?
z-Jr}!&0&p(-Kr~sdxS<$zebrS0cI@OW|qght0{*)<k)i4ayaY1z2oOjgL9~RYF{3l
z^}6Rkg)^{ca&rcbTuy<SdYy7mcz0|yg`VZ;Iqwqw`wS0B>!f2l`Mq7aJs5lt52Dsu
z=ASX}6fpq8iJCp$9<#Iu9njW&S>vjYhu^4oh!&&4>Z}F%=*X{LKG=7EJZuNsd`XX$
zdf(r1aEN;sWH~+8r_ibCU<crQT$M-RqQ1!bDk5xv`gj57q7E;*pdt31eoTqT4=sQc
zho6)U!6CyBNjV3^K9JQ_{s|DmCzlTdeMmy25GTKUK9*0Ht*`sLzbDU)v!Qf7u{0ni
z&wD_mUnrdsWvCoc7O@5N5<8*kXXIeuf#HyNBuZD$abRznz$p<r*lmiPq5%3IY)}T{
z?1~}0`?C}S-umvRKs{%dF$1`SQ<(ump6d&i5}i~Dk|(ahFPrR)0C=TPr?4S8$eB-4
z5f8;VsEXPO7{z`}A`N;dw}_v9Pe};#<o7aFIlT-7Klz^WQeaP*CzTv;9sux?cEq9D
U5*}Ari~r*8NT&)C8Q1qQpcbj`Pyhe`

literal 0
HcmV?d00001

diff --git a/tests/testfile-dwp-5.bz2 b/tests/testfile-dwp-5.bz2
new file mode 100755
index 0000000000000000000000000000000000000000..2c768eacb441e0d516f8b0d5ed327893c129246b
GIT binary patch
literal 4223
z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p~PS0b1ZPQ1Qx?lw;0MANOA2g?7H?RWW29^BpZEQNG`x9GW#EYzI(wQg)
z60*=`+)Kq}1+K^y7^wmJX%B99?y+TS$g7v6Bf;G<Bcs1&to$E|u@)$5v&J;<Ww?L^
zVK*2-O3Uul!go3#Pa-8S3ixv={ys2%;h|QhrofZ5r(gR&fw$ej116I2Ux!53AeMtP
z#Y)~iw4SW#9*$%&ecHdNTckCsH^vsP55kjxH$YV#c~;7yPrAv7DHo2sN3w=${fjGA
zOV!d&qnN|Te+&mrLwZ?;$w;GdWDqZ1C`l=eLt5j9upaXtq-dZ@I}gfoP=dh$O|;@N
WM7|mb`|m1%%`ln(+h>5R`2PSJoD2*A

literal 0
HcmV?d00001

diff --git a/tests/testfile-dwp.source b/tests/testfile-dwp.source
new file mode 100644
index 00000000..b0b0a97c
--- /dev/null
+++ b/tests/testfile-dwp.source
@@ -0,0 +1,102 @@
+# Nonsensical program used to generate example DWARF package files with type
+# units, location lists, range lists, and macros.
+
+# = foobar.h =
+
+struct Foo
+{
+  int a, b;
+  int foo ();
+};
+
+struct Bar
+{
+  long a, b;
+  long bar ();
+};
+
+#define FROB(x) ((x) ^ 0x2a2a2a2a)
+#define FRY(x) ((x) * 0x100000001b3)
+
+inline long
+fibonacci (unsigned int n)
+{
+  if (n == 0)
+    return 0;
+  else
+    {
+      long a = 0;
+      long b = 1;
+      for (unsigned int i = 2; i < n; i++)
+	{
+	  long tmp = a + b;
+	  a = b;
+	  b = tmp;
+	}
+      return b;
+    }
+}
+
+# = foo.cc =
+
+#include "foobar.h"
+
+#define ZERO() (1 - 1)
+
+int
+x_x (int x)
+{
+  for (int i = x; i > ZERO(); i--)
+    x *= x;
+  return x;
+}
+
+int
+Foo::foo ()
+{
+  int x = a;
+  if (a > b)
+    x -= b;
+  return FROB (x_x (x));
+}
+
+# = bar.cc =
+
+#include "foobar.h"
+
+#define ONE 1
+
+long
+Bar::bar ()
+{
+  if (a == b)
+    return ONE;
+  else
+    return a > b ? b : a;
+}
+
+# = main.cc =
+
+#include "foobar.h"
+
+#define MAIN_ARGS int argc, char **argv
+
+int
+main(MAIN_ARGS)
+{
+  struct Foo myfoo { argc, FROB (argc) };
+  struct Bar mybar { fibonacci (argc), FRY (argc) };
+  return myfoo.foo() + mybar.bar();
+}
+
+# Built with GCC at commit 80048aa13a6b ("debug/111409 - don't generate COMDAT
+# macro sections for split DWARF").
+$ g++ -gdwarf-5 -gsplit-dwarf -fdebug-types-section -g3 -O2 foo.cc bar.cc main.cc -o testfile-dwp-5
+# GNU dwp as of binutils 2.41 only supports DWARF 4.
+$ llvm-dwp -e testfile-dwp-5 -o testfile-dwp-5.dwp
+
+$ g++ -gdwarf-4 -gsplit-dwarf -fdebug-types-section -g3 -O2 foo.cc bar.cc main.cc -o testfile-dwp-4
+$ dwp -e testfile-dwp-4
+
+$ g++ -gdwarf-4 -gstrict-dwarf -gsplit-dwarf -fdebug-types-section -g3 -O2 foo.cc bar.cc main.cc -o testfile-dwp-4-strict
+$ dwp -e testfile-dwp-4-strict
-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 09/14] libdw, libdwfl: Save original path of ELF file
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
                   ` (7 preceding siblings ...)
  2023-09-27 18:20 ` [PATCH 08/14] libdw: Parse DWARF package file index sections Omar Sandoval
@ 2023-09-27 18:20 ` Omar Sandoval
  2023-11-02 17:04   ` Mark Wielaard
  2023-09-27 18:20 ` [PATCH 10/14] libdw: Try .dwp file in __libdw_find_split_unit() Omar Sandoval
                   ` (7 subsequent siblings)
  16 siblings, 1 reply; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:20 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

libdw and libdwfl currently save the path of the directory containing
the ELF file to use when searching for alt and dwo files.  To search for
dwp files, we need the file name too.  Add an elfpath field to Dwarf,
and set the debugdir field from it.  Also update libdwfl to set elfpath
and debugdir.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libdw/ChangeLog                | 11 ++++++++++-
 libdw/dwarf_begin_elf.c        | 34 ++++++++++++++++++++--------------
 libdw/dwarf_end.c              |  3 ++-
 libdw/libdwP.h                 | 12 ++++++++++--
 libdwfl/ChangeLog              |  9 +++++++++
 libdwfl/dwfl_module.c          |  2 +-
 libdwfl/dwfl_module_getdwarf.c | 11 +++++++----
 libdwfl/libdwflP.h             |  2 +-
 libdwfl/offline.c              |  4 ++--
 9 files changed, 62 insertions(+), 26 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 1d229094..f491587f 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -20,7 +20,7 @@
 	instead of dbg parameter, which is now unused.
 	* libdwP.h (Dwarf_Macro_Op_Table): Replace is_64bit with address_size
 	and offset_size.  Add dbg.
-	(Dwarf): Add cu_index and tu_index.
+	(Dwarf): Add cu_index and tu_index.  Add elfpath.
 	(Dwarf_CU): Add dwp_row.
 	(Dwarf_Package_Index): New type.
 	(DW_SECT_TYPES): New macro.
@@ -28,6 +28,9 @@
 	(dwarf_cu_dwp_section_info): New INTDECL.
 	Add IDX_debug_cu_index and IDX_debug_tu_index.  Add
 	DWARF_E_UNKNOWN_SECTION.
+	(__libdw_debugdir): Replace declaration with...
+	(__libdw_elfpath): New declaration.
+	(__libdw_set_debugdir): New declaration.
 	* dwarf_begin_elf.c (dwarf_scnnames): Add IDX_debug_cu_index and
 	IDX_debug_tu_index.
 	(scn_to_string_section_idx): Ditto.
@@ -35,8 +38,14 @@
 	.zdebug_cu_index, and .zdebug_tu_index.
 	(check_section): Change .dwo suffix matching to account for
 	.debug_cu_index and .debug_tu_index.
+	(__libdw_debugdir): Replace with..
+	(__libdw_elfpath): New function.
+	(__libdw_set_debugdir): New function.
+	(valid_p): Call __libdw_elfpath and __libdw_set_debugdir instead of
+	__libdw_debugdir.
 	* Makefile.am (libdw_a_SOURCES): Add dwarf_cu_dwp_section_info.c.
 	* dwarf_end.c (dwarf_end): Free dwarf->cu_index and dwarf->tu_index.
+	Free dwarf->elfpath.
 	* dwarf_error.c (errmsgs): Add DWARF_E_UNKNOWN_SECTION.
 	* libdw.h (dwarf_cu_dwp_section_info): New declaration.
 	* libdw.map (ELFUTILS_0.190): Add dwarf_cu_dwp_section_info.
diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index 7936d343..323a91d0 100644
--- a/libdw/dwarf_begin_elf.c
+++ b/libdw/dwarf_begin_elf.c
@@ -272,24 +272,27 @@ check_section (Dwarf *result, size_t shstrndx, Elf_Scn *scn, bool inscngrp)
   return result;
 }
 
-
-/* Helper function to set debugdir field.  We want to cache the dir
-   where we found this Dwarf ELF file to locate alt and dwo files.  */
 char *
-__libdw_debugdir (int fd)
+__libdw_elfpath (int fd)
 {
   /* strlen ("/proc/self/fd/") = 14 + strlen (<MAXINT>) = 10 + 1 = 25.  */
   char devfdpath[25];
   sprintf (devfdpath, "/proc/self/fd/%u", fd);
-  char *fdpath = realpath (devfdpath, NULL);
-  char *fddir;
-  if (fdpath != NULL && fdpath[0] == '/'
-      && (fddir = strrchr (fdpath, '/')) != NULL)
-    {
-      *++fddir = '\0';
-      return fdpath;
-    }
-  return NULL;
+  return realpath (devfdpath, NULL);
+}
+
+
+void
+__libdw_set_debugdir (Dwarf *dbg)
+{
+  if (dbg->elfpath == NULL || dbg->elfpath[0] != '/')
+    return;
+  size_t dirlen = strrchr (dbg->elfpath, '/') - dbg->elfpath + 1;
+  dbg->debugdir = malloc (dirlen + 1);
+  if (dbg->debugdir == NULL)
+    return;
+  memcpy (dbg->debugdir, dbg->elfpath, dirlen);
+  dbg->debugdir[dirlen] = '\0';
 }
 
 
@@ -421,7 +424,10 @@ valid_p (Dwarf *result)
     }
 
   if (result != NULL)
-    result->debugdir = __libdw_debugdir (result->elf->fildes);
+    {
+      result->elfpath = __libdw_elfpath (result->elf->fildes);
+      __libdw_set_debugdir(result);
+    }
 
   return result;
 }
diff --git a/libdw/dwarf_end.c b/libdw/dwarf_end.c
index 18a419ce..b7f817d9 100644
--- a/libdw/dwarf_end.c
+++ b/libdw/dwarf_end.c
@@ -147,7 +147,8 @@ dwarf_end (Dwarf *dwarf)
 	  close (dwarf->alt_fd);
 	}
 
-      /* The cached dir we found the Dwarf ELF file in.  */
+      /* The cached path and dir we found the Dwarf ELF file in.  */
+      free (dwarf->elfpath);
       free (dwarf->debugdir);
 
       /* Free the context descriptor.  */
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 13ca58ce..214d1711 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -169,6 +169,10 @@ struct Dwarf
   /* The underlying ELF file.  */
   Elf *elf;
 
+  /* The (absolute) path to the ELF file, if known.  To help locating
+     dwp files.  */
+  char *elfpath;
+
   /* The (absolute) path to the ELF dir, if known.  To help locating
      alt and dwo files.  */
   char *debugdir;
@@ -1385,9 +1389,13 @@ __libdw_link_skel_split (Dwarf_CU *skel, Dwarf_CU *split)
 int __libdw_addrx (Dwarf_CU *cu, Dwarf_Word idx, Dwarf_Addr *addr);
 
 
-/* Helper function to set debugdir field in Dwarf, used from dwarf_begin_elf
+/* Helper function to set elfpath field in Dwarf, used from dwarf_begin_elf
    and libdwfl process_file.  */
-char * __libdw_debugdir (int fd);
+char * __libdw_elfpath (int fd);
+
+/* Helper function to set debugdir field in Dwarf after elfpath field has been
+   set.  */
+void __libdw_set_debugdir (Dwarf *dbg);
 
 
 /* Given the directory of a debug file, an absolute or relative dir
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 54d85921..abbf0dfe 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,12 @@
+2023-09-27  Omar Sandoval  <osandov@fb.com>
+	* dwfl_module.c (__libdwfl_module_free): Free mod->elfpath instead of
+	mod->elfdir.
+	* dwfl_module_getdwarf.c (load_dw): Set mod->dw->elfpath and call
+	__libdw_set_debugdir instead of setting mod->dw->debugdir.
+	* libdwflP.h (Dwfl_Module): Replace elfdir with elfpath.
+	* offline.c (process_elf): Call __libdw_elfpath and set mod->elfpath
+	instead of mod->elfdir.
+
 2023-04-24  John Gallagher  <john@gllghr.com>
 
 	* gzip.c: Fix memory leak in unzip()
diff --git a/libdwfl/dwfl_module.c b/libdwfl/dwfl_module.c
index 221d726d..c4d872d4 100644
--- a/libdwfl/dwfl_module.c
+++ b/libdwfl/dwfl_module.c
@@ -119,7 +119,7 @@ __libdwfl_module_free (Dwfl_Module *mod)
     free (mod->reloc_info);
 
   free (mod->name);
-  free (mod->elfdir);
+  free (mod->elfpath);
   free (mod);
 }
 
diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
index 9ba499bb..6f98c02b 100644
--- a/libdwfl/dwfl_module_getdwarf.c
+++ b/libdwfl/dwfl_module_getdwarf.c
@@ -1362,11 +1362,14 @@ load_dw (Dwfl_Module *mod, struct dwfl_file *debugfile)
     }
 
   /* We might have already closed the fd when we asked dwarf_begin_elf to
-     create an Dwarf.  Help out a little in case we need to find an alt or
-     dwo file later.  */
-  if (mod->dw->debugdir == NULL && mod->elfdir != NULL
+     create an Dwarf.  Help out a little in case we need to find an alt,
+     dwo, or dwp file later.  */
+  if (mod->dw->elfpath == NULL && mod->elfpath != NULL
       && debugfile == &mod->main)
-    mod->dw->debugdir = strdup (mod->elfdir);
+    {
+      mod->dw->elfpath = strdup (mod->elfpath);
+      __libdw_set_debugdir (mod->dw);
+    }
 
   /* Until we have iterated through all CU's, we might do lazy lookups.  */
   mod->lazycu = 1;
diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h
index cdc528d0..b3dfea1d 100644
--- a/libdwfl/libdwflP.h
+++ b/libdwfl/libdwflP.h
@@ -186,7 +186,7 @@ struct Dwfl_Module
   Elf_Data *symxndxdata;	/* Data in the extended section index table. */
   Elf_Data *aux_symxndxdata;	/* Data in the extended auxiliary table. */
 
-  char *elfdir;			/* The dir where we found the main Elf.  */
+  char *elfpath;		/* The path where we found the main Elf.  */
 
   Dwarf *dw;			/* libdw handle for its debugging info.  */
   Dwarf *alt;			/* Dwarf used for dwarf_setalt, or NULL.  */
diff --git a/libdwfl/offline.c b/libdwfl/offline.c
index e090b42b..50abe8c3 100644
--- a/libdwfl/offline.c
+++ b/libdwfl/offline.c
@@ -151,9 +151,9 @@ process_elf (Dwfl *dwfl, const char *name, const char *file_name, int fd,
       /* Don't keep the file descriptor around.  */
       if (mod->main.fd != -1 && elf_cntl (mod->main.elf, ELF_C_FDREAD) == 0)
 	{
-	  /* Grab the dir path in case we want to report this file as
+	  /* Grab the path in case we want to report this file as
 	     Dwarf later.  */
-	  mod->elfdir = __libdw_debugdir (mod->main.fd);
+	  mod->elfpath = __libdw_elfpath (mod->main.fd);
 	  close (mod->main.fd);
 	  mod->main.fd = -1;
 	}
-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 10/14] libdw: Try .dwp file in __libdw_find_split_unit()
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
                   ` (8 preceding siblings ...)
  2023-09-27 18:20 ` [PATCH 09/14] libdw, libdwfl: Save original path of ELF file Omar Sandoval
@ 2023-09-27 18:20 ` Omar Sandoval
  2023-11-02 19:56   ` Mark Wielaard
  2023-09-27 18:21 ` [PATCH 11/14] tests: Handle DW_MACRO_{define,undef}_{strx,sup} in dwarf-getmacros Omar Sandoval
                   ` (6 subsequent siblings)
  16 siblings, 1 reply; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:20 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

Try opening the file in the location suggested by the standard (the
skeleton file name + ".dwp") and looking up the unit in the package
index.  The rest is similar to .dwo files, with slightly different
cleanup since a single Dwarf handle is shared.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libdw/ChangeLog                   | 11 ++++-
 libdw/dwarf_begin_elf.c           |  1 +
 libdw/dwarf_cu_dwp_section_info.c | 19 ++++++++
 libdw/dwarf_end.c                 | 10 ++++-
 libdw/libdwP.h                    | 16 ++++++-
 libdw/libdw_find_split_unit.c     | 75 ++++++++++++++++++++++++++++---
 6 files changed, 122 insertions(+), 10 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index f491587f..f37d9411 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,6 +1,8 @@
 2023-09-27  Omar Sandoval  <osandov@fb.com>
 
 	* libdw_find_split_unit.c (try_split_file): Make static.
+	(try_dwp_file): New function.
+	(__libdw_find_split_unit): Call try_dwp_file.
 	* dwarf_entrypc.c (dwarf_entrypc): Call dwarf_lowpc.
 	* dwarf_ranges.c (dwarf_ranges): Use skeleton ranges section for
 	skeleton units.
@@ -20,7 +22,8 @@
 	instead of dbg parameter, which is now unused.
 	* libdwP.h (Dwarf_Macro_Op_Table): Replace is_64bit with address_size
 	and offset_size.  Add dbg.
-	(Dwarf): Add cu_index and tu_index.  Add elfpath.
+	(Dwarf): Add cu_index and tu_index.  Add elfpath.  Add dwp_dwarf and
+	dwp_fd.
 	(Dwarf_CU): Add dwp_row.
 	(Dwarf_Package_Index): New type.
 	(DW_SECT_TYPES): New macro.
@@ -31,6 +34,8 @@
 	(__libdw_debugdir): Replace declaration with...
 	(__libdw_elfpath): New declaration.
 	(__libdw_set_debugdir): New declaration.
+	(__libdw_dwp_findcu_id): New declaration.
+	(__libdw_link_skel_split): Handle .debug_addr for dwp.
 	* dwarf_begin_elf.c (dwarf_scnnames): Add IDX_debug_cu_index and
 	IDX_debug_tu_index.
 	(scn_to_string_section_idx): Ditto.
@@ -43,9 +48,11 @@
 	(__libdw_set_debugdir): New function.
 	(valid_p): Call __libdw_elfpath and __libdw_set_debugdir instead of
 	__libdw_debugdir.
+	(dwarf_begin_elf): Initialize result->dwp_fd.
 	* Makefile.am (libdw_a_SOURCES): Add dwarf_cu_dwp_section_info.c.
 	* dwarf_end.c (dwarf_end): Free dwarf->cu_index and dwarf->tu_index.
-	Free dwarf->elfpath.
+	Free dwarf->elfpath.  Free dwarf->dwp_dwarf and close dwarf->dwp_fd.
+	(cu_free): Don't free split dbg if it is dwp_dwarf.
 	* dwarf_error.c (errmsgs): Add DWARF_E_UNKNOWN_SECTION.
 	* libdw.h (dwarf_cu_dwp_section_info): New declaration.
 	* libdw.map (ELFUTILS_0.190): Add dwarf_cu_dwp_section_info.
diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index 323a91d0..ca2b7e2a 100644
--- a/libdw/dwarf_begin_elf.c
+++ b/libdw/dwarf_begin_elf.c
@@ -567,6 +567,7 @@ dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp)
 
   result->elf = elf;
   result->alt_fd = -1;
+  result->dwp_fd = -1;
 
   /* Initialize the memory handling.  Initial blocks are allocated on first
      actual allocation.  */
diff --git a/libdw/dwarf_cu_dwp_section_info.c b/libdw/dwarf_cu_dwp_section_info.c
index 6766fb9a..7bf08d9d 100644
--- a/libdw/dwarf_cu_dwp_section_info.c
+++ b/libdw/dwarf_cu_dwp_section_info.c
@@ -340,6 +340,25 @@ __libdw_dwp_find_unit (Dwarf *dbg, bool debug_types, Dwarf_Off off,
 				   abbrev_offsetp, NULL);
 }
 
+Dwarf_CU *
+internal_function
+__libdw_dwp_findcu_id (Dwarf *dbg, uint64_t unit_id8)
+{
+  Dwarf_Package_Index *index = __libdw_package_index (dbg, false);
+  uint32_t unit_row;
+  Dwarf_Off offset;
+  Dwarf_CU *cu;
+  if (__libdw_dwp_unit_row (index, unit_id8, &unit_row) == 0
+      && __libdw_dwp_section_info (index, unit_row, DW_SECT_INFO, &offset,
+				   NULL) == 0
+      && (cu = __libdw_findcu (dbg, offset, false)) != NULL
+      && cu->unit_type == DW_UT_split_compile
+      && cu->unit_id8 == unit_id8)
+    return cu;
+  else
+    return NULL;
+}
+
 int
 dwarf_cu_dwp_section_info (Dwarf_CU *cu, unsigned int section,
 			   Dwarf_Off *offsetp, Dwarf_Off *sizep)
diff --git a/libdw/dwarf_end.c b/libdw/dwarf_end.c
index b7f817d9..78224ddb 100644
--- a/libdw/dwarf_end.c
+++ b/libdw/dwarf_end.c
@@ -66,7 +66,9 @@ cu_free (void *arg)
 	  /* The fake_addr_cu might be shared, only release one.  */
 	  if (p->dbg->fake_addr_cu == p->split->dbg->fake_addr_cu)
 	    p->split->dbg->fake_addr_cu = NULL;
-	  INTUSE(dwarf_end) (p->split->dbg);
+	  /* There is only one DWP file. We free it later.  */
+	  if (p->split->dbg != p->dbg->dwp_dwarf)
+	    INTUSE(dwarf_end) (p->split->dbg);
 	}
     }
 }
@@ -147,6 +149,12 @@ dwarf_end (Dwarf *dwarf)
 	  close (dwarf->alt_fd);
 	}
 
+      if (dwarf->dwp_fd != -1)
+	{
+	  INTUSE(dwarf_end) (dwarf->dwp_dwarf);
+	  close (dwarf->dwp_fd);
+	}
+
       /* The cached path and dir we found the Dwarf ELF file in.  */
       free (dwarf->elfpath);
       free (dwarf->debugdir);
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 214d1711..16355274 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -180,6 +180,9 @@ struct Dwarf
   /* dwz alternate DWARF file.  */
   Dwarf *alt_dwarf;
 
+  /* DWARF package file.  */
+  Dwarf *dwp_dwarf;
+
   /* The section data.  */
   Elf_Data *sectiondata[IDX_last];
 
@@ -197,6 +200,9 @@ struct Dwarf
      close this file descriptor.  */
   int alt_fd;
 
+  /* File descriptor of DWARF package file.  */
+  int dwp_fd;
+
   /* Information for traversing the .debug_pubnames section.  This is
      an array and separately allocated with malloc.  */
   struct pubnames_s
@@ -719,6 +725,10 @@ extern int __libdw_dwp_find_unit (Dwarf *dbg, bool debug_types, Dwarf_Off off,
 				  Dwarf_Off *abbrev_offsetp)
      __nonnull_attribute__ (1, 7, 8) internal_function;
 
+/* Find the compilation unit in a DWARF package file with the given id.  */
+extern Dwarf_CU *__libdw_dwp_findcu_id (Dwarf *dbg, uint64_t unit_id8)
+     __nonnull_attribute__ (1) internal_function;
+
 /* Get abbreviation with given code.  */
 extern Dwarf_Abbrev *__libdw_findabbrev (struct Dwarf_CU *cu,
 					 unsigned int code)
@@ -1373,8 +1383,10 @@ __libdw_link_skel_split (Dwarf_CU *skel, Dwarf_CU *split)
      There is only one per split debug.  */
   Dwarf *dbg = skel->dbg;
   Dwarf *sdbg = split->dbg;
-  if (sdbg->sectiondata[IDX_debug_addr] == NULL
-      && dbg->sectiondata[IDX_debug_addr] != NULL)
+  if (dbg->sectiondata[IDX_debug_addr] != NULL
+      && (sdbg->sectiondata[IDX_debug_addr] == NULL
+	  || (sdbg->sectiondata[IDX_debug_addr]
+	      == dbg->sectiondata[IDX_debug_addr])))
     {
       sdbg->sectiondata[IDX_debug_addr]
 	= dbg->sectiondata[IDX_debug_addr];
diff --git a/libdw/libdw_find_split_unit.c b/libdw/libdw_find_split_unit.c
index 533f8072..e1e78951 100644
--- a/libdw/libdw_find_split_unit.c
+++ b/libdw/libdw_find_split_unit.c
@@ -85,6 +85,67 @@ try_split_file (Dwarf_CU *cu, const char *dwo_path)
     }
 }
 
+static void
+try_dwp_file (Dwarf_CU *cu)
+{
+  if (cu->dbg->dwp_dwarf == NULL)
+    {
+      if (cu->dbg->elfpath != NULL)
+	{
+	  /* The DWARF 5 standard says "the package file is typically placed in
+	     the same directory as the application, and is given the same name
+	     with a '.dwp' extension".  */
+	  size_t elfpath_len = strlen (cu->dbg->elfpath);
+	  char *dwp_path = malloc (elfpath_len + 5);
+	  if (dwp_path == NULL)
+	    {
+	      __libdw_seterrno (DWARF_E_NOMEM);
+	      return;
+	    }
+	  memcpy (dwp_path, cu->dbg->elfpath, elfpath_len);
+	  strcpy (dwp_path + elfpath_len, ".dwp");
+	  int dwp_fd = open (dwp_path, O_RDONLY);
+	  free (dwp_path);
+	  if (dwp_fd != -1)
+	    {
+	      Dwarf *dwp_dwarf = dwarf_begin (dwp_fd, DWARF_C_READ);
+	      /* There's no way to know whether we got the correct file until
+		 we look up the unit, but it should at least be a dwp file.  */
+	      if (dwp_dwarf != NULL
+		  && (dwp_dwarf->sectiondata[IDX_debug_cu_index] != NULL
+		      || dwp_dwarf->sectiondata[IDX_debug_tu_index] != NULL))
+		{
+		  cu->dbg->dwp_dwarf = dwp_dwarf;
+		  cu->dbg->dwp_fd = dwp_fd;
+		}
+	      else
+		close (dwp_fd);
+	    }
+	}
+      if (cu->dbg->dwp_dwarf == NULL)
+	cu->dbg->dwp_dwarf = (Dwarf *) -1;
+    }
+
+  if (cu->dbg->dwp_dwarf != (Dwarf *) -1)
+    {
+      Dwarf_CU *split = __libdw_dwp_findcu_id (cu->dbg->dwp_dwarf,
+					       cu->unit_id8);
+      if (split != NULL)
+	{
+	  if (tsearch (split->dbg, &cu->dbg->split_tree,
+		       __libdw_finddbg_cb) == NULL)
+	    {
+	      /* Something went wrong.  Don't link.  */
+	      __libdw_seterrno (DWARF_E_NOMEM);
+	      return;
+	    }
+
+	  /* Link skeleton and split compile units.  */
+	  __libdw_link_skel_split (cu, split);
+	}
+    }
+}
+
 Dwarf_CU *
 internal_function
 __libdw_find_split_unit (Dwarf_CU *cu)
@@ -98,14 +159,18 @@ __libdw_find_split_unit (Dwarf_CU *cu)
      same id as the skeleton.  */
   if (cu->unit_type == DW_UT_skeleton)
     {
+      /* First, try the dwp file.  */
+      try_dwp_file (cu);
+
       Dwarf_Die cudie = CUDIE (cu);
       Dwarf_Attribute dwo_name;
-      /* It is fine if dwo_dir doesn't exists, but then dwo_name needs
-	 to be an absolute path.  */
-      if (dwarf_attr (&cudie, DW_AT_dwo_name, &dwo_name) != NULL
-	  || dwarf_attr (&cudie, DW_AT_GNU_dwo_name, &dwo_name) != NULL)
+      /* Try a dwo file.  It is fine if dwo_dir doesn't exist, but then
+	 dwo_name needs to be an absolute path.  */
+      if (cu->split == (Dwarf_CU *) -1
+	  && (dwarf_attr (&cudie, DW_AT_dwo_name, &dwo_name) != NULL
+	      || dwarf_attr (&cudie, DW_AT_GNU_dwo_name, &dwo_name) != NULL))
 	{
-	  /* First try the dwo file name in the same directory
+	  /* Try the dwo file name in the same directory
 	     as we found the skeleton file.  */
 	  const char *dwo_file = dwarf_formstring (&dwo_name);
 	  const char *debugdir = cu->dbg->debugdir;
-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 11/14] tests: Handle DW_MACRO_{define,undef}_{strx,sup} in dwarf-getmacros
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
                   ` (9 preceding siblings ...)
  2023-09-27 18:20 ` [PATCH 10/14] libdw: Try .dwp file in __libdw_find_split_unit() Omar Sandoval
@ 2023-09-27 18:21 ` Omar Sandoval
  2023-11-02 20:30   ` [PATCH 11/14] tests: Handle DW_MACRO_{define, undef}_{strx, sup} " Mark Wielaard
  2023-09-27 18:21 ` [PATCH 12/14] tests: Optionally dump all units " Omar Sandoval
                   ` (5 subsequent siblings)
  16 siblings, 1 reply; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:21 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 tests/ChangeLog         | 3 +++
 tests/dwarf-getmacros.c | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 687a9f32..4380c57f 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -14,6 +14,9 @@
 	* testfile-dwp-5.bz2: New test file.
 	* testfile-dwp-5.dwp.bz2: New test file.
 	* testfile-dwp.source: New file.
+	* dwarf-getmacros.c (mac): Add DW_MACRO_define_sup,
+	DW_MACRO_define_strx, DW_MACRO_undef_sup, and DW_MACRO_undef_strx
+	cases to opcode switch statement.
 
 2023-04-21  Frank Ch. Eigler <fche@redhat.com>
 
diff --git a/tests/dwarf-getmacros.c b/tests/dwarf-getmacros.c
index ac70248d..e291bfd2 100644
--- a/tests/dwarf-getmacros.c
+++ b/tests/dwarf-getmacros.c
@@ -82,6 +82,8 @@ mac (Dwarf_Macro *macro, void *dbg)
 
     case DW_MACINFO_define:
     case DW_MACRO_define_strp:
+    case DW_MACRO_define_sup:
+    case DW_MACRO_define_strx:
       {
 	const char *value;
 	dwarf_macro_param2 (macro, NULL, &value);
@@ -91,6 +93,8 @@ mac (Dwarf_Macro *macro, void *dbg)
 
     case DW_MACINFO_undef:
     case DW_MACRO_undef_strp:
+    case DW_MACRO_undef_sup:
+    case DW_MACRO_undef_strx:
       break;
 
     default:
-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 12/14] tests: Optionally dump all units in dwarf-getmacros
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
                   ` (10 preceding siblings ...)
  2023-09-27 18:21 ` [PATCH 11/14] tests: Handle DW_MACRO_{define,undef}_{strx,sup} in dwarf-getmacros Omar Sandoval
@ 2023-09-27 18:21 ` Omar Sandoval
  2023-11-02 20:39   ` Mark Wielaard
  2023-09-27 18:21 ` [PATCH 13/14] libdw: Apply DWARF package file section offsets where appropriate Omar Sandoval
                   ` (4 subsequent siblings)
  16 siblings, 1 reply; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:21 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

If instead of a CU offset an empty string is given as the second
argument, dump all units.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 tests/ChangeLog         |  3 +++
 tests/dwarf-getmacros.c | 51 +++++++++++++++++++++++++++++++++--------
 2 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 4380c57f..97261444 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -17,6 +17,9 @@
 	* dwarf-getmacros.c (mac): Add DW_MACRO_define_sup,
 	DW_MACRO_define_strx, DW_MACRO_undef_sup, and DW_MACRO_undef_strx
 	cases to opcode switch statement.
+	(getmacros): New function.
+	(main): If second argument is empty, call getmacros on every unit.
+	Otherwise, call getmacros on given unit.
 
 2023-04-21  Frank Ch. Eigler <fche@redhat.com>
 
diff --git a/tests/dwarf-getmacros.c b/tests/dwarf-getmacros.c
index e291bfd2..8381d42c 100644
--- a/tests/dwarf-getmacros.c
+++ b/tests/dwarf-getmacros.c
@@ -121,26 +121,57 @@ include (Dwarf *dbg, Dwarf_Off macoff, ptrdiff_t token)
       }
 }
 
+static void
+getmacros (Dwarf *dbg, Dwarf_Die *die, bool new_style)
+{
+  for (ptrdiff_t off = new_style ? DWARF_GETMACROS_START : 0;
+       (off = dwarf_getmacros (die, mac, dbg, off)); )
+    if (off == -1)
+      {
+	puts (dwarf_errmsg (-1));
+	break;
+      }
+}
+
 int
 main (int argc, char *argv[])
 {
   assert (argc >= 3);
   const char *name = argv[1];
-  ptrdiff_t cuoff = strtol (argv[2], NULL, 0);
   bool new_style = argc > 3;
 
   int fd = open (name, O_RDONLY);
   Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
 
-  Dwarf_Die cudie_mem, *cudie = dwarf_offdie (dbg, cuoff, &cudie_mem);
-
-  for (ptrdiff_t off = new_style ? DWARF_GETMACROS_START : 0;
-       (off = dwarf_getmacros (cudie, mac, dbg, off)); )
-    if (off == -1)
-      {
-	puts (dwarf_errmsg (dwarf_errno ()));
-	break;
-      }
+  if (argv[2][0] == '\0')
+    {
+      Dwarf_CU *cu = NULL;
+      Dwarf_Die cudie, subdie;
+      uint8_t unit_type;
+      while (dwarf_get_units (dbg, cu, &cu, NULL,
+			      &unit_type, &cudie, &subdie) == 0)
+	{
+	  Dwarf_Die *die = (unit_type == DW_UT_skeleton
+			    ? &subdie : &cudie);
+	  if (! dwarf_hasattr (die, DW_AT_macro_info)
+	      && ! dwarf_hasattr (die, DW_AT_GNU_macros)
+	      && ! dwarf_hasattr (die, DW_AT_macros))
+	    continue;
+	  printf ("CU %s\n", dwarf_diename (die));
+	  getmacros (dbg, die, new_style);
+	}
+    }
+  else
+    {
+      ptrdiff_t cuoff = strtol (argv[2], NULL, 0);
+      Dwarf_Die cudie_mem, *cudie = dwarf_offdie (dbg, cuoff, &cudie_mem);
+      if (cudie == NULL)
+	{
+	  puts (dwarf_errmsg (-1));
+	  return 1;
+	}
+      getmacros (dbg, cudie, new_style);
+    }
 
   dwarf_end (dbg);
 
-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 13/14] libdw: Apply DWARF package file section offsets where appropriate
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
                   ` (11 preceding siblings ...)
  2023-09-27 18:21 ` [PATCH 12/14] tests: Optionally dump all units " Omar Sandoval
@ 2023-09-27 18:21 ` Omar Sandoval
  2023-11-02 22:20   ` Mark Wielaard
  2023-09-27 18:21 ` [PATCH 14/14] libdw: Handle overflowed DW_SECT_INFO offsets in DWARF package file indexes Omar Sandoval
                   ` (3 subsequent siblings)
  16 siblings, 1 reply; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:21 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

The final piece of DWARF package file support is that offsets have to be
interpreted relative to the section offset from the package index.
.debug_abbrev.dwo is already covered, so sprinkle around calls to
dwarf_cu_dwp_section_info for the remaining sections: .debug_line.dwo,
.debug_loclists.dwo/.debug_loc.dwo, .debug_str_offsets.dwo,
.debug_macro.dwo/.debug_macinfo.dwo, and .debug_rnglists.dwo.  With all
of that in place, we can finally test various libdw functions on dwp
files.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libdw/ChangeLog               |   10 +-
 libdw/dwarf_getlocation.c     |    6 +
 libdw/dwarf_getmacros.c       |   26 +-
 libdw/libdwP.h                |   38 +-
 tests/ChangeLog               |    8 +-
 tests/run-all-dwarf-ranges.sh |  114 +++
 tests/run-dwarf-getmacros.sh  | 1412 +++++++++++++++++++++++++++++++++
 tests/run-get-units-split.sh  |   18 +
 tests/run-varlocs.sh          |  112 +++
 9 files changed, 1726 insertions(+), 18 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index f37d9411..08b2c3e6 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -12,10 +12,13 @@
 	* dwarf_getmacros.c (get_macinfo_table): Replace assignment of
 	table->is_64bit with assignments of table->address_size and
 	table->offset_size.  Assume default DW_AT_stmt_list of 0 for split
-	DWARF.  Set table->dbg.
+	DWARF.  Set table->dbg.  Call dwarf_cu_dwp_section_info and add offset
+	to line_offset.
 	(get_table_for_offset): Ditto.
 	(read_macros): Get fake CU offset_size from table->offset_size instead
 	of table->is_64bit.
+	(get_offset_from): Call dwarf_cu_dwp_section_info and add offset to
+	*retp.
 	* dwarf_macro_getsrcfiles.c (dwarf_macro_getsrcfiles): Get
 	address_size for __libdw_getsrclines from table->address_size instead
 	of table->is_64bit.  Get dbg for __libdw_getsrclines from table->dbg
@@ -36,6 +39,9 @@
 	(__libdw_set_debugdir): New declaration.
 	(__libdw_dwp_findcu_id): New declaration.
 	(__libdw_link_skel_split): Handle .debug_addr for dwp.
+	(str_offsets_base_off): Call dwarf_cu_dwp_section_info and add offset.
+	(__libdw_cu_ranges_base): Ditto.
+	(__libdw_cu_locs_base): Ditto.
 	* dwarf_begin_elf.c (dwarf_scnnames): Add IDX_debug_cu_index and
 	IDX_debug_tu_index.
 	(scn_to_string_section_idx): Ditto.
@@ -60,6 +66,8 @@
 	__libdw_dwp_find_unit, and use it to adjust abbrev_offset and assign
 	newp->dwp_row.
 	* dwarf_cu_dwp_section_info.c: New file.
+	* dwarf_getlocation.c (initial_offset): Call dwarf_cu_dwp_section_info
+	and add offset to start_offset.
 
 2023-02-22  Mark Wielaard  <mark@klomp.org>
 
diff --git a/libdw/dwarf_getlocation.c b/libdw/dwarf_getlocation.c
index 553fdc98..37b32fc1 100644
--- a/libdw/dwarf_getlocation.c
+++ b/libdw/dwarf_getlocation.c
@@ -812,6 +812,12 @@ initial_offset (Dwarf_Attribute *attr, ptrdiff_t *offset)
 			    : DWARF_E_NO_DEBUG_LOCLISTS),
 			    NULL, &start_offset) == NULL)
 	return -1;
+
+      Dwarf_Off loc_off;
+      if (INTUSE(dwarf_cu_dwp_section_info) (attr->cu, DW_SECT_LOCLISTS,
+					     &loc_off, NULL) != 0)
+	return -1;
+      start_offset += loc_off;
     }
 
   *offset = start_offset;
diff --git a/libdw/dwarf_getmacros.c b/libdw/dwarf_getmacros.c
index a3a78884..2667eb45 100644
--- a/libdw/dwarf_getmacros.c
+++ b/libdw/dwarf_getmacros.c
@@ -47,7 +47,15 @@ get_offset_from (Dwarf_Die *die, int name, Dwarf_Word *retp)
     return -1;
 
   /* Offset into the corresponding section.  */
-  return INTUSE(dwarf_formudata) (&attr, retp);
+  if (INTUSE(dwarf_formudata) (&attr, retp) != 0)
+    return -1;
+
+  Dwarf_Off offset;
+  if (INTUSE(dwarf_cu_dwp_section_info) (die->cu, DW_SECT_MACRO, &offset, NULL)
+      != 0)
+    return -1;
+  *retp += offset;
+  return 0;
 }
 
 static int
@@ -131,6 +139,14 @@ get_macinfo_table (Dwarf *dbg, Dwarf_Word macoff, Dwarf_Die *cudie)
   else if (cudie->cu->unit_type == DW_UT_split_compile
 	   && dbg->sectiondata[IDX_debug_line] != NULL)
     line_offset = 0;
+  if (line_offset != (Dwarf_Off) -1)
+    {
+      Dwarf_Off dwp_offset;
+      if (INTUSE(dwarf_cu_dwp_section_info) (cudie->cu, DW_SECT_LINE,
+					     &dwp_offset, NULL) != 0)
+	return NULL;
+      line_offset += dwp_offset;
+    }
 
   Dwarf_Macro_Op_Table *table = libdw_alloc (dbg, Dwarf_Macro_Op_Table,
 					     macinfo_data_size, 1);
@@ -188,6 +204,14 @@ get_table_for_offset (Dwarf *dbg, Dwarf_Word macoff,
 	if (unlikely (INTUSE(dwarf_formudata) (attr, &line_offset) != 0))
 	  return NULL;
     }
+  if (line_offset != (Dwarf_Off) -1 && cudie != NULL)
+    {
+      Dwarf_Off dwp_offset;
+      if (INTUSE(dwarf_cu_dwp_section_info) (cudie->cu, DW_SECT_LINE,
+					     &dwp_offset, NULL) != 0)
+	return NULL;
+      line_offset += dwp_offset;
+    }
 
   uint8_t address_size;
   if (cudie != NULL)
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 16355274..bdbf5e5a 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -1111,25 +1111,27 @@ str_offsets_base_off (Dwarf *dbg, Dwarf_CU *cu)
 	cu = first_cu;
     }
 
+  Dwarf_Off off = 0;
   if (cu != NULL)
     {
       if (cu->str_off_base == (Dwarf_Off) -1)
 	{
+	  dwarf_cu_dwp_section_info (cu, DW_SECT_STR_OFFSETS, &off, NULL);
 	  Dwarf_Die cu_die = CUDIE(cu);
 	  Dwarf_Attribute attr;
 	  if (dwarf_attr (&cu_die, DW_AT_str_offsets_base, &attr) != NULL)
 	    {
-	      Dwarf_Word off;
-	      if (dwarf_formudata (&attr, &off) == 0)
+	      Dwarf_Word base;
+	      if (dwarf_formudata (&attr, &base) == 0)
 		{
-		  cu->str_off_base = off;
+		  cu->str_off_base = off + base;
 		  return cu->str_off_base;
 		}
 	    }
 	  /* For older DWARF simply assume zero (no header).  */
 	  if (cu->version < 5)
 	    {
-	      cu->str_off_base = 0;
+	      cu->str_off_base = off;
 	      return cu->str_off_base;
 	    }
 
@@ -1142,7 +1144,6 @@ str_offsets_base_off (Dwarf *dbg, Dwarf_CU *cu)
 
   /* No str_offsets_base attribute, we have to assume "zero".
      But there could be a header first.  */
-  Dwarf_Off off = 0;
   if (dbg == NULL)
     goto no_header;
 
@@ -1184,7 +1185,7 @@ str_offsets_base_off (Dwarf *dbg, Dwarf_CU *cu)
   /* padding */
   read_2ubyte_unaligned_inc (dbg, readp);
 
-  off = (Dwarf_Off) (readp - start);
+  off += (Dwarf_Off) (readp - start);
 
  no_header:
   if (cu != NULL)
@@ -1222,18 +1223,22 @@ __libdw_cu_ranges_base (Dwarf_CU *cu)
 	}
       else
 	{
+	  Dwarf_Off dwp_offset = 0;
+	  dwarf_cu_dwp_section_info (cu, DW_SECT_RNGLISTS, &dwp_offset, NULL);
+	  offset = dwp_offset;
+
 	  if (dwarf_attr (&cu_die, DW_AT_rnglists_base, &attr) != NULL)
 	    {
 	      Dwarf_Word off;
 	      if (dwarf_formudata (&attr, &off) == 0)
-		offset = off;
+		offset += off;
 	    }
 
 	  /* There wasn't an rnglists_base, if the Dwarf does have a
 	     .debug_rnglists section, then it might be we need the
 	     base after the first header. */
 	  Elf_Data *data = cu->dbg->sectiondata[IDX_debug_rnglists];
-	  if (offset == 0 && data != NULL)
+	  if (offset == dwp_offset && data != NULL)
 	    {
 	      Dwarf *dbg = cu->dbg;
 	      const unsigned char *readp = data->d_buf;
@@ -1279,8 +1284,8 @@ __libdw_cu_ranges_base (Dwarf_CU *cu)
 	      if (unit_length - 8 < needed)
 		goto no_header;
 
-	      offset = (Dwarf_Off) (offset_array_start
-				    - (unsigned char *) data->d_buf);
+	      offset += (Dwarf_Off) (offset_array_start
+				     - (unsigned char *) data->d_buf);
 	    }
 	}
     no_header:
@@ -1297,21 +1302,24 @@ __libdw_cu_locs_base (Dwarf_CU *cu)
 {
   if (cu->locs_base == (Dwarf_Off) -1)
     {
-      Dwarf_Off offset = 0;
+      Dwarf_Off dwp_offset = 0;
+      dwarf_cu_dwp_section_info (cu, DW_SECT_LOCLISTS, &dwp_offset, NULL);
+      Dwarf_Off offset = dwp_offset;
+
       Dwarf_Die cu_die = CUDIE(cu);
       Dwarf_Attribute attr;
       if (dwarf_attr (&cu_die, DW_AT_loclists_base, &attr) != NULL)
 	{
 	  Dwarf_Word off;
 	  if (dwarf_formudata (&attr, &off) == 0)
-	    offset = off;
+	    offset += off;
 	}
 
       /* There wasn't an loclists_base, if the Dwarf does have a
 	 .debug_loclists section, then it might be we need the
 	 base after the first header. */
       Elf_Data *data = cu->dbg->sectiondata[IDX_debug_loclists];
-      if (offset == 0 && data != NULL)
+      if (offset == dwp_offset && data != NULL)
 	{
 	  Dwarf *dbg = cu->dbg;
 	  const unsigned char *readp = data->d_buf;
@@ -1357,8 +1365,8 @@ __libdw_cu_locs_base (Dwarf_CU *cu)
 	  if (unit_length - 8 < needed)
 	    goto no_header;
 
-	  offset = (Dwarf_Off) (offset_array_start
-				- (unsigned char *) data->d_buf);
+	  offset += (Dwarf_Off) (offset_array_start
+				 - (unsigned char *) data->d_buf);
 	}
 
     no_header:
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 97261444..93503f57 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,6 +1,7 @@
 2023-09-27  Omar Sandoval  <osandov@fb.com>
 
-	* run-varlocs.sh: Add entry PC to split units.
+	* run-varlocs.sh: Add entry PC to split units.  Check testfile-dwp-5
+	and testfile-dwp-4.
 	* Makefile.am (check_PROGRAMS): Add cu-dwp-section-info.
 	(TESTS): Add run-cu-dwp-section-info.sh
 	(EXTRA_DIST): Add run-cu-dwp-section-info.sh and new test files.
@@ -20,6 +21,11 @@
 	(getmacros): New function.
 	(main): If second argument is empty, call getmacros on every unit.
 	Otherwise, call getmacros on given unit.
+	* run-all-dwarf-ranges.sh: Check testfile-dwp-5 and testfile-dwp-4.
+	* run-dwarf-getmacros.sh: Check testfile-dwp-5 and
+	testfile-dwp-4-strict.
+	* run-get-units-split.sh: Check testfile-dwp-5, testfile-dwp-4, and
+	testfile-dwp-4-strict.
 
 2023-04-21  Frank Ch. Eigler <fche@redhat.com>
 
diff --git a/tests/run-all-dwarf-ranges.sh b/tests/run-all-dwarf-ranges.sh
index cefb4231..61141cfa 100755
--- a/tests/run-all-dwarf-ranges.sh
+++ b/tests/run-all-dwarf-ranges.sh
@@ -126,4 +126,118 @@ die: no_subject (2e)
 
 EOF
 
+# See testfile-dwp.source.
+testfiles testfile-dwp-5 testfile-dwp-5.dwp
+testfiles testfile-dwp-4 testfile-dwp-4.dwp
+
+testrun_compare ${abs_builddir}/all-dwarf-ranges testfile-dwp-5 << EOF
+die: foo.cc (11)
+ 401190..401200
+
+die: foo (2e)
+ 4011c0..401200
+
+die: x_x (1d)
+ 4011cb..4011eb
+ 4011f8..401200
+
+die: <unknown> (b)
+ 4011cb..4011eb
+ 4011f8..401200
+
+die: x_x (2e)
+ 401190..4011bd
+
+die: <unknown> (b)
+ 401190..401190
+ 401192..4011bb
+
+die: bar.cc (11)
+ 401200..40121b
+
+die: bar (2e)
+ 401200..40121b
+
+die: main.cc (11)
+ 401020..4010a0
+
+die: main (2e)
+ 401020..4010a0
+
+die: fibonacci (1d)
+ 401030..401032
+ 401036..401060
+ 401099..4010a0
+
+die: fibonacci (1d)
+ 40103a..401060
+ 401099..4010a0
+
+die: <unknown> (b)
+ 40103a..401060
+ 401099..4010a0
+
+die: <unknown> (b)
+ 40103a..401044
+ 401050..401060
+
+die: <unknown> (b)
+ 401050..401053
+ 401056..401059
+
+EOF
+
+testrun_compare ${abs_builddir}/all-dwarf-ranges testfile-dwp-4 << EOF
+die: foo.cc (11)
+ 401190..401200
+
+die: foo (2e)
+ 4011c0..401200
+
+die: x_x (1d)
+ 4011cb..4011eb
+ 4011f8..401200
+
+die: <unknown> (b)
+ 4011cb..4011eb
+ 4011f8..401200
+
+die: x_x (2e)
+ 401190..4011bd
+
+die: bar.cc (11)
+ 401200..40121b
+
+die: bar (2e)
+ 401200..40121b
+
+die: main.cc (11)
+ 401020..4010a0
+
+die: main (2e)
+ 401020..4010a0
+
+die: fibonacci (1d)
+ 401030..401032
+ 401036..401060
+ 401099..4010a0
+
+die: fibonacci (1d)
+ 40103a..401060
+ 401099..4010a0
+
+die: <unknown> (b)
+ 40103a..401060
+ 401099..4010a0
+
+die: <unknown> (b)
+ 40103a..401044
+ 401050..401060
+
+die: <unknown> (b)
+ 401050..401053
+ 401056..401059
+
+EOF
+
 exit 0
diff --git a/tests/run-dwarf-getmacros.sh b/tests/run-dwarf-getmacros.sh
index 0a488fa3..220c2426 100755
--- a/tests/run-dwarf-getmacros.sh
+++ b/tests/run-dwarf-getmacros.sh
@@ -707,4 +707,1416 @@ file /home/petr/proj/elfutils/master/elfutils/x.c
 /file
 EOF
 
+# See testfile-dwp.source.
+testfiles testfile-dwp-5 testfile-dwp-5.dwp
+testfiles testfile-dwp-4-strict testfile-dwp-4-strict.dwp
+
+# Not testfile-dwp-4 because it's unclear what to do about
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99319.
+for file in testfile-dwp-5 testfile-dwp-4-strict; do
+	testrun_compare ${abs_builddir}/dwarf-getmacros "$file" '' '' << EOF
+CU foo.cc
+__STDC__ 1
+__cplusplus 201703L
+__STDC_UTF_16__ 1
+__STDC_UTF_32__ 1
+__STDC_HOSTED__ 1
+__GNUC__ 14
+__GNUC_MINOR__ 0
+__GNUC_PATCHLEVEL__ 0
+__VERSION__ "14.0.0 20230920 (experimental)"
+__ATOMIC_RELAXED 0
+__ATOMIC_SEQ_CST 5
+__ATOMIC_ACQUIRE 2
+__ATOMIC_RELEASE 3
+__ATOMIC_ACQ_REL 4
+__ATOMIC_CONSUME 1
+__OPTIMIZE__ 1
+__FINITE_MATH_ONLY__ 0
+_LP64 1
+__LP64__ 1
+__SIZEOF_INT__ 4
+__SIZEOF_LONG__ 8
+__SIZEOF_LONG_LONG__ 8
+__SIZEOF_SHORT__ 2
+__SIZEOF_FLOAT__ 4
+__SIZEOF_DOUBLE__ 8
+__SIZEOF_LONG_DOUBLE__ 16
+__SIZEOF_SIZE_T__ 8
+__CHAR_BIT__ 8
+__BIGGEST_ALIGNMENT__ 16
+__ORDER_LITTLE_ENDIAN__ 1234
+__ORDER_BIG_ENDIAN__ 4321
+__ORDER_PDP_ENDIAN__ 3412
+__BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+__FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
+__SIZEOF_POINTER__ 8
+__GNUC_EXECUTION_CHARSET_NAME "UTF-8"
+__GNUC_WIDE_EXECUTION_CHARSET_NAME "UTF-32LE"
+__GNUG__ 14
+__SIZE_TYPE__ long unsigned int
+__PTRDIFF_TYPE__ long int
+__WCHAR_TYPE__ int
+__WINT_TYPE__ unsigned int
+__INTMAX_TYPE__ long int
+__UINTMAX_TYPE__ long unsigned int
+__CHAR16_TYPE__ short unsigned int
+__CHAR32_TYPE__ unsigned int
+__SIG_ATOMIC_TYPE__ int
+__INT8_TYPE__ signed char
+__INT16_TYPE__ short int
+__INT32_TYPE__ int
+__INT64_TYPE__ long int
+__UINT8_TYPE__ unsigned char
+__UINT16_TYPE__ short unsigned int
+__UINT32_TYPE__ unsigned int
+__UINT64_TYPE__ long unsigned int
+__INT_LEAST8_TYPE__ signed char
+__INT_LEAST16_TYPE__ short int
+__INT_LEAST32_TYPE__ int
+__INT_LEAST64_TYPE__ long int
+__UINT_LEAST8_TYPE__ unsigned char
+__UINT_LEAST16_TYPE__ short unsigned int
+__UINT_LEAST32_TYPE__ unsigned int
+__UINT_LEAST64_TYPE__ long unsigned int
+__INT_FAST8_TYPE__ signed char
+__INT_FAST16_TYPE__ long int
+__INT_FAST32_TYPE__ long int
+__INT_FAST64_TYPE__ long int
+__UINT_FAST8_TYPE__ unsigned char
+__UINT_FAST16_TYPE__ long unsigned int
+__UINT_FAST32_TYPE__ long unsigned int
+__UINT_FAST64_TYPE__ long unsigned int
+__INTPTR_TYPE__ long int
+__UINTPTR_TYPE__ long unsigned int
+__GXX_WEAK__ 1
+__DEPRECATED 1
+__GXX_RTTI 1
+__cpp_rtti 199711L
+__GXX_EXPERIMENTAL_CXX0X__ 1
+__cpp_binary_literals 201304L
+__cpp_hex_float 201603L
+__cpp_runtime_arrays 198712L
+__cpp_raw_strings 200710L
+__cpp_unicode_literals 200710L
+__cpp_user_defined_literals 200809L
+__cpp_lambdas 200907L
+__cpp_decltype 200707L
+__cpp_attributes 200809L
+__cpp_rvalue_reference 200610L
+__cpp_rvalue_references 200610L
+__cpp_variadic_templates 200704L
+__cpp_initializer_lists 200806L
+__cpp_delegating_constructors 200604L
+__cpp_nsdmi 200809L
+__cpp_inheriting_constructors 201511L
+__cpp_ref_qualifiers 200710L
+__cpp_alias_templates 200704L
+__cpp_return_type_deduction 201304L
+__cpp_init_captures 201304L
+__cpp_generic_lambdas 201304L
+__cpp_decltype_auto 201304L
+__cpp_aggregate_nsdmi 201304L
+__cpp_variable_templates 201304L
+__cpp_digit_separators 201309L
+__cpp_unicode_characters 201411L
+__cpp_static_assert 201411L
+__cpp_namespace_attributes 201411L
+__cpp_enumerator_attributes 201411L
+__cpp_nested_namespace_definitions 201411L
+__cpp_fold_expressions 201603L
+__cpp_nontype_template_args 201411L
+__cpp_range_based_for 201603L
+__cpp_constexpr 201603L
+__cpp_if_constexpr 201606L
+__cpp_capture_star_this 201603L
+__cpp_inline_variables 201606L
+__cpp_aggregate_bases 201603L
+__cpp_deduction_guides 201703L
+__cpp_noexcept_function_type 201510L
+__cpp_template_auto 201606L
+__cpp_structured_bindings 201606L
+__cpp_variadic_using 201611L
+__cpp_guaranteed_copy_elision 201606L
+__cpp_nontype_template_parameter_auto 201606L
+__cpp_sized_deallocation 201309L
+__cpp_aligned_new 201606L
+__STDCPP_DEFAULT_NEW_ALIGNMENT__ 16
+__cpp_template_template_args 201611L
+__cpp_threadsafe_static_init 200806L
+__STDCPP_THREADS__ 1
+__EXCEPTIONS 1
+__cpp_exceptions 199711L
+__GXX_ABI_VERSION 1019
+__SCHAR_MAX__ 0x7f
+__SHRT_MAX__ 0x7fff
+__INT_MAX__ 0x7fffffff
+__LONG_MAX__ 0x7fffffffffffffffL
+__LONG_LONG_MAX__ 0x7fffffffffffffffLL
+__WCHAR_MAX__ 0x7fffffff
+__WCHAR_MIN__ (-__WCHAR_MAX__ - 1)
+__WINT_MAX__ 0xffffffffU
+__WINT_MIN__ 0U
+__PTRDIFF_MAX__ 0x7fffffffffffffffL
+__SIZE_MAX__ 0xffffffffffffffffUL
+__SCHAR_WIDTH__ 8
+__SHRT_WIDTH__ 16
+__INT_WIDTH__ 32
+__LONG_WIDTH__ 64
+__LONG_LONG_WIDTH__ 64
+__WCHAR_WIDTH__ 32
+__WINT_WIDTH__ 32
+__PTRDIFF_WIDTH__ 64
+__SIZE_WIDTH__ 64
+__GLIBCXX_TYPE_INT_N_0 __int128
+__GLIBCXX_BITSIZE_INT_N_0 128
+__INTMAX_MAX__ 0x7fffffffffffffffL
+__INTMAX_C(c) c ## L
+__UINTMAX_MAX__ 0xffffffffffffffffUL
+__UINTMAX_C(c) c ## UL
+__INTMAX_WIDTH__ 64
+__SIG_ATOMIC_MAX__ 0x7fffffff
+__SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)
+__SIG_ATOMIC_WIDTH__ 32
+__INT8_MAX__ 0x7f
+__INT16_MAX__ 0x7fff
+__INT32_MAX__ 0x7fffffff
+__INT64_MAX__ 0x7fffffffffffffffL
+__UINT8_MAX__ 0xff
+__UINT16_MAX__ 0xffff
+__UINT32_MAX__ 0xffffffffU
+__UINT64_MAX__ 0xffffffffffffffffUL
+__INT_LEAST8_MAX__ 0x7f
+__INT8_C(c) c
+__INT_LEAST8_WIDTH__ 8
+__INT_LEAST16_MAX__ 0x7fff
+__INT16_C(c) c
+__INT_LEAST16_WIDTH__ 16
+__INT_LEAST32_MAX__ 0x7fffffff
+__INT32_C(c) c
+__INT_LEAST32_WIDTH__ 32
+__INT_LEAST64_MAX__ 0x7fffffffffffffffL
+__INT64_C(c) c ## L
+__INT_LEAST64_WIDTH__ 64
+__UINT_LEAST8_MAX__ 0xff
+__UINT8_C(c) c
+__UINT_LEAST16_MAX__ 0xffff
+__UINT16_C(c) c
+__UINT_LEAST32_MAX__ 0xffffffffU
+__UINT32_C(c) c ## U
+__UINT_LEAST64_MAX__ 0xffffffffffffffffUL
+__UINT64_C(c) c ## UL
+__INT_FAST8_MAX__ 0x7f
+__INT_FAST8_WIDTH__ 8
+__INT_FAST16_MAX__ 0x7fffffffffffffffL
+__INT_FAST16_WIDTH__ 64
+__INT_FAST32_MAX__ 0x7fffffffffffffffL
+__INT_FAST32_WIDTH__ 64
+__INT_FAST64_MAX__ 0x7fffffffffffffffL
+__INT_FAST64_WIDTH__ 64
+__UINT_FAST8_MAX__ 0xff
+__UINT_FAST16_MAX__ 0xffffffffffffffffUL
+__UINT_FAST32_MAX__ 0xffffffffffffffffUL
+__UINT_FAST64_MAX__ 0xffffffffffffffffUL
+__INTPTR_MAX__ 0x7fffffffffffffffL
+__INTPTR_WIDTH__ 64
+__UINTPTR_MAX__ 0xffffffffffffffffUL
+__GCC_IEC_559 2
+__GCC_IEC_559_COMPLEX 2
+__FLT_EVAL_METHOD__ 0
+__FLT_EVAL_METHOD_TS_18661_3__ 0
+__DEC_EVAL_METHOD__ 2
+__FLT_RADIX__ 2
+__FLT_MANT_DIG__ 24
+__FLT_DIG__ 6
+__FLT_MIN_EXP__ (-125)
+__FLT_MIN_10_EXP__ (-37)
+__FLT_MAX_EXP__ 128
+__FLT_MAX_10_EXP__ 38
+__FLT_DECIMAL_DIG__ 9
+__FLT_MAX__ 3.40282346638528859811704183484516925e+38F
+__FLT_NORM_MAX__ 3.40282346638528859811704183484516925e+38F
+__FLT_MIN__ 1.17549435082228750796873653722224568e-38F
+__FLT_EPSILON__ 1.19209289550781250000000000000000000e-7F
+__FLT_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F
+__FLT_HAS_DENORM__ 1
+__FLT_HAS_INFINITY__ 1
+__FLT_HAS_QUIET_NAN__ 1
+__FLT_IS_IEC_60559__ 1
+__DBL_MANT_DIG__ 53
+__DBL_DIG__ 15
+__DBL_MIN_EXP__ (-1021)
+__DBL_MIN_10_EXP__ (-307)
+__DBL_MAX_EXP__ 1024
+__DBL_MAX_10_EXP__ 308
+__DBL_DECIMAL_DIG__ 17
+__DBL_MAX__ double(1.79769313486231570814527423731704357e+308L)
+__DBL_NORM_MAX__ double(1.79769313486231570814527423731704357e+308L)
+__DBL_MIN__ double(2.22507385850720138309023271733240406e-308L)
+__DBL_EPSILON__ double(2.22044604925031308084726333618164062e-16L)
+__DBL_DENORM_MIN__ double(4.94065645841246544176568792868221372e-324L)
+__DBL_HAS_DENORM__ 1
+__DBL_HAS_INFINITY__ 1
+__DBL_HAS_QUIET_NAN__ 1
+__DBL_IS_IEC_60559__ 1
+__LDBL_MANT_DIG__ 64
+__LDBL_DIG__ 18
+__LDBL_MIN_EXP__ (-16381)
+__LDBL_MIN_10_EXP__ (-4931)
+__LDBL_MAX_EXP__ 16384
+__LDBL_MAX_10_EXP__ 4932
+__DECIMAL_DIG__ 21
+__LDBL_DECIMAL_DIG__ 21
+__LDBL_MAX__ 1.18973149535723176502126385303097021e+4932L
+__LDBL_NORM_MAX__ 1.18973149535723176502126385303097021e+4932L
+__LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
+__LDBL_EPSILON__ 1.08420217248550443400745280086994171e-19L
+__LDBL_DENORM_MIN__ 3.64519953188247460252840593361941982e-4951L
+__LDBL_HAS_DENORM__ 1
+__LDBL_HAS_INFINITY__ 1
+__LDBL_HAS_QUIET_NAN__ 1
+__LDBL_IS_IEC_60559__ 1
+__FLT16_MANT_DIG__ 11
+__FLT16_DIG__ 3
+__FLT16_MIN_EXP__ (-13)
+__FLT16_MIN_10_EXP__ (-4)
+__FLT16_MAX_EXP__ 16
+__FLT16_MAX_10_EXP__ 4
+__FLT16_DECIMAL_DIG__ 5
+__FLT16_MAX__ 6.55040000000000000000000000000000000e+4F16
+__FLT16_NORM_MAX__ 6.55040000000000000000000000000000000e+4F16
+__FLT16_MIN__ 6.10351562500000000000000000000000000e-5F16
+__FLT16_EPSILON__ 9.76562500000000000000000000000000000e-4F16
+__FLT16_DENORM_MIN__ 5.96046447753906250000000000000000000e-8F16
+__FLT16_HAS_DENORM__ 1
+__FLT16_HAS_INFINITY__ 1
+__FLT16_HAS_QUIET_NAN__ 1
+__FLT16_IS_IEC_60559__ 1
+__FLT32_MANT_DIG__ 24
+__FLT32_DIG__ 6
+__FLT32_MIN_EXP__ (-125)
+__FLT32_MIN_10_EXP__ (-37)
+__FLT32_MAX_EXP__ 128
+__FLT32_MAX_10_EXP__ 38
+__FLT32_DECIMAL_DIG__ 9
+__FLT32_MAX__ 3.40282346638528859811704183484516925e+38F32
+__FLT32_NORM_MAX__ 3.40282346638528859811704183484516925e+38F32
+__FLT32_MIN__ 1.17549435082228750796873653722224568e-38F32
+__FLT32_EPSILON__ 1.19209289550781250000000000000000000e-7F32
+__FLT32_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F32
+__FLT32_HAS_DENORM__ 1
+__FLT32_HAS_INFINITY__ 1
+__FLT32_HAS_QUIET_NAN__ 1
+__FLT32_IS_IEC_60559__ 1
+__FLT64_MANT_DIG__ 53
+__FLT64_DIG__ 15
+__FLT64_MIN_EXP__ (-1021)
+__FLT64_MIN_10_EXP__ (-307)
+__FLT64_MAX_EXP__ 1024
+__FLT64_MAX_10_EXP__ 308
+__FLT64_DECIMAL_DIG__ 17
+__FLT64_MAX__ 1.79769313486231570814527423731704357e+308F64
+__FLT64_NORM_MAX__ 1.79769313486231570814527423731704357e+308F64
+__FLT64_MIN__ 2.22507385850720138309023271733240406e-308F64
+__FLT64_EPSILON__ 2.22044604925031308084726333618164062e-16F64
+__FLT64_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F64
+__FLT64_HAS_DENORM__ 1
+__FLT64_HAS_INFINITY__ 1
+__FLT64_HAS_QUIET_NAN__ 1
+__FLT64_IS_IEC_60559__ 1
+__FLT128_MANT_DIG__ 113
+__FLT128_DIG__ 33
+__FLT128_MIN_EXP__ (-16381)
+__FLT128_MIN_10_EXP__ (-4931)
+__FLT128_MAX_EXP__ 16384
+__FLT128_MAX_10_EXP__ 4932
+__FLT128_DECIMAL_DIG__ 36
+__FLT128_MAX__ 1.18973149535723176508575932662800702e+4932F128
+__FLT128_NORM_MAX__ 1.18973149535723176508575932662800702e+4932F128
+__FLT128_MIN__ 3.36210314311209350626267781732175260e-4932F128
+__FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34F128
+__FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966F128
+__FLT128_HAS_DENORM__ 1
+__FLT128_HAS_INFINITY__ 1
+__FLT128_HAS_QUIET_NAN__ 1
+__FLT128_IS_IEC_60559__ 1
+__FLT32X_MANT_DIG__ 53
+__FLT32X_DIG__ 15
+__FLT32X_MIN_EXP__ (-1021)
+__FLT32X_MIN_10_EXP__ (-307)
+__FLT32X_MAX_EXP__ 1024
+__FLT32X_MAX_10_EXP__ 308
+__FLT32X_DECIMAL_DIG__ 17
+__FLT32X_MAX__ 1.79769313486231570814527423731704357e+308F32x
+__FLT32X_NORM_MAX__ 1.79769313486231570814527423731704357e+308F32x
+__FLT32X_MIN__ 2.22507385850720138309023271733240406e-308F32x
+__FLT32X_EPSILON__ 2.22044604925031308084726333618164062e-16F32x
+__FLT32X_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F32x
+__FLT32X_HAS_DENORM__ 1
+__FLT32X_HAS_INFINITY__ 1
+__FLT32X_HAS_QUIET_NAN__ 1
+__FLT32X_IS_IEC_60559__ 1
+__FLT64X_MANT_DIG__ 64
+__FLT64X_DIG__ 18
+__FLT64X_MIN_EXP__ (-16381)
+__FLT64X_MIN_10_EXP__ (-4931)
+__FLT64X_MAX_EXP__ 16384
+__FLT64X_MAX_10_EXP__ 4932
+__FLT64X_DECIMAL_DIG__ 21
+__FLT64X_MAX__ 1.18973149535723176502126385303097021e+4932F64x
+__FLT64X_NORM_MAX__ 1.18973149535723176502126385303097021e+4932F64x
+__FLT64X_MIN__ 3.36210314311209350626267781732175260e-4932F64x
+__FLT64X_EPSILON__ 1.08420217248550443400745280086994171e-19F64x
+__FLT64X_DENORM_MIN__ 3.64519953188247460252840593361941982e-4951F64x
+__FLT64X_HAS_DENORM__ 1
+__FLT64X_HAS_INFINITY__ 1
+__FLT64X_HAS_QUIET_NAN__ 1
+__FLT64X_IS_IEC_60559__ 1
+__BFLT16_MANT_DIG__ 8
+__BFLT16_DIG__ 2
+__BFLT16_MIN_EXP__ (-125)
+__BFLT16_MIN_10_EXP__ (-37)
+__BFLT16_MAX_EXP__ 128
+__BFLT16_MAX_10_EXP__ 38
+__BFLT16_DECIMAL_DIG__ 4
+__BFLT16_MAX__ 3.38953138925153547590470800371487867e+38BF16
+__BFLT16_NORM_MAX__ 3.38953138925153547590470800371487867e+38BF16
+__BFLT16_MIN__ 1.17549435082228750796873653722224568e-38BF16
+__BFLT16_EPSILON__ 7.81250000000000000000000000000000000e-3BF16
+__BFLT16_DENORM_MIN__ 9.18354961579912115600575419704879436e-41BF16
+__BFLT16_HAS_DENORM__ 1
+__BFLT16_HAS_INFINITY__ 1
+__BFLT16_HAS_QUIET_NAN__ 1
+__BFLT16_IS_IEC_60559__ 0
+__DEC32_MANT_DIG__ 7
+__DEC32_MIN_EXP__ (-94)
+__DEC32_MAX_EXP__ 97
+__DEC32_MIN__ 1E-95DF
+__DEC32_MAX__ 9.999999E96DF
+__DEC32_EPSILON__ 1E-6DF
+__DEC32_SUBNORMAL_MIN__ 0.000001E-95DF
+__DEC64_MANT_DIG__ 16
+__DEC64_MIN_EXP__ (-382)
+__DEC64_MAX_EXP__ 385
+__DEC64_MIN__ 1E-383DD
+__DEC64_MAX__ 9.999999999999999E384DD
+__DEC64_EPSILON__ 1E-15DD
+__DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD
+__DEC128_MANT_DIG__ 34
+__DEC128_MIN_EXP__ (-6142)
+__DEC128_MAX_EXP__ 6145
+__DEC128_MIN__ 1E-6143DL
+__DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
+__DEC128_EPSILON__ 1E-33DL
+__DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL
+__REGISTER_PREFIX__ 
+__USER_LABEL_PREFIX__ 
+__GNUC_STDC_INLINE__ 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+__GCC_ATOMIC_BOOL_LOCK_FREE 2
+__GCC_ATOMIC_CHAR_LOCK_FREE 2
+__GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
+__GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
+__GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
+__GCC_ATOMIC_SHORT_LOCK_FREE 2
+__GCC_ATOMIC_INT_LOCK_FREE 2
+__GCC_ATOMIC_LONG_LOCK_FREE 2
+__GCC_ATOMIC_LLONG_LOCK_FREE 2
+__GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
+__GCC_DESTRUCTIVE_SIZE 64
+__GCC_CONSTRUCTIVE_SIZE 64
+__GCC_ATOMIC_POINTER_LOCK_FREE 2
+__HAVE_SPECULATION_SAFE_VALUE 1
+__GCC_HAVE_DWARF2_CFI_ASM 1
+__PRAGMA_REDEFINE_EXTNAME 1
+__SIZEOF_INT128__ 16
+__SIZEOF_WCHAR_T__ 4
+__SIZEOF_WINT_T__ 4
+__SIZEOF_PTRDIFF_T__ 8
+__amd64 1
+__amd64__ 1
+__x86_64 1
+__x86_64__ 1
+__SIZEOF_FLOAT80__ 16
+__SIZEOF_FLOAT128__ 16
+__ATOMIC_HLE_ACQUIRE 65536
+__ATOMIC_HLE_RELEASE 131072
+__GCC_ASM_FLAG_OUTPUTS__ 1
+__k8 1
+__k8__ 1
+__code_model_small__ 1
+__MMX__ 1
+__SSE__ 1
+__SSE2__ 1
+__FXSR__ 1
+__SSE_MATH__ 1
+__SSE2_MATH__ 1
+__MMX_WITH_SSE__ 1
+__SEG_FS 1
+__SEG_GS 1
+__gnu_linux__ 1
+__linux 1
+__linux__ 1
+linux 1
+__unix 1
+__unix__ 1
+unix 1
+__ELF__ 1
+__DECIMAL_BID_FORMAT__ 1
+_GNU_SOURCE 1
+file /home/osandov/src/elfutils/tests/foo.cc
+ file /usr/include/stdc-predef.h
+  _STDC_PREDEF_H 1
+  __STDC_IEC_559__ 1
+  __STDC_IEC_60559_BFP__ 201404L
+  __STDC_IEC_559_COMPLEX__ 1
+  __STDC_IEC_60559_COMPLEX__ 201404L
+  __STDC_ISO_10646__ 201706L
+ /file
+ file /home/osandov/src/elfutils/tests/foobar.h
+  FROB(x) ((x) ^ 0x2a2a2a2a)
+  FRY(x) ((x) * 0x100000001b3)
+ /file
+ ZERO() (1 - 1)
+/file
+CU bar.cc
+__STDC__ 1
+__cplusplus 201703L
+__STDC_UTF_16__ 1
+__STDC_UTF_32__ 1
+__STDC_HOSTED__ 1
+__GNUC__ 14
+__GNUC_MINOR__ 0
+__GNUC_PATCHLEVEL__ 0
+__VERSION__ "14.0.0 20230920 (experimental)"
+__ATOMIC_RELAXED 0
+__ATOMIC_SEQ_CST 5
+__ATOMIC_ACQUIRE 2
+__ATOMIC_RELEASE 3
+__ATOMIC_ACQ_REL 4
+__ATOMIC_CONSUME 1
+__OPTIMIZE__ 1
+__FINITE_MATH_ONLY__ 0
+_LP64 1
+__LP64__ 1
+__SIZEOF_INT__ 4
+__SIZEOF_LONG__ 8
+__SIZEOF_LONG_LONG__ 8
+__SIZEOF_SHORT__ 2
+__SIZEOF_FLOAT__ 4
+__SIZEOF_DOUBLE__ 8
+__SIZEOF_LONG_DOUBLE__ 16
+__SIZEOF_SIZE_T__ 8
+__CHAR_BIT__ 8
+__BIGGEST_ALIGNMENT__ 16
+__ORDER_LITTLE_ENDIAN__ 1234
+__ORDER_BIG_ENDIAN__ 4321
+__ORDER_PDP_ENDIAN__ 3412
+__BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+__FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
+__SIZEOF_POINTER__ 8
+__GNUC_EXECUTION_CHARSET_NAME "UTF-8"
+__GNUC_WIDE_EXECUTION_CHARSET_NAME "UTF-32LE"
+__GNUG__ 14
+__SIZE_TYPE__ long unsigned int
+__PTRDIFF_TYPE__ long int
+__WCHAR_TYPE__ int
+__WINT_TYPE__ unsigned int
+__INTMAX_TYPE__ long int
+__UINTMAX_TYPE__ long unsigned int
+__CHAR16_TYPE__ short unsigned int
+__CHAR32_TYPE__ unsigned int
+__SIG_ATOMIC_TYPE__ int
+__INT8_TYPE__ signed char
+__INT16_TYPE__ short int
+__INT32_TYPE__ int
+__INT64_TYPE__ long int
+__UINT8_TYPE__ unsigned char
+__UINT16_TYPE__ short unsigned int
+__UINT32_TYPE__ unsigned int
+__UINT64_TYPE__ long unsigned int
+__INT_LEAST8_TYPE__ signed char
+__INT_LEAST16_TYPE__ short int
+__INT_LEAST32_TYPE__ int
+__INT_LEAST64_TYPE__ long int
+__UINT_LEAST8_TYPE__ unsigned char
+__UINT_LEAST16_TYPE__ short unsigned int
+__UINT_LEAST32_TYPE__ unsigned int
+__UINT_LEAST64_TYPE__ long unsigned int
+__INT_FAST8_TYPE__ signed char
+__INT_FAST16_TYPE__ long int
+__INT_FAST32_TYPE__ long int
+__INT_FAST64_TYPE__ long int
+__UINT_FAST8_TYPE__ unsigned char
+__UINT_FAST16_TYPE__ long unsigned int
+__UINT_FAST32_TYPE__ long unsigned int
+__UINT_FAST64_TYPE__ long unsigned int
+__INTPTR_TYPE__ long int
+__UINTPTR_TYPE__ long unsigned int
+__GXX_WEAK__ 1
+__DEPRECATED 1
+__GXX_RTTI 1
+__cpp_rtti 199711L
+__GXX_EXPERIMENTAL_CXX0X__ 1
+__cpp_binary_literals 201304L
+__cpp_hex_float 201603L
+__cpp_runtime_arrays 198712L
+__cpp_raw_strings 200710L
+__cpp_unicode_literals 200710L
+__cpp_user_defined_literals 200809L
+__cpp_lambdas 200907L
+__cpp_decltype 200707L
+__cpp_attributes 200809L
+__cpp_rvalue_reference 200610L
+__cpp_rvalue_references 200610L
+__cpp_variadic_templates 200704L
+__cpp_initializer_lists 200806L
+__cpp_delegating_constructors 200604L
+__cpp_nsdmi 200809L
+__cpp_inheriting_constructors 201511L
+__cpp_ref_qualifiers 200710L
+__cpp_alias_templates 200704L
+__cpp_return_type_deduction 201304L
+__cpp_init_captures 201304L
+__cpp_generic_lambdas 201304L
+__cpp_decltype_auto 201304L
+__cpp_aggregate_nsdmi 201304L
+__cpp_variable_templates 201304L
+__cpp_digit_separators 201309L
+__cpp_unicode_characters 201411L
+__cpp_static_assert 201411L
+__cpp_namespace_attributes 201411L
+__cpp_enumerator_attributes 201411L
+__cpp_nested_namespace_definitions 201411L
+__cpp_fold_expressions 201603L
+__cpp_nontype_template_args 201411L
+__cpp_range_based_for 201603L
+__cpp_constexpr 201603L
+__cpp_if_constexpr 201606L
+__cpp_capture_star_this 201603L
+__cpp_inline_variables 201606L
+__cpp_aggregate_bases 201603L
+__cpp_deduction_guides 201703L
+__cpp_noexcept_function_type 201510L
+__cpp_template_auto 201606L
+__cpp_structured_bindings 201606L
+__cpp_variadic_using 201611L
+__cpp_guaranteed_copy_elision 201606L
+__cpp_nontype_template_parameter_auto 201606L
+__cpp_sized_deallocation 201309L
+__cpp_aligned_new 201606L
+__STDCPP_DEFAULT_NEW_ALIGNMENT__ 16
+__cpp_template_template_args 201611L
+__cpp_threadsafe_static_init 200806L
+__STDCPP_THREADS__ 1
+__EXCEPTIONS 1
+__cpp_exceptions 199711L
+__GXX_ABI_VERSION 1019
+__SCHAR_MAX__ 0x7f
+__SHRT_MAX__ 0x7fff
+__INT_MAX__ 0x7fffffff
+__LONG_MAX__ 0x7fffffffffffffffL
+__LONG_LONG_MAX__ 0x7fffffffffffffffLL
+__WCHAR_MAX__ 0x7fffffff
+__WCHAR_MIN__ (-__WCHAR_MAX__ - 1)
+__WINT_MAX__ 0xffffffffU
+__WINT_MIN__ 0U
+__PTRDIFF_MAX__ 0x7fffffffffffffffL
+__SIZE_MAX__ 0xffffffffffffffffUL
+__SCHAR_WIDTH__ 8
+__SHRT_WIDTH__ 16
+__INT_WIDTH__ 32
+__LONG_WIDTH__ 64
+__LONG_LONG_WIDTH__ 64
+__WCHAR_WIDTH__ 32
+__WINT_WIDTH__ 32
+__PTRDIFF_WIDTH__ 64
+__SIZE_WIDTH__ 64
+__GLIBCXX_TYPE_INT_N_0 __int128
+__GLIBCXX_BITSIZE_INT_N_0 128
+__INTMAX_MAX__ 0x7fffffffffffffffL
+__INTMAX_C(c) c ## L
+__UINTMAX_MAX__ 0xffffffffffffffffUL
+__UINTMAX_C(c) c ## UL
+__INTMAX_WIDTH__ 64
+__SIG_ATOMIC_MAX__ 0x7fffffff
+__SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)
+__SIG_ATOMIC_WIDTH__ 32
+__INT8_MAX__ 0x7f
+__INT16_MAX__ 0x7fff
+__INT32_MAX__ 0x7fffffff
+__INT64_MAX__ 0x7fffffffffffffffL
+__UINT8_MAX__ 0xff
+__UINT16_MAX__ 0xffff
+__UINT32_MAX__ 0xffffffffU
+__UINT64_MAX__ 0xffffffffffffffffUL
+__INT_LEAST8_MAX__ 0x7f
+__INT8_C(c) c
+__INT_LEAST8_WIDTH__ 8
+__INT_LEAST16_MAX__ 0x7fff
+__INT16_C(c) c
+__INT_LEAST16_WIDTH__ 16
+__INT_LEAST32_MAX__ 0x7fffffff
+__INT32_C(c) c
+__INT_LEAST32_WIDTH__ 32
+__INT_LEAST64_MAX__ 0x7fffffffffffffffL
+__INT64_C(c) c ## L
+__INT_LEAST64_WIDTH__ 64
+__UINT_LEAST8_MAX__ 0xff
+__UINT8_C(c) c
+__UINT_LEAST16_MAX__ 0xffff
+__UINT16_C(c) c
+__UINT_LEAST32_MAX__ 0xffffffffU
+__UINT32_C(c) c ## U
+__UINT_LEAST64_MAX__ 0xffffffffffffffffUL
+__UINT64_C(c) c ## UL
+__INT_FAST8_MAX__ 0x7f
+__INT_FAST8_WIDTH__ 8
+__INT_FAST16_MAX__ 0x7fffffffffffffffL
+__INT_FAST16_WIDTH__ 64
+__INT_FAST32_MAX__ 0x7fffffffffffffffL
+__INT_FAST32_WIDTH__ 64
+__INT_FAST64_MAX__ 0x7fffffffffffffffL
+__INT_FAST64_WIDTH__ 64
+__UINT_FAST8_MAX__ 0xff
+__UINT_FAST16_MAX__ 0xffffffffffffffffUL
+__UINT_FAST32_MAX__ 0xffffffffffffffffUL
+__UINT_FAST64_MAX__ 0xffffffffffffffffUL
+__INTPTR_MAX__ 0x7fffffffffffffffL
+__INTPTR_WIDTH__ 64
+__UINTPTR_MAX__ 0xffffffffffffffffUL
+__GCC_IEC_559 2
+__GCC_IEC_559_COMPLEX 2
+__FLT_EVAL_METHOD__ 0
+__FLT_EVAL_METHOD_TS_18661_3__ 0
+__DEC_EVAL_METHOD__ 2
+__FLT_RADIX__ 2
+__FLT_MANT_DIG__ 24
+__FLT_DIG__ 6
+__FLT_MIN_EXP__ (-125)
+__FLT_MIN_10_EXP__ (-37)
+__FLT_MAX_EXP__ 128
+__FLT_MAX_10_EXP__ 38
+__FLT_DECIMAL_DIG__ 9
+__FLT_MAX__ 3.40282346638528859811704183484516925e+38F
+__FLT_NORM_MAX__ 3.40282346638528859811704183484516925e+38F
+__FLT_MIN__ 1.17549435082228750796873653722224568e-38F
+__FLT_EPSILON__ 1.19209289550781250000000000000000000e-7F
+__FLT_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F
+__FLT_HAS_DENORM__ 1
+__FLT_HAS_INFINITY__ 1
+__FLT_HAS_QUIET_NAN__ 1
+__FLT_IS_IEC_60559__ 1
+__DBL_MANT_DIG__ 53
+__DBL_DIG__ 15
+__DBL_MIN_EXP__ (-1021)
+__DBL_MIN_10_EXP__ (-307)
+__DBL_MAX_EXP__ 1024
+__DBL_MAX_10_EXP__ 308
+__DBL_DECIMAL_DIG__ 17
+__DBL_MAX__ double(1.79769313486231570814527423731704357e+308L)
+__DBL_NORM_MAX__ double(1.79769313486231570814527423731704357e+308L)
+__DBL_MIN__ double(2.22507385850720138309023271733240406e-308L)
+__DBL_EPSILON__ double(2.22044604925031308084726333618164062e-16L)
+__DBL_DENORM_MIN__ double(4.94065645841246544176568792868221372e-324L)
+__DBL_HAS_DENORM__ 1
+__DBL_HAS_INFINITY__ 1
+__DBL_HAS_QUIET_NAN__ 1
+__DBL_IS_IEC_60559__ 1
+__LDBL_MANT_DIG__ 64
+__LDBL_DIG__ 18
+__LDBL_MIN_EXP__ (-16381)
+__LDBL_MIN_10_EXP__ (-4931)
+__LDBL_MAX_EXP__ 16384
+__LDBL_MAX_10_EXP__ 4932
+__DECIMAL_DIG__ 21
+__LDBL_DECIMAL_DIG__ 21
+__LDBL_MAX__ 1.18973149535723176502126385303097021e+4932L
+__LDBL_NORM_MAX__ 1.18973149535723176502126385303097021e+4932L
+__LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
+__LDBL_EPSILON__ 1.08420217248550443400745280086994171e-19L
+__LDBL_DENORM_MIN__ 3.64519953188247460252840593361941982e-4951L
+__LDBL_HAS_DENORM__ 1
+__LDBL_HAS_INFINITY__ 1
+__LDBL_HAS_QUIET_NAN__ 1
+__LDBL_IS_IEC_60559__ 1
+__FLT16_MANT_DIG__ 11
+__FLT16_DIG__ 3
+__FLT16_MIN_EXP__ (-13)
+__FLT16_MIN_10_EXP__ (-4)
+__FLT16_MAX_EXP__ 16
+__FLT16_MAX_10_EXP__ 4
+__FLT16_DECIMAL_DIG__ 5
+__FLT16_MAX__ 6.55040000000000000000000000000000000e+4F16
+__FLT16_NORM_MAX__ 6.55040000000000000000000000000000000e+4F16
+__FLT16_MIN__ 6.10351562500000000000000000000000000e-5F16
+__FLT16_EPSILON__ 9.76562500000000000000000000000000000e-4F16
+__FLT16_DENORM_MIN__ 5.96046447753906250000000000000000000e-8F16
+__FLT16_HAS_DENORM__ 1
+__FLT16_HAS_INFINITY__ 1
+__FLT16_HAS_QUIET_NAN__ 1
+__FLT16_IS_IEC_60559__ 1
+__FLT32_MANT_DIG__ 24
+__FLT32_DIG__ 6
+__FLT32_MIN_EXP__ (-125)
+__FLT32_MIN_10_EXP__ (-37)
+__FLT32_MAX_EXP__ 128
+__FLT32_MAX_10_EXP__ 38
+__FLT32_DECIMAL_DIG__ 9
+__FLT32_MAX__ 3.40282346638528859811704183484516925e+38F32
+__FLT32_NORM_MAX__ 3.40282346638528859811704183484516925e+38F32
+__FLT32_MIN__ 1.17549435082228750796873653722224568e-38F32
+__FLT32_EPSILON__ 1.19209289550781250000000000000000000e-7F32
+__FLT32_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F32
+__FLT32_HAS_DENORM__ 1
+__FLT32_HAS_INFINITY__ 1
+__FLT32_HAS_QUIET_NAN__ 1
+__FLT32_IS_IEC_60559__ 1
+__FLT64_MANT_DIG__ 53
+__FLT64_DIG__ 15
+__FLT64_MIN_EXP__ (-1021)
+__FLT64_MIN_10_EXP__ (-307)
+__FLT64_MAX_EXP__ 1024
+__FLT64_MAX_10_EXP__ 308
+__FLT64_DECIMAL_DIG__ 17
+__FLT64_MAX__ 1.79769313486231570814527423731704357e+308F64
+__FLT64_NORM_MAX__ 1.79769313486231570814527423731704357e+308F64
+__FLT64_MIN__ 2.22507385850720138309023271733240406e-308F64
+__FLT64_EPSILON__ 2.22044604925031308084726333618164062e-16F64
+__FLT64_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F64
+__FLT64_HAS_DENORM__ 1
+__FLT64_HAS_INFINITY__ 1
+__FLT64_HAS_QUIET_NAN__ 1
+__FLT64_IS_IEC_60559__ 1
+__FLT128_MANT_DIG__ 113
+__FLT128_DIG__ 33
+__FLT128_MIN_EXP__ (-16381)
+__FLT128_MIN_10_EXP__ (-4931)
+__FLT128_MAX_EXP__ 16384
+__FLT128_MAX_10_EXP__ 4932
+__FLT128_DECIMAL_DIG__ 36
+__FLT128_MAX__ 1.18973149535723176508575932662800702e+4932F128
+__FLT128_NORM_MAX__ 1.18973149535723176508575932662800702e+4932F128
+__FLT128_MIN__ 3.36210314311209350626267781732175260e-4932F128
+__FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34F128
+__FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966F128
+__FLT128_HAS_DENORM__ 1
+__FLT128_HAS_INFINITY__ 1
+__FLT128_HAS_QUIET_NAN__ 1
+__FLT128_IS_IEC_60559__ 1
+__FLT32X_MANT_DIG__ 53
+__FLT32X_DIG__ 15
+__FLT32X_MIN_EXP__ (-1021)
+__FLT32X_MIN_10_EXP__ (-307)
+__FLT32X_MAX_EXP__ 1024
+__FLT32X_MAX_10_EXP__ 308
+__FLT32X_DECIMAL_DIG__ 17
+__FLT32X_MAX__ 1.79769313486231570814527423731704357e+308F32x
+__FLT32X_NORM_MAX__ 1.79769313486231570814527423731704357e+308F32x
+__FLT32X_MIN__ 2.22507385850720138309023271733240406e-308F32x
+__FLT32X_EPSILON__ 2.22044604925031308084726333618164062e-16F32x
+__FLT32X_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F32x
+__FLT32X_HAS_DENORM__ 1
+__FLT32X_HAS_INFINITY__ 1
+__FLT32X_HAS_QUIET_NAN__ 1
+__FLT32X_IS_IEC_60559__ 1
+__FLT64X_MANT_DIG__ 64
+__FLT64X_DIG__ 18
+__FLT64X_MIN_EXP__ (-16381)
+__FLT64X_MIN_10_EXP__ (-4931)
+__FLT64X_MAX_EXP__ 16384
+__FLT64X_MAX_10_EXP__ 4932
+__FLT64X_DECIMAL_DIG__ 21
+__FLT64X_MAX__ 1.18973149535723176502126385303097021e+4932F64x
+__FLT64X_NORM_MAX__ 1.18973149535723176502126385303097021e+4932F64x
+__FLT64X_MIN__ 3.36210314311209350626267781732175260e-4932F64x
+__FLT64X_EPSILON__ 1.08420217248550443400745280086994171e-19F64x
+__FLT64X_DENORM_MIN__ 3.64519953188247460252840593361941982e-4951F64x
+__FLT64X_HAS_DENORM__ 1
+__FLT64X_HAS_INFINITY__ 1
+__FLT64X_HAS_QUIET_NAN__ 1
+__FLT64X_IS_IEC_60559__ 1
+__BFLT16_MANT_DIG__ 8
+__BFLT16_DIG__ 2
+__BFLT16_MIN_EXP__ (-125)
+__BFLT16_MIN_10_EXP__ (-37)
+__BFLT16_MAX_EXP__ 128
+__BFLT16_MAX_10_EXP__ 38
+__BFLT16_DECIMAL_DIG__ 4
+__BFLT16_MAX__ 3.38953138925153547590470800371487867e+38BF16
+__BFLT16_NORM_MAX__ 3.38953138925153547590470800371487867e+38BF16
+__BFLT16_MIN__ 1.17549435082228750796873653722224568e-38BF16
+__BFLT16_EPSILON__ 7.81250000000000000000000000000000000e-3BF16
+__BFLT16_DENORM_MIN__ 9.18354961579912115600575419704879436e-41BF16
+__BFLT16_HAS_DENORM__ 1
+__BFLT16_HAS_INFINITY__ 1
+__BFLT16_HAS_QUIET_NAN__ 1
+__BFLT16_IS_IEC_60559__ 0
+__DEC32_MANT_DIG__ 7
+__DEC32_MIN_EXP__ (-94)
+__DEC32_MAX_EXP__ 97
+__DEC32_MIN__ 1E-95DF
+__DEC32_MAX__ 9.999999E96DF
+__DEC32_EPSILON__ 1E-6DF
+__DEC32_SUBNORMAL_MIN__ 0.000001E-95DF
+__DEC64_MANT_DIG__ 16
+__DEC64_MIN_EXP__ (-382)
+__DEC64_MAX_EXP__ 385
+__DEC64_MIN__ 1E-383DD
+__DEC64_MAX__ 9.999999999999999E384DD
+__DEC64_EPSILON__ 1E-15DD
+__DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD
+__DEC128_MANT_DIG__ 34
+__DEC128_MIN_EXP__ (-6142)
+__DEC128_MAX_EXP__ 6145
+__DEC128_MIN__ 1E-6143DL
+__DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
+__DEC128_EPSILON__ 1E-33DL
+__DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL
+__REGISTER_PREFIX__ 
+__USER_LABEL_PREFIX__ 
+__GNUC_STDC_INLINE__ 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+__GCC_ATOMIC_BOOL_LOCK_FREE 2
+__GCC_ATOMIC_CHAR_LOCK_FREE 2
+__GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
+__GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
+__GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
+__GCC_ATOMIC_SHORT_LOCK_FREE 2
+__GCC_ATOMIC_INT_LOCK_FREE 2
+__GCC_ATOMIC_LONG_LOCK_FREE 2
+__GCC_ATOMIC_LLONG_LOCK_FREE 2
+__GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
+__GCC_DESTRUCTIVE_SIZE 64
+__GCC_CONSTRUCTIVE_SIZE 64
+__GCC_ATOMIC_POINTER_LOCK_FREE 2
+__HAVE_SPECULATION_SAFE_VALUE 1
+__GCC_HAVE_DWARF2_CFI_ASM 1
+__PRAGMA_REDEFINE_EXTNAME 1
+__SIZEOF_INT128__ 16
+__SIZEOF_WCHAR_T__ 4
+__SIZEOF_WINT_T__ 4
+__SIZEOF_PTRDIFF_T__ 8
+__amd64 1
+__amd64__ 1
+__x86_64 1
+__x86_64__ 1
+__SIZEOF_FLOAT80__ 16
+__SIZEOF_FLOAT128__ 16
+__ATOMIC_HLE_ACQUIRE 65536
+__ATOMIC_HLE_RELEASE 131072
+__GCC_ASM_FLAG_OUTPUTS__ 1
+__k8 1
+__k8__ 1
+__code_model_small__ 1
+__MMX__ 1
+__SSE__ 1
+__SSE2__ 1
+__FXSR__ 1
+__SSE_MATH__ 1
+__SSE2_MATH__ 1
+__MMX_WITH_SSE__ 1
+__SEG_FS 1
+__SEG_GS 1
+__gnu_linux__ 1
+__linux 1
+__linux__ 1
+linux 1
+__unix 1
+__unix__ 1
+unix 1
+__ELF__ 1
+__DECIMAL_BID_FORMAT__ 1
+_GNU_SOURCE 1
+file /home/osandov/src/elfutils/tests/bar.cc
+ file /usr/include/stdc-predef.h
+  _STDC_PREDEF_H 1
+  __STDC_IEC_559__ 1
+  __STDC_IEC_60559_BFP__ 201404L
+  __STDC_IEC_559_COMPLEX__ 1
+  __STDC_IEC_60559_COMPLEX__ 201404L
+  __STDC_ISO_10646__ 201706L
+ /file
+ file /home/osandov/src/elfutils/tests/foobar.h
+  FROB(x) ((x) ^ 0x2a2a2a2a)
+  FRY(x) ((x) * 0x100000001b3)
+ /file
+ ONE 1
+/file
+CU main.cc
+__STDC__ 1
+__cplusplus 201703L
+__STDC_UTF_16__ 1
+__STDC_UTF_32__ 1
+__STDC_HOSTED__ 1
+__GNUC__ 14
+__GNUC_MINOR__ 0
+__GNUC_PATCHLEVEL__ 0
+__VERSION__ "14.0.0 20230920 (experimental)"
+__ATOMIC_RELAXED 0
+__ATOMIC_SEQ_CST 5
+__ATOMIC_ACQUIRE 2
+__ATOMIC_RELEASE 3
+__ATOMIC_ACQ_REL 4
+__ATOMIC_CONSUME 1
+__OPTIMIZE__ 1
+__FINITE_MATH_ONLY__ 0
+_LP64 1
+__LP64__ 1
+__SIZEOF_INT__ 4
+__SIZEOF_LONG__ 8
+__SIZEOF_LONG_LONG__ 8
+__SIZEOF_SHORT__ 2
+__SIZEOF_FLOAT__ 4
+__SIZEOF_DOUBLE__ 8
+__SIZEOF_LONG_DOUBLE__ 16
+__SIZEOF_SIZE_T__ 8
+__CHAR_BIT__ 8
+__BIGGEST_ALIGNMENT__ 16
+__ORDER_LITTLE_ENDIAN__ 1234
+__ORDER_BIG_ENDIAN__ 4321
+__ORDER_PDP_ENDIAN__ 3412
+__BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+__FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
+__SIZEOF_POINTER__ 8
+__GNUC_EXECUTION_CHARSET_NAME "UTF-8"
+__GNUC_WIDE_EXECUTION_CHARSET_NAME "UTF-32LE"
+__GNUG__ 14
+__SIZE_TYPE__ long unsigned int
+__PTRDIFF_TYPE__ long int
+__WCHAR_TYPE__ int
+__WINT_TYPE__ unsigned int
+__INTMAX_TYPE__ long int
+__UINTMAX_TYPE__ long unsigned int
+__CHAR16_TYPE__ short unsigned int
+__CHAR32_TYPE__ unsigned int
+__SIG_ATOMIC_TYPE__ int
+__INT8_TYPE__ signed char
+__INT16_TYPE__ short int
+__INT32_TYPE__ int
+__INT64_TYPE__ long int
+__UINT8_TYPE__ unsigned char
+__UINT16_TYPE__ short unsigned int
+__UINT32_TYPE__ unsigned int
+__UINT64_TYPE__ long unsigned int
+__INT_LEAST8_TYPE__ signed char
+__INT_LEAST16_TYPE__ short int
+__INT_LEAST32_TYPE__ int
+__INT_LEAST64_TYPE__ long int
+__UINT_LEAST8_TYPE__ unsigned char
+__UINT_LEAST16_TYPE__ short unsigned int
+__UINT_LEAST32_TYPE__ unsigned int
+__UINT_LEAST64_TYPE__ long unsigned int
+__INT_FAST8_TYPE__ signed char
+__INT_FAST16_TYPE__ long int
+__INT_FAST32_TYPE__ long int
+__INT_FAST64_TYPE__ long int
+__UINT_FAST8_TYPE__ unsigned char
+__UINT_FAST16_TYPE__ long unsigned int
+__UINT_FAST32_TYPE__ long unsigned int
+__UINT_FAST64_TYPE__ long unsigned int
+__INTPTR_TYPE__ long int
+__UINTPTR_TYPE__ long unsigned int
+__GXX_WEAK__ 1
+__DEPRECATED 1
+__GXX_RTTI 1
+__cpp_rtti 199711L
+__GXX_EXPERIMENTAL_CXX0X__ 1
+__cpp_binary_literals 201304L
+__cpp_hex_float 201603L
+__cpp_runtime_arrays 198712L
+__cpp_raw_strings 200710L
+__cpp_unicode_literals 200710L
+__cpp_user_defined_literals 200809L
+__cpp_lambdas 200907L
+__cpp_decltype 200707L
+__cpp_attributes 200809L
+__cpp_rvalue_reference 200610L
+__cpp_rvalue_references 200610L
+__cpp_variadic_templates 200704L
+__cpp_initializer_lists 200806L
+__cpp_delegating_constructors 200604L
+__cpp_nsdmi 200809L
+__cpp_inheriting_constructors 201511L
+__cpp_ref_qualifiers 200710L
+__cpp_alias_templates 200704L
+__cpp_return_type_deduction 201304L
+__cpp_init_captures 201304L
+__cpp_generic_lambdas 201304L
+__cpp_decltype_auto 201304L
+__cpp_aggregate_nsdmi 201304L
+__cpp_variable_templates 201304L
+__cpp_digit_separators 201309L
+__cpp_unicode_characters 201411L
+__cpp_static_assert 201411L
+__cpp_namespace_attributes 201411L
+__cpp_enumerator_attributes 201411L
+__cpp_nested_namespace_definitions 201411L
+__cpp_fold_expressions 201603L
+__cpp_nontype_template_args 201411L
+__cpp_range_based_for 201603L
+__cpp_constexpr 201603L
+__cpp_if_constexpr 201606L
+__cpp_capture_star_this 201603L
+__cpp_inline_variables 201606L
+__cpp_aggregate_bases 201603L
+__cpp_deduction_guides 201703L
+__cpp_noexcept_function_type 201510L
+__cpp_template_auto 201606L
+__cpp_structured_bindings 201606L
+__cpp_variadic_using 201611L
+__cpp_guaranteed_copy_elision 201606L
+__cpp_nontype_template_parameter_auto 201606L
+__cpp_sized_deallocation 201309L
+__cpp_aligned_new 201606L
+__STDCPP_DEFAULT_NEW_ALIGNMENT__ 16
+__cpp_template_template_args 201611L
+__cpp_threadsafe_static_init 200806L
+__STDCPP_THREADS__ 1
+__EXCEPTIONS 1
+__cpp_exceptions 199711L
+__GXX_ABI_VERSION 1019
+__SCHAR_MAX__ 0x7f
+__SHRT_MAX__ 0x7fff
+__INT_MAX__ 0x7fffffff
+__LONG_MAX__ 0x7fffffffffffffffL
+__LONG_LONG_MAX__ 0x7fffffffffffffffLL
+__WCHAR_MAX__ 0x7fffffff
+__WCHAR_MIN__ (-__WCHAR_MAX__ - 1)
+__WINT_MAX__ 0xffffffffU
+__WINT_MIN__ 0U
+__PTRDIFF_MAX__ 0x7fffffffffffffffL
+__SIZE_MAX__ 0xffffffffffffffffUL
+__SCHAR_WIDTH__ 8
+__SHRT_WIDTH__ 16
+__INT_WIDTH__ 32
+__LONG_WIDTH__ 64
+__LONG_LONG_WIDTH__ 64
+__WCHAR_WIDTH__ 32
+__WINT_WIDTH__ 32
+__PTRDIFF_WIDTH__ 64
+__SIZE_WIDTH__ 64
+__GLIBCXX_TYPE_INT_N_0 __int128
+__GLIBCXX_BITSIZE_INT_N_0 128
+__INTMAX_MAX__ 0x7fffffffffffffffL
+__INTMAX_C(c) c ## L
+__UINTMAX_MAX__ 0xffffffffffffffffUL
+__UINTMAX_C(c) c ## UL
+__INTMAX_WIDTH__ 64
+__SIG_ATOMIC_MAX__ 0x7fffffff
+__SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)
+__SIG_ATOMIC_WIDTH__ 32
+__INT8_MAX__ 0x7f
+__INT16_MAX__ 0x7fff
+__INT32_MAX__ 0x7fffffff
+__INT64_MAX__ 0x7fffffffffffffffL
+__UINT8_MAX__ 0xff
+__UINT16_MAX__ 0xffff
+__UINT32_MAX__ 0xffffffffU
+__UINT64_MAX__ 0xffffffffffffffffUL
+__INT_LEAST8_MAX__ 0x7f
+__INT8_C(c) c
+__INT_LEAST8_WIDTH__ 8
+__INT_LEAST16_MAX__ 0x7fff
+__INT16_C(c) c
+__INT_LEAST16_WIDTH__ 16
+__INT_LEAST32_MAX__ 0x7fffffff
+__INT32_C(c) c
+__INT_LEAST32_WIDTH__ 32
+__INT_LEAST64_MAX__ 0x7fffffffffffffffL
+__INT64_C(c) c ## L
+__INT_LEAST64_WIDTH__ 64
+__UINT_LEAST8_MAX__ 0xff
+__UINT8_C(c) c
+__UINT_LEAST16_MAX__ 0xffff
+__UINT16_C(c) c
+__UINT_LEAST32_MAX__ 0xffffffffU
+__UINT32_C(c) c ## U
+__UINT_LEAST64_MAX__ 0xffffffffffffffffUL
+__UINT64_C(c) c ## UL
+__INT_FAST8_MAX__ 0x7f
+__INT_FAST8_WIDTH__ 8
+__INT_FAST16_MAX__ 0x7fffffffffffffffL
+__INT_FAST16_WIDTH__ 64
+__INT_FAST32_MAX__ 0x7fffffffffffffffL
+__INT_FAST32_WIDTH__ 64
+__INT_FAST64_MAX__ 0x7fffffffffffffffL
+__INT_FAST64_WIDTH__ 64
+__UINT_FAST8_MAX__ 0xff
+__UINT_FAST16_MAX__ 0xffffffffffffffffUL
+__UINT_FAST32_MAX__ 0xffffffffffffffffUL
+__UINT_FAST64_MAX__ 0xffffffffffffffffUL
+__INTPTR_MAX__ 0x7fffffffffffffffL
+__INTPTR_WIDTH__ 64
+__UINTPTR_MAX__ 0xffffffffffffffffUL
+__GCC_IEC_559 2
+__GCC_IEC_559_COMPLEX 2
+__FLT_EVAL_METHOD__ 0
+__FLT_EVAL_METHOD_TS_18661_3__ 0
+__DEC_EVAL_METHOD__ 2
+__FLT_RADIX__ 2
+__FLT_MANT_DIG__ 24
+__FLT_DIG__ 6
+__FLT_MIN_EXP__ (-125)
+__FLT_MIN_10_EXP__ (-37)
+__FLT_MAX_EXP__ 128
+__FLT_MAX_10_EXP__ 38
+__FLT_DECIMAL_DIG__ 9
+__FLT_MAX__ 3.40282346638528859811704183484516925e+38F
+__FLT_NORM_MAX__ 3.40282346638528859811704183484516925e+38F
+__FLT_MIN__ 1.17549435082228750796873653722224568e-38F
+__FLT_EPSILON__ 1.19209289550781250000000000000000000e-7F
+__FLT_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F
+__FLT_HAS_DENORM__ 1
+__FLT_HAS_INFINITY__ 1
+__FLT_HAS_QUIET_NAN__ 1
+__FLT_IS_IEC_60559__ 1
+__DBL_MANT_DIG__ 53
+__DBL_DIG__ 15
+__DBL_MIN_EXP__ (-1021)
+__DBL_MIN_10_EXP__ (-307)
+__DBL_MAX_EXP__ 1024
+__DBL_MAX_10_EXP__ 308
+__DBL_DECIMAL_DIG__ 17
+__DBL_MAX__ double(1.79769313486231570814527423731704357e+308L)
+__DBL_NORM_MAX__ double(1.79769313486231570814527423731704357e+308L)
+__DBL_MIN__ double(2.22507385850720138309023271733240406e-308L)
+__DBL_EPSILON__ double(2.22044604925031308084726333618164062e-16L)
+__DBL_DENORM_MIN__ double(4.94065645841246544176568792868221372e-324L)
+__DBL_HAS_DENORM__ 1
+__DBL_HAS_INFINITY__ 1
+__DBL_HAS_QUIET_NAN__ 1
+__DBL_IS_IEC_60559__ 1
+__LDBL_MANT_DIG__ 64
+__LDBL_DIG__ 18
+__LDBL_MIN_EXP__ (-16381)
+__LDBL_MIN_10_EXP__ (-4931)
+__LDBL_MAX_EXP__ 16384
+__LDBL_MAX_10_EXP__ 4932
+__DECIMAL_DIG__ 21
+__LDBL_DECIMAL_DIG__ 21
+__LDBL_MAX__ 1.18973149535723176502126385303097021e+4932L
+__LDBL_NORM_MAX__ 1.18973149535723176502126385303097021e+4932L
+__LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
+__LDBL_EPSILON__ 1.08420217248550443400745280086994171e-19L
+__LDBL_DENORM_MIN__ 3.64519953188247460252840593361941982e-4951L
+__LDBL_HAS_DENORM__ 1
+__LDBL_HAS_INFINITY__ 1
+__LDBL_HAS_QUIET_NAN__ 1
+__LDBL_IS_IEC_60559__ 1
+__FLT16_MANT_DIG__ 11
+__FLT16_DIG__ 3
+__FLT16_MIN_EXP__ (-13)
+__FLT16_MIN_10_EXP__ (-4)
+__FLT16_MAX_EXP__ 16
+__FLT16_MAX_10_EXP__ 4
+__FLT16_DECIMAL_DIG__ 5
+__FLT16_MAX__ 6.55040000000000000000000000000000000e+4F16
+__FLT16_NORM_MAX__ 6.55040000000000000000000000000000000e+4F16
+__FLT16_MIN__ 6.10351562500000000000000000000000000e-5F16
+__FLT16_EPSILON__ 9.76562500000000000000000000000000000e-4F16
+__FLT16_DENORM_MIN__ 5.96046447753906250000000000000000000e-8F16
+__FLT16_HAS_DENORM__ 1
+__FLT16_HAS_INFINITY__ 1
+__FLT16_HAS_QUIET_NAN__ 1
+__FLT16_IS_IEC_60559__ 1
+__FLT32_MANT_DIG__ 24
+__FLT32_DIG__ 6
+__FLT32_MIN_EXP__ (-125)
+__FLT32_MIN_10_EXP__ (-37)
+__FLT32_MAX_EXP__ 128
+__FLT32_MAX_10_EXP__ 38
+__FLT32_DECIMAL_DIG__ 9
+__FLT32_MAX__ 3.40282346638528859811704183484516925e+38F32
+__FLT32_NORM_MAX__ 3.40282346638528859811704183484516925e+38F32
+__FLT32_MIN__ 1.17549435082228750796873653722224568e-38F32
+__FLT32_EPSILON__ 1.19209289550781250000000000000000000e-7F32
+__FLT32_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F32
+__FLT32_HAS_DENORM__ 1
+__FLT32_HAS_INFINITY__ 1
+__FLT32_HAS_QUIET_NAN__ 1
+__FLT32_IS_IEC_60559__ 1
+__FLT64_MANT_DIG__ 53
+__FLT64_DIG__ 15
+__FLT64_MIN_EXP__ (-1021)
+__FLT64_MIN_10_EXP__ (-307)
+__FLT64_MAX_EXP__ 1024
+__FLT64_MAX_10_EXP__ 308
+__FLT64_DECIMAL_DIG__ 17
+__FLT64_MAX__ 1.79769313486231570814527423731704357e+308F64
+__FLT64_NORM_MAX__ 1.79769313486231570814527423731704357e+308F64
+__FLT64_MIN__ 2.22507385850720138309023271733240406e-308F64
+__FLT64_EPSILON__ 2.22044604925031308084726333618164062e-16F64
+__FLT64_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F64
+__FLT64_HAS_DENORM__ 1
+__FLT64_HAS_INFINITY__ 1
+__FLT64_HAS_QUIET_NAN__ 1
+__FLT64_IS_IEC_60559__ 1
+__FLT128_MANT_DIG__ 113
+__FLT128_DIG__ 33
+__FLT128_MIN_EXP__ (-16381)
+__FLT128_MIN_10_EXP__ (-4931)
+__FLT128_MAX_EXP__ 16384
+__FLT128_MAX_10_EXP__ 4932
+__FLT128_DECIMAL_DIG__ 36
+__FLT128_MAX__ 1.18973149535723176508575932662800702e+4932F128
+__FLT128_NORM_MAX__ 1.18973149535723176508575932662800702e+4932F128
+__FLT128_MIN__ 3.36210314311209350626267781732175260e-4932F128
+__FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34F128
+__FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966F128
+__FLT128_HAS_DENORM__ 1
+__FLT128_HAS_INFINITY__ 1
+__FLT128_HAS_QUIET_NAN__ 1
+__FLT128_IS_IEC_60559__ 1
+__FLT32X_MANT_DIG__ 53
+__FLT32X_DIG__ 15
+__FLT32X_MIN_EXP__ (-1021)
+__FLT32X_MIN_10_EXP__ (-307)
+__FLT32X_MAX_EXP__ 1024
+__FLT32X_MAX_10_EXP__ 308
+__FLT32X_DECIMAL_DIG__ 17
+__FLT32X_MAX__ 1.79769313486231570814527423731704357e+308F32x
+__FLT32X_NORM_MAX__ 1.79769313486231570814527423731704357e+308F32x
+__FLT32X_MIN__ 2.22507385850720138309023271733240406e-308F32x
+__FLT32X_EPSILON__ 2.22044604925031308084726333618164062e-16F32x
+__FLT32X_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F32x
+__FLT32X_HAS_DENORM__ 1
+__FLT32X_HAS_INFINITY__ 1
+__FLT32X_HAS_QUIET_NAN__ 1
+__FLT32X_IS_IEC_60559__ 1
+__FLT64X_MANT_DIG__ 64
+__FLT64X_DIG__ 18
+__FLT64X_MIN_EXP__ (-16381)
+__FLT64X_MIN_10_EXP__ (-4931)
+__FLT64X_MAX_EXP__ 16384
+__FLT64X_MAX_10_EXP__ 4932
+__FLT64X_DECIMAL_DIG__ 21
+__FLT64X_MAX__ 1.18973149535723176502126385303097021e+4932F64x
+__FLT64X_NORM_MAX__ 1.18973149535723176502126385303097021e+4932F64x
+__FLT64X_MIN__ 3.36210314311209350626267781732175260e-4932F64x
+__FLT64X_EPSILON__ 1.08420217248550443400745280086994171e-19F64x
+__FLT64X_DENORM_MIN__ 3.64519953188247460252840593361941982e-4951F64x
+__FLT64X_HAS_DENORM__ 1
+__FLT64X_HAS_INFINITY__ 1
+__FLT64X_HAS_QUIET_NAN__ 1
+__FLT64X_IS_IEC_60559__ 1
+__BFLT16_MANT_DIG__ 8
+__BFLT16_DIG__ 2
+__BFLT16_MIN_EXP__ (-125)
+__BFLT16_MIN_10_EXP__ (-37)
+__BFLT16_MAX_EXP__ 128
+__BFLT16_MAX_10_EXP__ 38
+__BFLT16_DECIMAL_DIG__ 4
+__BFLT16_MAX__ 3.38953138925153547590470800371487867e+38BF16
+__BFLT16_NORM_MAX__ 3.38953138925153547590470800371487867e+38BF16
+__BFLT16_MIN__ 1.17549435082228750796873653722224568e-38BF16
+__BFLT16_EPSILON__ 7.81250000000000000000000000000000000e-3BF16
+__BFLT16_DENORM_MIN__ 9.18354961579912115600575419704879436e-41BF16
+__BFLT16_HAS_DENORM__ 1
+__BFLT16_HAS_INFINITY__ 1
+__BFLT16_HAS_QUIET_NAN__ 1
+__BFLT16_IS_IEC_60559__ 0
+__DEC32_MANT_DIG__ 7
+__DEC32_MIN_EXP__ (-94)
+__DEC32_MAX_EXP__ 97
+__DEC32_MIN__ 1E-95DF
+__DEC32_MAX__ 9.999999E96DF
+__DEC32_EPSILON__ 1E-6DF
+__DEC32_SUBNORMAL_MIN__ 0.000001E-95DF
+__DEC64_MANT_DIG__ 16
+__DEC64_MIN_EXP__ (-382)
+__DEC64_MAX_EXP__ 385
+__DEC64_MIN__ 1E-383DD
+__DEC64_MAX__ 9.999999999999999E384DD
+__DEC64_EPSILON__ 1E-15DD
+__DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD
+__DEC128_MANT_DIG__ 34
+__DEC128_MIN_EXP__ (-6142)
+__DEC128_MAX_EXP__ 6145
+__DEC128_MIN__ 1E-6143DL
+__DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
+__DEC128_EPSILON__ 1E-33DL
+__DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL
+__REGISTER_PREFIX__ 
+__USER_LABEL_PREFIX__ 
+__GNUC_STDC_INLINE__ 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+__GCC_ATOMIC_BOOL_LOCK_FREE 2
+__GCC_ATOMIC_CHAR_LOCK_FREE 2
+__GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
+__GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
+__GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
+__GCC_ATOMIC_SHORT_LOCK_FREE 2
+__GCC_ATOMIC_INT_LOCK_FREE 2
+__GCC_ATOMIC_LONG_LOCK_FREE 2
+__GCC_ATOMIC_LLONG_LOCK_FREE 2
+__GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
+__GCC_DESTRUCTIVE_SIZE 64
+__GCC_CONSTRUCTIVE_SIZE 64
+__GCC_ATOMIC_POINTER_LOCK_FREE 2
+__HAVE_SPECULATION_SAFE_VALUE 1
+__GCC_HAVE_DWARF2_CFI_ASM 1
+__PRAGMA_REDEFINE_EXTNAME 1
+__SIZEOF_INT128__ 16
+__SIZEOF_WCHAR_T__ 4
+__SIZEOF_WINT_T__ 4
+__SIZEOF_PTRDIFF_T__ 8
+__amd64 1
+__amd64__ 1
+__x86_64 1
+__x86_64__ 1
+__SIZEOF_FLOAT80__ 16
+__SIZEOF_FLOAT128__ 16
+__ATOMIC_HLE_ACQUIRE 65536
+__ATOMIC_HLE_RELEASE 131072
+__GCC_ASM_FLAG_OUTPUTS__ 1
+__k8 1
+__k8__ 1
+__code_model_small__ 1
+__MMX__ 1
+__SSE__ 1
+__SSE2__ 1
+__FXSR__ 1
+__SSE_MATH__ 1
+__SSE2_MATH__ 1
+__MMX_WITH_SSE__ 1
+__SEG_FS 1
+__SEG_GS 1
+__gnu_linux__ 1
+__linux 1
+__linux__ 1
+linux 1
+__unix 1
+__unix__ 1
+unix 1
+__ELF__ 1
+__DECIMAL_BID_FORMAT__ 1
+_GNU_SOURCE 1
+file /home/osandov/src/elfutils/tests/main.cc
+ file /usr/include/stdc-predef.h
+  _STDC_PREDEF_H 1
+  __STDC_IEC_559__ 1
+  __STDC_IEC_60559_BFP__ 201404L
+  __STDC_IEC_559_COMPLEX__ 1
+  __STDC_IEC_60559_COMPLEX__ 201404L
+  __STDC_ISO_10646__ 201706L
+ /file
+ file /home/osandov/src/elfutils/tests/foobar.h
+  FROB(x) ((x) ^ 0x2a2a2a2a)
+  FRY(x) ((x) * 0x100000001b3)
+ /file
+ MAIN_ARGS int argc, char **argv
+/file
+EOF
+done
+
 exit 0
diff --git a/tests/run-get-units-split.sh b/tests/run-get-units-split.sh
index 7a43c670..6c7a4f25 100755
--- a/tests/run-get-units-split.sh
+++ b/tests/run-get-units-split.sh
@@ -63,4 +63,22 @@ EOF
 testrun_on_self_exe ${abs_builddir}/get-units-split
 testrun_on_self_lib ${abs_builddir}/get-units-split
 
+# See testfile-dwp.source.
+testfiles testfile-dwp-5 testfile-dwp-5.dwp
+testfiles testfile-dwp-4 testfile-dwp-4.dwp
+testfiles testfile-dwp-4-strict testfile-dwp-4-strict.dwp
+
+for file in testfile-dwp-5 testfile-dwp-4 testfile-dwp-4-strict; do
+	testrun_compare ${abs_builddir}/get-units-split "$file" << EOF
+file: $file
+Got cudie unit_type: 4
+Found a skeleton unit, with split die: foo.cc
+Got cudie unit_type: 4
+Found a skeleton unit, with split die: bar.cc
+Got cudie unit_type: 4
+Found a skeleton unit, with split die: main.cc
+
+EOF
+done
+
 exit 0
diff --git a/tests/run-varlocs.sh b/tests/run-varlocs.sh
index cbbcf6c7..4ac5f367 100755
--- a/tests/run-varlocs.sh
+++ b/tests/run-varlocs.sh
@@ -601,4 +601,116 @@ module 'testfile-splitdwarf4-not-split4.debug'
       [4011a0,4011a1) {lit0, stack_value}
 EOF
 
+# See testfile-dwp.source.
+testfiles testfile-dwp-5 testfile-dwp-5.dwp
+testfiles testfile-dwp-4 testfile-dwp-4.dwp
+
+testrun_compare ${abs_builddir}/varlocs -e testfile-dwp-5 << EOF
+module 'testfile-dwp-5'
+[84] CU 'foo.cc'@401190
+  [c6] function 'foo'@4011c0
+    frame_base: {call_frame_cfa {bregx(7,8)}}
+    [e1] parameter 'this'
+      [4011c0,401200) {reg5}
+    [ea] variable 'x'
+      [4011c2,4011d4) {reg0}
+      [4011d4,4011d7) {reg1}
+      [4011d7,4011d9) {breg1(1), stack_value}
+      [4011f1,401200) {reg0}
+  [f9] inlined function 'x_x'@4011cb
+    [104] parameter 'x'
+      [4011cb,4011eb) {reg0}
+      [4011f1,401200) {reg0}
+  [14a] function 'x_x'@401190
+    frame_base: {call_frame_cfa {bregx(7,8)}}
+    [15b] parameter 'x'
+      [401190,4011a1) {reg5}
+      [4011a1,4011bd) {reg0}
+module 'testfile-dwp-5'
+[1fa] CU 'bar.cc'@401200
+  [23c] function 'bar'@401200
+    frame_base: {call_frame_cfa {bregx(7,8)}}
+    [253] parameter 'this'
+      [401200,40121b) {reg5}
+module 'testfile-dwp-5'
+[272] CU 'main.cc'@0
+  [2c7] function 'main'@401020
+    frame_base: {call_frame_cfa {bregx(7,8)}}
+    [2e0] parameter 'argc'
+      [401020,401068) {reg5}
+      [401068,401080) {fbreg(-40)}
+      [401080,401084) {breg5(0)}
+      [401084,401099) {entry_value(1) {reg5}, stack_value}
+      [401099,4010a0) {reg5}
+    [2ec] parameter 'argv'
+      [401020,40104b) {reg4}
+      [40104b,401099) {entry_value(1) {reg4}, stack_value}
+      [401099,4010a0) {reg4}
+    [2f8] variable 'myfoo'
+      [401020,4010a0) {fbreg(-40)}
+    [303] variable 'mybar'
+      [401020,4010a0) {fbreg(-32)}
+  [30d] inlined function 'fibonacci'@401030
+    [31c] parameter 'n'
+      [401030,401060) {reg5}
+      [401099,4010a0) {reg5}
+  [326] inlined function 'fibonacci'
+    [32f] parameter 'n'
+      <no value>
+EOF
+
+testrun_compare ${abs_builddir}/varlocs -e testfile-dwp-4 << EOF
+module 'testfile-dwp-4'
+[b] CU 'foo.cc'@401190
+  [54] function 'foo'@4011c0
+    frame_base: {call_frame_cfa {bregx(7,8)}}
+    [6f] parameter 'this'
+      [4011c0,401200) {reg5}
+    [78] variable 'x'
+      [4011c2,4011d4) {reg0}
+      [4011d4,4011d7) {reg1}
+      [4011d7,4011d9) {breg1(1), stack_value}
+      [4011f1,401200) {reg0}
+  [8a] inlined function 'x_x'@4011cb
+    [98] parameter 'x'
+      [4011cb,4011eb) {reg0}
+      [4011f1,401200) {reg0}
+  [e7] function 'x_x'@401190
+    frame_base: {call_frame_cfa {bregx(7,8)}}
+    [f8] parameter 'x'
+      [401190,4011a1) {reg5}
+      [4011a1,4011bd) {reg0}
+module 'testfile-dwp-4'
+[129] CU 'bar.cc'@401200
+  [172] function 'bar'@401200
+    frame_base: {call_frame_cfa {bregx(7,8)}}
+    [189] parameter 'this'
+      [401200,40121b) {reg5}
+module 'testfile-dwp-4'
+[19f] CU 'main.cc'@0
+  [1fd] function 'main'@401020
+    frame_base: {call_frame_cfa {bregx(7,8)}}
+    [216] parameter 'argc'
+      [401020,401068) {reg5}
+      [401068,401080) {fbreg(-40)}
+      [401080,401084) {breg5(0)}
+      [401084,401097) {GNU_entry_value(1) {reg5}, stack_value}
+      [401099,4010a0) {reg5}
+    [228] parameter 'argv'
+      [401020,40104b) {reg4}
+      [40104b,401099) {GNU_entry_value(1) {reg4}, stack_value}
+      [401099,4010a0) {reg4}
+    [23a] variable 'myfoo'
+      [401020,4010a0) {fbreg(-40)}
+    [247] variable 'mybar'
+      [401020,4010a0) {fbreg(-32)}
+  [253] inlined function 'fibonacci'@401030
+    [265] parameter 'n'
+      [401030,401060) {reg5}
+      [401099,4010a0) {reg5}
+  [272] inlined function 'fibonacci'
+    [27e] parameter 'n'
+      <no value>
+EOF
+
 exit 0
-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 14/14] libdw: Handle overflowed DW_SECT_INFO offsets in DWARF package file indexes
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
                   ` (12 preceding siblings ...)
  2023-09-27 18:21 ` [PATCH 13/14] libdw: Apply DWARF package file section offsets where appropriate Omar Sandoval
@ 2023-09-27 18:21 ` Omar Sandoval
  2023-09-27 19:20 ` [PATCH 00/14] elfutils: DWARF package (.dwp) file support Frank Ch. Eigler
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 18:21 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

Meta uses DWARF package files for our large, statically-linked C++
applications.  Some of our largest applications have more than 4GB in
.debug_info.dwo, but the section offsets in .debug_cu_index and
.debug_tu_index are 32 bits; see the discussion here [1].  We
implemented a workaround/extension for this in LLVM.  Implement the
equivalent in libdw.

To test this, we need files with more than 4GB in .debug_info.dwo.  I
created these artificially by editing GCC's assembly output.  They
compress down to 6KB.  I test them from run-large-elf-file.sh to take
advantage of the existing checks for large file support.

1: https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libdw/ChangeLog                               |   1 +
 libdw/dwarf_cu_dwp_section_info.c             | 143 +++++++++++++-
 libdw/dwarf_end.c                             |  15 +-
 libdw/libdwP.h                                |   3 +
 tests/ChangeLog                               |   7 +
 tests/Makefile.am                             |   6 +-
 tests/run-large-elf-file.sh                   | 174 ++++++++++++++++++
 tests/testfile-dwp-4-cu-index-overflow.bz2    | Bin 0 -> 4490 bytes
 .../testfile-dwp-4-cu-index-overflow.dwp.bz2  | Bin 0 -> 5584 bytes
 tests/testfile-dwp-5-cu-index-overflow.bz2    | Bin 0 -> 4544 bytes
 .../testfile-dwp-5-cu-index-overflow.dwp.bz2  | Bin 0 -> 5790 bytes
 tests/testfile-dwp-cu-index-overflow.source   |  86 +++++++++
 12 files changed, 430 insertions(+), 5 deletions(-)
 create mode 100755 tests/testfile-dwp-4-cu-index-overflow.bz2
 create mode 100644 tests/testfile-dwp-4-cu-index-overflow.dwp.bz2
 create mode 100755 tests/testfile-dwp-5-cu-index-overflow.bz2
 create mode 100644 tests/testfile-dwp-5-cu-index-overflow.dwp.bz2
 create mode 100644 tests/testfile-dwp-cu-index-overflow.source

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 08b2c3e6..158983e3 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -59,6 +59,7 @@
 	* dwarf_end.c (dwarf_end): Free dwarf->cu_index and dwarf->tu_index.
 	Free dwarf->elfpath.  Free dwarf->dwp_dwarf and close dwarf->dwp_fd.
 	(cu_free): Don't free split dbg if it is dwp_dwarf.
+	(dwarf_package_index_free): New function.
 	* dwarf_error.c (errmsgs): Add DWARF_E_UNKNOWN_SECTION.
 	* libdw.h (dwarf_cu_dwp_section_info): New declaration.
 	* libdw.map (ELFUTILS_0.190): Add dwarf_cu_dwp_section_info.
diff --git a/libdw/dwarf_cu_dwp_section_info.c b/libdw/dwarf_cu_dwp_section_info.c
index 7bf08d9d..8999c382 100644
--- a/libdw/dwarf_cu_dwp_section_info.c
+++ b/libdw/dwarf_cu_dwp_section_info.c
@@ -30,6 +30,8 @@
 # include <config.h>
 #endif
 
+#include <assert.h>
+
 #include "libdwP.h"
 
 static Dwarf_Package_Index *
@@ -161,6 +163,7 @@ __libdw_read_package_index (Dwarf *dbg, bool tu)
   index->indices = indices;
   index->section_offsets = section_offsets;
   index->section_sizes = section_sizes;
+  index->debug_info_offsets = NULL;
 
   return index;
 }
@@ -177,6 +180,137 @@ __libdw_package_index (Dwarf *dbg, bool tu)
   if (index == NULL)
     return NULL;
 
+  /* Offsets in the section offset table are 32-bit unsigned integers.  In
+     practice, the .debug_info.dwo section for very large executables can be
+     larger than 4GB.  GNU dwp as of binutils 2.41 and llvm-dwp before LLVM 15
+     both accidentally truncate offsets larger than 4GB.
+
+     LLVM 15 detects the overflow and errors out instead; see LLVM commit
+     f8df8114715b ("[DWP][DWARF] Detect and error on debug info offset
+     overflow").  However, lldb in LLVM 16 supports using dwp files with
+     truncated offsets by recovering them directly from the unit headers in the
+     .debug_info.dwo section; see LLVM commit c0db06227721 ("[DWARFLibrary] Add
+     support to re-construct cu-index").  Since LLVM 17, the overflow error can
+     be turned into a warning instead; see LLVM commit 53a483cee801 ("[DWP] add
+     overflow check for llvm-dwp tools if offset overflow").
+
+     LLVM's support for > 4GB offsets is effectively an extension to the DWARF
+     package file format, which we implement here.  The strategy is to walk the
+     unit headers in .debug_info.dwo in lockstep with the DW_SECT_INFO columns
+     in the section offset tables.  As long as they are in the same order
+     (which they are in practice for both GNU dwp and llvm-dwp), we can
+     correlate the truncated offset and produce a corrected array of offsets.
+
+     Note that this will be fixed properly in DWARF 6:
+     https://dwarfstd.org/issues/220708.2.html.  */
+  if (index->sections[DW_SECT_INFO - 1] != UINT32_MAX
+      && dbg->sectiondata[IDX_debug_info]->d_size > UINT32_MAX)
+    {
+      Dwarf_Package_Index *cu_index, *tu_index = NULL;
+      if (tu)
+	{
+	  tu_index = index;
+	  assert (dbg->cu_index == NULL);
+	  cu_index = __libdw_read_package_index (dbg, false);
+	  if (cu_index == NULL)
+	    {
+	      free(index);
+	      return NULL;
+	    }
+	}
+      else
+	{
+	  cu_index = index;
+	  if (dbg->sectiondata[IDX_debug_tu_index] != NULL
+	      && dbg->sectiondata[IDX_debug_types] == NULL)
+	    {
+	      assert (dbg->tu_index == NULL);
+	      tu_index = __libdw_read_package_index (dbg, true);
+	      if (tu_index == NULL)
+		{
+		  free(index);
+		  return NULL;
+		}
+	    }
+	}
+
+      cu_index->debug_info_offsets = malloc (cu_index->unit_count
+					     * sizeof (Dwarf_Off));
+      if (cu_index->debug_info_offsets == NULL)
+	{
+	  free (tu_index);
+	  free (cu_index);
+	  __libdw_seterrno (DWARF_E_NOMEM);
+	  return NULL;
+	}
+      if (tu_index != NULL)
+	{
+	  tu_index->debug_info_offsets = malloc (tu_index->unit_count
+						 * sizeof (Dwarf_Off));
+	  if (tu_index->debug_info_offsets == NULL)
+	    {
+	      free (tu_index);
+	      free (cu_index->debug_info_offsets);
+	      free (cu_index);
+	      __libdw_seterrno (DWARF_E_NOMEM);
+	      return NULL;
+	    }
+	}
+
+      Dwarf_Off off = 0;
+      uint32_t cui = 0, tui = 0;
+      uint32_t cu_count = cu_index->unit_count;
+      const unsigned char *cu_offset
+	= cu_index->section_offsets + cu_index->sections[DW_SECT_INFO - 1] * 4;
+      uint32_t tu_count = 0;
+      const unsigned char *tu_offset;
+      if (tu_index != NULL)
+	{
+	  tu_count = tu_index->unit_count;
+	  tu_offset = tu_index->section_offsets
+		      + tu_index->sections[DW_SECT_INFO - 1] * 4;
+	}
+      while (cui < cu_count || tui < tu_count)
+	{
+	  Dwarf_Off next_off;
+	  uint8_t unit_type;
+	  if (__libdw_next_unit (dbg, false, off, &next_off, NULL, NULL,
+				 &unit_type, NULL, NULL, NULL, NULL, NULL)
+	      != 0)
+	    {
+	    not_sorted:
+	      free (cu_index->debug_info_offsets);
+	      cu_index->debug_info_offsets = NULL;
+	      if (tu_index != NULL)
+		{
+		  free (tu_index->debug_info_offsets);
+		  tu_index->debug_info_offsets = NULL;
+		}
+	      break;
+	    }
+	  if (unit_type != DW_UT_split_type && cui < cu_count)
+	    {
+	      if ((off & UINT32_MAX) != read_4ubyte_unaligned (dbg, cu_offset))
+		goto not_sorted;
+	      cu_index->debug_info_offsets[cui++] = off;
+	      cu_offset += cu_index->section_count * 4;
+	    }
+	  else if (unit_type == DW_UT_split_type && tui < tu_count)
+	    {
+	      if ((off & UINT32_MAX) != read_4ubyte_unaligned (dbg, tu_offset))
+		goto not_sorted;
+	      tu_index->debug_info_offsets[tui++] = off;
+	      tu_offset += tu_index->section_count * 4;
+	    }
+	  off = next_off;
+	}
+
+      if (tu)
+	dbg->cu_index = cu_index;
+      else if (tu_index != NULL)
+	dbg->tu_index = tu_index;
+    }
+
   if (tu)
     dbg->tu_index = index;
   else
@@ -244,8 +378,13 @@ __libdw_dwp_section_info (Dwarf_Package_Index *index, uint32_t unit_row,
   size_t i = (size_t)(unit_row - 1) * index->section_count
 	     + index->sections[section - 1];
   if (offsetp != NULL)
-    *offsetp = read_4ubyte_unaligned (index->dbg,
-				      index->section_offsets + i * 4);
+    {
+      if (section == DW_SECT_INFO && index->debug_info_offsets != NULL)
+	*offsetp = index->debug_info_offsets[unit_row - 1];
+      else
+	*offsetp = read_4ubyte_unaligned (index->dbg,
+					  index->section_offsets + i * 4);
+    }
   if (sizep != NULL)
     *sizep = read_4ubyte_unaligned (index->dbg,
 				    index->section_sizes + i * 4);
diff --git a/libdw/dwarf_end.c b/libdw/dwarf_end.c
index 78224ddb..ed8d27be 100644
--- a/libdw/dwarf_end.c
+++ b/libdw/dwarf_end.c
@@ -40,6 +40,17 @@
 #include "cfi.h"
 
 
+static void
+dwarf_package_index_free (Dwarf_Package_Index *index)
+{
+  if (index != NULL)
+    {
+      free (index->debug_info_offsets);
+      free (index);
+    }
+}
+
+
 static void
 noop_free (void *arg __attribute__ ((unused)))
 {
@@ -79,8 +90,8 @@ dwarf_end (Dwarf *dwarf)
 {
   if (dwarf != NULL)
     {
-      free (dwarf->tu_index);
-      free (dwarf->cu_index);
+      dwarf_package_index_free (dwarf->tu_index);
+      dwarf_package_index_free (dwarf->cu_index);
 
       if (dwarf->cfi != NULL)
 	/* Clean up the CFI cache.  */
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index bdbf5e5a..422e7bb8 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -371,6 +371,9 @@ typedef struct Dwarf_Package_Index_s
   const unsigned char *indices;
   const unsigned char *section_offsets;
   const unsigned char *section_sizes;
+  /* If DW_SECT_INFO section offsets were truncated to 32 bits, recovered
+     64-bit offsets.  */
+  Dwarf_Off *debug_info_offsets;
 } Dwarf_Package_Index;
 
 /* Used in GNU DebugFission for DWARF 4.  Reserved in DWARF 5.  */
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 93503f57..d899cac8 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -26,6 +26,13 @@
 	testfile-dwp-4-strict.
 	* run-get-units-split.sh: Check testfile-dwp-5, testfile-dwp-4, and
 	testfile-dwp-4-strict.
+	* testfile-dwp-4-cu-index-overflow.bz2: New test file.
+	* testfile-dwp-4-cu-index-overflow.dwp.bz2: New test file.
+	* testfile-dwp-5-cu-index-overflow.bz2: New test file.
+	* testfile-dwp-5-cu-index-overflow.dwp.bz2: New test file.
+	* testfile-dwp-cu-index-overflow.source: New file.
+	* run-large-elf-file.sh: Check testfile-dwp-5-cu-index-overflow and
+	testfile-dwp-4-cu-index-overflow.
 
 2023-04-21  Frank Ch. Eigler <fche@redhat.com>
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0938882b..c62e7d4c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -633,7 +633,11 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
 	     testfile-dwp-4.bz2 testfile-dwp-4.dwp.bz2 \
 	     testfile-dwp-4-strict.bz2 testfile-dwp-4-strict.dwp.bz2 \
 	     testfile-dwp-5.bz2 testfile-dwp-5.dwp.bz2 testfile-dwp.source \
-	     run-cu-dwp-section-info.sh
+	     run-cu-dwp-section-info.sh testfile-dwp-5-cu-index-overflow \
+	     testfile-dwp-5-cu-index-overflow.dwp \
+	     testfile-dwp-4-cu-index-overflow \
+	     testfile-dwp-4-cu-index-overflow.dwp \
+	     testfile-dwp-cu-index-overflow.source
 
 
 if USE_VALGRIND
diff --git a/tests/run-large-elf-file.sh b/tests/run-large-elf-file.sh
index 7116de53..8108cb4b 100755
--- a/tests/run-large-elf-file.sh
+++ b/tests/run-large-elf-file.sh
@@ -122,4 +122,178 @@ test_file testfile38
 # 64bit, big endian, non-rel
 test_file testfile27
 
+# See testfile-dwp-cu-index-overflow.source
+testfiles testfile-dwp-5-cu-index-overflow testfile-dwp-5-cu-index-overflow.dwp
+
+testrun_compare ${abs_builddir}/cu-dwp-section-info testfile-dwp-5-cu-index-overflow.dwp << EOF
+file: testfile-dwp-5-cu-index-overflow.dwp
+INFO: 0x0 0x8000004c
+TYPES: 0x0 0x0
+ABBREV: 0x0 0x50
+LINE: 0x0 0x61
+LOCLISTS: 0x0 0x0
+STR_OFFSETS: 0x0 0x1c
+MACRO: 0x0 0x0
+RNGLISTS: 0x0 0x0
+
+INFO: 0x8000004c 0x6f
+TYPES: 0x0 0x0
+ABBREV: 0x50 0x15e
+LINE: 0x61 0x63
+LOCLISTS: 0x0 0xd4
+STR_OFFSETS: 0x1c 0x24
+MACRO: 0x0 0x0
+RNGLISTS: 0x0 0x22
+
+INFO: 0x800000bb 0xff
+TYPES: 0x0 0x0
+ABBREV: 0x50 0x15e
+LINE: 0x61 0x63
+LOCLISTS: 0x0 0xd4
+STR_OFFSETS: 0x1c 0x24
+MACRO: 0x0 0x0
+RNGLISTS: 0x0 0x22
+
+INFO: 0x800001ba 0x8000004c
+TYPES: 0x0 0x0
+ABBREV: 0x1ae 0x50
+LINE: 0xc4 0x61
+LOCLISTS: 0x0 0x0
+STR_OFFSETS: 0x40 0x1c
+MACRO: 0x0 0x0
+RNGLISTS: 0x0 0x0
+
+INFO: 0x100000206 0x6c
+TYPES: 0x0 0x0
+ABBREV: 0x1fe 0xc8
+LINE: 0x125 0x63
+LOCLISTS: 0x0 0x0
+STR_OFFSETS: 0x5c 0x20
+MACRO: 0x0 0x0
+RNGLISTS: 0x0 0x0
+
+INFO: 0x100000272 0x6f
+TYPES: 0x0 0x0
+ABBREV: 0x1fe 0xc8
+LINE: 0x125 0x63
+LOCLISTS: 0x0 0x0
+STR_OFFSETS: 0x5c 0x20
+MACRO: 0x0 0x0
+RNGLISTS: 0x0 0x0
+
+INFO: 0x1000002e1 0x182
+TYPES: 0x0 0x0
+ABBREV: 0x2c6 0x188
+LINE: 0x188 0x65
+LOCLISTS: 0xd4 0xee
+STR_OFFSETS: 0x7c 0x44
+MACRO: 0x0 0x0
+RNGLISTS: 0x22 0x43
+
+EOF
+
+testrun_compare ${abs_builddir}/get-units-split testfile-dwp-5-cu-index-overflow << EOF
+file: testfile-dwp-5-cu-index-overflow
+Got cudie unit_type: 4
+Found a skeleton unit, with split die: filler1.cc
+Got cudie unit_type: 4
+Found a skeleton unit, with split die: foo.cc
+Got cudie unit_type: 4
+Found a skeleton unit, with split die: filler2.cc
+Got cudie unit_type: 4
+Found a skeleton unit, with split die: bar.cc
+Got cudie unit_type: 4
+Found a skeleton unit, with split die: main.cc
+
+EOF
+
+rm -f testfile-dwp-5-cu-index-overflow testfile-dwp-5-cu-index-overflow.dwp
+
+# See testfile-dwp-cu-index-overflow.source
+testfiles testfile-dwp-4-cu-index-overflow testfile-dwp-4-cu-index-overflow.dwp
+
+testrun_compare ${abs_builddir}/cu-dwp-section-info testfile-dwp-4-cu-index-overflow.dwp << EOF
+file: testfile-dwp-4-cu-index-overflow.dwp
+INFO: 0x0 0x8000004b
+TYPES: 0x0 0x0
+ABBREV: 0x0 0x58
+LINE: 0x0 0x2c
+LOCLISTS: 0x0 0x0
+STR_OFFSETS: 0x0 0x14
+MACRO: 0x0 0x0
+RNGLISTS: 0x0 0x0
+
+INFO: 0x8000004b 0x116
+TYPES: 0x0 0x0
+ABBREV: 0x58 0x16f
+LINE: 0x2c 0x34
+LOCLISTS: 0x0 0x110
+STR_OFFSETS: 0x14 0x1c
+MACRO: 0x0 0x0
+RNGLISTS: 0x0 0x0
+
+INFO: 0x80000161 0x8000004b
+TYPES: 0x0 0x0
+ABBREV: 0x1c7 0x58
+LINE: 0x60 0x2c
+LOCLISTS: 0x0 0x0
+STR_OFFSETS: 0x30 0x14
+MACRO: 0x0 0x0
+RNGLISTS: 0x0 0x0
+
+INFO: 0x1000001ac 0x6e
+TYPES: 0x0 0x0
+ABBREV: 0x21f 0xd4
+LINE: 0x8c 0x34
+LOCLISTS: 0x0 0x0
+STR_OFFSETS: 0x44 0x18
+MACRO: 0x0 0x0
+RNGLISTS: 0x0 0x0
+
+INFO: 0x10000021a 0x1b5
+TYPES: 0x0 0x0
+ABBREV: 0x2f3 0x19b
+LINE: 0xc0 0x35
+LOCLISTS: 0x110 0x12a
+STR_OFFSETS: 0x5c 0x3c
+MACRO: 0x0 0x0
+RNGLISTS: 0x0 0x0
+
+INFO: 0x0 0x0
+TYPES: 0x0 0x6e
+ABBREV: 0x58 0x16f
+LINE: 0x2c 0x34
+LOCLISTS: 0x0 0x110
+STR_OFFSETS: 0x14 0x1c
+MACRO: 0x0 0x0
+RNGLISTS: 0x0 0x0
+
+INFO: 0x0 0x0
+TYPES: 0x6e 0x6b
+ABBREV: 0x21f 0xd4
+LINE: 0x8c 0x34
+LOCLISTS: 0x0 0x0
+STR_OFFSETS: 0x44 0x18
+MACRO: 0x0 0x0
+RNGLISTS: 0x0 0x0
+
+EOF
+
+testrun_compare ${abs_builddir}/get-units-split testfile-dwp-4-cu-index-overflow << EOF
+file: testfile-dwp-4-cu-index-overflow
+Got cudie unit_type: 4
+Found a skeleton unit, with split die: filler1.cc
+Got cudie unit_type: 4
+Found a skeleton unit, with split die: foo.cc
+Got cudie unit_type: 4
+Found a skeleton unit, with split die: filler2.cc
+Got cudie unit_type: 4
+Found a skeleton unit, with split die: bar.cc
+Got cudie unit_type: 4
+Found a skeleton unit, with split die: main.cc
+
+EOF
+
+rm -f testfile-dwp-4-cu-index-overflow testfile-dwp-4-cu-index-overflow.dwp
+
 exit 0
diff --git a/tests/testfile-dwp-4-cu-index-overflow.bz2 b/tests/testfile-dwp-4-cu-index-overflow.bz2
new file mode 100755
index 0000000000000000000000000000000000000000..2aaa4f40b8d0bacf75f617a9ad642a6ead10a6ef
GIT binary patch
literal 4490
zcmV;55q0iDT4*^jL0KkKS;k-Cc>o)=|NsC0|NZ~}|NsC0|NH;{|M&kt?f>n5|9$`N
z=j{Lg|9{{RZ<ao}(My`Dk55m&`;Cm=F`~7;?t4tw^M=|%wA58qNmbmQn&8O@rqNGn
zFbI>`Bs^2d%5OzKMLb0Eo+Q)KW~0duQKmt)4^zn+Jxq^K#M(_gL7+CF>SzJ9jT${e
zBh(Cl^#Bb6)M9#`q2(HEpwR**YBFg(O&cJlnx2y<>Kac_dYeQ%lT1hIPt=X5dV^{-
zdYJ$NAT$7afHcqm4^g3rWXKHw4F{+I00w{&Q^7>k%|;Uw6GoT-m=g%ZGHHNJCYoYk
z353F8dWHmPp^=Gzn3)WkX^_atiG*N=34jP`h|?oOK~(h+4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FVY(<ds?s%f*(TlHDGRjG!(+-5Ez%zvoL7ULyDFqYzD>(7#AszH1cHL>GoTC8T`v`
zKS`GP?A+?9b5SVn+GC(+o2FTbL5=4;-P~N_Q10HFislyUmTw7h8(ttWzHNrDx#Sw=
z#NI!I$C+v&j&j^k%c7M0%cgYkX3?8M5LZaG-Tvo&%w1Xox<RkIZ8jZaN1|(fF=S9<
cv5k{-!`^WyR8f~#y8q(tNT&)C7|Z-GAc(;2K>z>%

literal 0
HcmV?d00001

diff --git a/tests/testfile-dwp-4-cu-index-overflow.dwp.bz2 b/tests/testfile-dwp-4-cu-index-overflow.dwp.bz2
new file mode 100644
index 0000000000000000000000000000000000000000..0718c1b2c40310655cdb78ae9859b7b682a5fcaf
GIT binary patch
literal 5584
zcmeHL`#aP98~@Bk8^eq-qZ(tjg@z%bcB1Au4G&Tl$>vZgdZZp9!a}1tt<s!^970h#
zcu3^XVKU`VNQqQWo{mpczUuq^{te&n5AOGM-Pe6x_x--E_jO<Q>vg}bH$8x7XF>DF
zbNn}Ty>L`akS+bRAHN^@zO?wZX@2R;#N<3#l1QZz+LaU_*h0Vy$_9_u+g!rI$HY&J
za`{^Ci}96G;e5_q{3%VZxmCFoN))ZK)X|fzlm#l2ud0^H^;l)jiF_EkQd%i3tQ6Rk
z%mDyM0#JZo#shMY-k)9g(xNqN8BeB50l-w5Y&i*%EEhpA!Q6k>{q)dV<YjLtfMGnD
zJ!?uN10~I1D!>C|%V*iF*n?Glfft)cNVww%zZ4xY(hl0m!zz<9h^HEGIUt|hZql_*
zq`w8PKUrrZ_g<YPh1fhjb^Jr~0#*P8IeBevY)okp8r0a-ih`PG&=4b6`1M@N*e1)2
zN46+R_cp`psnuspPfSZktf@}!EtGEY%SMJ?Bt(JEg4UIx%D5-;(BO!)^s&+$O`<So
zj<0eQmwUFx62Z~6<Ov8<)|a3A4tp3@R-^5+JMKJrZTGGcQ*^=cx4H{AhkSNu<w@sI
zR4;FrhlZ<MomsQ7_w=p>Bt+J~O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D>CAh78JT{B?stjI#l+
zfCC=FsDx$CZckp4_~|NP6B9z4=^1Y7lhY?A1@pw%+im3F(o=wRZ`=L$7&849XL^5m
zuW*bPs2M<N`t<>Kg6Kql;!datlwc}CIqTL{Xb6c~0+oWrp_YwTa$7lQ2I!I%h5=NP
z>H324V6S*!z4;wbyxa$lM8bB;FAacWnwBNEa@kfm`ew0Tl$<bc1*{4J!l@JhE%&Q5
z|EN3{u|g@6Pgkl@sj!+Zy+7joGk%Y)NV84afO_!43-f%5ms>TGVCI!Tq;*)P96d$^
zG>fAG<*W(tms)v)Zb|{KCGEh8e*OrU0L+S%66PjyFjt|sa#({7=gWFF%+k0Mi+?xM
zYB5XzR_;84DIJ&>3`z8JQkgu?8r0@Z^U6?|f-)fbtJ^3K633kW`PwAXQ%ZM34+@?u
zJI9_9=h0AxmJOJufT`gr-Tc5PkgBaTK;I$lK6{l+oXDyii+RM#e_G6#Br@8*uwn%q
z|F)gd{?nHz3J}qe)JYi+qVtC?l5euFGKfkg2reLyL<WX-sKRM2fGB}ReSa1-WuH2n
zbdLvLlb*{uLzdhuMtN#<32-VBRKI@Vk7jixygi$`=pChIS<JQ)D~*sFo=*4h^IU<x
zHjnF+f{Gt@LYPpNi14d^#4%kht96+Q7z79h97l-duf^u^@1g_9K+U`OQeo^`J(FC)
eiyaLXv9Se&FXq;zt~I*<_`8xR!i0lpwgQk5HZ@-W

literal 0
HcmV?d00001

diff --git a/tests/testfile-dwp-5-cu-index-overflow.dwp.bz2 b/tests/testfile-dwp-5-cu-index-overflow.dwp.bz2
new file mode 100644
index 0000000000000000000000000000000000000000..dce34e3f51d637e4773c3c8e4ebeb4666b4c0571
GIT binary patch
literal 5790
zcmeHL`B#!#7k(K;P%)g5>I+eEC`yUUxLGd<s3eJFnhmH_s9~mMWrLuEWKKC0k|rsc
z1C^DP+Td`_xdOGcv~H$0ShqB@x^~OYd;f{=`@!?WS$nPLoM-K|*WS-L>!EKJtZ}A=
z5dA~Cy58CAB*Bwr=h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ejpcG@?8-BK5^%9A4D7C}%v~liYq9SM!?2A9&9hXmiFzR)`gD36h59nq
zE0d=k?9}w8>}!$gO4&O8_72PqrNa7ihX|oJ=pu0#ytj^o>~;yhUSe-vy>qADc_pf@
zs-r1lIhK=?nX#ZT<=`3fB#q(9u-Y1fQ+Wxl;W{P&xlDk5?7!vaxuXDLjPT`Kb8`wo
z+*PKx6UZ6dn<R>mXg8dgoa)4*vN>yRU4Hm2hWP^90KNKVOTO%<L!fpwKkR`Hr`O-%
zZaS<u-ez=I^>YFNE2GzrIKk4P?UVN1zg~9Me;B%9v@|-+x9|vBdvwGoSZbPu{-s*{
z3@MmO?NtObN8jFQwH@GZ<Wc!BAd2eqgaK|!A$Xpoz6>qR1BvYXG(&Jn+@fhHWbJ`c
z`P+AeR$fbnky{tm91{d-TlynDQbj>>Ua^c3KN}cJ)D|s0!(M5xrV-SBhk&(W-UO9*
ztF%|l6*g5|C=r3QJvSXavlk|?ZKc@`kIMBb<a%TTeWj<y`Pbg6>|Q<zn0&PN;(OME
zEzc}x>n`@z)3<<Or!R*4Axms)&*%#OKI;74G%_h;G5+rBP}YICQN#)hCwTqd8ffuX
ZQVs!Wj1ebEH_TeZF<rUYrnf)Q{|jo{jkEv&

literal 0
HcmV?d00001

diff --git a/tests/testfile-dwp-cu-index-overflow.source b/tests/testfile-dwp-cu-index-overflow.source
new file mode 100644
index 00000000..2de15441
--- /dev/null
+++ b/tests/testfile-dwp-cu-index-overflow.source
@@ -0,0 +1,86 @@
+# Dummy program that we patch to generate a dwp file with more than 4GB of
+# .debug_info.
+
+# Generate 2 dummy files that result in DWARF blocks.
+$ for (( i = 1; i <= 2; i++ )); do echo 'constexpr int filler'$i'[] = { 1 };' > filler$i.cc; done
+$ g++ -O2 -g -gsplit-dwarf -fdebug-types-section -dA -S filler{1,2}.cc foo.cc bar.cc main.cc
+# Patch the DWARF blocks to be 2GB.
+$ for (( i = 1; i <= 2; i++ )); do patch -p1 << EOF
+--- a/filler$i.s
++++ b/filler$i.s
+@@ -7,5 +7,5 @@
+ 	.section	.debug_info.dwo,"e",@progbits
+ .Ldebug_info0:
+-	.long	0x49	# Length of Compilation Unit Info
++	.long	0x80000048	# Length of Compilation Unit Info
+ 	.value	0x5	# DWARF version number
+ 	.byte	0x5	# DW_UT_split_compile
+@@ -51,9 +51,6 @@
+ 	.long	0x29	# DW_AT_type
+ 			# DW_AT_const_expr
+-	.byte	0x4	# DW_AT_const_value
+-	.byte	0x1	# fp or vector constant word 0
+-	.byte	0	# fp or vector constant word 1
+-	.byte	0	# fp or vector constant word 2
+-	.byte	0	# fp or vector constant word 3
++	.long	0x80000000	# DW_AT_const_value
++	.fill	0x80000000
+ 	.byte	0	# end of children of DIE 0x14
+ 	.section	.debug_info,"",@progbits
+@@ -171,5 +168,5 @@
+ 	.uleb128 0x19	# (DW_FORM_flag_present)
+ 	.uleb128 0x1c	# (DW_AT_const_value)
+-	.uleb128 0xa	# (DW_FORM_block1)
++	.uleb128 0x4	# (DW_FORM_block4)
+ 	.byte	0
+ 	.byte	0
+EOF
+done
+$ for (( i = 1; i <= 2; i++ )); do as filler$i.s -o filler$i.o; done
+$ as foo.s -o foo.o
+$ as bar.s -o bar.o
+$ as main.s -o main.o
+$ g++ filler1.o foo.o filler2.o bar.o main.o -o testfile-dwp-5-cu-index-overflow
+# -continue-on-cu-index-overflow was added in LLVM 17:
+# https://reviews.llvm.org/D144565.
+$ llvm-dwp -continue-on-cu-index-overflow filler1.o foo.o filler2.o bar.o main.o -o testfile-dwp-5-cu-index-overflow.dwp
+
+# Same thing for DWARF 4.
+$ g++ -O2 -g -gdwarf-4 -gsplit-dwarf -fdebug-types-section -dA -S filler{1,2}.cc foo.cc bar.cc main.cc
+$ for (( i = 1; i <= 2; i++ )); do patch -p1 << EOF
+--- a/filler$i.s
++++ b/filler$i.s
+@@ -6,5 +6,5 @@
+ 	.section	.debug_info.dwo,"e",@progbits
+ .Ldebug_info0:
+-	.long	0x48	# Length of Compilation Unit Info
++	.long	0x80000047	# Length of Compilation Unit Info
+ 	.value	0x4	# DWARF version number
+ 	.long	.Ldebug_abbrev0	# Offset Into Abbrev. Section
+@@ -49,9 +49,6 @@
+ 	.long	0x28	# DW_AT_type
+ 			# DW_AT_const_expr
+-	.byte	0x4	# DW_AT_const_value
+-	.byte	0x1	# fp or vector constant word 0
+-	.byte	0	# fp or vector constant word 1
+-	.byte	0	# fp or vector constant word 2
+-	.byte	0	# fp or vector constant word 3
++	.long	0x80000000	# DW_AT_const_value
++	.fill	0x80000000
+ 	.byte	0	# end of children of DIE 0xb
+ 	.section	.debug_info,"",@progbits
+@@ -172,5 +169,5 @@
+ 	.uleb128 0x19	# (DW_FORM_flag_present)
+ 	.uleb128 0x1c	# (DW_AT_const_value)
+-	.uleb128 0xa	# (DW_FORM_block1)
++	.uleb128 0x4	# (DW_FORM_block4)
+ 	.byte	0
+ 	.byte	0
+EOF
+done
+$ for (( i = 1; i <= 2; i++ )); do as filler$i.s -o filler$i.o; done
+$ as foo.s -o foo.o
+$ as bar.s -o bar.o
+$ as main.s -o main.o
+$ g++ filler1.o foo.o filler2.o bar.o main.o -o testfile-dwp-4-cu-index-overflow
+$ llvm-dwp -continue-on-cu-index-overflow filler1.o foo.o filler2.o bar.o main.o -o testfile-dwp-4-cu-index-overflow.dwp
-- 
2.41.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 00/14] elfutils: DWARF package (.dwp) file support
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
                   ` (13 preceding siblings ...)
  2023-09-27 18:21 ` [PATCH 14/14] libdw: Handle overflowed DW_SECT_INFO offsets in DWARF package file indexes Omar Sandoval
@ 2023-09-27 19:20 ` Frank Ch. Eigler
  2023-09-27 20:17   ` Omar Sandoval
  2023-10-03 21:54 ` Mark Wielaard
  2023-11-02 23:05 ` Mark Wielaard
  16 siblings, 1 reply; 38+ messages in thread
From: Frank Ch. Eigler @ 2023-09-27 19:20 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: elfutils-devel

Hi -

> This patch series adds support for DWARF package files to libdw and the
> elfutils tools. It supports the GNU DebugFission format for DWARF 4 [1]
> and the format standardized in DWARF 5 (section 7.3.5 "DWARF Package
> Files"). It supports both automatically opening the .dwp file for a
> skeleton unit and examining the .dwp file alone, just like for .dwo
> files. [...]

Does this work have any implications for debuginfod?

- FChE


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 00/14] elfutils: DWARF package (.dwp) file support
  2023-09-27 19:20 ` [PATCH 00/14] elfutils: DWARF package (.dwp) file support Frank Ch. Eigler
@ 2023-09-27 20:17   ` Omar Sandoval
  0 siblings, 0 replies; 38+ messages in thread
From: Omar Sandoval @ 2023-09-27 20:17 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: elfutils-devel

On Wed, Sep 27, 2023 at 03:20:40PM -0400, Frank Ch. Eigler wrote:
> Hi -
> 
> > This patch series adds support for DWARF package files to libdw and the
> > elfutils tools. It supports the GNU DebugFission format for DWARF 4 [1]
> > and the format standardized in DWARF 5 (section 7.3.5 "DWARF Package
> > Files"). It supports both automatically opening the .dwp file for a
> > skeleton unit and examining the .dwp file alone, just like for .dwo
> > files. [...]
> 
> Does this work have any implications for debuginfod?

Until anyone using debuginfod wants to use DWARF package files, not
really. The problems that split DWARF solves aren't super relevant to
Linux distributions, so I don't expect that will happen any time soon.

If that changes, then debuginfod could add a /$build_id/debuginfo.dwp
endpoint. Note that dwp files don't contain a build ID note. They are
associated with the main debug file only by name. To quote the DWARF 5
standard: "a package file is typically placed in the same directory as
the application, and is given the same name with a '.dwp' extension."

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 01/14] libdw: Make try_split_file static
  2023-09-27 18:20 ` [PATCH 01/14] libdw: Make try_split_file static Omar Sandoval
@ 2023-10-03 16:09   ` Mark Wielaard
  0 siblings, 0 replies; 38+ messages in thread
From: Mark Wielaard @ 2023-10-03 16:09 UTC (permalink / raw)
  To: Omar Sandoval, elfutils-devel

Hi Omar,

On Wed, 2023-09-27 at 11:20 -0700, Omar Sandoval wrote:
> It's only used in libdw_find_split_unit.c.

Obvious correct. Applied.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 02/14] libdw: Handle split DWARF in dwarf_entrypc
  2023-09-27 18:20 ` [PATCH 02/14] libdw: Handle split DWARF in dwarf_entrypc Omar Sandoval
@ 2023-10-03 16:10   ` Mark Wielaard
  0 siblings, 0 replies; 38+ messages in thread
From: Mark Wielaard @ 2023-10-03 16:10 UTC (permalink / raw)
  To: Omar Sandoval, elfutils-devel

Hi Omar,

On Wed, 2023-09-27 at 11:20 -0700, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> If a DIE has no DW_AT_entry_pc attribute, dwarf_entrypc looks for
> DW_AT_low_pc in that DIE.  But for a split compilation unit DIE,
> DW_AT_low_pc is in the corresponding skeleton DIE, so this fails.
> dwarf_lowpc already handles this fallback, so use it instead.

Nice find. Also interesting varlocs already "tested" for that and we
hadn't noticed before. Applied.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 03/14] libdw: Handle DW_AT_ranges in split DWARF 5 skeleton in dwarf_ranges
  2023-09-27 18:20 ` [PATCH 03/14] libdw: Handle DW_AT_ranges in split DWARF 5 skeleton in dwarf_ranges Omar Sandoval
@ 2023-10-03 16:10   ` Mark Wielaard
  0 siblings, 0 replies; 38+ messages in thread
From: Mark Wielaard @ 2023-10-03 16:10 UTC (permalink / raw)
  To: Omar Sandoval, elfutils-devel

Hi Omar,

On Wed, 2023-09-27 at 11:20 -0700, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> When commit 879f3a4f99df ("libdw: Handle .debug_rnglists in
> dwarf_ranges.") added support for split DWARF 5 in 2018, GCC put all
> range lists for split DWARF in the .debug_rnglists section of the
> skeleton file (similarly to GNU DebugFission, which puts all range lists
> in .debug_ranges in the skeleton file).
> 
> In 2021, after a discussion on the dwarf-discuss mailing list [1], GCC
> changed this to match Clang's behavior.  Now, ranges are in
> .debug_rnglists.dwo in the split file, _except_ for one: the skeleton
> unit DIE has a DW_AT_ranges attribute, and its ranges are in
> .debug_rnglists in the skeleton file.  See GCC commit 4b33c5aaab9e
> ("dwarf2out: Fix up ranges for -gdwarf-5 -gsplit-dwarf [PR99490]") and
> the Issue 210310.1 clarifying the DWARF standard [2].
> 
> Unfortunately, this confuses dwarf_ranges, which always uses
> .debug_rnglists.dwo if it exists.  Fix it by special casing the unit
> DIE: its range lists should be in .debug_rnglists if that exists, and
> .debug_rnglists.dwo otherwise.
> 
> 1: https://lists.dwarfstd.org/pipermail/dwarf-discuss/2021-March/002009.html
> 2: https://dwarfstd.org/issues/210310.1.html

Thanks for all these references in the commit message.
With that the 2 line change looks good. Applied.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 04/14] libdw: Handle other string forms in dwarf_macro_param2
  2023-09-27 18:20 ` [PATCH 04/14] libdw: Handle other string forms in dwarf_macro_param2 Omar Sandoval
@ 2023-10-03 16:11   ` Mark Wielaard
  0 siblings, 0 replies; 38+ messages in thread
From: Mark Wielaard @ 2023-10-03 16:11 UTC (permalink / raw)
  To: Omar Sandoval, elfutils-devel

Hi Omar,

On Wed, 2023-09-27 at 11:20 -0700, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> dwarf_getmacros handles the additional macro string forms added by DWARF
> 5, but dwarf_macro_param2 doesn't.  Update it with the list of all
> string forms allowed in .debug_macro.  In particular, GCC and Clang
> generate DW_MACRO_define_strx and DW_MACRO_undef_strx, which
> dwarf_macro_param2 couldn't handle.

So as far as I can see this is always only used for DWARF5 forms and
never uses the DW_FORM_GNU_strp_alt or DW_FORM_GNU_str_index because
the GNU DebugFission extension for DWARF4 kept the old macinfo format,
just moved it to the dwo.

Thanks for catching this. Applied.

Cheers,

Mark


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 05/14] libdw: Fix dwarf_macro_getsrcfiles for DWARF 5
  2023-09-27 18:20 ` [PATCH 05/14] libdw: Fix dwarf_macro_getsrcfiles for DWARF 5 Omar Sandoval
@ 2023-10-03 21:29   ` Mark Wielaard
  0 siblings, 0 replies; 38+ messages in thread
From: Mark Wielaard @ 2023-10-03 21:29 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: elfutils-devel

Hi Omar,

On Wed, Sep 27, 2023 at 11:20:54AM -0700, Omar Sandoval wrote:
> Dwarf_Macro_Op_Table::is_64bit conflates the address size and the offset
> size: for .debug_macinfo, it is initialized based on the compilation
> unit's address size, but for .debug_macro, it is initialized based on
> the macro unit's offset size.  is_64bit is used to determine the address
> size to pass to __libdw_getsrclines.  For a 64-bit architecture using
> DWARF 5 with 32-bit offsets (the common case), this fails because
> read_srclines checks that the given address size matches the address
> size from the line number program header.
> 
> Fix it by splitting is_64bit into separate address_size and offset_size
> members.

Very nice catch. You are right that for DWARF5 the line table header
already gives the address_size. It is slightly embarassing our sanity
check here failed. Thanks for fixing.

I had to think a bit on why we didn't need to set the address_size for
the fake_cu. But that is only needed to read address class
forms. Which aren't valid forms in macro data.

Applied,

Mark

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 06/14] libdw: Handle split DWARF in dwarf_macro_getsrcfiles
  2023-09-27 18:20 ` [PATCH 06/14] libdw: Handle split DWARF in dwarf_macro_getsrcfiles Omar Sandoval
@ 2023-10-03 21:49   ` Mark Wielaard
  0 siblings, 0 replies; 38+ messages in thread
From: Mark Wielaard @ 2023-10-03 21:49 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: elfutils-devel

Hi Omar,

On Wed, Sep 27, 2023 at 11:20:55AM -0700, Omar Sandoval wrote:
> Macro information references file names from the line number information
> table, which is tricky in split DWARF for a couple of reasons.
> 
> First, the line number information for a macro unit comes from the
> .debug_line.dwo section in the split file, not the .debug_line section
> in the skeleton file.  This was not specified in the GNU DebugFission
> design document [1] or the DWARF 5 standard, but it is how GCC and Clang
> behave in practice and was clarified in DWARF standard issue
> 200602.1 [2] for the upcoming DWARF 6 standard.
> 
> dwarf_macro_getsrcfiles uses the line number information from whichever
> Dwarf handle it was passed.  This is error-prone, since the most natural
> thing to do is to pass the skeleton Dwarf handle.  Fix this by storing
> the appropriate Dwarf handle in Dwarf_Macro_Op_Table and using that one.

Too bad we cannot fix the function signature because that would be an
API break. But this makes sense (thanks again for the references).

> Second, for .debug_macinfo.dwo in GNU DebugFission (generated by gcc
> -gdwarf-4 -gstrict-dwarf -gsplit-dwarf), the offset into .debug_line.dwo
> is implicitly 0.  Again, this isn't in any specification, but it's how
> GCC behaves in practice (Clang never generates macro information for
> DWARF 4 split DWARF).  Make get_macinfo_table default to 0 for split
> DWARF when it can't find DW_AT_stmt_list.

Makes sense, it cannot really be any other offset than zero.

Applied,

Mark

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 00/14] elfutils: DWARF package (.dwp) file support
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
                   ` (14 preceding siblings ...)
  2023-09-27 19:20 ` [PATCH 00/14] elfutils: DWARF package (.dwp) file support Frank Ch. Eigler
@ 2023-10-03 21:54 ` Mark Wielaard
  2023-11-02 23:05 ` Mark Wielaard
  16 siblings, 0 replies; 38+ messages in thread
From: Mark Wielaard @ 2023-10-03 21:54 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: elfutils-devel

Hi Omar,

On Wed, Sep 27, 2023 at 11:20:49AM -0700, Omar Sandoval wrote:
> This patch series adds support for DWARF package files to libdw and the
> elfutils tools. It supports the GNU DebugFission format for DWARF 4 [1]
> and the format standardized in DWARF 5 (section 7.3.5 "DWARF Package
> Files"). It supports both automatically opening the .dwp file for a
> skeleton unit and examining the .dwp file alone, just like for .dwo
> files.
> 
> Patch 1 is a trivial cleanup I found while developing this. Patches 2-6
> are fixes for unrelated bugs in split DWARF and/or DWARF 5 that I
> encountered while adding test cases for this series. I didn't add test
> cases explicitly for those fixes because they are covered by the dwp
> tests later in the series.
> 
> The actual dwp support is in patches 7-10 and 13, including test cases.
> Patches 11 and 12 enable testing macro information in dwp files. Patch
> 14 adds support and tests for an LLVM extension to the dwp format.

Thanks, I went through patches 1 to 6 and applied them all.

Sorry for the buildbot failures, neither the centos7 x86_64 one, nor
the gentoo sparc one is obviously caused by your patches. And both
were spurious, later builds are green again.

I'll go through the rest later. But there are more unreviewed patches,
so it might take a bit.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 07/14] libdw: Recognize .debug_[ct]u_index sections in dwarf_elf_begin
  2023-09-27 18:20 ` [PATCH 07/14] libdw: Recognize .debug_[ct]u_index sections in dwarf_elf_begin Omar Sandoval
@ 2023-11-01 14:03   ` Mark Wielaard
  2023-11-01 17:30     ` Omar Sandoval
  0 siblings, 1 reply; 38+ messages in thread
From: Mark Wielaard @ 2023-11-01 14:03 UTC (permalink / raw)
  To: Omar Sandoval, elfutils-devel

Hi Omar,

On Wed, 2023-09-27 at 11:20 -0700, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> DWARF package (.dwp) files have a .debug_cu_index section and,
> optionally, a .debug_tu_index section.  Add them to the list of DWARF
> sections.
> 
> Unfortunately, it's not that simple: the other debug sections in a dwp
> file have names ending with .dwo, which confuses the checks introduced
> by commit 5b21e70216b8 ("libdw: dwarf_elf_begin should use either plain,
> dwo or lto DWARF sections.").  So, we also have to special case
> .debug_cu_index and .debug_tu_index in scn_dwarf_type and check_section
> to treat them as TYPE_DWO sections.

This seems to work, but I wonder if we should have a specific TYPE_DWP?
It doesn't really matter now, because the enum dwarf_type is only used
internally. But I was hoping to extend the dwarf_begin interface with a
flag so that you can open a DWARF as a specific type. For example there
are single file split DWARF files. Which contain both "plain" and
".dwo" sections. Currently you can only open them as "plain", but there
are actually two "views" of such files.

https://sourceware.org/bugzilla/show_bug.cgi?id=28573

Do you think there are reasons to open a file as either TYPE_DWO or
TYPE_DWP? Or doesn't that not make sense?

> Signed-off-by: Omar Sandoval <osandov@fb.com>
> ---
>  libdw/ChangeLog         |  8 +++++++
>  libdw/dwarf_begin_elf.c | 53 +++++++++++++++++++++--------------------
>  libdw/libdwP.h          |  2 ++
>  3 files changed, 37 insertions(+), 26 deletions(-)
> 
> diff --git a/libdw/ChangeLog b/libdw/ChangeLog
> index be1e40bc..52327688 100644
> --- a/libdw/ChangeLog
> +++ b/libdw/ChangeLog
> @@ -20,6 +20,14 @@
>  	instead of dbg parameter, which is now unused.
>  	* libdwP.h (Dwarf_Macro_Op_Table): Replace is_64bit with address_size
>  	and offset_size.  Add dbg.
> +	Add IDX_debug_cu_index and IDX_debug_tu_index.
> +	* dwarf_begin_elf.c (dwarf_scnnames): Add IDX_debug_cu_index and
> +	IDX_debug_tu_index.
> +	(scn_to_string_section_idx): Ditto.
> +	(scn_dwarf_type): Check for .debug_cu_index, .debug_tu_index,
> +	.zdebug_cu_index, and .zdebug_tu_index.
> +	(check_section): Change .dwo suffix matching to account for
> +	.debug_cu_index and .debug_tu_index.
>  
>  2023-02-22  Mark Wielaard  <mark@klomp.org>
>  
> diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
> index 92d76d24..7936d343 100644
> --- a/libdw/dwarf_begin_elf.c
> +++ b/libdw/dwarf_begin_elf.c
> @@ -67,6 +67,8 @@ static const char dwarf_scnnames[IDX_last][19] =
>    [IDX_debug_macro] = ".debug_macro",
>    [IDX_debug_ranges] = ".debug_ranges",
>    [IDX_debug_rnglists] = ".debug_rnglists",
> +  [IDX_debug_cu_index] = ".debug_cu_index",
> +  [IDX_debug_tu_index] = ".debug_tu_index",
>    [IDX_gnu_debugaltlink] = ".gnu_debugaltlink"
>  };
>  #define ndwarf_scnnames (sizeof (dwarf_scnnames) / sizeof (dwarf_scnnames[0]))
> @@ -92,6 +94,8 @@ static const enum string_section_index scn_to_string_section_idx[IDX_last] =
>    [IDX_debug_macro] = STR_SCN_IDX_last,
>    [IDX_debug_ranges] = STR_SCN_IDX_last,
>    [IDX_debug_rnglists] = STR_SCN_IDX_last,
> +  [IDX_debug_cu_index] = STR_SCN_IDX_last,
> +  [IDX_debug_tu_index] = STR_SCN_IDX_last,
>    [IDX_gnu_debugaltlink] = STR_SCN_IDX_last
>  };

OK

> @@ -109,6 +113,11 @@ scn_dwarf_type (Dwarf *result, size_t shstrndx, Elf_Scn *scn)
>      {
>        if (startswith (scnname, ".gnu.debuglto_.debug"))
>  	return TYPE_GNU_LTO;
> +      else if (strcmp (scnname, ".debug_cu_index") == 0
> +	       || strcmp (scnname, ".debug_tu_index") == 0
> +	       || strcmp (scnname, ".zdebug_cu_index") == 0
> +	       || strcmp (scnname, ".zdebug_tu_index") == 0)
> +	return TYPE_DWO;
>        else if (startswith (scnname, ".debug_") || startswith (scnname, ".zdebug_"))
>  	{
>  	  size_t len = strlen (scnname);

OK

> @@ -173,42 +182,34 @@ check_section (Dwarf *result, size_t shstrndx, Elf_Scn *scn, bool inscngrp)
>    bool gnu_compressed = false;
>    for (cnt = 0; cnt < ndwarf_scnnames; ++cnt)
>      {
> +      /* .debug_cu_index and .debug_tu_index don't have a .dwo suffix,
> +	 but they are for DWO.  */
> +      if (result->type != TYPE_DWO
> +	  && (cnt == IDX_debug_cu_index || cnt == IDX_debug_tu_index))
> +	continue;
> +      bool need_dot_dwo =
> +	(result->type == TYPE_DWO
> +	 && cnt != IDX_debug_cu_index
> +	 && cnt != IDX_debug_tu_index);
>        size_t dbglen = strlen (dwarf_scnnames[cnt]);
>        size_t scnlen = strlen (scnname);
>        if (strncmp (scnname, dwarf_scnnames[cnt], dbglen) == 0
> -	  && (dbglen == scnlen
> -	      || (scnlen == dbglen + 4
> +	  && ((!need_dot_dwo && dbglen == scnlen)
> +	      || (need_dot_dwo
> +		  && scnlen == dbglen + 4
>  		  && strstr (scnname, ".dwo") == scnname + dbglen)))
> -	{
> -	  if (dbglen == scnlen)
> -	    {
> -	      if (result->type == TYPE_PLAIN)
> -		break;
> -	    }
> -	  else if (result->type == TYPE_DWO)
> -	    break;
> -	}
> +	break;
>        else if (scnname[0] == '.' && scnname[1] == 'z'
>  	       && (strncmp (&scnname[2], &dwarf_scnnames[cnt][1],
>  			    dbglen - 1) == 0
> -		   && (scnlen == dbglen + 1
> -		       || (scnlen == dbglen + 5
> +		   && ((!need_dot_dwo && scnlen == dbglen + 1)
> +		       || (need_dot_dwo
> +			   && scnlen == dbglen + 5
>  			   && strstr (scnname,
>  				      ".dwo") == scnname + dbglen + 1))))
>  	{
> -	  if (scnlen == dbglen + 1)
> -	    {
> -	      if (result->type == TYPE_PLAIN)
> -		{
> -		  gnu_compressed = true;
> -		  break;
> -		}
> -	    }
> -	  else if (result->type <= TYPE_DWO)
> -	    {
> -	      gnu_compressed = true;
> -	      break;
> -	    }
> +	  gnu_compressed = true;
> +	  break;
>  	}
>        else if (scnlen > 14 /* .gnu.debuglto_ prefix. */
>  	       && startswith (scnname, ".gnu.debuglto_")

OK. It took me a bit to realize how this works. But the idea is that we
do two scans over the section names in global_read the first one sets
the result->type and then in the second scan this function is called to
check the found section is part of the type. That we also set
gnu_compressed in this loop makes thing extra funny. But you did
simplify that check. Thanks.

> diff --git a/libdw/libdwP.h b/libdw/libdwP.h
> index 77959b3b..0c44d40c 100644
> --- a/libdw/libdwP.h
> +++ b/libdw/libdwP.h
> @@ -82,6 +82,8 @@ enum
>      IDX_debug_macro,
>      IDX_debug_ranges,
>      IDX_debug_rnglists,
> +    IDX_debug_cu_index,
> +    IDX_debug_tu_index,
>      IDX_gnu_debugaltlink,
>      IDX_last
>    };

OK.

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 07/14] libdw: Recognize .debug_[ct]u_index sections in dwarf_elf_begin
  2023-11-01 14:03   ` Mark Wielaard
@ 2023-11-01 17:30     ` Omar Sandoval
  0 siblings, 0 replies; 38+ messages in thread
From: Omar Sandoval @ 2023-11-01 17:30 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

On Wed, Nov 01, 2023 at 03:03:57PM +0100, Mark Wielaard wrote:
> Hi Omar,
> 
> On Wed, 2023-09-27 at 11:20 -0700, Omar Sandoval wrote:
> > From: Omar Sandoval <osandov@fb.com>
> > 
> > DWARF package (.dwp) files have a .debug_cu_index section and,
> > optionally, a .debug_tu_index section.  Add them to the list of DWARF
> > sections.
> > 
> > Unfortunately, it's not that simple: the other debug sections in a dwp
> > file have names ending with .dwo, which confuses the checks introduced
> > by commit 5b21e70216b8 ("libdw: dwarf_elf_begin should use either plain,
> > dwo or lto DWARF sections.").  So, we also have to special case
> > .debug_cu_index and .debug_tu_index in scn_dwarf_type and check_section
> > to treat them as TYPE_DWO sections.
> 
> This seems to work, but I wonder if we should have a specific TYPE_DWP?

I tried this, and it made check_section even more confusing (because
then we need a more complicated check than result->type == section
type). I came to the same conclusion that since this is internal for
now, it didn't really matter. Although maybe the name TYPE_SPLIT would
make more sense now rather than overloading TYPE_DWO.

When this becomes public, separate TYPE_DWO and TYPE_DWP types might be
nicer so that a hypothetical dwarf_get_type function could tell you
whether you got a dwo file or a dwp file.

> It doesn't really matter now, because the enum dwarf_type is only used
> internally. But I was hoping to extend the dwarf_begin interface with a
> flag so that you can open a DWARF as a specific type. For example there
> are single file split DWARF files. Which contain both "plain" and
> ".dwo" sections. Currently you can only open them as "plain", but there
> are actually two "views" of such files.
> 
> https://sourceware.org/bugzilla/show_bug.cgi?id=28573
> 
> Do you think there are reasons to open a file as either TYPE_DWO or
> TYPE_DWP? Or doesn't that not make sense?

If we were to treat a dwp file as a dwo file, I guess we'd have to
pretend it only contained one unit and ignore the rest, which I don't
think makes much sense. So even if we had separate types for them, I
don't know if we should allow that.

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 08/14] libdw: Parse DWARF package file index sections
  2023-09-27 18:20 ` [PATCH 08/14] libdw: Parse DWARF package file index sections Omar Sandoval
@ 2023-11-01 23:07   ` Mark Wielaard
  2023-11-07  6:45     ` Omar Sandoval
  0 siblings, 1 reply; 38+ messages in thread
From: Mark Wielaard @ 2023-11-01 23:07 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: elfutils-devel

Hi Omar,

On Wed, Sep 27, 2023 at 11:20:57AM -0700, Omar Sandoval wrote:
> The .debug_cu_index and .debug_tu_index sections in DWARF package files
> are basically hash tables mapping a unit's 8 byte signature to an offset
> and size in each section used by that unit [1].  Add support for parsing
> and doing lookups in the index sections.
> 
> We look up a unit in the index when we intern it and cache its hash
> table row in Dwarf_CU.

This looks good. Thanks for the various testcases.

Do I understand correctly that binutils dwp only does the DWARF4 GNU
extension and llvm-dwp only does the DWARF5 standardized format? Maybe
we should create a eu-dwp that does both.

It looks like you are very careful checking boundaries, but it would
be bad to do some fuzzing on this.

> Then, a new function, dwarf_cu_dwp_section_info,
> can be used to look up the section offsets and sizes for a unit.  This
> will mostly be used internally in libdw, but it will also be needed in
> static inline functions shared with eu-readelf.  Additionally, making it
> public it makes dwp support much easier for external tools that do their
> own low-level parsing of DWARF information, like drgn [2].

Although I am not against this new interface, I am not super
enthousiastic about it.

There is one odd part, DW_SECT_TYPES should be defined in dwarf.h with
the other DW_SECT constants, otherwise it cannot be used (unless you
define it yourself to 2).

For eu-readelf we don't really need it being public, it already cheats
a little and uses some (non-public) libdwP.h functions. That is
actually not great either. So if there is a public function that is
available that is actually preferred. But if it is just for
eu-readelf, I don't think it is really needed. And it seems you
haven't actually added the support to eu-readelf to print these
offsets.

It is fine to expose these offsets and sizes, but how exactly are you
using them in drgn? It seems we don't have any other interfaces in
libdw that you can then use these with.

Can we split off this public interface from the rest of this patch?
But then we also need to split off the tests. So maybe keep them together?

> 1: https://gcc.gnu.org/wiki/DebugFissionDWP#Format_of_the_CU_and_TU_Index_Sections
> 2: https://github.com/osandov/drgn
> 
> Signed-off-by: Omar Sandoval <osandov@fb.com>
> ---
>  libdw/ChangeLog                     |  18 +-
>  libdw/Makefile.am                   |   2 +-
>  libdw/dwarf_cu_dwp_section_info.c   | 371 ++++++++++++++++++++++++++++
>  libdw/dwarf_end.c                   |   3 +
>  libdw/dwarf_error.c                 |   1 +
>  libdw/libdw.h                       |  23 ++
>  libdw/libdw.map                     |   5 +
>  libdw/libdwP.h                      |  36 +++
>  libdw/libdw_findcu.c                |   8 +
>  tests/.gitignore                    |   1 +
>  tests/ChangeLog                     |  13 +
>  tests/Makefile.am                   |  11 +-
>  tests/cu-dwp-section-info.c         |  74 ++++++
>  tests/run-cu-dwp-section-info.sh    | 168 +++++++++++++
>  tests/testfile-dwp-4-strict.bz2     | Bin 0 -> 4169 bytes
>  tests/testfile-dwp-4-strict.dwp.bz2 | Bin 0 -> 6871 bytes
>  tests/testfile-dwp-4.bz2            | Bin 0 -> 4194 bytes
>  tests/testfile-dwp-4.dwp.bz2        | Bin 0 -> 10098 bytes
>  tests/testfile-dwp-5.bz2            | Bin 0 -> 4223 bytes
>  tests/testfile-dwp-5.dwp.bz2        | Bin 0 -> 10313 bytes
>  tests/testfile-dwp.source           | 102 ++++++++
>  21 files changed, 831 insertions(+), 5 deletions(-)
>  create mode 100644 libdw/dwarf_cu_dwp_section_info.c
>  create mode 100644 tests/cu-dwp-section-info.c
>  create mode 100755 tests/run-cu-dwp-section-info.sh
>  create mode 100755 tests/testfile-dwp-4-strict.bz2
>  create mode 100644 tests/testfile-dwp-4-strict.dwp.bz2
>  create mode 100755 tests/testfile-dwp-4.bz2
>  create mode 100644 tests/testfile-dwp-4.dwp.bz2
>  create mode 100755 tests/testfile-dwp-5.bz2
>  create mode 100644 tests/testfile-dwp-5.dwp.bz2
>  create mode 100644 tests/testfile-dwp.source
> 
> diff --git a/libdw/ChangeLog b/libdw/ChangeLog
> index 52327688..1d229094 100644
> --- a/libdw/ChangeLog
> +++ b/libdw/ChangeLog
> @@ -20,7 +20,14 @@
>  	instead of dbg parameter, which is now unused.
>  	* libdwP.h (Dwarf_Macro_Op_Table): Replace is_64bit with address_size
>  	and offset_size.  Add dbg.
> -	Add IDX_debug_cu_index and IDX_debug_tu_index.
> +	(Dwarf): Add cu_index and tu_index.
> +	(Dwarf_CU): Add dwp_row.
> +	(Dwarf_Package_Index): New type.
> +	(DW_SECT_TYPES): New macro.
> +	(__libdw_dwp_find_unit): New declaration.
> +	(dwarf_cu_dwp_section_info): New INTDECL.
> +	Add IDX_debug_cu_index and IDX_debug_tu_index.  Add
> +	DWARF_E_UNKNOWN_SECTION.
>  	* dwarf_begin_elf.c (dwarf_scnnames): Add IDX_debug_cu_index and
>  	IDX_debug_tu_index.
>  	(scn_to_string_section_idx): Ditto.
> @@ -28,6 +35,15 @@
>  	.zdebug_cu_index, and .zdebug_tu_index.
>  	(check_section): Change .dwo suffix matching to account for
>  	.debug_cu_index and .debug_tu_index.
> +	* Makefile.am (libdw_a_SOURCES): Add dwarf_cu_dwp_section_info.c.
> +	* dwarf_end.c (dwarf_end): Free dwarf->cu_index and dwarf->tu_index.
> +	* dwarf_error.c (errmsgs): Add DWARF_E_UNKNOWN_SECTION.
> +	* libdw.h (dwarf_cu_dwp_section_info): New declaration.
> +	* libdw.map (ELFUTILS_0.190): Add dwarf_cu_dwp_section_info.
> +	* libdw_findcu.c (__libdw_intern_next_unit): Call
> +	__libdw_dwp_find_unit, and use it to adjust abbrev_offset and assign
> +	newp->dwp_row.
> +	* dwarf_cu_dwp_section_info.c: New file.
>  
>  2023-02-22  Mark Wielaard  <mark@klomp.org>
>  
> diff --git a/libdw/Makefile.am b/libdw/Makefile.am
> index e548f38c..5363c02a 100644
> --- a/libdw/Makefile.am
> +++ b/libdw/Makefile.am
> @@ -93,7 +93,7 @@ libdw_a_SOURCES = dwarf_begin.c dwarf_begin_elf.c dwarf_end.c dwarf_getelf.c \
>  		  dwarf_cu_die.c dwarf_peel_type.c dwarf_default_lower_bound.c \
>  		  dwarf_die_addr_die.c dwarf_get_units.c \
>  		  libdw_find_split_unit.c dwarf_cu_info.c \
> -		  dwarf_next_lines.c
> +		  dwarf_next_lines.c dwarf_cu_dwp_section_info.c
>  
>  if MAINTAINER_MODE
>  BUILT_SOURCES = $(srcdir)/known-dwarf.h
> diff --git a/libdw/dwarf_cu_dwp_section_info.c b/libdw/dwarf_cu_dwp_section_info.c
> new file mode 100644
> index 00000000..6766fb9a
> --- /dev/null
> +++ b/libdw/dwarf_cu_dwp_section_info.c
> @@ -0,0 +1,371 @@
> +/* Read DWARF package file index sections.
> +   Copyright (c) Meta Platforms, Inc. and affiliates.

Please do add a year (2023) here.

> +   This file is part of elfutils.
> +
> +   This file is free software; you can redistribute it and/or modify
> +   it under the terms of either
> +
> +     * the GNU Lesser General Public License as published by the Free
> +       Software Foundation; either version 3 of the License, or (at
> +       your option) any later version
> +
> +   or
> +
> +     * the GNU General Public License as published by the Free
> +       Software Foundation; either version 2 of the License, or (at
> +       your option) any later version
> +
> +   or both in parallel, as here.
> +
> +   elfutils is distributed in the hope that it will be useful, but
> +   WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   General Public License for more details.
> +
> +   You should have received copies of the GNU General Public License and
> +   the GNU Lesser General Public License along with this program.  If
> +   not, see <http://www.gnu.org/licenses/>.  */
> +
> +#ifdef HAVE_CONFIG_H
> +# include <config.h>
> +#endif
> +
> +#include "libdwP.h"
> +
> +static Dwarf_Package_Index *
> +__libdw_read_package_index (Dwarf *dbg, bool tu)
> +{
> +  Elf_Data *data;
> +  if (tu)
> +    data = dbg->sectiondata[IDX_debug_tu_index];
> +  else
> +    data = dbg->sectiondata[IDX_debug_cu_index];
> +
> +  /* We need at least 16 bytes for the header.  */
> +  if (data == NULL || data->d_size < 16)
> +    {
> +    invalid:
> +      __libdw_seterrno (DWARF_E_INVALID_DWARF);
> +      return NULL;
> +    }
> +
> +  const unsigned char *datap = data->d_buf;
> +  const unsigned char *endp = datap + data->d_size;
> +  uint16_t version;
> +  /* In GNU DebugFission for DWARF 4, the version is 2 as a uword.  In the
> +     standardized DWARF 5 format, it is a uhalf followed by a padding uhalf.
> +     Check for both.  */
> +  if (read_4ubyte_unaligned (dbg, datap) == 2)
> +    version = 2;
> +  else
> +    {
> +      version = read_2ubyte_unaligned (dbg, datap);
> +      if (version != 5)
> +	{
> +	  __libdw_seterrno (DWARF_E_VERSION);
> +	  return NULL;
> +	}
> +    }
> +  datap += 4;

OK. the spec says padding should be zero, but we can ignore that.

> +  uint32_t section_count = read_4ubyte_unaligned_inc (dbg, datap);
> +  uint32_t unit_count = read_4ubyte_unaligned_inc (dbg, datap);
> +  uint32_t slot_count = read_4ubyte_unaligned_inc (dbg, datap);

OK, checked d_size >= 16 above.

> +  /* The specification has a stricter requirement that
> +     slot_count > 3 * unit_count / 2, but this is enough for us.  */
> +  if (slot_count < unit_count)
> +    goto invalid;
> +
> +  /* After the header, the section must contain:
> +
> +       8 byte signature per hash table slot
> +     + 4 byte index per hash table slot
> +     + Section offset table with 1 header row, 1 row per unit, 1 column per
> +       section, 4 bytes per field
> +     + Section size table with 1 row per unit, 1 column per section, 4 bytes
> +       per field
> +
> +     We have to be careful about overflow when checking this.  */
> +  const unsigned char *hash_table = datap;
> +  if ((size_t) (endp - hash_table) < (uint64_t) slot_count * 12)
> +    goto invalid;
> +  const unsigned char *indices = hash_table + (size_t) slot_count * 8;
> +  const unsigned char *sections = indices + (size_t) slot_count * 4;
> +  if ((size_t) (endp - sections) < (uint64_t) section_count * 4)
> +    goto invalid;
> +  const unsigned char *section_offsets = sections + (size_t) section_count * 4;
> +  if ((uint64_t) unit_count * section_count > UINT64_MAX / 8
> +      || ((size_t) (endp - section_offsets)
> +	  < (uint64_t) unit_count * section_count * 8))
> +    goto invalid;
> +  const unsigned char *section_sizes
> +    = section_offsets + (uint64_t) unit_count * section_count * 4;

OK.

> +  Dwarf_Package_Index *index = malloc (sizeof (*index));
> +  if (index == NULL)
> +    {
> +      __libdw_seterrno (DWARF_E_NOMEM);
> +      return NULL;
> +    }
> +
> +  index->dbg = dbg;
> +  /* Set absent sections to UINT32_MAX.  */
> +  memset (index->sections, 0xff, sizeof (index->sections));

OK, although I would have preferred a simple for loop and let the
compiler optimize it.

> +  for (size_t i = 0; i < section_count; i++)
> +    {
> +      uint32_t section = read_4ubyte_unaligned (dbg, sections + i * 4);
> +      /* 2 is DW_SECT_TYPES in version 2 and reserved in version 5.  We ignore
> +         it for version 5.
> +	 5 is DW_SECT_LOC in version 2 and DW_SECT_LOCLISTS in version 5.  We
> +	 use the same index for both.
> +	 7 is DW_SECT_MACINFO in version 2 and DW_SECT_MACRO in version 5.  We
> +	 use the same index for both.
> +	 8 is DW_SECT_MACRO in version 2 and DW_SECT_RNGLISTS in version 5.  We
> +	 use the same index for version 2's DW_SECT_MACRO as version 2's
> +	 DW_SECT_MACINFO/version 5's DW_SECT_MACRO.
> +	 We ignore unknown sections.  */
> +      if (section == 0)
> +	continue;
> +      if (version == 2)
> +	{
> +	  if (section > 8)
> +	    continue;
> +	  else if (section == 8)
> +	    section = DW_SECT_MACRO;
> +	}
> +      else if (section == 2
> +	       || (section
> +		   > sizeof (index->sections) / sizeof (index->sections[0])))
> +	continue;
> +      index->sections[section - 1] = i;
> +    }
> +
> +  /* DW_SECT_INFO (or DW_SECT_TYPES for DWARF 4 type units) and DW_SECT_ABBREV
> +     are required.  */
> +  if (((!tu || dbg->sectiondata[IDX_debug_types] == NULL)
> +       && index->sections[DW_SECT_INFO - 1] == UINT32_MAX)
> +      || (tu && dbg->sectiondata[IDX_debug_types] != NULL
> +	  && index->sections[DW_SECT_TYPES - 1] == UINT32_MAX)
> +      || index->sections[DW_SECT_ABBREV - 1] == UINT32_MAX)
> +    {
> +      free (index);
> +      __libdw_seterrno (DWARF_E_INVALID_DWARF);
> +      return NULL;
> +    }
> +
> +  index->section_count = section_count;
> +  index->unit_count = unit_count;
> +  index->slot_count = slot_count;
> +  index->last_unit_found = 0;
> +  index->hash_table = hash_table;
> +  index->indices = indices;
> +  index->section_offsets = section_offsets;
> +  index->section_sizes = section_sizes;
> +
> +  return index;
> +}

OK.

> +static Dwarf_Package_Index *
> +__libdw_package_index (Dwarf *dbg, bool tu)
> +{
> +  if (tu && dbg->tu_index != NULL)
> +    return dbg->tu_index;
> +  else if (!tu && dbg->cu_index != NULL)
> +    return dbg->cu_index;
> +
> +  Dwarf_Package_Index *index = __libdw_read_package_index (dbg, tu);
> +  if (index == NULL)
> +    return NULL;
> +
> +  if (tu)
> +    dbg->tu_index = index;
> +  else
> +    dbg->cu_index = index;
> +  return index;
> +}

OK. Might need locking for thread-safety patch Heather is working on.

> +static int
> +__libdw_dwp_unit_row (Dwarf_Package_Index *index, uint64_t unit_id,
> +		      uint32_t *unit_rowp)
> +{
> +  if (index == NULL)
> +    return -1;
> +
> +  uint32_t hash = unit_id;
> +  uint32_t hash2 = (unit_id >> 32) | 1;
> +  /* Only check each slot once.  */
> +  for (uint32_t n = index->slot_count; n-- > 0; )
> +    {
> +      size_t slot = hash & (index->slot_count - 1);
> +      uint64_t sig = read_8ubyte_unaligned (index->dbg,
> +					    index->hash_table + slot * 8);
> +      if (sig == unit_id)
> +	{
> +	  uint32_t row = read_4ubyte_unaligned (index->dbg,
> +						index->indices + slot * 4);
> +	  if (row > index->unit_count)
> +	    {
> +	      __libdw_seterrno (DWARF_E_INVALID_DWARF);
> +	      return -1;
> +	    }
> +	  *unit_rowp = row;
> +	  return 0;
> +	}
> +      else if (sig == 0
> +	       && read_4ubyte_unaligned (index->dbg,
> +					 index->indices + slot * 4) == 0)
> +	break;
> +      hash += hash2;
> +    }
> +  *unit_rowp = 0;
> +  return 0;
> +}

OK.

> +static int
> +__libdw_dwp_section_info (Dwarf_Package_Index *index, uint32_t unit_row,
> +			  unsigned int section, Dwarf_Off *offsetp,
> +			  Dwarf_Off *sizep)
> +{
> +  if (index == NULL)
> +    return -1;
> +  if (unit_row == 0)
> +    {
> +      __libdw_seterrno (DWARF_E_INVALID_DWARF);
> +      return -1;
> +    }

OK, but why isn't the caller checking this?

> +  if (index->sections[section - 1] == UINT32_MAX)
> +    {
> +      if (offsetp != NULL)
> +	*offsetp = 0;
> +      if (sizep != NULL)
> +	*sizep = 0;
> +      return 0;
> +    }
> +  size_t i = (size_t)(unit_row - 1) * index->section_count
> +	     + index->sections[section - 1];
> +  if (offsetp != NULL)
> +    *offsetp = read_4ubyte_unaligned (index->dbg,
> +				      index->section_offsets + i * 4);
> +  if (sizep != NULL)
> +    *sizep = read_4ubyte_unaligned (index->dbg,
> +				    index->section_sizes + i * 4);
> +  return 0;
> +}

OK.

> +int
> +internal_function
> +__libdw_dwp_find_unit (Dwarf *dbg, bool debug_types, Dwarf_Off off,
> +		       uint16_t version, uint8_t unit_type, uint64_t unit_id8,
> +		       uint32_t *unit_rowp, Dwarf_Off *abbrev_offsetp)
> +{
> +  if (version >= 5
> +      && unit_type != DW_UT_split_compile && unit_type != DW_UT_split_type)
> +    {
> +    not_dwp:
> +      *unit_rowp = 0;
> +      *abbrev_offsetp = 0;
> +      return 0;
> +    }
> +  bool tu = unit_type == DW_UT_split_type || debug_types;
> +  if (dbg->sectiondata[tu ? IDX_debug_tu_index : IDX_debug_cu_index] == NULL)
> +    goto not_dwp;

OK. So this is for "normal" dwo, where the offset is zero,

> +  Dwarf_Package_Index *index = __libdw_package_index (dbg, tu);
> +  if (index == NULL)
> +    return -1;
> +
> +  /* This is always called for ascending offsets.  The most obvious way for a
> +     producer to generate the section offset table is sorted by offset; both
> +     GNU dwp and llvm-dwp do this.  In this common case, we can avoid the full
> +     lookup.  */
> +  if (index->last_unit_found < index->unit_count)
> +    {
> +      Dwarf_Off offset, size;
> +      if (__libdw_dwp_section_info (index, index->last_unit_found + 1,
> +				    debug_types ? DW_SECT_TYPES : DW_SECT_INFO,
> +				    &offset, &size) != 0)
> +	return -1;
> +      if (offset <= off && off - offset < size)
> +	{
> +	  *unit_rowp = ++index->last_unit_found;
> +	  goto done;
> +	}
> +      else
> +	/* The units are not sorted. Don't try again.  */
> +	index->last_unit_found = index->unit_count;
> +    }

OK. Again another point to have some locking for the thread-safety case.

> +  if (version >= 5 || debug_types)
> +    {
> +      /* In DWARF 5 and in type units, the unit signature is available in the
> +         unit header.  */
> +      if (__libdw_dwp_unit_row (index, unit_id8, unit_rowp) != 0)
> +	return -1;
> +    }
> +  else
> +    {
> +      /* In DWARF 4 compilation units, the unit signature is an attribute.  We
> +	 can't parse attributes in the split unit until we get the abbreviation
> +	 table offset from the package index, which is a chicken-and-egg
> +	 problem.  We could get the signature from the skeleton unit, but that
> +	 may not be available.
> +
> +	 Instead, we resort to a linear scan through the section offset table.
> +	 Finding all units is therefore quadratic in the number of units.
> +	 However, this will likely never be needed in practice because of the
> +	 sorted fast path above.  If this ceases to be the case, we can try to
> +	 plumb through the skeleton unit's signature when it is available, or
> +	 build a sorted lookup table for binary search.  */
> +      if (index->sections[DW_SECT_INFO - 1] == UINT32_MAX)
> +	{
> +	  __libdw_seterrno (DWARF_E_INVALID_DWARF);
> +	  return -1;
> +	}
> +      for (uint32_t i = 0; i < index->unit_count; i++)
> +	{
> +	  Dwarf_Off offset, size;
> +	  __libdw_dwp_section_info (index, i + 1, DW_SECT_INFO, &offset,
> +				    &size);
> +	  if (offset <= off && off - offset < size)
> +	    {
> +	      *unit_rowp = i + 1;
> +	      goto done;
> +	    }
> +	}
> +      __libdw_seterrno (DWARF_E_INVALID_DWARF);
> +      return -1;
> +    }
> +
> + done:
> +  return __libdw_dwp_section_info (index, *unit_rowp, DW_SECT_ABBREV,
> +				   abbrev_offsetp, NULL);
> +}

OK.

> +int
> +dwarf_cu_dwp_section_info (Dwarf_CU *cu, unsigned int section,
> +			   Dwarf_Off *offsetp, Dwarf_Off *sizep)
> +{
> +  if (cu == NULL)
> +    return -1;
> +  if (section < DW_SECT_INFO || section > DW_SECT_RNGLISTS)
> +    {
> +      __libdw_seterrno (DWARF_E_UNKNOWN_SECTION);
> +      return -1;
> +    }
> +  if (cu->dwp_row == 0)
> +    {
> +      if (offsetp != NULL)
> +	*offsetp = 0;
> +      if (sizep != NULL)
> +	*sizep = 0;
> +      return 0;
> +    }
> +  else
> +    {
> +      Dwarf_Package_Index *index
> +	= cu->unit_type == DW_UT_split_compile
> +	? cu->dbg->cu_index : cu->dbg->tu_index;
> +      return __libdw_dwp_section_info (index, cu->dwp_row, section, offsetp,
> +				       sizep);
> +    }
> +}
> +INTDEF(dwarf_cu_dwp_section_info)

OK. Although I would like to see this public function as a separate
patch if possible.

> diff --git a/libdw/dwarf_end.c b/libdw/dwarf_end.c
> index 8dd075cf..18a419ce 100644
> --- a/libdw/dwarf_end.c
> +++ b/libdw/dwarf_end.c
> @@ -77,6 +77,9 @@ dwarf_end (Dwarf *dwarf)
>  {
>    if (dwarf != NULL)
>      {
> +      free (dwarf->tu_index);
> +      free (dwarf->cu_index);
> +
>        if (dwarf->cfi != NULL)
>  	/* Clean up the CFI cache.  */
>  	__libdw_destroy_frame_cache (dwarf->cfi);

OK.

> diff --git a/libdw/dwarf_error.c b/libdw/dwarf_error.c
> index 46ea16b3..0123cfa2 100644
> --- a/libdw/dwarf_error.c
> +++ b/libdw/dwarf_error.c
> @@ -102,6 +102,7 @@ static const char *errmsgs[] =
>      [DWARF_E_NOT_CUDIE] = N_("not a CU (unit) DIE"),
>      [DWARF_E_UNKNOWN_LANGUAGE] = N_("unknown language code"),
>      [DWARF_E_NO_DEBUG_ADDR] = N_(".debug_addr section missing"),
> +    [DWARF_E_UNKNOWN_SECTION] = N_("unknown section"),
>    };
>  #define nerrmsgs (sizeof (errmsgs) / sizeof (errmsgs[0]))

OK

> diff --git a/libdw/libdw.h b/libdw/libdw.h
> index 64d1689a..545ad043 100644
> --- a/libdw/libdw.h
> +++ b/libdw/libdw.h
> @@ -1081,6 +1081,29 @@ extern int dwarf_frame_register (Dwarf_Frame *frame, int regno,
>    __nonnull_attribute__ (3, 4, 5);
>  
>  
> +/* Return offset and/or size of CU's contribution to SECTION in a DWARF package
> +   file.
> +
> +   If CU is not from a DWARF package file, the file does not have SECTION, or CU
> +   does not contribute to SECTION, then *SIZEP is set to 0.
> +
> +   SECTION is a DW_SECT section identifier.  Note that the original GNU DWARF
> +   package file extension for DWARF 4 used slightly different section
> +   identifiers.  This function uses the standardized section identifiers and
> +   maps the GNU DWARF 4 identifiers to their standard DWARF 5 analogues:
> +   DW_SECT_LOCLISTS (5) refers to .debug_locs.dwo for DWARF 4.
> +   DW_SECT_MACRO (7) refers to .debug_macinfo.dwo for DWARF 4 or
> +   .debug_macro.dwo for the GNU .debug_macro extension for DWARF 4 (section
> +   identifier 8 is DW_SECT_RNGLISTS in DWARF 5, NOT DW_SECT_MACRO like in the
> +   GNU extension.)
> +   .debug_types.dwo does not have a DWARF 5 equivalent, so this function accepts
> +   the original DW_SECT_TYPES (2).
> +
> +   Returns 0 for success or -1 for errors.  OFFSETP and SIZEP may be NULL.  */
> +extern int dwarf_cu_dwp_section_info (Dwarf_CU *cu, unsigned int section,
> +				      Dwarf_Off *offsetp, Dwarf_Off *sizep);
> +
> +
>  /* Return error code of last failing function call.  This value is kept
>     separately for each thread.  */
>  extern int dwarf_errno (void);

OK, but see above (rather have this as a separate patch) and below
(DW_SECT_TYPES not publicly defined).

> diff --git a/libdw/libdw.map b/libdw/libdw.map
> index 5331ad45..2104b007 100644
> --- a/libdw/libdw.map
> +++ b/libdw/libdw.map
> @@ -373,3 +373,8 @@ ELFUTILS_0.188 {
>      dwfl_frame_reg;
>      dwfl_report_offline_memory;
>  } ELFUTILS_0.186;
> +
> +ELFUTILS_0.190 {
> +  global:
> +    dwarf_cu_dwp_section_info;
> +} ELFUTILS_0.188;

OK, but ,,, etc,

> diff --git a/libdw/libdwP.h b/libdw/libdwP.h
> index 0c44d40c..13ca58ce 100644
> --- a/libdw/libdwP.h
> +++ b/libdw/libdwP.h
> @@ -147,6 +147,7 @@ enum
>    DWARF_E_NOT_CUDIE,
>    DWARF_E_UNKNOWN_LANGUAGE,
>    DWARF_E_NO_DEBUG_ADDR,
> +  DWARF_E_UNKNOWN_SECTION,
>  };
>  

OK.

> @@ -227,6 +228,11 @@ struct Dwarf
>    /* Cached info from the CFI section.  */
>    struct Dwarf_CFI_s *cfi;
>  
> +  /* DWARF package file CU index section.  */
> +  struct Dwarf_Package_Index_s *cu_index;
> +  /* DWARF package file TU index section.  */
> +  struct Dwarf_Package_Index_s *tu_index;
> +
>    /* Fake loc CU.  Used when synthesizing attributes for Dwarf_Ops that
>       came from a location list entry in dwarf_getlocation_attr.
>       Depending on version this is the .debug_loc or .debug_loclists
> @@ -339,6 +345,26 @@ struct Dwarf_Aranges_s
>    } info[0];
>  };

OK.
 
> +/* DWARF package file unit index.  */
> +typedef struct Dwarf_Package_Index_s
> +{
> +  Dwarf *dbg;
> +  uint32_t section_count;
> +  uint32_t unit_count;
> +  uint32_t slot_count;
> +  /* Mapping from DW_SECT_* - 1 to column number in the section tables, or
> +     UINT32_MAX if not present.  */
> +  uint32_t sections[DW_SECT_RNGLISTS];
> +  /* Row number of last unit found in the index.  */
> +  uint32_t last_unit_found;
> +  const unsigned char *hash_table;
> +  const unsigned char *indices;
> +  const unsigned char *section_offsets;
> +  const unsigned char *section_sizes;
> +} Dwarf_Package_Index;

OK.

> +/* Used in GNU DebugFission for DWARF 4.  Reserved in DWARF 5.  */
> +#define DW_SECT_TYPES 2

Should be in dwarf.h.

>  /* CU representation.  */
>  struct Dwarf_CU
> @@ -346,6 +372,8 @@ struct Dwarf_CU
>    Dwarf *dbg;
>    Dwarf_Off start;
>    Dwarf_Off end;
> +  /* Row number of this unit in DWARF package file index.  */
> +  uint32_t dwp_row;
>    uint8_t address_size;
>    uint8_t offset_size;
>    uint16_t version;

OK.

> @@ -680,6 +708,13 @@ extern struct Dwarf *__libdw_find_split_dbg_addr (Dwarf *dbg, void *addr)
>  extern struct Dwarf_CU *__libdw_find_split_unit (Dwarf_CU *cu)
>       internal_function;
>  
> +/* Find a unit in a DWARF package file for __libdw_intern_next_unit.  */
> +extern int __libdw_dwp_find_unit (Dwarf *dbg, bool debug_types, Dwarf_Off off,
> +				  uint16_t version, uint8_t unit_type,
> +				  uint64_t unit_id8, uint32_t *unit_rowp,
> +				  Dwarf_Off *abbrev_offsetp)
> +     __nonnull_attribute__ (1, 7, 8) internal_function;
> +
>  /* Get abbreviation with given code.  */
>  extern Dwarf_Abbrev *__libdw_findabbrev (struct Dwarf_CU *cu,
>  					 unsigned int code)

OK.

> @@ -1380,6 +1415,7 @@ INTDECL (dwarf_attr_integrate)
>  INTDECL (dwarf_begin)
>  INTDECL (dwarf_begin_elf)
>  INTDECL (dwarf_child)
> +INTDECL (dwarf_cu_dwp_section_info)
>  INTDECL (dwarf_default_lower_bound)
>  INTDECL (dwarf_dieoffset)
>  INTDECL (dwarf_diename)

OM, but etc.

> diff --git a/libdw/libdw_findcu.c b/libdw/libdw_findcu.c
> index ed744231..6c7dcfb5 100644
> --- a/libdw/libdw_findcu.c
> +++ b/libdw/libdw_findcu.c
> @@ -143,6 +143,13 @@ __libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
>    if (unlikely (*offsetp > data->d_size))
>      *offsetp = data->d_size;
>  
> +  uint32_t dwp_row;
> +  Dwarf_Off dwp_abbrev_offset;
> +  if (__libdw_dwp_find_unit (dbg, debug_types, oldoff, version, unit_type,
> +			     unit_id8, &dwp_row, &dwp_abbrev_offset) != 0)
> +    return NULL;
> +  abbrev_offset += dwp_abbrev_offset;
> +
>    /* Create an entry for this CU.  */
>    struct Dwarf_CU *newp = libdw_typed_alloc (dbg, struct Dwarf_CU);
>  
> @@ -150,6 +157,7 @@ __libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
>    newp->sec_idx = sec_idx;
>    newp->start = oldoff;
>    newp->end = *offsetp;
> +  newp->dwp_row = dwp_row;
>    newp->address_size = address_size;
>    newp->offset_size = offset_size;
>    newp->version = version;

OK.

> diff --git a/tests/.gitignore b/tests/.gitignore
> index b9aa22ba..e9a61a2d 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -28,6 +28,7 @@
>  /backtrace-dwarf
>  /buildid
>  /core-dump-backtrace.lock
> +/cu-dwp-section-info
>  /debugaltlink
>  /debuginfod_build_id_find
>  /debuglink
> diff --git a/tests/ChangeLog b/tests/ChangeLog
> index f934c114..687a9f32 100644
> --- a/tests/ChangeLog
> +++ b/tests/ChangeLog
> @@ -1,6 +1,19 @@
>  2023-09-27  Omar Sandoval  <osandov@fb.com>
>  
>  	* run-varlocs.sh: Add entry PC to split units.
> +	* Makefile.am (check_PROGRAMS): Add cu-dwp-section-info.
> +	(TESTS): Add run-cu-dwp-section-info.sh
> +	(EXTRA_DIST): Add run-cu-dwp-section-info.sh and new test files.
> +	(cu_dwp_section_info_LDADD): New variable.
> +	* cu-dwp-section-info.c: New test.
> +	* run-cu-dwp-section-info.sh: New test.
> +	* testfile-dwp-4-strict.bz2: New test file.
> +	* testfile-dwp-4-strict.dwp.bz2: New test file.
> +	* testfile-dwp-4.bz2: New test file.
> +	* testfile-dwp-4.dwp.bz2: New test file.
> +	* testfile-dwp-5.bz2: New test file.
> +	* testfile-dwp-5.dwp.bz2: New test file.
> +	* testfile-dwp.source: New file.
>  
>  2023-04-21  Frank Ch. Eigler <fche@redhat.com>
>  
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 32b18e6e..0938882b 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -62,7 +62,7 @@ check_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
>  		  dwelf_elf_e_machine_string \
>  		  getphdrnum leb128 read_unaligned \
>  		  msg_tst system-elf-libelf-test system-elf-gelf-test \
> -		  nvidia_extended_linemap_libdw \
> +		  nvidia_extended_linemap_libdw cu-dwp-section-info \
>  		  $(asm_TESTS)
>  
>  asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
> @@ -211,7 +211,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \
>  	$(asm_TESTS) run-disasm-bpf.sh run-low_high_pc-dw-form-indirect.sh \
>  	run-nvidia-extended-linemap-libdw.sh run-nvidia-extended-linemap-readelf.sh \
>  	run-readelf-dw-form-indirect.sh run-strip-largealign.sh \
> -	run-readelf-Dd.sh
> +	run-readelf-Dd.sh run-cu-dwp-section-info.sh
>  
>  if !BIARCH
>  export ELFUTILS_DISABLE_BIARCH = 1
> @@ -629,7 +629,11 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
>  	     run-nvidia-extended-linemap-libdw.sh run-nvidia-extended-linemap-readelf.sh \
>  	     testfile_nvidia_linemap.bz2 \
>  	     testfile-largealign.o.bz2 run-strip-largealign.sh \
> -	     run-funcretval++11.sh
> +	     run-funcretval++11.sh \
> +	     testfile-dwp-4.bz2 testfile-dwp-4.dwp.bz2 \
> +	     testfile-dwp-4-strict.bz2 testfile-dwp-4-strict.dwp.bz2 \
> +	     testfile-dwp-5.bz2 testfile-dwp-5.dwp.bz2 testfile-dwp.source \
> +	     run-cu-dwp-section-info.sh
>  
>  
>  if USE_VALGRIND
> @@ -804,6 +808,7 @@ getphdrnum_LDADD = $(libelf) $(libdw)
>  leb128_LDADD = $(libelf) $(libdw)
>  read_unaligned_LDADD = $(libelf) $(libdw)
>  nvidia_extended_linemap_libdw_LDADD = $(libelf) $(libdw)
> +cu_dwp_section_info_LDADD = $(libdw)
>  
>  # We want to test the libelf headers against the system elf.h header.
>  # Don't include any -I CPPFLAGS. Except when we install our own elf.h.

OK.

> diff --git a/tests/cu-dwp-section-info.c b/tests/cu-dwp-section-info.c
> new file mode 100644
> index 00000000..e92f35b6
> --- /dev/null
> +++ b/tests/cu-dwp-section-info.c
> @@ -0,0 +1,74 @@
> +/* Test program for dwarf_cu_dwp_section_info
> +   Copyright (c) Meta Platforms, Inc. and affiliates.

Should have a year (2023).

> +   This file is part of elfutils.
> +
> +   This file is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   elfutils is distributed in the hope that it will be useful, but
> +   WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +#ifdef HAVE_CONFIG_H
> +# include <config.h>
> +#endif
> +#include <stdio.h>
> +#include <inttypes.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +#include <unistd.h>
> +
> +#include <dwarf.h>
> +#include ELFUTILS_HEADER(dw)
> +
> +int
> +main (int argc, char *argv[])
> +{
> +  for (int i = 1; i < argc; i++)
> +    {
> +      printf ("file: %s\n", argv[i]);
> +      int fd = open (argv[i], O_RDONLY);
> +      Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
> +      if (dbg == NULL)
> +	{
> +	  printf ("%s not usable: %s\n", argv[i], dwarf_errmsg (-1));
> +	  return -1;
> +	}
> +
> +      Dwarf_CU *cu = NULL;
> +      while (dwarf_get_units (dbg, cu, &cu, NULL, NULL, NULL, NULL) == 0)
> +	{
> +#define SECTION_INFO(section) do {					\
> +	    printf (#section ": ");					\
> +	    Dwarf_Off offset, size;					\
> +	    if (dwarf_cu_dwp_section_info (cu, DW_SECT_##section,	\
> +					   &offset, &size) == 0)	\
> +	      printf ("0x%" PRIx64 " 0x%" PRIx64 "\n", offset, size);	\
> +	    else							\
> +	      printf ("%s\n", dwarf_errmsg (-1));			\
> +	  } while (0)
> +	  SECTION_INFO (INFO);
> +#define DW_SECT_TYPES 2
> +	  SECTION_INFO (TYPES);
> +	  SECTION_INFO (ABBREV);
> +	  SECTION_INFO (LINE);
> +	  SECTION_INFO (LOCLISTS);
> +	  SECTION_INFO (STR_OFFSETS);
> +	  SECTION_INFO (MACRO);
> +	  SECTION_INFO (RNGLISTS);
> +	  printf ("\n");
> +	}
> +
> +      dwarf_end (dbg);
> +      close (fd);
> +    }
> +
> +  return 0;
> +}

OK. But now I finally see the actual use of the new public function.
So

> diff --git a/tests/run-cu-dwp-section-info.sh b/tests/run-cu-dwp-section-info.sh
> new file mode 100755
> index 00000000..f8596f2c
> --- /dev/null
> +++ b/tests/run-cu-dwp-section-info.sh
> @@ -0,0 +1,168 @@
> +#! /bin/sh
> +# Copyright (c) Meta Platforms, Inc. and affiliates.
> +# This file is part of elfutils.
> +#
> +# This file is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# elfutils is distributed in the hope that it will be useful, but
> +# WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +. $srcdir/test-subr.sh
> +
> +# See testfile-dwp.source.
> +testfiles testfile-dwp-5.dwp testfile-dwp-4.dwp testfile-dwp-4-strict.dwp
> +
> +testrun_compare ${abs_builddir}/cu-dwp-section-info testfile-dwp-5.dwp << EOF
> +file: testfile-dwp-5.dwp
> +INFO: 0x0 0x70
> +TYPES: 0x0 0x0
> +ABBREV: 0x0 0x160
> +LINE: 0x0 0x7f
> +LOCLISTS: 0x0 0xdb
> +STR_OFFSETS: 0x0 0x75c
> +MACRO: 0x0 0x6c6
> +RNGLISTS: 0x0 0x22
> +
> +INFO: 0x70 0x108
> +TYPES: 0x0 0x0
> +ABBREV: 0x0 0x160
> +LINE: 0x0 0x7f
> +LOCLISTS: 0x0 0xdb
> +STR_OFFSETS: 0x0 0x75c
> +MACRO: 0x0 0x6c6
> +RNGLISTS: 0x0 0x22
> +
> +INFO: 0x178 0x6e
> +TYPES: 0x0 0x0
> +ABBREV: 0x160 0xca
> +LINE: 0x7f 0x7f
> +LOCLISTS: 0x0 0x0
> +STR_OFFSETS: 0x75c 0x758
> +MACRO: 0x6c6 0x6c5
> +RNGLISTS: 0x0 0x0
> +
> +INFO: 0x1e6 0x78
> +TYPES: 0x0 0x0
> +ABBREV: 0x160 0xca
> +LINE: 0x7f 0x7f
> +LOCLISTS: 0x0 0x0
> +STR_OFFSETS: 0x75c 0x758
> +MACRO: 0x6c6 0x6c5
> +RNGLISTS: 0x0 0x0
> +
> +INFO: 0x25e 0x193
> +TYPES: 0x0 0x0
> +ABBREV: 0x22a 0x18a
> +LINE: 0xfe 0x81
> +LOCLISTS: 0xdb 0xc9
> +STR_OFFSETS: 0xeb4 0x77c
> +MACRO: 0xd8b 0x6c6
> +RNGLISTS: 0x22 0x43
> +
> +EOF
> +
> +testrun_compare ${abs_builddir}/cu-dwp-section-info testfile-dwp-4.dwp << EOF
> +file: testfile-dwp-4.dwp
> +INFO: 0x0 0x11e
> +TYPES: 0x0 0x0
> +ABBREV: 0x0 0x172
> +LINE: 0x0 0x52
> +LOCLISTS: 0x0 0x11b
> +STR_OFFSETS: 0x0 0x754
> +MACRO: 0x0 0x6c7
> +RNGLISTS: 0x0 0x0
> +
> +INFO: 0x11e 0x76
> +TYPES: 0x0 0x0
> +ABBREV: 0x172 0xd7
> +LINE: 0x52 0x52
> +LOCLISTS: 0x0 0x0
> +STR_OFFSETS: 0x754 0x750
> +MACRO: 0x6c7 0x6c6
> +RNGLISTS: 0x0 0x0
> +
> +INFO: 0x194 0x1c5
> +TYPES: 0x0 0x0
> +ABBREV: 0x249 0x19e
> +LINE: 0xa4 0x53
> +LOCLISTS: 0x11b 0xf1
> +STR_OFFSETS: 0xea4 0x774
> +MACRO: 0xd8d 0x6c7
> +RNGLISTS: 0x0 0x0
> +
> +INFO: 0x0 0x0
> +TYPES: 0x0 0x6f
> +ABBREV: 0x0 0x172
> +LINE: 0x0 0x52
> +LOCLISTS: 0x0 0x11b
> +STR_OFFSETS: 0x0 0x754
> +MACRO: 0x0 0x6c7
> +RNGLISTS: 0x0 0x0
> +
> +INFO: 0x0 0x0
> +TYPES: 0x6f 0x6d
> +ABBREV: 0x172 0xd7
> +LINE: 0x52 0x52
> +LOCLISTS: 0x0 0x0
> +STR_OFFSETS: 0x754 0x750
> +MACRO: 0x6c7 0x6c6
> +RNGLISTS: 0x0 0x0
> +
> +EOF
> +
> +testrun_compare ${abs_builddir}/cu-dwp-section-info testfile-dwp-4-strict.dwp << EOF
> +file: testfile-dwp-4-strict.dwp
> +INFO: 0x0 0x105
> +TYPES: 0x0 0x0
> +ABBREV: 0x0 0x15f
> +LINE: 0x0 0x52
> +LOCLISTS: 0x0 0xe2
> +STR_OFFSETS: 0x0 0x24
> +MACRO: 0x0 0x38e4
> +RNGLISTS: 0x0 0x0
> +
> +INFO: 0x105 0x72
> +TYPES: 0x0 0x0
> +ABBREV: 0x15f 0xd3
> +LINE: 0x52 0x52
> +LOCLISTS: 0x0 0x0
> +STR_OFFSETS: 0x24 0x20
> +MACRO: 0x38e4 0x38db
> +RNGLISTS: 0x0 0x0
> +
> +INFO: 0x177 0x17b
> +TYPES: 0x0 0x0
> +ABBREV: 0x232 0x157
> +LINE: 0xa4 0x53
> +LOCLISTS: 0xe2 0xb1
> +STR_OFFSETS: 0x44 0x44
> +MACRO: 0x71bf 0x38f5
> +RNGLISTS: 0x0 0x0
> +
> +INFO: 0x0 0x0
> +TYPES: 0x0 0x6e
> +ABBREV: 0x0 0x15f
> +LINE: 0x0 0x52
> +LOCLISTS: 0x0 0xe2
> +STR_OFFSETS: 0x0 0x24
> +MACRO: 0x0 0x38e4
> +RNGLISTS: 0x0 0x0
> +
> +INFO: 0x0 0x0
> +TYPES: 0x6e 0x6b
> +ABBREV: 0x15f 0xd3
> +LINE: 0x52 0x52
> +LOCLISTS: 0x0 0x0
> +STR_OFFSETS: 0x24 0x20
> +MACRO: 0x38e4 0x38db
> +RNGLISTS: 0x0 0x0
> +
> +EOF

OK
 
> diff --git a/tests/testfile-dwp.source b/tests/testfile-dwp.source
> new file mode 100644
> index 00000000..b0b0a97c
> --- /dev/null
> +++ b/tests/testfile-dwp.source
> @@ -0,0 +1,102 @@
> +# Nonsensical program used to generate example DWARF package files with type
> +# units, location lists, range lists, and macros.
> +
> +# = foobar.h =
> +
> +struct Foo
> +{
> +  int a, b;
> +  int foo ();
> +};
> +
> +struct Bar
> +{
> +  long a, b;
> +  long bar ();
> +};
> +
> +#define FROB(x) ((x) ^ 0x2a2a2a2a)
> +#define FRY(x) ((x) * 0x100000001b3)
> +
> +inline long
> +fibonacci (unsigned int n)
> +{
> +  if (n == 0)
> +    return 0;
> +  else
> +    {
> +      long a = 0;
> +      long b = 1;
> +      for (unsigned int i = 2; i < n; i++)
> +	{
> +	  long tmp = a + b;
> +	  a = b;
> +	  b = tmp;
> +	}
> +      return b;
> +    }
> +}
> +
> +# = foo.cc =
> +
> +#include "foobar.h"
> +
> +#define ZERO() (1 - 1)
> +
> +int
> +x_x (int x)
> +{
> +  for (int i = x; i > ZERO(); i--)
> +    x *= x;
> +  return x;
> +}
> +
> +int
> +Foo::foo ()
> +{
> +  int x = a;
> +  if (a > b)
> +    x -= b;
> +  return FROB (x_x (x));
> +}
> +
> +# = bar.cc =
> +
> +#include "foobar.h"
> +
> +#define ONE 1
> +
> +long
> +Bar::bar ()
> +{
> +  if (a == b)
> +    return ONE;
> +  else
> +    return a > b ? b : a;
> +}
> +
> +# = main.cc =
> +
> +#include "foobar.h"
> +
> +#define MAIN_ARGS int argc, char **argv
> +
> +int
> +main(MAIN_ARGS)
> +{
> +  struct Foo myfoo { argc, FROB (argc) };
> +  struct Bar mybar { fibonacci (argc), FRY (argc) };
> +  return myfoo.foo() + mybar.bar();
> +}
> +
> +# Built with GCC at commit 80048aa13a6b ("debug/111409 - don't generate COMDAT
> +# macro sections for split DWARF").
> +$ g++ -gdwarf-5 -gsplit-dwarf -fdebug-types-section -g3 -O2 foo.cc bar.cc main.cc -o testfile-dwp-5
> +# GNU dwp as of binutils 2.41 only supports DWARF 4.
> +$ llvm-dwp -e testfile-dwp-5 -o testfile-dwp-5.dwp
> +
> +$ g++ -gdwarf-4 -gsplit-dwarf -fdebug-types-section -g3 -O2 foo.cc bar.cc main.cc -o testfile-dwp-4
> +$ dwp -e testfile-dwp-4
> +
> +$ g++ -gdwarf-4 -gstrict-dwarf -gsplit-dwarf -fdebug-types-section -g3 -O2 foo.cc bar.cc main.cc -o testfile-dwp-4-strict
> +$ dwp -e testfile-dwp-4-strict

Thanks for including this.
Added to EXTRA_DIST. OK.

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 09/14] libdw, libdwfl: Save original path of ELF file
  2023-09-27 18:20 ` [PATCH 09/14] libdw, libdwfl: Save original path of ELF file Omar Sandoval
@ 2023-11-02 17:04   ` Mark Wielaard
  2023-11-07  6:46     ` Omar Sandoval
  0 siblings, 1 reply; 38+ messages in thread
From: Mark Wielaard @ 2023-11-02 17:04 UTC (permalink / raw)
  To: Omar Sandoval, elfutils-devel

Hi Omar,

On Wed, 2023-09-27 at 11:20 -0700, Omar Sandoval wrote:
> libdw and libdwfl currently save the path of the directory containing
> the ELF file to use when searching for alt and dwo files.  To search for
> dwp files, we need the file name too.  Add an elfpath field to Dwarf,
> and set the debugdir field from it.  Also update libdwfl to set elfpath
> and debugdir.

This looks good. We will need some locking around this code when we
integrate the thread-safety work. But that should be pretty clear.

> 
> Signed-off-by: Omar Sandoval <osandov@fb.com>
> ---
>  libdw/ChangeLog                | 11 ++++++++++-
>  libdw/dwarf_begin_elf.c        | 34 ++++++++++++++++++++--------------
>  libdw/dwarf_end.c              |  3 ++-
>  libdw/libdwP.h                 | 12 ++++++++++--
>  libdwfl/ChangeLog              |  9 +++++++++
>  libdwfl/dwfl_module.c          |  2 +-
>  libdwfl/dwfl_module_getdwarf.c | 11 +++++++----
>  libdwfl/libdwflP.h             |  2 +-
>  libdwfl/offline.c              |  4 ++--
>  9 files changed, 62 insertions(+), 26 deletions(-)
> 
> diff --git a/libdw/ChangeLog b/libdw/ChangeLog
> index 1d229094..f491587f 100644
> --- a/libdw/ChangeLog
> +++ b/libdw/ChangeLog
> @@ -20,7 +20,7 @@
>  	instead of dbg parameter, which is now unused.
>  	* libdwP.h (Dwarf_Macro_Op_Table): Replace is_64bit with address_size
>  	and offset_size.  Add dbg.
> -	(Dwarf): Add cu_index and tu_index.
> +	(Dwarf): Add cu_index and tu_index.  Add elfpath.
>  	(Dwarf_CU): Add dwp_row.
>  	(Dwarf_Package_Index): New type.
>  	(DW_SECT_TYPES): New macro.
> @@ -28,6 +28,9 @@
>  	(dwarf_cu_dwp_section_info): New INTDECL.
>  	Add IDX_debug_cu_index and IDX_debug_tu_index.  Add
>  	DWARF_E_UNKNOWN_SECTION.
> +	(__libdw_debugdir): Replace declaration with...
> +	(__libdw_elfpath): New declaration.
> +	(__libdw_set_debugdir): New declaration.
>  	* dwarf_begin_elf.c (dwarf_scnnames): Add IDX_debug_cu_index and
>  	IDX_debug_tu_index.
>  	(scn_to_string_section_idx): Ditto.
> @@ -35,8 +38,14 @@
>  	.zdebug_cu_index, and .zdebug_tu_index.
>  	(check_section): Change .dwo suffix matching to account for
>  	.debug_cu_index and .debug_tu_index.
> +	(__libdw_debugdir): Replace with..
> +	(__libdw_elfpath): New function.
> +	(__libdw_set_debugdir): New function.
> +	(valid_p): Call __libdw_elfpath and __libdw_set_debugdir instead of
> +	__libdw_debugdir.
>  	* Makefile.am (libdw_a_SOURCES): Add dwarf_cu_dwp_section_info.c.
>  	* dwarf_end.c (dwarf_end): Free dwarf->cu_index and dwarf->tu_index.
> +	Free dwarf->elfpath.
>  	* dwarf_error.c (errmsgs): Add DWARF_E_UNKNOWN_SECTION.
>  	* libdw.h (dwarf_cu_dwp_section_info): New declaration.
>  	* libdw.map (ELFUTILS_0.190): Add dwarf_cu_dwp_section_info.

I had to recreate the ChangeLog entry because we skipped your patch 08.
In the future lets just move the ChangeLog Entry into the commit
message (we just updated CONTRIBUTING to recommend this). That makes
rebasing slightly

> diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
> index 7936d343..323a91d0 100644
> --- a/libdw/dwarf_begin_elf.c
> +++ b/libdw/dwarf_begin_elf.c
> @@ -272,24 +272,27 @@ check_section (Dwarf *result, size_t shstrndx, Elf_Scn *scn, bool inscngrp)
>    return result;
>  }
>  
> -
> -/* Helper function to set debugdir field.  We want to cache the dir
> -   where we found this Dwarf ELF file to locate alt and dwo files.  */
>  char *
> -__libdw_debugdir (int fd)
> +__libdw_elfpath (int fd)
>  {
>    /* strlen ("/proc/self/fd/") = 14 + strlen (<MAXINT>) = 10 + 1 = 25.  */
>    char devfdpath[25];
>    sprintf (devfdpath, "/proc/self/fd/%u", fd);
> -  char *fdpath = realpath (devfdpath, NULL);
> -  char *fddir;
> -  if (fdpath != NULL && fdpath[0] == '/'
> -      && (fddir = strrchr (fdpath, '/')) != NULL)
> -    {
> -      *++fddir = '\0';
> -      return fdpath;
> -    }
> -  return NULL;
> +  return realpath (devfdpath, NULL);
> +}
> +
> +
> +void
> +__libdw_set_debugdir (Dwarf *dbg)
> +{
> +  if (dbg->elfpath == NULL || dbg->elfpath[0] != '/')
> +    return;
> +  size_t dirlen = strrchr (dbg->elfpath, '/') - dbg->elfpath + 1;
> +  dbg->debugdir = malloc (dirlen + 1);
> +  if (dbg->debugdir == NULL)
> +    return;
> +  memcpy (dbg->debugdir, dbg->elfpath, dirlen);
> +  dbg->debugdir[dirlen] = '\0';
>  }
> 

This looks slightly nicer than the original code it replaces.

>  
> @@ -421,7 +424,10 @@ valid_p (Dwarf *result)
>      }
>  
>    if (result != NULL)
> -    result->debugdir = __libdw_debugdir (result->elf->fildes);
> +    {
> +      result->elfpath = __libdw_elfpath (result->elf->fildes);
> +      __libdw_set_debugdir(result);
> +    }
>  
>    return result;
>  }

OK.

> diff --git a/libdw/dwarf_end.c b/libdw/dwarf_end.c
> index 18a419ce..b7f817d9 100644
> --- a/libdw/dwarf_end.c
> +++ b/libdw/dwarf_end.c
> @@ -147,7 +147,8 @@ dwarf_end (Dwarf *dwarf)
>  	  close (dwarf->alt_fd);
>  	}
>  
> -      /* The cached dir we found the Dwarf ELF file in.  */
> +      /* The cached path and dir we found the Dwarf ELF file in.  */
> +      free (dwarf->elfpath);
>        free (dwarf->debugdir);
>  
>        /* Free the context descriptor.  */
> diff --git a/libdw/libdwP.h b/libdw/libdwP.h
> index 13ca58ce..214d1711 100644
> --- a/libdw/libdwP.h
> +++ b/libdw/libdwP.h
> @@ -169,6 +169,10 @@ struct Dwarf
>    /* The underlying ELF file.  */
>    Elf *elf;
>  
> +  /* The (absolute) path to the ELF file, if known.  To help locating
> +     dwp files.  */
> +  char *elfpath;
> +
>    /* The (absolute) path to the ELF dir, if known.  To help locating
>       alt and dwo files.  */
>    char *debugdir;
> @@ -1385,9 +1389,13 @@ __libdw_link_skel_split (Dwarf_CU *skel, Dwarf_CU *split)
>  int __libdw_addrx (Dwarf_CU *cu, Dwarf_Word idx, Dwarf_Addr *addr);
>  
>  
> -/* Helper function to set debugdir field in Dwarf, used from dwarf_begin_elf
> +/* Helper function to set elfpath field in Dwarf, used from dwarf_begin_elf
>     and libdwfl process_file.  */
> -char * __libdw_debugdir (int fd);
> +char * __libdw_elfpath (int fd);
> +
> +/* Helper function to set debugdir field in Dwarf after elfpath field has been
> +   set.  */
> +void __libdw_set_debugdir (Dwarf *dbg);
>  
>  
>  /* Given the directory of a debug file, an absolute or relative dir

OK

> diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
> index 54d85921..abbf0dfe 100644
> --- a/libdwfl/ChangeLog
> +++ b/libdwfl/ChangeLog
> @@ -1,3 +1,12 @@
> +2023-09-27  Omar Sandoval  <osandov@fb.com>
> +	* dwfl_module.c (__libdwfl_module_free): Free mod->elfpath instead of
> +	mod->elfdir.
> +	* dwfl_module_getdwarf.c (load_dw): Set mod->dw->elfpath and call
> +	__libdw_set_debugdir instead of setting mod->dw->debugdir.
> +	* libdwflP.h (Dwfl_Module): Replace elfdir with elfpath.
> +	* offline.c (process_elf): Call __libdw_elfpath and set mod->elfpath
> +	instead of mod->elfdir.
> +
>  2023-04-24  John Gallagher  <john@gllghr.com>
>  
>  	* gzip.c: Fix memory leak in unzip()
> diff --git a/libdwfl/dwfl_module.c b/libdwfl/dwfl_module.c
> index 221d726d..c4d872d4 100644
> --- a/libdwfl/dwfl_module.c
> +++ b/libdwfl/dwfl_module.c
> @@ -119,7 +119,7 @@ __libdwfl_module_free (Dwfl_Module *mod)
>      free (mod->reloc_info);
>  
>    free (mod->name);
> -  free (mod->elfdir);
> +  free (mod->elfpath);
>    free (mod);
>  }

OK

> diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
> index 9ba499bb..6f98c02b 100644
> --- a/libdwfl/dwfl_module_getdwarf.c
> +++ b/libdwfl/dwfl_module_getdwarf.c
> @@ -1362,11 +1362,14 @@ load_dw (Dwfl_Module *mod, struct dwfl_file *debugfile)
>      }
>  
>    /* We might have already closed the fd when we asked dwarf_begin_elf to
> -     create an Dwarf.  Help out a little in case we need to find an alt or
> -     dwo file later.  */
> -  if (mod->dw->debugdir == NULL && mod->elfdir != NULL
> +     create an Dwarf.  Help out a little in case we need to find an alt,
> +     dwo, or dwp file later.  */
> +  if (mod->dw->elfpath == NULL && mod->elfpath != NULL
>        && debugfile == &mod->main)
> -    mod->dw->debugdir = strdup (mod->elfdir);
> +    {
> +      mod->dw->elfpath = strdup (mod->elfpath);
> +      __libdw_set_debugdir (mod->dw);
> +    }

This is the same pattern as above. When adding the thread-safety locks
we might want to wrap this in a properly locked helper function.

>    /* Until we have iterated through all CU's, we might do lazy lookups.  */
>    mod->lazycu = 1;
> diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h
> index cdc528d0..b3dfea1d 100644
> --- a/libdwfl/libdwflP.h
> +++ b/libdwfl/libdwflP.h
> @@ -186,7 +186,7 @@ struct Dwfl_Module
>    Elf_Data *symxndxdata;	/* Data in the extended section index table. */
>    Elf_Data *aux_symxndxdata;	/* Data in the extended auxiliary table. */
>  
> -  char *elfdir;			/* The dir where we found the main Elf.  */
> +  char *elfpath;		/* The path where we found the main Elf.  */
>  
>    Dwarf *dw;			/* libdw handle for its debugging info.  */
>    Dwarf *alt;			/* Dwarf used for dwarf_setalt, or NULL.  */
> diff --git a/libdwfl/offline.c b/libdwfl/offline.c
> index e090b42b..50abe8c3 100644
> --- a/libdwfl/offline.c
> +++ b/libdwfl/offline.c
> @@ -151,9 +151,9 @@ process_elf (Dwfl *dwfl, const char *name, const char *file_name, int fd,
>        /* Don't keep the file descriptor around.  */
>        if (mod->main.fd != -1 && elf_cntl (mod->main.elf, ELF_C_FDREAD) == 0)
>  	{
> -	  /* Grab the dir path in case we want to report this file as
> +	  /* Grab the path in case we want to report this file as
>  	     Dwarf later.  */
> -	  mod->elfdir = __libdw_debugdir (mod->main.fd);
> +	  mod->elfpath = __libdw_elfpath (mod->main.fd);
>  	  close (mod->main.fd);
>  	  mod->main.fd = -1;
>  	}

OK.

Pushed,

Mark


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 10/14] libdw: Try .dwp file in __libdw_find_split_unit()
  2023-09-27 18:20 ` [PATCH 10/14] libdw: Try .dwp file in __libdw_find_split_unit() Omar Sandoval
@ 2023-11-02 19:56   ` Mark Wielaard
  2023-11-07  7:07     ` Omar Sandoval
  0 siblings, 1 reply; 38+ messages in thread
From: Mark Wielaard @ 2023-11-02 19:56 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: elfutils-devel

Hi Omar,

On Wed, Sep 27, 2023 at 11:20:59AM -0700, Omar Sandoval wrote:
> Try opening the file in the location suggested by the standard (the
> skeleton file name + ".dwp") and looking up the unit in the package
> index.  The rest is similar to .dwo files, with slightly different
> cleanup since a single Dwarf handle is shared.

This seems a good default given it is what the standard says.
But do you know of any distro doing this?

The case I am wondering about is for separate .debug files (which
surprisingly isn't standardized). In that case this would be
foobar.debug.dwz (and not foobar.dwz).

It might also be an idea to just create one file with both the
skeletons and the .dwo and dwz index sections.
 
> Signed-off-by: Omar Sandoval <osandov@fb.com>
> ---
>  libdw/ChangeLog                   | 11 ++++-
>  libdw/dwarf_begin_elf.c           |  1 +
>  libdw/dwarf_cu_dwp_section_info.c | 19 ++++++++
>  libdw/dwarf_end.c                 | 10 ++++-
>  libdw/libdwP.h                    | 16 ++++++-
>  libdw/libdw_find_split_unit.c     | 75 ++++++++++++++++++++++++++++---
>  6 files changed, 122 insertions(+), 10 deletions(-)
> 
> diff --git a/libdw/ChangeLog b/libdw/ChangeLog
> index f491587f..f37d9411 100644
> --- a/libdw/ChangeLog
> +++ b/libdw/ChangeLog
> @@ -1,6 +1,8 @@
>  2023-09-27  Omar Sandoval  <osandov@fb.com>
>  
>  	* libdw_find_split_unit.c (try_split_file): Make static.
> +	(try_dwp_file): New function.
> +	(__libdw_find_split_unit): Call try_dwp_file.
>  	* dwarf_entrypc.c (dwarf_entrypc): Call dwarf_lowpc.
>  	* dwarf_ranges.c (dwarf_ranges): Use skeleton ranges section for
>  	skeleton units.
> @@ -20,7 +22,8 @@
>  	instead of dbg parameter, which is now unused.
>  	* libdwP.h (Dwarf_Macro_Op_Table): Replace is_64bit with address_size
>  	and offset_size.  Add dbg.
> -	(Dwarf): Add cu_index and tu_index.  Add elfpath.
> +	(Dwarf): Add cu_index and tu_index.  Add elfpath.  Add dwp_dwarf and
> +	dwp_fd.
>  	(Dwarf_CU): Add dwp_row.
>  	(Dwarf_Package_Index): New type.
>  	(DW_SECT_TYPES): New macro.
> @@ -31,6 +34,8 @@
>  	(__libdw_debugdir): Replace declaration with...
>  	(__libdw_elfpath): New declaration.
>  	(__libdw_set_debugdir): New declaration.
> +	(__libdw_dwp_findcu_id): New declaration.
> +	(__libdw_link_skel_split): Handle .debug_addr for dwp.
>  	* dwarf_begin_elf.c (dwarf_scnnames): Add IDX_debug_cu_index and
>  	IDX_debug_tu_index.
>  	(scn_to_string_section_idx): Ditto.
> @@ -43,9 +48,11 @@
>  	(__libdw_set_debugdir): New function.
>  	(valid_p): Call __libdw_elfpath and __libdw_set_debugdir instead of
>  	__libdw_debugdir.
> +	(dwarf_begin_elf): Initialize result->dwp_fd.
>  	* Makefile.am (libdw_a_SOURCES): Add dwarf_cu_dwp_section_info.c.
>  	* dwarf_end.c (dwarf_end): Free dwarf->cu_index and dwarf->tu_index.
> -	Free dwarf->elfpath.
> +	Free dwarf->elfpath.  Free dwarf->dwp_dwarf and close dwarf->dwp_fd.
> +	(cu_free): Don't free split dbg if it is dwp_dwarf.
>  	* dwarf_error.c (errmsgs): Add DWARF_E_UNKNOWN_SECTION.
>  	* libdw.h (dwarf_cu_dwp_section_info): New declaration.
>  	* libdw.map (ELFUTILS_0.190): Add dwarf_cu_dwp_section_info.
> diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
> index 323a91d0..ca2b7e2a 100644
> --- a/libdw/dwarf_begin_elf.c
> +++ b/libdw/dwarf_begin_elf.c
> @@ -567,6 +567,7 @@ dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp)
>  
>    result->elf = elf;
>    result->alt_fd = -1;
> +  result->dwp_fd = -1;
>  
>    /* Initialize the memory handling.  Initial blocks are allocated on first
>       actual allocation.  */
> diff --git a/libdw/dwarf_cu_dwp_section_info.c b/libdw/dwarf_cu_dwp_section_info.c
> index 6766fb9a..7bf08d9d 100644
> --- a/libdw/dwarf_cu_dwp_section_info.c
> +++ b/libdw/dwarf_cu_dwp_section_info.c
> @@ -340,6 +340,25 @@ __libdw_dwp_find_unit (Dwarf *dbg, bool debug_types, Dwarf_Off off,
>  				   abbrev_offsetp, NULL);
>  }
>  
> +Dwarf_CU *
> +internal_function
> +__libdw_dwp_findcu_id (Dwarf *dbg, uint64_t unit_id8)
> +{
> +  Dwarf_Package_Index *index = __libdw_package_index (dbg, false);
> +  uint32_t unit_row;
> +  Dwarf_Off offset;
> +  Dwarf_CU *cu;
> +  if (__libdw_dwp_unit_row (index, unit_id8, &unit_row) == 0
> +      && __libdw_dwp_section_info (index, unit_row, DW_SECT_INFO, &offset,
> +				   NULL) == 0
> +      && (cu = __libdw_findcu (dbg, offset, false)) != NULL
> +      && cu->unit_type == DW_UT_split_compile
> +      && cu->unit_id8 == unit_id8)
> +    return cu;
> +  else
> +    return NULL;
> +}

No lookup for split_type?

>  int
>  dwarf_cu_dwp_section_info (Dwarf_CU *cu, unsigned int section,
>  			   Dwarf_Off *offsetp, Dwarf_Off *sizep)
> diff --git a/libdw/dwarf_end.c b/libdw/dwarf_end.c
> index b7f817d9..78224ddb 100644
> --- a/libdw/dwarf_end.c
> +++ b/libdw/dwarf_end.c
> @@ -66,7 +66,9 @@ cu_free (void *arg)
>  	  /* The fake_addr_cu might be shared, only release one.  */
>  	  if (p->dbg->fake_addr_cu == p->split->dbg->fake_addr_cu)
>  	    p->split->dbg->fake_addr_cu = NULL;
> -	  INTUSE(dwarf_end) (p->split->dbg);
> +	  /* There is only one DWP file. We free it later.  */
> +	  if (p->split->dbg != p->dbg->dwp_dwarf)
> +	    INTUSE(dwarf_end) (p->split->dbg);
>  	}
>      }
>  }
> @@ -147,6 +149,12 @@ dwarf_end (Dwarf *dwarf)
>  	  close (dwarf->alt_fd);
>  	}
>  
> +      if (dwarf->dwp_fd != -1)
> +	{
> +	  INTUSE(dwarf_end) (dwarf->dwp_dwarf);
> +	  close (dwarf->dwp_fd);
> +	}
> +
>        /* The cached path and dir we found the Dwarf ELF file in.  */
>        free (dwarf->elfpath);
>        free (dwarf->debugdir);

OK

> diff --git a/libdw/libdwP.h b/libdw/libdwP.h
> index 214d1711..16355274 100644
> --- a/libdw/libdwP.h
> +++ b/libdw/libdwP.h
> @@ -180,6 +180,9 @@ struct Dwarf
>    /* dwz alternate DWARF file.  */
>    Dwarf *alt_dwarf;
>  
> +  /* DWARF package file.  */
> +  Dwarf *dwp_dwarf;
> +
>    /* The section data.  */
>    Elf_Data *sectiondata[IDX_last];
>  
> @@ -197,6 +200,9 @@ struct Dwarf
>       close this file descriptor.  */
>    int alt_fd;
>  
> +  /* File descriptor of DWARF package file.  */
> +  int dwp_fd;
> +
>    /* Information for traversing the .debug_pubnames section.  This is
>       an array and separately allocated with malloc.  */
>    struct pubnames_s
> @@ -719,6 +725,10 @@ extern int __libdw_dwp_find_unit (Dwarf *dbg, bool debug_types, Dwarf_Off off,
>  				  Dwarf_Off *abbrev_offsetp)
>       __nonnull_attribute__ (1, 7, 8) internal_function;
>  
> +/* Find the compilation unit in a DWARF package file with the given id.  */
> +extern Dwarf_CU *__libdw_dwp_findcu_id (Dwarf *dbg, uint64_t unit_id8)
> +     __nonnull_attribute__ (1) internal_function;
> +
>  /* Get abbreviation with given code.  */
>  extern Dwarf_Abbrev *__libdw_findabbrev (struct Dwarf_CU *cu,
>  					 unsigned int code)

OK.

> @@ -1373,8 +1383,10 @@ __libdw_link_skel_split (Dwarf_CU *skel, Dwarf_CU *split)
>       There is only one per split debug.  */
>    Dwarf *dbg = skel->dbg;
>    Dwarf *sdbg = split->dbg;
> -  if (sdbg->sectiondata[IDX_debug_addr] == NULL
> -      && dbg->sectiondata[IDX_debug_addr] != NULL)
> +  if (dbg->sectiondata[IDX_debug_addr] != NULL
> +      && (sdbg->sectiondata[IDX_debug_addr] == NULL
> +	  || (sdbg->sectiondata[IDX_debug_addr]
> +	      == dbg->sectiondata[IDX_debug_addr])))
>      {
>        sdbg->sectiondata[IDX_debug_addr]
>  	= dbg->sectiondata[IDX_debug_addr];

ehe? What exactly are we checking here?

> diff --git a/libdw/libdw_find_split_unit.c b/libdw/libdw_find_split_unit.c
> index 533f8072..e1e78951 100644
> --- a/libdw/libdw_find_split_unit.c
> +++ b/libdw/libdw_find_split_unit.c
> @@ -85,6 +85,67 @@ try_split_file (Dwarf_CU *cu, const char *dwo_path)
>      }
>  }
>  
> +static void
> +try_dwp_file (Dwarf_CU *cu)
> +{
> +  if (cu->dbg->dwp_dwarf == NULL)
> +    {
> +      if (cu->dbg->elfpath != NULL)
> +	{
> +	  /* The DWARF 5 standard says "the package file is typically placed in
> +	     the same directory as the application, and is given the same name
> +	     with a '.dwp' extension".  */
> +	  size_t elfpath_len = strlen (cu->dbg->elfpath);
> +	  char *dwp_path = malloc (elfpath_len + 5);
> +	  if (dwp_path == NULL)
> +	    {
> +	      __libdw_seterrno (DWARF_E_NOMEM);
> +	      return;
> +	    }

Yes, but the caller doesn't check for errors. So the seterrno is not
very useful.

> +	  memcpy (dwp_path, cu->dbg->elfpath, elfpath_len);
> +	  strcpy (dwp_path + elfpath_len, ".dwp");
> +	  int dwp_fd = open (dwp_path, O_RDONLY);
> +	  free (dwp_path);
> +	  if (dwp_fd != -1)
> +	    {
> +	      Dwarf *dwp_dwarf = dwarf_begin (dwp_fd, DWARF_C_READ);
> +	      /* There's no way to know whether we got the correct file until
> +		 we look up the unit, but it should at least be a dwp file.  */
> +	      if (dwp_dwarf != NULL
> +		  && (dwp_dwarf->sectiondata[IDX_debug_cu_index] != NULL
> +		      || dwp_dwarf->sectiondata[IDX_debug_tu_index] != NULL))
> +		{
> +		  cu->dbg->dwp_dwarf = dwp_dwarf;
> +		  cu->dbg->dwp_fd = dwp_fd;
> +		}
> +	      else
> +		close (dwp_fd);
> +	    }
> +	}
> +      if (cu->dbg->dwp_dwarf == NULL)
> +	cu->dbg->dwp_dwarf = (Dwarf *) -1;
> +    }
> +
> +  if (cu->dbg->dwp_dwarf != (Dwarf *) -1)
> +    {
> +      Dwarf_CU *split = __libdw_dwp_findcu_id (cu->dbg->dwp_dwarf,
> +					       cu->unit_id8);
> +      if (split != NULL)
> +	{
> +	  if (tsearch (split->dbg, &cu->dbg->split_tree,
> +		       __libdw_finddbg_cb) == NULL)
> +	    {
> +	      /* Something went wrong.  Don't link.  */
> +	      __libdw_seterrno (DWARF_E_NOMEM);
> +	      return;
> +	    }

Same as above.

> +	  /* Link skeleton and split compile units.  */
> +	  __libdw_link_skel_split (cu, split);
> +	}
> +    }
> +}

OK.

>  Dwarf_CU *
>  internal_function
>  __libdw_find_split_unit (Dwarf_CU *cu)
> @@ -98,14 +159,18 @@ __libdw_find_split_unit (Dwarf_CU *cu)
>       same id as the skeleton.  */
>    if (cu->unit_type == DW_UT_skeleton)
>      {
> +      /* First, try the dwp file.  */
> +      try_dwp_file (cu);
> +
>        Dwarf_Die cudie = CUDIE (cu);
>        Dwarf_Attribute dwo_name;
> -      /* It is fine if dwo_dir doesn't exists, but then dwo_name needs
> -	 to be an absolute path.  */
> -      if (dwarf_attr (&cudie, DW_AT_dwo_name, &dwo_name) != NULL
> -	  || dwarf_attr (&cudie, DW_AT_GNU_dwo_name, &dwo_name) != NULL)
> +      /* Try a dwo file.  It is fine if dwo_dir doesn't exist, but then
> +	 dwo_name needs to be an absolute path.  */
> +      if (cu->split == (Dwarf_CU *) -1
> +	  && (dwarf_attr (&cudie, DW_AT_dwo_name, &dwo_name) != NULL
> +	      || dwarf_attr (&cudie, DW_AT_GNU_dwo_name, &dwo_name) != NULL))
>  	{
> -	  /* First try the dwo file name in the same directory
> +	  /* Try the dwo file name in the same directory
>  	     as we found the skeleton file.  */
>  	  const char *dwo_file = dwarf_formstring (&dwo_name);
>  	  const char *debugdir = cu->dbg->debugdir;

OK. Because try_dwp_file will call __libdw_link_skel_split to set
cu->split.

This again will have to be analyzed carefully when we add the
thread-safety work.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 11/14] tests: Handle DW_MACRO_{define, undef}_{strx, sup} in dwarf-getmacros
  2023-09-27 18:21 ` [PATCH 11/14] tests: Handle DW_MACRO_{define,undef}_{strx,sup} in dwarf-getmacros Omar Sandoval
@ 2023-11-02 20:30   ` Mark Wielaard
  0 siblings, 0 replies; 38+ messages in thread
From: Mark Wielaard @ 2023-11-02 20:30 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: elfutils-devel

Hi Omar,

On Wed, Sep 27, 2023 at 11:21:00AM -0700, Omar Sandoval wrote:
> +	* dwarf-getmacros.c (mac): Add DW_MACRO_define_sup,
> +	DW_MACRO_define_strx, DW_MACRO_undef_sup, and DW_MACRO_undef_strx
> +	cases to opcode switch statement.

Looks sane. Applied and pushed.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 12/14] tests: Optionally dump all units in dwarf-getmacros
  2023-09-27 18:21 ` [PATCH 12/14] tests: Optionally dump all units " Omar Sandoval
@ 2023-11-02 20:39   ` Mark Wielaard
  0 siblings, 0 replies; 38+ messages in thread
From: Mark Wielaard @ 2023-11-02 20:39 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: elfutils-devel

Hi Omar,

On Wed, Sep 27, 2023 at 11:21:01AM -0700, Omar Sandoval wrote:
> If instead of a CU offset an empty string is given as the second
> argument, dump all units.

Pushed,

Mark

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 13/14] libdw: Apply DWARF package file section offsets where appropriate
  2023-09-27 18:21 ` [PATCH 13/14] libdw: Apply DWARF package file section offsets where appropriate Omar Sandoval
@ 2023-11-02 22:20   ` Mark Wielaard
  2023-11-07 16:55     ` Omar Sandoval
  0 siblings, 1 reply; 38+ messages in thread
From: Mark Wielaard @ 2023-11-02 22:20 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: elfutils-devel

Hi Omar,

On Wed, Sep 27, 2023 at 11:21:02AM -0700, Omar Sandoval wrote:
> The final piece of DWARF package file support is that offsets have to be
> interpreted relative to the section offset from the package index.
> .debug_abbrev.dwo is already covered, so sprinkle around calls to
> dwarf_cu_dwp_section_info for the remaining sections: .debug_line.dwo,
> .debug_loclists.dwo/.debug_loc.dwo, .debug_str_offsets.dwo,
> .debug_macro.dwo/.debug_macinfo.dwo, and .debug_rnglists.dwo.  With all
> of that in place, we can finally test various libdw functions on dwp
> files.

This looks good, but obviously needs some earlier patches.

> diff --git a/libdw/ChangeLog b/libdw/ChangeLog
> index f37d9411..08b2c3e6 100644
> --- a/libdw/ChangeLog
> +++ b/libdw/ChangeLog
> @@ -12,10 +12,13 @@
>  	* dwarf_getmacros.c (get_macinfo_table): Replace assignment of
>  	table->is_64bit with assignments of table->address_size and
>  	table->offset_size.  Assume default DW_AT_stmt_list of 0 for split
> -	DWARF.  Set table->dbg.
> +	DWARF.  Set table->dbg.  Call dwarf_cu_dwp_section_info and add offset
> +	to line_offset.
>  	(get_table_for_offset): Ditto.
>  	(read_macros): Get fake CU offset_size from table->offset_size instead
>  	of table->is_64bit.
> +	(get_offset_from): Call dwarf_cu_dwp_section_info and add offset to
> +	*retp.
>  	* dwarf_macro_getsrcfiles.c (dwarf_macro_getsrcfiles): Get
>  	address_size for __libdw_getsrclines from table->address_size instead
>  	of table->is_64bit.  Get dbg for __libdw_getsrclines from table->dbg
> @@ -36,6 +39,9 @@
>  	(__libdw_set_debugdir): New declaration.
>  	(__libdw_dwp_findcu_id): New declaration.
>  	(__libdw_link_skel_split): Handle .debug_addr for dwp.
> +	(str_offsets_base_off): Call dwarf_cu_dwp_section_info and add offset.
> +	(__libdw_cu_ranges_base): Ditto.
> +	(__libdw_cu_locs_base): Ditto.
>  	* dwarf_begin_elf.c (dwarf_scnnames): Add IDX_debug_cu_index and
>  	IDX_debug_tu_index.
>  	(scn_to_string_section_idx): Ditto.
> @@ -60,6 +66,8 @@
>  	__libdw_dwp_find_unit, and use it to adjust abbrev_offset and assign
>  	newp->dwp_row.
>  	* dwarf_cu_dwp_section_info.c: New file.
> +	* dwarf_getlocation.c (initial_offset): Call dwarf_cu_dwp_section_info
> +	and add offset to start_offset.
>  
>  2023-02-22  Mark Wielaard  <mark@klomp.org>
>  
> diff --git a/libdw/dwarf_getlocation.c b/libdw/dwarf_getlocation.c
> index 553fdc98..37b32fc1 100644
> --- a/libdw/dwarf_getlocation.c
> +++ b/libdw/dwarf_getlocation.c
> @@ -812,6 +812,12 @@ initial_offset (Dwarf_Attribute *attr, ptrdiff_t *offset)
>  			    : DWARF_E_NO_DEBUG_LOCLISTS),
>  			    NULL, &start_offset) == NULL)
>  	return -1;
> +
> +      Dwarf_Off loc_off;
> +      if (INTUSE(dwarf_cu_dwp_section_info) (attr->cu, DW_SECT_LOCLISTS,
> +					     &loc_off, NULL) != 0)
> +	return -1;
> +      start_offset += loc_off;
>      }
>  
>    *offset = start_offset;

OK. This already handled DW_FORM_loclistx, now also other loclist
refs.

> diff --git a/libdw/dwarf_getmacros.c b/libdw/dwarf_getmacros.c
> index a3a78884..2667eb45 100644
> --- a/libdw/dwarf_getmacros.c
> +++ b/libdw/dwarf_getmacros.c
> @@ -47,7 +47,15 @@ get_offset_from (Dwarf_Die *die, int name, Dwarf_Word *retp)
>      return -1;
>  
>    /* Offset into the corresponding section.  */
> -  return INTUSE(dwarf_formudata) (&attr, retp);
> +  if (INTUSE(dwarf_formudata) (&attr, retp) != 0)
> +    return -1;
> +
> +  Dwarf_Off offset;
> +  if (INTUSE(dwarf_cu_dwp_section_info) (die->cu, DW_SECT_MACRO, &offset, NULL)
> +      != 0)
> +    return -1;
> +  *retp += offset;
> +  return 0;
>  }

OK.

>  static int
> @@ -131,6 +139,14 @@ get_macinfo_table (Dwarf *dbg, Dwarf_Word macoff, Dwarf_Die *cudie)
>    else if (cudie->cu->unit_type == DW_UT_split_compile
>  	   && dbg->sectiondata[IDX_debug_line] != NULL)
>      line_offset = 0;
> +  if (line_offset != (Dwarf_Off) -1)
> +    {
> +      Dwarf_Off dwp_offset;
> +      if (INTUSE(dwarf_cu_dwp_section_info) (cudie->cu, DW_SECT_LINE,
> +					     &dwp_offset, NULL) != 0)
> +	return NULL;
> +      line_offset += dwp_offset;
> +    }

OK.
 
>    Dwarf_Macro_Op_Table *table = libdw_alloc (dbg, Dwarf_Macro_Op_Table,
>  					     macinfo_data_size, 1);
> @@ -188,6 +204,14 @@ get_table_for_offset (Dwarf *dbg, Dwarf_Word macoff,
>  	if (unlikely (INTUSE(dwarf_formudata) (attr, &line_offset) != 0))
>  	  return NULL;
>      }
> +  if (line_offset != (Dwarf_Off) -1 && cudie != NULL)
> +    {
> +      Dwarf_Off dwp_offset;
> +      if (INTUSE(dwarf_cu_dwp_section_info) (cudie->cu, DW_SECT_LINE,
> +					     &dwp_offset, NULL) != 0)
> +	return NULL;
> +      line_offset += dwp_offset;
> +    }
>  
>    uint8_t address_size;
>    if (cudie != NULL)

OK.

> diff --git a/libdw/libdwP.h b/libdw/libdwP.h
> index 16355274..bdbf5e5a 100644
> --- a/libdw/libdwP.h
> +++ b/libdw/libdwP.h
> @@ -1111,25 +1111,27 @@ str_offsets_base_off (Dwarf *dbg, Dwarf_CU *cu)
>  	cu = first_cu;
>      }
>  
> +  Dwarf_Off off = 0;
>    if (cu != NULL)
>      {
>        if (cu->str_off_base == (Dwarf_Off) -1)
>  	{
> +	  dwarf_cu_dwp_section_info (cu, DW_SECT_STR_OFFSETS, &off, NULL);
>  	  Dwarf_Die cu_die = CUDIE(cu);
>  	  Dwarf_Attribute attr;
>  	  if (dwarf_attr (&cu_die, DW_AT_str_offsets_base, &attr) != NULL)
>  	    {
> -	      Dwarf_Word off;
> -	      if (dwarf_formudata (&attr, &off) == 0)
> +	      Dwarf_Word base;
> +	      if (dwarf_formudata (&attr, &base) == 0)
>  		{
> -		  cu->str_off_base = off;
> +		  cu->str_off_base = off + base;
>  		  return cu->str_off_base;
>  		}
>  	    }
>  	  /* For older DWARF simply assume zero (no header).  */
>  	  if (cu->version < 5)
>  	    {
> -	      cu->str_off_base = 0;
> +	      cu->str_off_base = off;
>  	      return cu->str_off_base;
>  	    }
>  
> @@ -1142,7 +1144,6 @@ str_offsets_base_off (Dwarf *dbg, Dwarf_CU *cu)
>  
>    /* No str_offsets_base attribute, we have to assume "zero".
>       But there could be a header first.  */
> -  Dwarf_Off off = 0;
>    if (dbg == NULL)
>      goto no_header;
>  
> @@ -1184,7 +1185,7 @@ str_offsets_base_off (Dwarf *dbg, Dwarf_CU *cu)
>    /* padding */
>    read_2ubyte_unaligned_inc (dbg, readp);
>  
> -  off = (Dwarf_Off) (readp - start);
> +  off += (Dwarf_Off) (readp - start);
>  
>   no_header:
>    if (cu != NULL)


OK, so the dwp section offset gets added to the base attribute offset.

> @@ -1222,18 +1223,22 @@ __libdw_cu_ranges_base (Dwarf_CU *cu)
>  	}
>        else
>  	{
> +	  Dwarf_Off dwp_offset = 0;
> +	  dwarf_cu_dwp_section_info (cu, DW_SECT_RNGLISTS, &dwp_offset, NULL);

Shouldn't we check there wasn't an error?

> +	  offset = dwp_offset;
> +
>  	  if (dwarf_attr (&cu_die, DW_AT_rnglists_base, &attr) != NULL)
>  	    {
>  	      Dwarf_Word off;
>  	      if (dwarf_formudata (&attr, &off) == 0)
> -		offset = off;
> +		offset += off;
>  	    }
>  
>  	  /* There wasn't an rnglists_base, if the Dwarf does have a
>  	     .debug_rnglists section, then it might be we need the
>  	     base after the first header. */
>  	  Elf_Data *data = cu->dbg->sectiondata[IDX_debug_rnglists];
> -	  if (offset == 0 && data != NULL)
> +	  if (offset == dwp_offset && data != NULL)
>  	    {
>  	      Dwarf *dbg = cu->dbg;
>  	      const unsigned char *readp = data->d_buf;
> @@ -1279,8 +1284,8 @@ __libdw_cu_ranges_base (Dwarf_CU *cu)
>  	      if (unit_length - 8 < needed)
>  		goto no_header;
>  
> -	      offset = (Dwarf_Off) (offset_array_start
> -				    - (unsigned char *) data->d_buf);
> +	      offset += (Dwarf_Off) (offset_array_start
> +				     - (unsigned char *) data->d_buf);
>  	    }
>  	}
>      no_header:

OK, same for ranges.

> @@ -1297,21 +1302,24 @@ __libdw_cu_locs_base (Dwarf_CU *cu)
>  {
>    if (cu->locs_base == (Dwarf_Off) -1)
>      {
> -      Dwarf_Off offset = 0;
> +      Dwarf_Off dwp_offset = 0;
> +      dwarf_cu_dwp_section_info (cu, DW_SECT_LOCLISTS, &dwp_offset, NULL);

No error check?

> +      Dwarf_Off offset = dwp_offset;
> +
>        Dwarf_Die cu_die = CUDIE(cu);
>        Dwarf_Attribute attr;
>        if (dwarf_attr (&cu_die, DW_AT_loclists_base, &attr) != NULL)
>  	{
>  	  Dwarf_Word off;
>  	  if (dwarf_formudata (&attr, &off) == 0)
> -	    offset = off;
> +	    offset += off;
>  	}
>  
>        /* There wasn't an loclists_base, if the Dwarf does have a
>  	 .debug_loclists section, then it might be we need the
>  	 base after the first header. */
>        Elf_Data *data = cu->dbg->sectiondata[IDX_debug_loclists];
> -      if (offset == 0 && data != NULL)
> +      if (offset == dwp_offset && data != NULL)
>  	{
>  	  Dwarf *dbg = cu->dbg;
>  	  const unsigned char *readp = data->d_buf;
> @@ -1357,8 +1365,8 @@ __libdw_cu_locs_base (Dwarf_CU *cu)
>  	  if (unit_length - 8 < needed)
>  	    goto no_header;
>  
> -	  offset = (Dwarf_Off) (offset_array_start
> -				- (unsigned char *) data->d_buf);
> +	  offset += (Dwarf_Off) (offset_array_start
> +				 - (unsigned char *) data->d_buf);
>  	}
>  
>      no_header:

OK. Same for loclists.

> diff --git a/tests/ChangeLog b/tests/ChangeLog
> index 97261444..93503f57 100644
> --- a/tests/ChangeLog
> +++ b/tests/ChangeLog
> @@ -1,6 +1,7 @@
>  2023-09-27  Omar Sandoval  <osandov@fb.com>
>  
> -	* run-varlocs.sh: Add entry PC to split units.
> +	* run-varlocs.sh: Add entry PC to split units.  Check testfile-dwp-5
> +	and testfile-dwp-4.
>  	* Makefile.am (check_PROGRAMS): Add cu-dwp-section-info.
>  	(TESTS): Add run-cu-dwp-section-info.sh
>  	(EXTRA_DIST): Add run-cu-dwp-section-info.sh and new test files.
> @@ -20,6 +21,11 @@
>  	(getmacros): New function.
>  	(main): If second argument is empty, call getmacros on every unit.
>  	Otherwise, call getmacros on given unit.
> +	* run-all-dwarf-ranges.sh: Check testfile-dwp-5 and testfile-dwp-4.
> +	* run-dwarf-getmacros.sh: Check testfile-dwp-5 and
> +	testfile-dwp-4-strict.
> +	* run-get-units-split.sh: Check testfile-dwp-5, testfile-dwp-4, and
> +	testfile-dwp-4-strict.

Nice collection of tests.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 00/14] elfutils: DWARF package (.dwp) file support
  2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
                   ` (15 preceding siblings ...)
  2023-10-03 21:54 ` Mark Wielaard
@ 2023-11-02 23:05 ` Mark Wielaard
  2023-11-07 17:13   ` Omar Sandoval
  16 siblings, 1 reply; 38+ messages in thread
From: Mark Wielaard @ 2023-11-02 23:05 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: elfutils-devel

Hi Omar,

On Wed, Sep 27, 2023 at 11:20:49AM -0700, Omar Sandoval wrote:
> This patch series adds support for DWARF package files to libdw and the
> elfutils tools. It supports the GNU DebugFission format for DWARF 4 [1]
> and the format standardized in DWARF 5 (section 7.3.5 "DWARF Package
> Files"). It supports both automatically opening the .dwp file for a
> skeleton unit and examining the .dwp file alone, just like for .dwo
> files.

I had hoped to review and apply all this for the 0.190 release
tomorrow, but wasn't fast enough. In general it looks very good and
most has been applied as is. Except for the last patch I don't have
real concerns, just a few questions (see the specific reviews).

> Patch 1 is a trivial cleanup I found while developing this. Patches 2-6
> are fixes for unrelated bugs in split DWARF and/or DWARF 5 that I
> encountered while adding test cases for this series.

These have all been applied some time ago.

> The actual dwp support is in patches 7-10 and 13, including test cases.

7 and 9 have been applied already. 8 has some comments/nitpicks, I can
probably easily be convinced to accept it. 10 looks good, but depends
on 8, some questions, specificly about handling split type units. 13
looks good, but depends on 8 and 10.

> Patches 11 and 12 enable testing macro information in dwp files.

Both applied.

> Patch 14 adds support and tests for an LLVM extension to the dwp
> format.

I have to think a bit more on this.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 08/14] libdw: Parse DWARF package file index sections
  2023-11-01 23:07   ` Mark Wielaard
@ 2023-11-07  6:45     ` Omar Sandoval
  0 siblings, 0 replies; 38+ messages in thread
From: Omar Sandoval @ 2023-11-07  6:45 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

On Thu, Nov 02, 2023 at 12:07:04AM +0100, Mark Wielaard wrote:
> Hi Omar,
> 
> On Wed, Sep 27, 2023 at 11:20:57AM -0700, Omar Sandoval wrote:
> > The .debug_cu_index and .debug_tu_index sections in DWARF package files
> > are basically hash tables mapping a unit's 8 byte signature to an offset
> > and size in each section used by that unit [1].  Add support for parsing
> > and doing lookups in the index sections.
> > 
> > We look up a unit in the index when we intern it and cache its hash
> > table row in Dwarf_CU.
> 
> This looks good. Thanks for the various testcases.
> 
> Do I understand correctly that binutils dwp only does the DWARF4 GNU
> extension and llvm-dwp only does the DWARF5 standardized format? Maybe
> we should create a eu-dwp that does both.

llvm-dwp can do both the DWARF4 GNU format and the DWARF5 format.
binutils dwp can only do DWARF4.

> It looks like you are very careful checking boundaries, but it would
> be bad to do some fuzzing on this.
> 
> > Then, a new function, dwarf_cu_dwp_section_info,
> > can be used to look up the section offsets and sizes for a unit.  This
> > will mostly be used internally in libdw, but it will also be needed in
> > static inline functions shared with eu-readelf.  Additionally, making it
> > public it makes dwp support much easier for external tools that do their
> > own low-level parsing of DWARF information, like drgn [2].
> 
> Although I am not against this new interface, I am not super
> enthousiastic about it.
> 
> There is one odd part, DW_SECT_TYPES should be defined in dwarf.h with
> the other DW_SECT constants, otherwise it cannot be used (unless you
> define it yourself to 2).

Yeah, I wasn't sure about adding it or not since it's not technically
defined in the DWARF5 standard. But if we can count on future DWARF
standards not reusing the value 2 (which we probably can), I agree that
it seems better to add it to dwarf.h.

> For eu-readelf we don't really need it being public, it already cheats
> a little and uses some (non-public) libdwP.h functions. That is
> actually not great either. So if there is a public function that is
> available that is actually preferred. But if it is just for
> eu-readelf, I don't think it is really needed. And it seems you
> haven't actually added the support to eu-readelf to print these
> offsets.

Right, eu-readelf only uses it indirectly via the static inline
functions modified in patch 13. It looks like eu-readelf dynamically
links to libdw (on Fedora, at least), so either some part of the dwp
implementation needs to be exported, or a big chunk of it needs to be
inlined in libdwP.h, right?

Either way, I'd still love to have this interface for drgn.

> It is fine to expose these offsets and sizes, but how exactly are you
> using them in drgn? It seems we don't have any other interfaces in
> libdw that you can then use these with.

Here's the branch I linked to in my cover letter:
https://github.com/osandov/drgn/tree/dwp. I need this interface for the
couple of places where drgn parses DWARF itself.

One of those places is in the global name indexing step drgn does at
startup. We do this by enumerating all CUs using libdw, then using our
own purpose-built DWARF parser to do a fast, parallelized scan.

Our bespoke parser needs to know the base of the abbreviation table and
the string offsets table, which is easy without dwp. This interface also
makes it easy with dwp. Without this interface, I'd need to reimplement
the CU index parser in drgn :(

> Can we split off this public interface from the rest of this patch?
> But then we also need to split off the tests. So maybe keep them together?

Yeah, I included the interface in this patch exactly so that I could
test the implementation in the same patch. I'm happy to split that up
however you'd prefer.

[snip]

> > +  Dwarf_Package_Index *index = malloc (sizeof (*index));
> > +  if (index == NULL)
> > +    {
> > +      __libdw_seterrno (DWARF_E_NOMEM);
> > +      return NULL;
> > +    }
> > +
> > +  index->dbg = dbg;
> > +  /* Set absent sections to UINT32_MAX.  */
> > +  memset (index->sections, 0xff, sizeof (index->sections));
> 
> OK, although I would have preferred a simple for loop and let the
> compiler optimize it.

Ok, I can fix that.

[snip]

> > +static int
> > +__libdw_dwp_section_info (Dwarf_Package_Index *index, uint32_t unit_row,
> > +			  unsigned int section, Dwarf_Off *offsetp,
> > +			  Dwarf_Off *sizep)
> > +{
> > +  if (index == NULL)
> > +    return -1;
> > +  if (unit_row == 0)
> > +    {
> > +      __libdw_seterrno (DWARF_E_INVALID_DWARF);
> > +      return -1;
> > +    }
> 
> OK, but why isn't the caller checking this?

Partially becase it simplified callers like __libdw_dwp_findcu_id to not
require a separate check, and partially just to be defensive.

[snip]

Thanks for taking a look!

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 09/14] libdw, libdwfl: Save original path of ELF file
  2023-11-02 17:04   ` Mark Wielaard
@ 2023-11-07  6:46     ` Omar Sandoval
  0 siblings, 0 replies; 38+ messages in thread
From: Omar Sandoval @ 2023-11-07  6:46 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

On Thu, Nov 02, 2023 at 06:04:27PM +0100, Mark Wielaard wrote:
> Hi Omar,
> 
> On Wed, 2023-09-27 at 11:20 -0700, Omar Sandoval wrote:
> > libdw and libdwfl currently save the path of the directory containing
> > the ELF file to use when searching for alt and dwo files.  To search for
> > dwp files, we need the file name too.  Add an elfpath field to Dwarf,
> > and set the debugdir field from it.  Also update libdwfl to set elfpath
> > and debugdir.
> 
> This looks good. We will need some locking around this code when we
> integrate the thread-safety work. But that should be pretty clear.
> 
> > 
> > Signed-off-by: Omar Sandoval <osandov@fb.com>
> > ---
> >  libdw/ChangeLog                | 11 ++++++++++-
> >  libdw/dwarf_begin_elf.c        | 34 ++++++++++++++++++++--------------
> >  libdw/dwarf_end.c              |  3 ++-
> >  libdw/libdwP.h                 | 12 ++++++++++--
> >  libdwfl/ChangeLog              |  9 +++++++++
> >  libdwfl/dwfl_module.c          |  2 +-
> >  libdwfl/dwfl_module_getdwarf.c | 11 +++++++----
> >  libdwfl/libdwflP.h             |  2 +-
> >  libdwfl/offline.c              |  4 ++--
> >  9 files changed, 62 insertions(+), 26 deletions(-)
> > 
> > diff --git a/libdw/ChangeLog b/libdw/ChangeLog
> > index 1d229094..f491587f 100644
> > --- a/libdw/ChangeLog
> > +++ b/libdw/ChangeLog
> > @@ -20,7 +20,7 @@
> >  	instead of dbg parameter, which is now unused.
> >  	* libdwP.h (Dwarf_Macro_Op_Table): Replace is_64bit with address_size
> >  	and offset_size.  Add dbg.
> > -	(Dwarf): Add cu_index and tu_index.
> > +	(Dwarf): Add cu_index and tu_index.  Add elfpath.
> >  	(Dwarf_CU): Add dwp_row.
> >  	(Dwarf_Package_Index): New type.
> >  	(DW_SECT_TYPES): New macro.
> > @@ -28,6 +28,9 @@
> >  	(dwarf_cu_dwp_section_info): New INTDECL.
> >  	Add IDX_debug_cu_index and IDX_debug_tu_index.  Add
> >  	DWARF_E_UNKNOWN_SECTION.
> > +	(__libdw_debugdir): Replace declaration with...
> > +	(__libdw_elfpath): New declaration.
> > +	(__libdw_set_debugdir): New declaration.
> >  	* dwarf_begin_elf.c (dwarf_scnnames): Add IDX_debug_cu_index and
> >  	IDX_debug_tu_index.
> >  	(scn_to_string_section_idx): Ditto.
> > @@ -35,8 +38,14 @@
> >  	.zdebug_cu_index, and .zdebug_tu_index.
> >  	(check_section): Change .dwo suffix matching to account for
> >  	.debug_cu_index and .debug_tu_index.
> > +	(__libdw_debugdir): Replace with..
> > +	(__libdw_elfpath): New function.
> > +	(__libdw_set_debugdir): New function.
> > +	(valid_p): Call __libdw_elfpath and __libdw_set_debugdir instead of
> > +	__libdw_debugdir.
> >  	* Makefile.am (libdw_a_SOURCES): Add dwarf_cu_dwp_section_info.c.
> >  	* dwarf_end.c (dwarf_end): Free dwarf->cu_index and dwarf->tu_index.
> > +	Free dwarf->elfpath.
> >  	* dwarf_error.c (errmsgs): Add DWARF_E_UNKNOWN_SECTION.
> >  	* libdw.h (dwarf_cu_dwp_section_info): New declaration.
> >  	* libdw.map (ELFUTILS_0.190): Add dwarf_cu_dwp_section_info.
> 
> I had to recreate the ChangeLog entry because we skipped your patch 08.
> In the future lets just move the ChangeLog Entry into the commit
> message (we just updated CONTRIBUTING to recommend this). That makes
> rebasing slightly

Thanks for updating that, that's so much easier to work with :)

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 10/14] libdw: Try .dwp file in __libdw_find_split_unit()
  2023-11-02 19:56   ` Mark Wielaard
@ 2023-11-07  7:07     ` Omar Sandoval
  0 siblings, 0 replies; 38+ messages in thread
From: Omar Sandoval @ 2023-11-07  7:07 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

On Thu, Nov 02, 2023 at 08:56:14PM +0100, Mark Wielaard wrote:
> Hi Omar,
> 
> On Wed, Sep 27, 2023 at 11:20:59AM -0700, Omar Sandoval wrote:
> > Try opening the file in the location suggested by the standard (the
> > skeleton file name + ".dwp") and looking up the unit in the package
> > index.  The rest is similar to .dwo files, with slightly different
> > cleanup since a single Dwarf handle is shared.
> 
> This seems a good default given it is what the standard says.
> But do you know of any distro doing this?

I don't. As far as I know, Meta and Google are the only ones using dwp
widely, and we're putting it in the location recommended by the
standard. (I think some Rust tooling is starting to pick dwp up, too,
but I haven't looked into it much.)

> The case I am wondering about is for separate .debug files (which
> surprisingly isn't standardized). In that case this would be
> foobar.debug.dwz (and not foobar.dwz).
> 
> It might also be an idea to just create one file with both the
> skeletons and the .dwo and dwz index sections.
>  
> > Signed-off-by: Omar Sandoval <osandov@fb.com>
> > ---
> >  libdw/ChangeLog                   | 11 ++++-
> >  libdw/dwarf_begin_elf.c           |  1 +
> >  libdw/dwarf_cu_dwp_section_info.c | 19 ++++++++
> >  libdw/dwarf_end.c                 | 10 ++++-
> >  libdw/libdwP.h                    | 16 ++++++-
> >  libdw/libdw_find_split_unit.c     | 75 ++++++++++++++++++++++++++++---
> >  6 files changed, 122 insertions(+), 10 deletions(-)
> > 
> > diff --git a/libdw/ChangeLog b/libdw/ChangeLog
> > index f491587f..f37d9411 100644
> > --- a/libdw/ChangeLog
> > +++ b/libdw/ChangeLog
> > @@ -1,6 +1,8 @@
> >  2023-09-27  Omar Sandoval  <osandov@fb.com>
> >  
> >  	* libdw_find_split_unit.c (try_split_file): Make static.
> > +	(try_dwp_file): New function.
> > +	(__libdw_find_split_unit): Call try_dwp_file.
> >  	* dwarf_entrypc.c (dwarf_entrypc): Call dwarf_lowpc.
> >  	* dwarf_ranges.c (dwarf_ranges): Use skeleton ranges section for
> >  	skeleton units.
> > @@ -20,7 +22,8 @@
> >  	instead of dbg parameter, which is now unused.
> >  	* libdwP.h (Dwarf_Macro_Op_Table): Replace is_64bit with address_size
> >  	and offset_size.  Add dbg.
> > -	(Dwarf): Add cu_index and tu_index.  Add elfpath.
> > +	(Dwarf): Add cu_index and tu_index.  Add elfpath.  Add dwp_dwarf and
> > +	dwp_fd.
> >  	(Dwarf_CU): Add dwp_row.
> >  	(Dwarf_Package_Index): New type.
> >  	(DW_SECT_TYPES): New macro.
> > @@ -31,6 +34,8 @@
> >  	(__libdw_debugdir): Replace declaration with...
> >  	(__libdw_elfpath): New declaration.
> >  	(__libdw_set_debugdir): New declaration.
> > +	(__libdw_dwp_findcu_id): New declaration.
> > +	(__libdw_link_skel_split): Handle .debug_addr for dwp.
> >  	* dwarf_begin_elf.c (dwarf_scnnames): Add IDX_debug_cu_index and
> >  	IDX_debug_tu_index.
> >  	(scn_to_string_section_idx): Ditto.
> > @@ -43,9 +48,11 @@
> >  	(__libdw_set_debugdir): New function.
> >  	(valid_p): Call __libdw_elfpath and __libdw_set_debugdir instead of
> >  	__libdw_debugdir.
> > +	(dwarf_begin_elf): Initialize result->dwp_fd.
> >  	* Makefile.am (libdw_a_SOURCES): Add dwarf_cu_dwp_section_info.c.
> >  	* dwarf_end.c (dwarf_end): Free dwarf->cu_index and dwarf->tu_index.
> > -	Free dwarf->elfpath.
> > +	Free dwarf->elfpath.  Free dwarf->dwp_dwarf and close dwarf->dwp_fd.
> > +	(cu_free): Don't free split dbg if it is dwp_dwarf.
> >  	* dwarf_error.c (errmsgs): Add DWARF_E_UNKNOWN_SECTION.
> >  	* libdw.h (dwarf_cu_dwp_section_info): New declaration.
> >  	* libdw.map (ELFUTILS_0.190): Add dwarf_cu_dwp_section_info.
> > diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
> > index 323a91d0..ca2b7e2a 100644
> > --- a/libdw/dwarf_begin_elf.c
> > +++ b/libdw/dwarf_begin_elf.c
> > @@ -567,6 +567,7 @@ dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp)
> >  
> >    result->elf = elf;
> >    result->alt_fd = -1;
> > +  result->dwp_fd = -1;
> >  
> >    /* Initialize the memory handling.  Initial blocks are allocated on first
> >       actual allocation.  */
> > diff --git a/libdw/dwarf_cu_dwp_section_info.c b/libdw/dwarf_cu_dwp_section_info.c
> > index 6766fb9a..7bf08d9d 100644
> > --- a/libdw/dwarf_cu_dwp_section_info.c
> > +++ b/libdw/dwarf_cu_dwp_section_info.c
> > @@ -340,6 +340,25 @@ __libdw_dwp_find_unit (Dwarf *dbg, bool debug_types, Dwarf_Off off,
> >  				   abbrev_offsetp, NULL);
> >  }
> >  
> > +Dwarf_CU *
> > +internal_function
> > +__libdw_dwp_findcu_id (Dwarf *dbg, uint64_t unit_id8)
> > +{
> > +  Dwarf_Package_Index *index = __libdw_package_index (dbg, false);
> > +  uint32_t unit_row;
> > +  Dwarf_Off offset;
> > +  Dwarf_CU *cu;
> > +  if (__libdw_dwp_unit_row (index, unit_id8, &unit_row) == 0
> > +      && __libdw_dwp_section_info (index, unit_row, DW_SECT_INFO, &offset,
> > +				   NULL) == 0
> > +      && (cu = __libdw_findcu (dbg, offset, false)) != NULL
> > +      && cu->unit_type == DW_UT_split_compile
> > +      && cu->unit_id8 == unit_id8)
> > +    return cu;
> > +  else
> > +    return NULL;
> > +}
> 
> No lookup for split_type?

Type units don't have a skeleton (except apparently in some early
prototypes of the DWARF4 GNU format), so there's no need to look them up
this way.

[snip]

> > @@ -1373,8 +1383,10 @@ __libdw_link_skel_split (Dwarf_CU *skel, Dwarf_CU *split)
> >       There is only one per split debug.  */
> >    Dwarf *dbg = skel->dbg;
> >    Dwarf *sdbg = split->dbg;
> > -  if (sdbg->sectiondata[IDX_debug_addr] == NULL
> > -      && dbg->sectiondata[IDX_debug_addr] != NULL)
> > +  if (dbg->sectiondata[IDX_debug_addr] != NULL
> > +      && (sdbg->sectiondata[IDX_debug_addr] == NULL
> > +	  || (sdbg->sectiondata[IDX_debug_addr]
> > +	      == dbg->sectiondata[IDX_debug_addr])))
> >      {
> >        sdbg->sectiondata[IDX_debug_addr]
> >  	= dbg->sectiondata[IDX_debug_addr];
> 
> ehe? What exactly are we checking here?

Oops, I could've sworn I added a comment here. A couple more lines of
context in the diff are helpful here:

@@ -1371,12 +1381,14 @@ __libdw_link_skel_split (Dwarf_CU *skel, Dwarf_CU *split)
   /* Get .debug_addr and addr_base greedy.
      We also need it for the fake addr cu.
      There is only one per split debug.  */
   Dwarf *dbg = skel->dbg;
   Dwarf *sdbg = split->dbg;
-  if (sdbg->sectiondata[IDX_debug_addr] == NULL
-      && dbg->sectiondata[IDX_debug_addr] != NULL)
+  if (dbg->sectiondata[IDX_debug_addr] != NULL
+      && (sdbg->sectiondata[IDX_debug_addr] == NULL
+	  || (sdbg->sectiondata[IDX_debug_addr]
+	      == dbg->sectiondata[IDX_debug_addr])))
     {
       sdbg->sectiondata[IDX_debug_addr]
 	= dbg->sectiondata[IDX_debug_addr];
       split->addr_base = __libdw_cu_addr_base (skel);
       sdbg->fake_addr_cu = dbg->fake_addr_cu;

This is supposed to copy the .debug_addr section of the skeleton file to
the split file, and also copy the .debug_addr base of the skeleton unit
to the split unit. The former only needs to be done once per file, but
for DWP the latter needs to be done for every unit.

So the check is "link the .debug_addr info if this is the first time
we're linking this split file OR are we linking this split file to the
same skeleton file."

I'll add a comment.

> > diff --git a/libdw/libdw_find_split_unit.c b/libdw/libdw_find_split_unit.c
> > index 533f8072..e1e78951 100644
> > --- a/libdw/libdw_find_split_unit.c
> > +++ b/libdw/libdw_find_split_unit.c
> > @@ -85,6 +85,67 @@ try_split_file (Dwarf_CU *cu, const char *dwo_path)
> >      }
> >  }
> >  
> > +static void
> > +try_dwp_file (Dwarf_CU *cu)
> > +{
> > +  if (cu->dbg->dwp_dwarf == NULL)
> > +    {
> > +      if (cu->dbg->elfpath != NULL)
> > +	{
> > +	  /* The DWARF 5 standard says "the package file is typically placed in
> > +	     the same directory as the application, and is given the same name
> > +	     with a '.dwp' extension".  */
> > +	  size_t elfpath_len = strlen (cu->dbg->elfpath);
> > +	  char *dwp_path = malloc (elfpath_len + 5);
> > +	  if (dwp_path == NULL)
> > +	    {
> > +	      __libdw_seterrno (DWARF_E_NOMEM);
> > +	      return;
> > +	    }
> 
> Yes, but the caller doesn't check for errors. So the seterrno is not
> very useful.

I think I copied that from try_split_file. Should I update the caller?

[snip]

Thanks!

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 13/14] libdw: Apply DWARF package file section offsets where appropriate
  2023-11-02 22:20   ` Mark Wielaard
@ 2023-11-07 16:55     ` Omar Sandoval
  0 siblings, 0 replies; 38+ messages in thread
From: Omar Sandoval @ 2023-11-07 16:55 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

On Thu, Nov 02, 2023 at 11:20:33PM +0100, Mark Wielaard wrote:
> Hi Omar,
> 
> On Wed, Sep 27, 2023 at 11:21:02AM -0700, Omar Sandoval wrote:
> > The final piece of DWARF package file support is that offsets have to be
> > interpreted relative to the section offset from the package index.
> > .debug_abbrev.dwo is already covered, so sprinkle around calls to
> > dwarf_cu_dwp_section_info for the remaining sections: .debug_line.dwo,
> > .debug_loclists.dwo/.debug_loc.dwo, .debug_str_offsets.dwo,
> > .debug_macro.dwo/.debug_macinfo.dwo, and .debug_rnglists.dwo.  With all
> > of that in place, we can finally test various libdw functions on dwp
> > files.
> 
> This looks good, but obviously needs some earlier patches.

[snip]

> > @@ -1222,18 +1223,22 @@ __libdw_cu_ranges_base (Dwarf_CU *cu)
> >  	}
> >        else
> >  	{
> > +	  Dwarf_Off dwp_offset = 0;
> > +	  dwarf_cu_dwp_section_info (cu, DW_SECT_RNGLISTS, &dwp_offset, NULL);
> 
> Shouldn't we check there wasn't an error?

Yeah, I was a little confused by the error handling in these foo_base
functions. It doesn't seem like most of the callers are checking for
errors. The foo_base functions also seem to be treating invalid
attributes as if they don't exist (e.g., when dwarf_formudata returns an
error):

  if (dwarf_attr (&cu_die, DW_AT_rnglists_base, &attr) != NULL)
    {
      Dwarf_Word off;
      if (dwarf_formudata (&attr, &off) == 0)
	offset += off;
    }

So I suppose the equivalent for this change would be

  Dwarf_Off dwp_offset = 0;
  if (dwarf_cu_dwp_section_info (cu, DW_SECT_RNGLISTS, &dwp_offset, NULL) == 0)
    offset = dwp_offset;

[snip]

Thanks!

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 00/14] elfutils: DWARF package (.dwp) file support
  2023-11-02 23:05 ` Mark Wielaard
@ 2023-11-07 17:13   ` Omar Sandoval
  0 siblings, 0 replies; 38+ messages in thread
From: Omar Sandoval @ 2023-11-07 17:13 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

On Fri, Nov 03, 2023 at 12:05:57AM +0100, Mark Wielaard wrote:
> Hi Omar,
> 
> On Wed, Sep 27, 2023 at 11:20:49AM -0700, Omar Sandoval wrote:
> > This patch series adds support for DWARF package files to libdw and the
> > elfutils tools. It supports the GNU DebugFission format for DWARF 4 [1]
> > and the format standardized in DWARF 5 (section 7.3.5 "DWARF Package
> > Files"). It supports both automatically opening the .dwp file for a
> > skeleton unit and examining the .dwp file alone, just like for .dwo
> > files.
> 
> I had hoped to review and apply all this for the 0.190 release
> tomorrow, but wasn't fast enough.

No problem, I'll be happy to see it in 0.191 instead.

> In general it looks very good and
> most has been applied as is. Except for the last patch I don't have
> real concerns, just a few questions (see the specific reviews).
> 
> > Patch 1 is a trivial cleanup I found while developing this. Patches 2-6
> > are fixes for unrelated bugs in split DWARF and/or DWARF 5 that I
> > encountered while adding test cases for this series.
> 
> These have all been applied some time ago.
> 
> > The actual dwp support is in patches 7-10 and 13, including test cases.
> 
> 7 and 9 have been applied already. 8 has some comments/nitpicks, I can
> probably easily be convinced to accept it. 10 looks good, but depends
> on 8, some questions, specificly about handling split type units. 13
> looks good, but depends on 8 and 10.

I replied to patch 8 with how drgn wants to use the new interface. I
also replied with a couple of questions about how you'd like me to split
up patch 8 and handle errors in a couple of the existing codepaths.

> > Patches 11 and 12 enable testing macro information in dwp files.
> 
> Both applied.
> 
> > Patch 14 adds support and tests for an LLVM extension to the dwp
> > format.
> 
> I have to think a bit more on this.

Yeah, the whole situation is very unfortunate. I tried to keep the
workaround as unintrusive as possible, so it wouldn't be the end of the
world if we had to carry our own patch for it. Of course, since LLVM
supports it upstream, I'd definitely prefer for elfutils to support it
upstream, too.

I'll rebase my remaining patches and address the comments so far while I
wait for your responses.

Thanks!

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2023-11-07 17:13 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27 18:20 [PATCH 00/14] elfutils: DWARF package (.dwp) file support Omar Sandoval
2023-09-27 18:20 ` [PATCH 01/14] libdw: Make try_split_file static Omar Sandoval
2023-10-03 16:09   ` Mark Wielaard
2023-09-27 18:20 ` [PATCH 02/14] libdw: Handle split DWARF in dwarf_entrypc Omar Sandoval
2023-10-03 16:10   ` Mark Wielaard
2023-09-27 18:20 ` [PATCH 03/14] libdw: Handle DW_AT_ranges in split DWARF 5 skeleton in dwarf_ranges Omar Sandoval
2023-10-03 16:10   ` Mark Wielaard
2023-09-27 18:20 ` [PATCH 04/14] libdw: Handle other string forms in dwarf_macro_param2 Omar Sandoval
2023-10-03 16:11   ` Mark Wielaard
2023-09-27 18:20 ` [PATCH 05/14] libdw: Fix dwarf_macro_getsrcfiles for DWARF 5 Omar Sandoval
2023-10-03 21:29   ` Mark Wielaard
2023-09-27 18:20 ` [PATCH 06/14] libdw: Handle split DWARF in dwarf_macro_getsrcfiles Omar Sandoval
2023-10-03 21:49   ` Mark Wielaard
2023-09-27 18:20 ` [PATCH 07/14] libdw: Recognize .debug_[ct]u_index sections in dwarf_elf_begin Omar Sandoval
2023-11-01 14:03   ` Mark Wielaard
2023-11-01 17:30     ` Omar Sandoval
2023-09-27 18:20 ` [PATCH 08/14] libdw: Parse DWARF package file index sections Omar Sandoval
2023-11-01 23:07   ` Mark Wielaard
2023-11-07  6:45     ` Omar Sandoval
2023-09-27 18:20 ` [PATCH 09/14] libdw, libdwfl: Save original path of ELF file Omar Sandoval
2023-11-02 17:04   ` Mark Wielaard
2023-11-07  6:46     ` Omar Sandoval
2023-09-27 18:20 ` [PATCH 10/14] libdw: Try .dwp file in __libdw_find_split_unit() Omar Sandoval
2023-11-02 19:56   ` Mark Wielaard
2023-11-07  7:07     ` Omar Sandoval
2023-09-27 18:21 ` [PATCH 11/14] tests: Handle DW_MACRO_{define,undef}_{strx,sup} in dwarf-getmacros Omar Sandoval
2023-11-02 20:30   ` [PATCH 11/14] tests: Handle DW_MACRO_{define, undef}_{strx, sup} " Mark Wielaard
2023-09-27 18:21 ` [PATCH 12/14] tests: Optionally dump all units " Omar Sandoval
2023-11-02 20:39   ` Mark Wielaard
2023-09-27 18:21 ` [PATCH 13/14] libdw: Apply DWARF package file section offsets where appropriate Omar Sandoval
2023-11-02 22:20   ` Mark Wielaard
2023-11-07 16:55     ` Omar Sandoval
2023-09-27 18:21 ` [PATCH 14/14] libdw: Handle overflowed DW_SECT_INFO offsets in DWARF package file indexes Omar Sandoval
2023-09-27 19:20 ` [PATCH 00/14] elfutils: DWARF package (.dwp) file support Frank Ch. Eigler
2023-09-27 20:17   ` Omar Sandoval
2023-10-03 21:54 ` Mark Wielaard
2023-11-02 23:05 ` Mark Wielaard
2023-11-07 17:13   ` Omar Sandoval

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).