From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id 31490385702E for ; Tue, 24 May 2022 04:18:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 31490385702E Received: by mail-pj1-x102e.google.com with SMTP id z7-20020a17090abd8700b001df78c7c209so1014306pjr.1 for ; Mon, 23 May 2022 21:18:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=06ClLHoRhdiAop1lApqDp+FGnlF1RhuMiW+Yr7XP5DA=; b=6G+9K+xhnR5C+ORYPO8W+EiDikf3GmX6NymckFUO8Vapz37fSJWC3AIIfND1YikY8b j26KTwoBfEE7yV6A07+/Lt/Ex4+l9Qd5grpFRjmroLJc9aFs1dp9kXOoN2L69HWt9dyu AX4+gIYTJ9QLtWLnz1bz9WmqNJpYLkJVurNzOcBogPllSU/sdhmLdj4GMsHVxj/XEQE3 73CsVrfvEESo7LqhbehOAr/6jd1OQkODmLpCe2yXo4JK4pd0QfE6ozLtPJstpbwEZASN +1oH6uWNt+C8kCfhzhQ+YsC1bYmjPBQCyga8NGF9omkX7RmdIOMVvk5asFc0LqKkQ7ds Qsvg== X-Gm-Message-State: AOAM533wD5iY8X7xHgShJ1Tbj9VVlqZ82eKeGaRimjLNof/b0hhnaiOS XqMYLm8Ul9e2RwhvcqhyOWzzKxzKH+8= X-Google-Smtp-Source: ABdhPJx4R7gJ+/cPMiyZfeWsEMe1Oz3zMMikxyWFDI/tUmmoBi867dzHjqnCHs+O3O/NWsoyAJRKkA== X-Received: by 2002:a17:903:110e:b0:15e:f450:bee8 with SMTP id n14-20020a170903110e00b0015ef450bee8mr25697671plh.136.1653365916870; Mon, 23 May 2022 21:18:36 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id e18-20020a056a0000d200b0050dc76281ecsm8060716pfj.198.2022.05.23.21.18.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 21:18:36 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 748661140A63; Tue, 24 May 2022 13:48:33 +0930 (ACST) Date: Tue, 24 May 2022 13:48:33 +0930 From: Alan Modra To: binutils@sourceware.org Subject: PR29170, divide by zero displaying fuzzed .debug_names Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3037.3 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, T_SCC_BODY_TEXT_LINE 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: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 May 2022 04:18:40 -0000 PR 29170 * dwarf.c (display_debug_names): Don't attempt to display bucket clashes when bucket count is zero. diff --git a/binutils/dwarf.c b/binutils/dwarf.c index c855972a12f..d820c21527f 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -10149,32 +10149,35 @@ display_debug_names (struct dwarf_section *section, void *file) bucket_count), buckets_filled, (unsigned long) bucket_count); - uint32_t hash_prev = 0; - size_t hash_clash_count = 0; - size_t longest_clash = 0; - size_t this_length = 0; - size_t hashi; - for (hashi = 0; hashi < name_count; hashi++) - { - const uint32_t hash_this = hash_table_hashes[hashi]; - - if (hashi > 0) + if (bucket_count != 0) + { + uint32_t hash_prev = 0; + size_t hash_clash_count = 0; + size_t longest_clash = 0; + size_t this_length = 0; + size_t hashi; + for (hashi = 0; hashi < name_count; hashi++) { - if (hash_prev % bucket_count == hash_this % bucket_count) + const uint32_t hash_this = hash_table_hashes[hashi]; + + if (hashi > 0) { - ++hash_clash_count; - ++this_length; - longest_clash = MAX (longest_clash, this_length); + if (hash_prev % bucket_count == hash_this % bucket_count) + { + ++hash_clash_count; + ++this_length; + longest_clash = MAX (longest_clash, this_length); + } + else + this_length = 0; } - else - this_length = 0; + hash_prev = hash_this; } - hash_prev = hash_this; + printf (_("Out of %lu items there are %zu bucket clashes" + " (longest of %zu entries).\n"), + (unsigned long) name_count, hash_clash_count, longest_clash); + assert (name_count == buckets_filled + hash_clash_count); } - printf (_("Out of %lu items there are %zu bucket clashes" - " (longest of %zu entries).\n"), - (unsigned long) name_count, hash_clash_count, longest_clash); - assert (name_count == buckets_filled + hash_clash_count); struct abbrev_lookup_entry { -- Alan Modra Australia Development Lab, IBM