From patchwork Thu Aug 27 13:21:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 142311 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 620CA4BA23DE for ; Thu, 27 Aug 2026 13:22:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 620CA4BA23DE Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=baw4xRAh X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by sourceware.org (Postfix) with ESMTPS id A97294BA79AA for ; Thu, 27 Aug 2026 13:21:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A97294BA79AA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A97294BA79AA Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1036 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787836915; cv=none; b=PpMjWz4pCQ4584XJBS+PwGoCAZ8SC5qLSRhjhSXHITl3zUWBuknfKGUzoM+Hzvf7RtjSHD0EsNnMGPeuEKSSaJDHLaAjOZC0/jWRFV/+tQZAGLfPUnKgtg/rQSsy33otiRSFQYfcvESgGgLUpQszECUho0pRo4O3hukmnhNokrc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787836915; c=relaxed/simple; bh=X6nan3De4nJ7EqVj3w81/9fxSm0gQeNxrweN+lxt9wY=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=hleX5FrDx2v2QKE0NlKba4Thz/bVapqnqYbz+YeyU+hfqprf8josUxKiVc0B3LwtivOZrKB6dkHUEAxIYU6Ql2vU+2o3c+TvIMcGvLgRd6Ney5Ksk5xgvSyMlRsKk8uTBMPfHWCXbJNnU9AXofkxqJzVu0JEbvN6Ss1xAzyoENI= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=baw4xRAh DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A97294BA79AA Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-38759bcd877so2928213a91.2 for ; Thu, 27 Aug 2026 06:21:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787836915; x=1788441715; darn=sourceware.org; h=content-disposition:content-type:mime-version:message-id:subject:to :from:date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=24r14P1YqXLRxgfEfja3K/w9nFWm5JdHhh3G14WMjow=; b=baw4xRAh5HdGyPkM1ZeWbFR5PaFIS7cNRV+7+TYKIC2o3BpNtcLW37gaTS2O37qnc2 OEzMAkWrH16gc+UVdHFxS1zuq9GBSikW8HvgX42+bXXJpg25UIi3L0qMXRgmoEaCJDcj DjfKfnVz0q8v4XJjjw5wnwkRC5XCWZ54JHQ0unJCLA2yc19bHil8mQJE/g/E2tAr1UKt mBioZdvKjr5oLQcFEX91P3f7bs9sDg4c84OfZURSKybgzmoEK42XjJYgDZ+FbwchonRo EWAny6erMyP9aOmbhoo2SdLqOQdMPYKtnwHvyokJkch6UTaWGztlsKX/x2eCmu787PfB 6q0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787836915; x=1788441715; h=content-disposition:content-type:mime-version:message-id:subject:to :from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=24r14P1YqXLRxgfEfja3K/w9nFWm5JdHhh3G14WMjow=; b=g1LUuGBDW7IdNu+pwsRwxotk2v2NIkkhpvV8qFP8JaK/MPFyXlKXKGAz426hs11F2c kzjkRcGGax9i1nN7rbhTFD4dkcNvAmQbs9CHygYYEg7UBdZxNwJYzSFKE7d0CibswO9m K21u+J/I0OY07CJ0eVmkCITRxDldOGADU4FEOzHj8rFXrMMZcVpFTq2mA/1wVJLCAnn3 gAQlPscQz887J+AiFTZubuTNQe5Y9k97CkmHiOsTHTwfgB3bZMEH5kh4nAJNgn8iM16I AgN52J2td4XdBsc47qVIOuFacKVw8tXci/a+L6+CySmZGam/AE2CQfJsO+i3QLKAmB9k /Zmg== X-Gm-Message-State: AFuF++n1maUaU5dedG9mj8kNr90IVS1lkiY6Ke5ZESlCGNgWbLzpQGHt I4FnfwKcPLJ+bXZALNQwlG1ha2pyCSrHsa/MCSlMEMkTxs/AFSSnk8xhGAY9jA== X-Gm-Gg: AR+sD1040UtDbYvewHqKqehU28iHZhCduedcjlwWfoiodxBrMgBzVvvxSz4d4UVBxpR 9TqK8LipARvOdJtjbf0/Pw5JX321kpvg/M0WYzUc6Z32IXj11/lUWQy3A7UIFM+5FoKlz6CZr96 PGwnrPEqle1AXcqe7unofc/HUzfwwfNYqpU4hpWEXcQ3nxCWvZZ4L2/VRgg45WbuoPG56aY4VOl ZWl8WbPBnuj7+hswQT7JBGgMRkNs6ZKlnWx/s83N4sdz7pPeHeh3GZD1WFjBw0ZFFdrZ5kP3ZlO tY8teaG664kw34pusU6kNhMIiY3J8DBbi0rx7RUFv/cM1TQAZKdQbbUBBtkDJa6USO57EDh3hQ4 x3CWPXGF5mJiVU1IZspEG+ysk+ruD62+jYdxGBAcdC758juUe1boD0jkiCuVv9J47sDzVsddHT0 uZjdzwtxXqa2j8495kzJZuwb7THLj4aaU6g+dY89X1eFZsMctChVfhlfJ7XRJTYVoVEd9yeSRK/ qTd7Mz0jwGKQaOmawENuHVENOzJuw== X-Received: by 2002:a17:90b:2247:b0:385:393e:7124 with SMTP id 98e67ed59e1d1-3966d49471bmr28116298a91.14.1787836914501; Thu, 27 Aug 2026 06:21:54 -0700 (PDT) Received: from squeak.grove.modra.org (58-96-106-158.ip4.superloop.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3283d60bf36sm20237106eec.2.2026.08.27.06.21.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Aug 2026 06:21:54 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 1A1DB1141A4A; Thu, 27 Aug 2026 22:51:51 +0930 (ACST) Date: Thu, 27 Aug 2026 22:51:51 +0930 From: Alan Modra To: binutils@sourceware.org Subject: dwarf.c is_dwo_section Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3029.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org Extract out section name test for .dwo suffix into a new function. * dwarf.c (is_dwo_section): New function. (read_and_display_attr_value, display_debug_macro), (display_debug_loc, display_debug_str_offsets): Use it. diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 829bcb761f7..3152dbdbd1c 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -2113,6 +2113,13 @@ free_dwo_info (void) first_dwo_info = NULL; } +static bool +is_dwo_section (const struct dwarf_section *section) +{ + size_t len = strlen (section->name); + return len >= 4 && memcmp (section->name + len - 4, ".dwo", 4) == 0; +} + /* Ensure that START + UVALUE is less than END. Return an adjusted UVALUE if necessary to ensure this relationship. */ @@ -3884,8 +3891,7 @@ read_and_display_attr_value (unsigned long attribute, case DW_FORM_strx4: if (!do_loc) { - const char *suffix = section ? strrchr (section->name, '.') : NULL; - bool dwo = suffix && strcmp (suffix, ".dwo") == 0; + bool dwo = is_dwo_section (section); const char *strng; strng = fetch_indexed_string (uvalue, this_set, offset_size, dwo, @@ -3944,8 +3950,7 @@ read_and_display_attr_value (unsigned long attribute, if (!do_loc) { uint64_t base, idx; - const char *suffix = strrchr (section->name, '.'); - bool dwo = suffix && strcmp (suffix, ".dwo") == 0; + bool dwo = is_dwo_section (section); if (form == DW_FORM_loclistx) { @@ -7586,11 +7591,7 @@ display_debug_macro (struct dwarf_section *section, unsigned char *end = start + section->size; unsigned char *curr = start; unsigned char *extended_op_buf[256]; - bool is_dwo = false; - const char *suffix = strrchr (section->name, '.'); - - if (suffix && strcmp (suffix, ".dwo") == 0) - is_dwo = true; + bool is_dwo = is_dwo_section (section); if (is_dwo) { @@ -8604,14 +8605,10 @@ display_debug_loc (struct dwarf_section *section, void *file) int locs_sorted = 1; unsigned char *next = start, *vnext = vstart; unsigned int *array = NULL; - const char *suffix = strrchr (section->name, '.'); - bool is_dwo = false; + bool is_dwo = is_dwo_section (section); bool is_loclists = strstr (section->name, "debug_loclists") != NULL; uint64_t next_header_offset = 0; - if (suffix && strcmp (suffix, ".dwo") == 0) - is_dwo = true; - bytes = section->size; if (bytes == 0) @@ -9266,9 +9263,7 @@ display_debug_str_offsets (struct dwarf_section *section, unsigned char *end = start + section->size; unsigned char *curr = start; uint64_t debug_str_offsets_hdr_len; - - const char *suffix = strrchr (section->name, '.'); - bool dwo = suffix && strcmp (suffix, ".dwo") == 0; + bool dwo = is_dwo_section (section); if (dwo) load_debug_section_with_follow (str_dwo, file);