From patchwork Tue Nov 3 11:15:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 40956 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 5D64D3983A47; Tue, 3 Nov 2020 11:16:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D64D3983A47 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604402183; bh=safAgwVFhbKFCTx89ao/x1f+zFHWFBoJP8W4qJ3SlkA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=VZrd8WC+S7lMw8zvKbKfRRY0UzsfQY/wPVPDoow2SEWXI/aS01KfnMr5XUhYNDlwt 1bcx4fR6T4yCOHNL3YdrG+c86CSSTnzr9/ico28Wi/hkFKm7hT1BtUnbQYmd7bKt1N IYHmFk1Wa81yphxszIOmAxI6hdHp2OvrcaKQgssA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from beige.elm.relay.mailchannels.net (beige.elm.relay.mailchannels.net [23.83.212.16]) by sourceware.org (Postfix) with ESMTPS id 9C1E73854823 for ; Tue, 3 Nov 2020 11:16:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9C1E73854823 X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 1DAA1120425; Tue, 3 Nov 2020 11:16:14 +0000 (UTC) Received: from pdx1-sub0-mail-a31.g.dreamhost.com (100-96-9-93.trex.outbound.svc.cluster.local [100.96.9.93]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 156B6120C70; Tue, 3 Nov 2020 11:16:13 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a31.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.10); Tue, 03 Nov 2020 11:16:13 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Scare-Whistle: 521167461aae8805_1604402173401_3043415545 X-MC-Loop-Signature: 1604402173401:2899910284 X-MC-Ingress-Time: 1604402173400 Received: from pdx1-sub0-mail-a31.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a31.g.dreamhost.com (Postfix) with ESMTP id 948687F12C; Tue, 3 Nov 2020 03:16:12 -0800 (PST) Received: from rhbox.redhat.com (unknown [123.252.202.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a31.g.dreamhost.com (Postfix) with ESMTPSA id 6F6DC7F0DF; Tue, 3 Nov 2020 03:16:09 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a31 To: libc-alpha@sourceware.org Subject: [PATCH] Declare __warn_memset_zero_len internally for newer gcc [bz #25399] Date: Tue, 3 Nov 2020 16:45:34 +0530 Message-Id: <20201103111534.818940-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Cc: jakub@redhat.com, sguelton@redhat.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The __warn_memset_zero_len symbol, used to issue a linker warning about zero length memset calls, is included in warning-nop.o only when glibc is built with an older gcc, which is incorrect. When a program calling memset with zero length is built with either gcc < 5.0 or with clang (which advertises __GNUC__ as 4), it results in a link failure due to not finding the symbol in libc_nonshared.a. Fill in this gap by declaring __warn_memset_zero_len for newer gcc as well so that it is always available in libc_nonshared.a for any compiler to link against. --- debug/warning-nop.c | 10 ++++++++++ string/bits/string_fortified.h | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/debug/warning-nop.c b/debug/warning-nop.c index 4ab7e182b7..8df7b0d098 100644 --- a/debug/warning-nop.c +++ b/debug/warning-nop.c @@ -68,3 +68,13 @@ nop (void) #define __builtin_object_size(bos, level) 0 #include + +/* The public string_fortify.h header (included via string.h above) declares + __warn_memset_zero_len only when it is built with GCC < 5.0 or a non-gcc + compiler where compiler support for zero length memset warning may not be + available. Internally however we need to ensure that __warn_memset_zero_len + is always available when using older gcc or other compilers to link against + glibc. */ +#if __GNUC_PREREQ (5,0) +__warndecl (__warn_memset_zero_len, __WARN_MEMSET_ZERO_LEN_MSG); +#endif diff --git a/string/bits/string_fortified.h b/string/bits/string_fortified.h index 309d0f39b2..be88291f62 100644 --- a/string/bits/string_fortified.h +++ b/string/bits/string_fortified.h @@ -22,9 +22,11 @@ # error "Never use directly; include instead." #endif +#define __WARN_MEMSET_ZERO_LEN_MSG \ + "memset used with constant zero length parameter; this could be due to transposed parameters" + #if !__GNUC_PREREQ (5,0) -__warndecl (__warn_memset_zero_len, - "memset used with constant zero length parameter; this could be due to transposed parameters"); +__warndecl (__warn_memset_zero_len, __WARN_MEMSET_ZERO_LEN_MSG); #endif __fortify_function void *