From patchwork Wed Sep 27 18:21:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 76804 X-Patchwork-Delegate: mark@klomp.org Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1CE003875DF2 for ; Wed, 27 Sep 2023 18:21:49 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id 0C9163856DD6 for ; Wed, 27 Sep 2023 18:21:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0C9163856DD6 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=osandov.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=osandov.com Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1c451541f23so93958765ad.2 for ; Wed, 27 Sep 2023 11:21:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20230601.gappssmtp.com; s=20230601; t=1695838888; x=1696443688; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=m3b4weO5lENVz+HM9M0N37b3wP+fnUsrgsqtaqZZGQc=; b=uqXRj1zqd5SsJqhPZzMEvhG/GcZK6ZAd68SPhqU8k67HtLbYJx6bU/+GiNkOA0Zm1D Lev9CqPCVCO8OlKqYWCv0I2Z5+Tny/m+pZCXoB72F13AiNVjnNtlS+Y0lbiMNvO4BXVs ++wXVPacRhqKrjibu3iouUv3vdQzSIa9ZnMow63LVD1bN/NdSEM9f3Jx459/b8EbedM5 GGsNHhIN79nzBJ/6Y1gTy82Ul83v8bOwAbUQFGZfmlSCZhVyuZIQD/BzqIeul/8ykAHi bL6E2h7f7WuiyBOvkt/0YvJzqoMIdL9DoTt0uFeED2W79Tk/tfnHLJK2Uzoz/yJLAMIi efBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695838888; x=1696443688; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m3b4weO5lENVz+HM9M0N37b3wP+fnUsrgsqtaqZZGQc=; b=XRsR4GN9Ppel0VSTZDkKKLL6uzXh8xCX2XojDnzD0Fh1PaPJFMaIaRrbnx5D7Ush4T d77QftiScDEoo9NVp/icrIner0yarbZQ05qjdHd0M9Xm0tZe4XuwdQz4DMXTLH9/p9pf cVyiB22M2M38HTiucV4nAik7MIcv8N5z732q/aAX8kkhrBepn6x0/niE33fhH5vshwJv bLJT42HvjCgTN0/kbE2d27GJY33pUiqVjG5HALskKUVaHiH4f6+WVfBoHMW1TXsKHxuL iNI/tXo1e7cn9zV91uMvBx02EljPDVHGFMzY22LG2ahYv1Eqc//PXH9iri80+IEhfOKL CrCA== X-Gm-Message-State: AOJu0YzwU0RE7txMWFlMWHEBN3kSRN9QDH3zUSAikFrAXnYfkWw9GENJ LsKMzZEi0kmBIe+MR+VPjxxaq1M8iuKCvbzO1Z0pZw== X-Google-Smtp-Source: AGHT+IHd0BxU5YPUCJH50XILkY87Dkj2wiX4N2VpTxMmhmGW6QDC4BIOU6mzNvU+eTENbbu8c6uf+g== X-Received: by 2002:a17:902:ea02:b0:1c0:cb4d:df7c with SMTP id s2-20020a170902ea0200b001c0cb4ddf7cmr2767155plg.1.1695838887173; Wed, 27 Sep 2023 11:21:27 -0700 (PDT) Received: from telecaster.thefacebook.com ([2620:10d:c090:500::6:efab]) by smtp.gmail.com with ESMTPSA id u16-20020a170902e81000b001bf6ea340a9sm13397842plg.159.2023.09.27.11.21.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 11:21:26 -0700 (PDT) From: Omar Sandoval To: elfutils-devel@sourceware.org Subject: [PATCH 14/14] libdw: Handle overflowed DW_SECT_INFO offsets in DWARF package file indexes Date: Wed, 27 Sep 2023 11:21:03 -0700 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, LOTS_OF_MONEY, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" From: Omar Sandoval 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 --- 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 new file mode 100644 index 0000000000000000000000000000000000000000..0718c1b2c40310655cdb78ae9859b7b682a5fcaf GIT binary patch literal 5584 zcmeHL`#aP98~@Bk8^eq-qZ(tjg@z%bcB1Au4G&Tl$>vZgdZZp9!a}1ttvg}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)dVC|%V*iF*n?Glfft)cNVww%zZ4xY(hl0m!zz<9h^HEGIUt|hZql_* zq`w8PKUrrZ_gBt+J~OZK?&#W29$G!5Da!Kph%Q*h+2h0`bmqtWLK!`X{A zw@nzz4+`6b@7q*oI6?ztPE1gy3q+lv8MJH~OxXa|zmc8?)$# z_qq;N7=IF!?p_=3HN#GKZ`m7YtAQ4@RU5l;-};_(xn`rq-3|9Ix9I&8VezacX*%kz zNqoK@@qCFL$Ssv`cUsLF!MsI38&X=4>~r7feOt@XTC;r|`)U18^c-C=zdf9o*|kmT z4?2Xdl187mN9tKl?!0N|c`m`6p;C9MtDE9zrPX7v^sQ~@&Ecax`ZG6dW7Xh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>~;yhUSe-vy>qADc_pf@ zs-r1lIhK=?nX#ZT<=`3fB#q(9u-Y1fQ+Wxl;W{P&xlDk5?7!vaxuXDLjPT`Kb8`wo z+*PKx6UZ6dnmXg8dgoa)4*vN>yRU4Hm2hWP^90KNKVOTO%YFNE2GzrIKk4P?UVN1zg~9Me;B%9v@|-+x9|vBdvwGoSZbPu{-s*{ z3@MmO?NtObN8jFQwH@GZqR1BvYXG(&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|Qn`@z)3<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 #endif +#include + #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 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`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+4FC-Q000000000000000 z000000000000000004?eAOdNrJtwr&MLja7=}#%NG(*K10MX?%3_}5-HiJa;o}kI< zH1tf=^qCl*P;C(P0ku6wnqi13LDgFc{I?; zNv3HuXnJZrN2XBGp^2uM8eudUGypUJ&;g)i8fX9+00006f!09)9xqk3^8Kz2Wwa^_ zoLiBuB*G#l)-!~h!cNhs?abbdX{u!Evr4ou7XXedZ(7Eh>Uwz0U}Ut$yHH{d$)dJ| zvtIr6%sRfkK!VY!=SO$a5C}9tX@mv7O(^P6R>uTYJ+!e3br*4;asq|R za2BMSr-FqoVW&79amy_;SpPRV(~{FbjXUd$FpCwmi7od#Y?hrYK05&+R9u#H`ZDiK zu$PI$Ruk4Q8)BVUZ6r4D4NG)1{8*;U&zR3ln3wG|5sPW&w?{;$O($(m04b>pWONR; z{ge*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h^lys2fQvT)Phq)GWj$(QenVL0W)z_k~y3< z0@4OSq@-?a7ziLLfw+12b|(Z|Wo?KSUBL zqfv!)luvsr21Qh6#I2kqQ&E-t0Ik(tgBrf~1! z1lWo?XgOWnZWPH+Fam-mnLEC=`Ea1igOw8Y_j`vLh8^E@|>#e{fbW5DT|4^0OefR+@x;IVEAe z@QBFI*BwJh2V}^F@=YnIuCqsx{_wV~heC;fLZmfHb$bi<3BU-*!^m-$h)P=$EA1Jw z+upPYWFkXSJt7KIyI`W4%A;*Dg{>el)8K?j6D{IGRV8&~7pQv*#Y9U$8=cxf9ViIu zNQMRefeB)7Z~=)c8C_KH_B-Ep2B7Z6)BUyuEZNKZZu;lw!bT_C#8ZJAI)1x5N{cE; zFVY((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&%w1Xoxz>% 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 diff --git a/tests/testfile-dwp-5-cu-index-overflow.bz2 b/tests/testfile-dwp-5-cu-index-overflow.bz2 new file mode 100755 index 0000000000000000000000000000000000000000..07185fe56fcbfcf9a6fa01e6ef9428fee3843f34 GIT binary patch literal 4544 zcmV;x5kKxiT4*^jL0KkKS#1`;QUDv;|NsC0|NsC0|NsC0|NsC0|M&kp?XP|2|9}7Q zckX|G?|;gCWcQ)^#`e-Z&br15ikgvdTKp2Pej!JQ6TjgPe}C*Gf2=MssLyJ z4FCg1O#lXf0000zLq>oN000000gwR`2t^M_N06C4H4jiU8X64%00T_`4GjPQ00000 z02*ij0MGyc0000005vwKsp@F`LK!p~WDOb(G-5O{0MN)Z(9mgw8flQk4F-clO*AxV ziIJh8WYM5$f@z_qfuLbB4FgRL8Z-lHDA5|4H8-f#^kSY=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52olCU)7klu{#?7;x%UIdmS46>r}uwQd$TuEpaj(5GvX|1Z#RqZ+9 z174x8%n-auj1`Oe@Bk22Aj5h?1Pli`e>Nm=p-A%q7KTQH85dBJN60-C;8sEYq#0($ld>n9RctZWvN zx~9z4NZ?fgx&f!C5s)@Y(p13+TNgyPfE2Jah#_ZTSp*7QGD>CAh78JT{B?stjI#l+ zfCC=FsDx$CZckp4_~|NP6B9z4=^1Y7lhY?A1@pw%+im3F(o=wRZ`=L$7&849XL^5m zuW*bPs2MKg6Kql;!datlwc}CIqTL{Xb6c~0+oWrp_YwTa$7lQ2I!I%h5=NP z>H324V6S*!z4;wbyxa$lM8bB;FAacWnwBNEa@kfm`ew0Tl$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 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