From patchwork Tue Feb 28 00:04:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 62196 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2714242wrd; Mon, 27 Feb 2023 16:05:10 -0800 (PST) X-Google-Smtp-Source: AK7set+ZS/ZNrRfMPMg5xHx+w4n1REYw8CRuidGtMVxd1zD6WBBpnu/vaulJXqJohocEQdzGfxMT X-Received: by 2002:a17:907:8f0b:b0:879:2a5:dc3c with SMTP id wg11-20020a1709078f0b00b0087902a5dc3cmr413442ejc.40.1677542710317; Mon, 27 Feb 2023 16:05:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677542710; cv=none; d=google.com; s=arc-20160816; b=RtbL1JyTpb6HC8KSBoRuHB3VF97frMLPyOLAEDGA+Chh1qpyKhv0StXbEMTuWMbo3i weYJLvMTBjZ4jlHXji7YjjBnYwXVNhG4rXVS4dPhbUhbxcsaeuPFj+OhGhL63ETXTH1m 3XX/3QmmXIRaYB1U/XXKxYIop+balrlbYMM0GHyO7rLrKgaqT84Tfnqy+bnYTk4u2vrt 6Aoybv2gymdPjC1YcfF7kWJyG0lDQBeCZuI52TTXYkl20ocB9hcwI45D72L4RY8pBns5 ARoS8ojG7H4/1EPMpO4pX4/zEl0n9IPYnhbazkVr7NJEEBplB71Ct1tewD9TQ0KlKDSf p9uA== 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=FLDLPuDh7tqX0ypOwyHp/LqgVJVAC8F8eCDl/vS87j0=; b=DDWb42uBfNHwNBIqtXYDLruencgkPDcwDmyV5oPzBUCN2/Vv2WDG7hcMTVatxz3w3x 40zzhdM7w95nfMJbcpDGvYIcihO48FxpQwdr4s8RYgUlFpF1Rn95mRlvXMwx6/SQGU3J avuumbLmBVSSP0JD9omsd2Yfe8wa5A/zKRH6ii9T/uFIIGaXFzk/96qbT8/yocsfGqgx SZ4g++Y3+EdLiOihuIhYel2uxlCMGAMz+ogwWwXo1oS9AC0wwQXkIaLF4c/bJMM2c6Ma aUBbNk+3slUNp8VEvPF7sRhN7nwkOIbUeMBcI8pLMowL/DWCq7M4Vwuo0KSyoadnWCAY z4dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=tsY8aVBy; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j9-20020a170906278900b008da520f3fcdsi2256978ejc.224.2023.02.27.16.05.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 16:05:10 -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=tsY8aVBy; 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 5E0443858C00 for ; Tue, 28 Feb 2023 00:05:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E0443858C00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677542709; bh=FLDLPuDh7tqX0ypOwyHp/LqgVJVAC8F8eCDl/vS87j0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=tsY8aVByjxzx/Hq34X/BydFM6RYZmy2BeWROGmGgwcBjUWfwYVE6L5i4R6JmE1muA VsUMi9ZE844SjMjwi8CsUdCVzBphzwIVLoWEYHsyV1i1pZo+1t5NiP806YAKKnfUL7 j1CMIdBlMkwnJRFaT6SF9DVIaRxyFw1ytYBriLMU= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id 150883858D39 for ; Tue, 28 Feb 2023 00:05:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 150883858D39 Received: by mail-pl1-x62d.google.com with SMTP id z2so8615064plf.12 for ; Mon, 27 Feb 2023 16:05:00 -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=FLDLPuDh7tqX0ypOwyHp/LqgVJVAC8F8eCDl/vS87j0=; b=7xr3bdA6ZUBLByKmt77VoJCOcFU20/KEi25Dlwzu9JBU1MegW2xKfJEaWT0MjcL7ic fcvXyrbJIUNHSkSGXDPATU+3rRmjnLTEn3NKR4c5dHlvvtBvMz/xbGUQSHvIDUfOhpBS KToKyhKns3XHm1jNGi0ow/qU4J1IAeQBOi+SIeUA5xylJleIa9oGrBSZOK7m/Ab4aAdh 42Avzzz0nBBXuKRw7zjJIFJpQU5rk4lS//7GZjjH9o0wafSobPY3SPsYUdQ5fcAlRIQn /RxzQZieogw6elCNTxAm3l9ToXD9AYNFxQOvPzxR/n5xt78GhfsDBJSxRDGmmukAw0eo FklA== X-Gm-Message-State: AO0yUKURYR/VfOYMgxICQgmhLdgQi9EWili9ixeKQ49V/INSvmDR967z eKe7+yCNqIeiTg2V6HA8rKTo4ERry4M= X-Received: by 2002:a05:6a20:8f06:b0:cd:929d:2818 with SMTP id b6-20020a056a208f0600b000cd929d2818mr1591421pzk.11.1677542698800; Mon, 27 Feb 2023 16:04:58 -0800 (PST) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:4d08:cebd:d73f:b794]) by smtp.gmail.com with ESMTPSA id r29-20020a63441d000000b0050336b0b08csm3258861pga.19.2023.02.27.16.04.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 16:04:58 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 17FA01142C8C; Tue, 28 Feb 2023 10:34:56 +1030 (ACDT) Date: Tue, 28 Feb 2023 10:34:56 +1030 To: binutils@sourceware.org Subject: Another PE SEC_HAS_CONTENTS test Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3034.8 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?1759031025094683447?= X-GMAIL-MSGID: =?utf-8?q?1759031025094683447?= I'd skipped this one before, thinking "obfd, that's the linker output bfd so no need to test". Wrong, this is objcopy output. * peXXigen.c (_bfd_XX_bfd_copy_private_bfd_data_common): Test SEC_HAS_CONTENTS before reading section. diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c index 43f3a83743c..d59a97f0d11 100644 --- a/bfd/peXXigen.c +++ b/bfd/peXXigen.c @@ -3041,7 +3041,8 @@ _bfd_XX_bfd_copy_private_bfd_data_common (bfd * ibfd, bfd * obfd) return false; } - if (bfd_malloc_and_get_section (obfd, section, &data)) + if ((section->flags & SEC_HAS_CONTENTS) != 0 + && bfd_malloc_and_get_section (obfd, section, &data)) { unsigned int i; struct external_IMAGE_DEBUG_DIRECTORY *dd =