From patchwork Tue Jan 14 22:02:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 1223099 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-517385-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=T6TBJai8; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bH4QXu0w; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47y4FG5RM8z9s4Y for ; Wed, 15 Jan 2020 09:02:25 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:reply-to:to:cc:date:mime-version :content-type; q=dns; s=default; b=GxmecVgDmGniKAfybxUFw3iSa3LGT 0BzDVzoGYdhW9U1pusnGV4rNMNrNUzjqj6z2sxk9zkGdvmi8rs68NL6+84GJOxoF 9nhsGvfREfvRixdNwYhFF6oI32XHwWzcyz0h1EQLlalPW+22mB+QghIWCSIwlthD E6yY6TPXXQFpRU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:reply-to:to:cc:date:mime-version :content-type; s=default; bh=2Fo1uhg5zX3e0gIT44gXN5EVQOM=; b=T6T BJai8Yrdua051dsHy1w7LhS5shYtVpRS2iTNTE6Xgo7J5464qHVIn7mvboeVsozu kPibUI1kX84kvhCzuZLXel55+BWj5onUM0aI5oRUeKna6+T0VAdd0iM5SXQTiD5v rjLMhcnAc3XzmT1465mQsGMtDe1G1nVLU6kBbNiE= Received: (qmail 47788 invoked by alias); 14 Jan 2020 22:02:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 47780 invoked by uid 89); 14 Jan 2020 22:02:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 Jan 2020 22:02:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579039325; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=JKY67n0tPWnY1JjAOSnyW8KG2icLlj0AT4ZViSU5pss=; b=bH4QXu0wiK8T64cPLJB6erw7fbja62NnR5ejS53rerP9fvIa9GuJkRBJ13CcOla0DSKtPw cPEnJhML1rQMjTtc+zAP6v1r54l7enoJRZVIZMu5Oi2/+Bc7sB1iEoqXH5YcriDcfmkC6b UvEBGvYh07+yhc8uy3Lblh+E90GeXE8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-421-7jFJLsU5MJCiOMV-qAGLdQ-1; Tue, 14 Jan 2020 17:02:04 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03A4C18543A0 for ; Tue, 14 Jan 2020 22:02:03 +0000 (UTC) Received: from ovpn-112-23.phx2.redhat.com (ovpn-112-23.phx2.redhat.com [10.3.112.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70CEF80F7E; Tue, 14 Jan 2020 22:02:02 +0000 (UTC) Message-ID: Subject: Fix for LTO compromised autoconf test in libiberty From: Jeff Law Reply-To: law@redhat.com To: gcc-patches Cc: nickc@redhat.com Date: Tue, 14 Jan 2020 15:02:01 -0700 User-Agent: Evolution 3.34.2 (3.34.2-1.fc31) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-IsSubscribed: yes GCC's ability to inline/clone self-recursive calls compromises the find_stack_direction test in libiberty's configure. The test essentially takes the address of a local in an outer and inner context then compares their addresses to determine the direction of stack growth. Inlining causes the locals to be allocated in the same context which totally defeats the purpose of the test. This patch adds attributes to prevent inlining/cloning and rebuilds the affected configure file. Note there are configure files in other directories, but I'm pretty sure they're using the cached value from libiberty and to fix them requires an upstream fix to autoconf since those defintions don't come from libiberty's aclocal.m4. I'm particularly keen to get this in now as GCC is the master for libiberty and Nick will be cutting a binutils release soon (and has agreed to pull in this change already). Getting the fix into binutils now means the various copies in Fedora won't have to be patched individually (mingw-binutils, avr-binutils, cross-binutils, arm- whatever-binutils, nacl-binutils and possibly others). You can see the effect by looking at how STACK_DIRECTION is defined in config.h. On x86 it should be "-1" and it is for the stage1 build if you use an old enough compiler ;-) But for stage2/stage3 it's "1" Bootstrapped and regression tested on x86_64. Verified STACK_DIRECTION is correct via hand inspection. OK for the trunk? diff --git a/libiberty/aclocal.m4 b/libiberty/aclocal.m4 index bf8a907100f..381ed3b27e3 100644 --- a/libiberty/aclocal.m4 +++ b/libiberty/aclocal.m4 @@ -147,7 +147,7 @@ if test $ac_cv_os_cray = yes; then fi AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction, -[AC_TRY_RUN([find_stack_direction () +[AC_TRY_RUN([__attribute__ ((noclone,noinline)) find_stack_direction () { static char *addr = 0; auto char dummy; diff --git a/libiberty/configure b/libiberty/configure index 7a34dabec32..e8391889cd7 100755 --- a/libiberty/configure +++ b/libiberty/configure @@ -6532,7 +6532,7 @@ else else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -find_stack_direction () +__attribute__ ((noclone,noinline)) find_stack_direction () { static char *addr = 0; auto char dummy;