From patchwork Thu Oct 17 15:48:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Matz X-Patchwork-Id: 99092 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4AF2D385840C for ; Thu, 17 Oct 2024 15:49:31 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id E4F983858D20 for ; Thu, 17 Oct 2024 15:48:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E4F983858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E4F983858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729180142; cv=none; b=p7SW/mG54MCH7DTTuWxnzMKT5Rg9qbEa1FLmL0chvPTd1W5aF/PvCx2qsXFFTSBR4O4+G4j3yo42uxOhmTgn0/wUcR6Res99AtBZYS3TJlHv77SeXY9/Z8G/CB67o4DINiDiqn0Sy6E1kSJx4iZEchA8AYRaf+EFuVdw/gkDDCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729180142; c=relaxed/simple; bh=iks/EVJVHibHCLm2R2SZcbHHJzhECx71xDt+NfXiL50=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:Message-ID:MIME-Version; b=JbVoJ8ROpdHgjmLiyD9HCpuA3DdWBZUVMDPKPEwXMD8pzdqRwpXaHMRLcFQVmCLcfeUE8JCTJAxja66gjIes4BJZO6XumFNjYT0HO84Qgt84sFbr5ECiRM9BTcO3ZeY9oEXVM0pjx3qOgxWsgcNvMCD3DmdMC9tWGBQ8aPerFGk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from knuth.suse.de (unknown [10.168.5.16]) by smtp-out2.suse.de (Postfix) with ESMTP id C17E71FD38 for ; Thu, 17 Oct 2024 15:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1729180130; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=8u3YOA65RTPngu87cO+fD5kykktlV+PSNUlt9FD9aJM=; b=t7+WXd9Yxmb66p9xJyvE2irSi/gRLUhAUWjCseqlu0vWpuzOYm1VdreCMrANFPYXRcIpoH n6KTih1hH5lCNPXBJVcoWOuz5m5Z0ihLkM3P7yfsDc5BdLMc5W0d7xP689++D96EelMD3K xGBnW/wbPdpa8xIzeVkObCuO8cC1x88= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1729180130; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=8u3YOA65RTPngu87cO+fD5kykktlV+PSNUlt9FD9aJM=; b=rD9kDneXXFTQPrTi3E8S0qt83aECwkVehzxGGa0o8V4BgmbnQQdPRMfRJMWYSbtt/PRBeh tFkxnXJXaWCLXCDA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1729180130; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=8u3YOA65RTPngu87cO+fD5kykktlV+PSNUlt9FD9aJM=; b=t7+WXd9Yxmb66p9xJyvE2irSi/gRLUhAUWjCseqlu0vWpuzOYm1VdreCMrANFPYXRcIpoH n6KTih1hH5lCNPXBJVcoWOuz5m5Z0ihLkM3P7yfsDc5BdLMc5W0d7xP689++D96EelMD3K xGBnW/wbPdpa8xIzeVkObCuO8cC1x88= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1729180130; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=8u3YOA65RTPngu87cO+fD5kykktlV+PSNUlt9FD9aJM=; b=rD9kDneXXFTQPrTi3E8S0qt83aECwkVehzxGGa0o8V4BgmbnQQdPRMfRJMWYSbtt/PRBeh tFkxnXJXaWCLXCDA== Received: by knuth.suse.de (Postfix, from userid 10510) id B1F20529C78; Thu, 17 Oct 2024 17:48:50 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by knuth.suse.de (Postfix) with ESMTP id A7926529C77 for ; Thu, 17 Oct 2024 17:48:50 +0200 (CEST) Date: Thu, 17 Oct 2024 17:48:50 +0200 (CEST) From: Michael Matz To: binutils@sourceware.org Subject: Fix for -Wstringop-overflow false positive Message-ID: MIME-Version: 1.0 X-Spam-Score: -4.20 X-Spamd-Result: default: False [-4.20 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; MISSING_XM_UA(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RECEIVED_HELO_LOCALHOST(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[binutils@sourceware.org]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid] X-Spam-Level: X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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.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 the way the overflow check was written wasn't understood by some GCC versions and produced false positives for the memset call being called potentially with object sizes that are larger than half address-space. --- My last change triggered the sourceware builder ( https://builder.sourceware.org/buildbot/#/builders/305/builds/455 ) As usual with -Wstringop-overflow invalidly so, but ... whatever. Applied as obvious. bfd/merge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bfd/merge.c b/bfd/merge.c index c811bc57eae..abb0269227e 100644 --- a/bfd/merge.c +++ b/bfd/merge.c @@ -181,9 +181,9 @@ sec_merge_maybe_resize (struct sec_merge_hash *table, unsigned added) do { - newnb *= 2; - if (!(unsigned int)newnb) + if (newnb >> (8 * sizeof(mapofs_type) - 1)) return false; + newnb *= 2; } while (NEEDS_RESIZE (bfdtab->count + added, newnb));