From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTP id 72A21394354F for ; Thu, 19 Mar 2020 00:06:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 72A21394354F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=segher@kernel.crashing.org Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEihh-0007iD-Bd for gcc-help@gcc.gnu.org; Wed, 18 Mar 2020 20:06:30 -0400 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 Received: from gate.crashing.org ([63.228.1.57]:55911) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEihh-0007dK-4R for gcc-help@gcc.gnu.org; Wed, 18 Mar 2020 20:06:29 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 02J06RHh022791; Wed, 18 Mar 2020 19:06:27 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 02J06Qcp022789; Wed, 18 Mar 2020 19:06:26 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 18 Mar 2020 19:06:26 -0500 From: Segher Boessenkool To: Jim Wilson Cc: noloader@gmail.com, gcc-help Subject: Re: Hot to test for _FORTIFY_SOURCE with Autoconf Message-ID: <20200319000626.GR22482@gate.crashing.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 63.228.1.57 X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2020 00:06:31 -0000 On Wed, Mar 18, 2020 at 03:17:27PM -0700, Jim Wilson wrote: > On Tue, Mar 17, 2020 at 5:16 PM Jeffrey Walton via Gcc-help > wrote: > > When _FORTIFY_SOURCE=2 is used, *_chk functions are used when the > > compiler can determine the destination buffer size. Effectively the > > compiler inserts those Microsoft safer functions that the libc folks > > rejected. > > Then that is how you test for it in a configure script. Just write a > trivial program that will generate a call to a *_chk function if > _FORTIFY_SOURCE=2 is supported, compile it, and then check for that, > either by greping the assembly source or running nm on the object > file. glibc itself uses #if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 1 Segher