From patchwork Mon Oct 9 02:12:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 823049 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-463730-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="cWe/rQ5n"; 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 3y9P1432gPz9t3B for ; Mon, 9 Oct 2017 13:13:24 +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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=h1jmBWmOa0p9AWeUKoG48cgwqxZjzSg12voWxdvzoYamVf7ACx CDx8NUTKLNAwvwo+mbRXu0C38YO8x6O5/BH4DcppZD0fcTcCNlGL+xSQur000uO4 uk2t8f/yuJdDrUqjfFyDM9xLquRJeaqETCljDZjkR0Il0man5X6GZlBRQ= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=+WI0vkGOGbG+egQjTzEFufrMxrg=; b=cWe/rQ5na5dVlU8duOVw m+s65EwjbDdfCsxyuFgnpvdd4G9svKji8isBzZI0/MVhw119P3Qsp89tpayai77G iia4e5h9QGdOAXWbuOOs/i1sL6iC0mtHFxF2/aIz505DccVFoFsWTtb9y9xBshiP cTVAE1MWc5tjbiFLNiOdor0= Received: (qmail 54513 invoked by alias); 9 Oct 2017 02:13:15 -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 54383 invoked by uid 89); 9 Oct 2017 02:13:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=libssp, H*UA:38.0, H*u:38.0 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Oct 2017 02:13:07 +0000 Received: from svr-orw-mbx-03.mgc.mentorg.com ([147.34.90.203]) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1e1NZ1-0000Ec-3Z from Sandra_Loosemore@mentor.com for gcc-patches@gcc.gnu.org; Sun, 08 Oct 2017 19:13:03 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Sun, 8 Oct 2017 19:13:01 -0700 To: "gcc-patches@gcc.gnu.org" From: Sandra Loosemore Subject: [patch] configure option to override TARGET_LIBC_PROVIDES_SSP Message-ID: <59DADB2B.5090608@codesourcery.com> Date: Sun, 8 Oct 2017 20:12:59 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 X-ClientProxiedBy: SVR-ORW-MBX-05.mgc.mentorg.com (147.34.90.205) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) This patch allows you to configure GCC to explicitly (not) add -lssp_nonshared -lssp link options when the -fstack-protector options are provided, by overriding the inferred default setting for TARGET_LIBC_PROVIDES_SSP. The specific use case this is for is a bare-metal target where the runtime support is provided by an external BSP library. Without the patch, you get linker errors about the missing libraries. Is this OK? I tested with an x86_64-linux-gnu bootstrap as well as both nios2-elf and nios2-linux-gnu (requiring another patch still in my queue). -Sandra Index: gcc/configure.ac =================================================================== --- gcc/configure.ac (revision 253502) +++ gcc/configure.ac (working copy) @@ -5751,10 +5751,25 @@ if test x$gcc_cv_solaris_crts = xyes; th [Define if the system-provided CRTs are present on Solaris.]) fi +AC_ARG_ENABLE(libssp, +[AS_HELP_STRING([--enable-libssp], [enable linking against libssp])], +[case "${enableval}" in + yes|no) + ;; + *) + AC_MSG_ERROR(unknown libssp setting $enableval) + ;; +esac], []) + # Test for stack protector support in target C library. AC_CACHE_CHECK(__stack_chk_fail in target C library, - gcc_cv_libc_provides_ssp, - [gcc_cv_libc_provides_ssp=no + gcc_cv_libc_provides_ssp, + [gcc_cv_libc_provides_ssp=no + if test "x$enable_libssp" = "xno"; then + gcc_cv_libc_provides_ssp=yes + elif test "x$enable_libssp" = "xyes"; then + gcc_cv_libc_provides_ssp=no + else case "$target" in *-*-musl*) # All versions of musl provide stack protector @@ -5791,8 +5806,9 @@ AC_CACHE_CHECK(__stack_chk_fail in targe AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes], [echo "no __stack_chk_fail on this target"]) ;; - *) gcc_cv_libc_provides_ssp=no ;; - esac]) + *) gcc_cv_libc_provides_ssp=no ;; + esac + fi]) if test x$gcc_cv_libc_provides_ssp = xyes; then AC_DEFINE(TARGET_LIBC_PROVIDES_SSP, 1,