From patchwork Wed Dec 21 07:28:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 35279 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3385034wrn; Tue, 20 Dec 2022 23:29:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXs3VJVpIyZVuSweDyu8h7RG4/e3gnyOM8M0iki0NnqBDvv6sfkoXJV9RGa5VukwHypYp0O2 X-Received: by 2002:a05:6402:4503:b0:472:d867:4c3d with SMTP id ez3-20020a056402450300b00472d8674c3dmr4523057edb.40.1671607747821; Tue, 20 Dec 2022 23:29:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671607747; cv=none; d=google.com; s=arc-20160816; b=SbQ6UUwk3uOJAWv++VHUFL/EDF0wkRtEcZl8KiQ8wzisCKKkkPdQwXL6rlpMFvZ68R nhHl2494nrpAaVzbq0vrx7Kggqx86l4m0Z+AcnqyTjpMadaVMgqMn12S0dyHekZ6nAZ/ LUK1t9JbTsPcIKMKEe8kZdV81CecNyUcHzEUf/tEv2D3M7L4fxo0gPCU9WTAO/qNjC/D Z7NM5MjsBEJUHSm9556Ha0AA3MFCdiwr1EalK62pUn6UvAiJzBpprBTZGa5f+TU/+ZQi cVbuVjB53ggnLJWbCPfumje5B9xN+HTvPPeLVVcSsiO7O504Oy7DgNPbsu2oKm283jCK xuWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=d36JwQqy/ERQumT8xIuHkyUGsys50DH10H0MbZan2BE=; b=vsHP8TCvD6nhkD4nkvVIXzJboX3HxO22ZAKX71JRk/vtQdt+m7dYNdvTX4sel+JKZ7 C/E6vBokhKkAFDG4mI0OIkKVIJ6hx5DjZbD7OhcyqoIWzKyUflYd7GX3CYXRBon4PLkM NNCj1M+F01ShwLgG6MY7Y85g31XbZzs1Ce+/JU33K+K6bRLi+Ikgxghg0DQAnSClR5lI HIl0GZK9HQkkKn2OeL3Q0lOXodgJd8TIn6KG1H1QpXOqraFGKsHfUMd8RVki7ZIK3M4y pUXYidbclz+nUIPpLlKgKGNsh6eAUg3yA7xBlx2HF38+McLnyYbKEwllK08uu69lHR64 52yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=mYjbRQag; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j16-20020aa7ca50000000b0046b1d405d4asi11817676edt.206.2022.12.20.23.29.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 23:29:07 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=mYjbRQag; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DAC683858023 for ; Wed, 21 Dec 2022 07:29:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DAC683858023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671607746; bh=d36JwQqy/ERQumT8xIuHkyUGsys50DH10H0MbZan2BE=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=mYjbRQagjwsGvDPZSbHYZRJdfSCa8z1gyJTV03yNMDuXTjXt/1zHm2dqIPEiYmDh5 8tr5VZJDAQi/mlxN/aC2cq72jLP7U90k90AnVsUO9CZ0m9FxSF9NN18sO1ZzyQ22E9 m9dq4NCFFzDcdabhBhl40jVnPUZD2cTxs4rBSrtE= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id 726CD3858425 for ; Wed, 21 Dec 2022 07:28:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 726CD3858425 Received: by mail-pl1-x62b.google.com with SMTP id d3so14684931plr.10 for ; Tue, 20 Dec 2022 23:28:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=d36JwQqy/ERQumT8xIuHkyUGsys50DH10H0MbZan2BE=; b=AxK3q/K7bUt+Zg84bbZUuz9BeR9apDUrWETV8QPMDFollWB5m3bxh5FDxtZy5xp0LD KsBVoziObXNKMKQvFfPySogpjOWRsT8g9LungJ/iUPrI1GfqEsmfCZRzchKElwP5zDGH 72NgGEbNcEVAZHGNo/T0OIDbTNDDUDoGF6Wn6/oeU5nFWySkFxWIYGt1UsFjz7pBONFQ fsp5iQ6D0WEF9N44IiWYWMf1H+TWUI/8FQzqnVvqG95HBVxic9zhFdtLG8ZMw7sBxyzt o2SIJTsA1OH/IOVu0mQzVCEVDEOfAdde9/LqeYwd0CLAX1pQepeXqn8Ikx4UM+Y3w6px oibA== X-Gm-Message-State: AFqh2kp8kR5PXJxQE1nspNBhiT1hhbBN3Z2y/1bz18xXDovt3QtX++mD 8v8miLyJOqyAalse0az+NRu1gi28YdM= X-Received: by 2002:a05:6a20:1446:b0:af:7989:2579 with SMTP id a6-20020a056a20144600b000af79892579mr22410674pzi.32.1671607736291; Tue, 20 Dec 2022 23:28:56 -0800 (PST) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:ce12:61a:16be:8722]) by smtp.gmail.com with ESMTPSA id x6-20020a17090a2b0600b0021885b05660sm711323pjc.24.2022.12.20.23.28.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 23:28:55 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 7160A1140321; Wed, 21 Dec 2022 17:58:53 +1030 (ACDT) Date: Wed, 21 Dec 2022 17:58:53 +1030 To: binutils@sourceware.org Subject: PR29922, SHT_NOBITS section avoids section size sanity check Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3035.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 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-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752807765665267007?= X-GMAIL-MSGID: =?utf-8?q?1752807765665267007?= PR 29922 * dwarf2.c (find_debug_info): Ignore sections without SEC_HAS_CONTENTS. diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index 95f45708e9d..0cd8152ee6e 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -4831,16 +4831,19 @@ find_debug_info (bfd *abfd, const struct dwarf_debug_section *debug_sections, { look = debug_sections[debug_info].uncompressed_name; msec = bfd_get_section_by_name (abfd, look); - if (msec != NULL) + /* Testing SEC_HAS_CONTENTS is an anti-fuzzer measure. Of + course debug sections always have contents. */ + if (msec != NULL && (msec->flags & SEC_HAS_CONTENTS) != 0) return msec; look = debug_sections[debug_info].compressed_name; msec = bfd_get_section_by_name (abfd, look); - if (msec != NULL) + if (msec != NULL && (msec->flags & SEC_HAS_CONTENTS) != 0) return msec; for (msec = abfd->sections; msec != NULL; msec = msec->next) - if (startswith (msec->name, GNU_LINKONCE_INFO)) + if ((msec->flags & SEC_HAS_CONTENTS) != 0 + && startswith (msec->name, GNU_LINKONCE_INFO)) return msec; return NULL; @@ -4848,6 +4851,9 @@ find_debug_info (bfd *abfd, const struct dwarf_debug_section *debug_sections, for (msec = after_sec->next; msec != NULL; msec = msec->next) { + if ((msec->flags & SEC_HAS_CONTENTS) == 0) + continue; + look = debug_sections[debug_info].uncompressed_name; if (strcmp (msec->name, look) == 0) return msec;