From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 7CAF6385CCA4 for ; Wed, 27 Sep 2023 18:21:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7CAF6385CCA4 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-pf1-x436.google.com with SMTP id d2e1a72fcca58-692eed30152so5622539b3a.1 for ; Wed, 27 Sep 2023 11:21:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20230601.gappssmtp.com; s=20230601; t=1695838876; x=1696443676; 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=G9+KaunBz7bDpEDqxBB0qdk1XgLi7+NF4Cqs+XUf4ZI=; b=zmkskKkPDwsFQKJtiY4WOBT8wcD+LKeO9pXSYaz6XYIpBa9CyP7QS52LwF3xq4tgxm El6e+GORQQSjHHFkCZb1JjxzxpaRe3UtbR1RE4EuU9jt12Qahf1QEmwYioJXs4mvn4bm 2In70Igigxy7XDVCxVp0B0G5V5VSB8J/DBzKl70obqPwxllehPc1qkG4poA3+gpiBo6X FD+GyTYBYBOSBfIlVggXfoQwv3xgnB8D3fLehR3F883kAqk/iL/9v7o0xPYsO2F4i96t GLr1rVoEb5aZSi34s7vpcRSzR5464Zxh4syWl3viFkVpIZhXfRBE7BP1lDSMU3LL4HFx cZ3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695838876; x=1696443676; 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=G9+KaunBz7bDpEDqxBB0qdk1XgLi7+NF4Cqs+XUf4ZI=; b=VE1HSITOHywRy+Dl34roPjq7DyXBB7VhDnpEZ+KKbRDye0RASwJ5zTu3e7CVO6EuIo CwTpdDiwkIjVAC8nYcg9cZ0dvzh7lhPK0U8XlqOg5WWHdEFs+hBC28QgfXxQ7HTGpkYd aTOSRD2scP8+gZe7cyi+DuX8Z+JWAT8vT2g8l/PvzGZj8ObvUNfMRXX9Zw0v3H7tRqz3 RTpHYHqF7qsR0c6ChN/oFIwaM2oTheWDOe7a9vq33S+EwMVfAajox6ptbxi9Rjq/qlKX 5+6+JcPQtqPMaotlkEk8T+VMD17QtVfWCY7EN853+SIVLAekydhq6IdLy7YeW4RlPfOM mPiA== X-Gm-Message-State: AOJu0YxHSNfpl6rriZZGyQOFAd2aznkn/a83eyp9UrCocu+1FeMQ7fPE 3X0k5WPcVfmI6irAssHvo3jWqFO1uXm+NX2n8uUH9Q== X-Google-Smtp-Source: AGHT+IEiUplHYaF3JWJOvHJOkMpUBdh3nWvGnv2f2mL8noGa+GSKeZWPEfGx9sijPCIxbzkGJWPS9g== X-Received: by 2002:a05:6a20:8f1a:b0:13d:5b8e:db83 with SMTP id b26-20020a056a208f1a00b0013d5b8edb83mr3172969pzk.9.1695838876099; Wed, 27 Sep 2023 11:21:16 -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.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 11:21:15 -0700 (PDT) From: Omar Sandoval To: elfutils-devel@sourceware.org Subject: [PATCH 03/14] libdw: Handle DW_AT_ranges in split DWARF 5 skeleton in dwarf_ranges Date: Wed, 27 Sep 2023 11:20:52 -0700 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,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 List-Id: From: Omar Sandoval 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 --- 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 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