From patchwork Thu Apr 6 11:33:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yash Shinde X-Patchwork-Id: 80212 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp951402vqo; Thu, 6 Apr 2023 04:34:25 -0700 (PDT) X-Google-Smtp-Source: AKy350Y9VWKf9buCg4KMCRWx9h3t4oe6PaUOWsEAxeCYRT7WQDMfvIU8a9t90Y3nVSm84r9gHdkj X-Received: by 2002:a17:906:c254:b0:946:c60b:470b with SMTP id bl20-20020a170906c25400b00946c60b470bmr6075615ejb.63.1680780865558; Thu, 06 Apr 2023 04:34:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680780865; cv=none; d=google.com; s=arc-20160816; b=fwcjxENCVVnFtgIjnAyzpY0CQPXnsMFd9vwCKrDfk06WvQwZtEl3C1PxSI4SeyY/M0 1G/iG52X9uaQ1KHT7A9avzTely6pIyv4IYb1AF5OokgW2tBYXkaNJ16mV/dsVnYQ2ALN ddJpiSHQdy3DmUTSBQyxBQAigRS8VAtr+1voNJAMuoJexZ4M19LUpcODZ1PjZfh+tMeg q6HjrpRhy2PG842KFL3eH9Obx3KZ0zEnzDNoYD78/eExiHFFjstf/XZgT/w9qdG5gVba hqe3Ww/9QPo21+eiKhy8DrOr0uH5VNm4E/RAhT1TUqYRcatyQYvVvwHroqlOwr77Q2oW kJmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=yWKQYbULAifYoEFdJHvqPLOU7QTkIsAUpx/P4V84Gq4=; b=SNGVEBWzamMZ92lnumaEFqESJMO0cR1S5k2sm+lRovZ5t9eo0Nw0Cq9ejIZQ1d7+0N w1qGsj7RVM/PL7PIpLSSR9b7YDgD7oeAFLQoPTZPmTf/aObKaf+XdqkndbgLBl1dmZHO 3meBOKwjeqzZU4pOv6oWo8JpOpzvjZWnnWVongNa6ghGb+sm3VFljRDdgw1qOS9oxs6L QCfS5mGlR97hE3/mkcT+cKsbIJy1FnqNgklyqrPEDUf9q3mUMGi39VFqf6lWGoNjtxSR 9dePE6KSpcsfS89HH4FgXnPyqi53kRza8vyqBzgEUDOXTQk4MIWY6DfAQce/HogFiR7i o3Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WWxJdkB5; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id lx16-20020a170906af1000b008c8f5756068si1038045ejb.766.2023.04.06.04.34.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Apr 2023 04:34:25 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WWxJdkB5; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3ADB53858C36 for ; Thu, 6 Apr 2023 11:34:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3ADB53858C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680780864; bh=yWKQYbULAifYoEFdJHvqPLOU7QTkIsAUpx/P4V84Gq4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=WWxJdkB5GWWnb+UCdTQCFuQepbiQkM20RbZwMrU2sSVPu9r17wpvbEbxNkYfT3vuT +VFk9pEGxC9mG4HGbqoZtkrKo2tnql9yLs0tzyYjXgxam3gTd28g4qJEOgWOCj5RYh GLOSwjYz/1q1WszgwSsWwLVJBIWuRX1LCImKE/NE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id 91F1A3858D32 for ; Thu, 6 Apr 2023 11:33:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 91F1A3858D32 Received: by mail-pj1-x1031.google.com with SMTP id j14-20020a17090a7e8e00b002448c0a8813so1536126pjl.0 for ; Thu, 06 Apr 2023 04:33:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680780819; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yWKQYbULAifYoEFdJHvqPLOU7QTkIsAUpx/P4V84Gq4=; b=Zq1UkyjuC7euWP0NCZzL5RTOOmGi1MrqO5ZTURCGakL3E654NSTKFlbY1413x3QmHi ARbTU+WPnnbNst/3B5OO+5GWVcsTucS/yV+OVGJzN9s98MeE+ZXA04Sg/1KgSwGgX1U0 j8waHefa/7IqAZppm6aO26q7tmNOwAJNuEzETzqOq4QNChajyzicu4D51M71a18oWOD2 NFXkAxdgP2g8D9xdfvqb0byOdhKFJT3wUFO+kt8h9EF+TUplbt55fRdrNeB2aZyNU2bR egpmqnVgCiMU06y7MscITw4SlJl6LLjw7ptkj4VwHZWkV/aqaIcL/dHh/NNYeXifhXmY Sx/g== X-Gm-Message-State: AAQBX9fNGbW1Ps0GBBF1waKVj49oZW/oMiLqJCEy0EL+10MTv2bmz8U8 XpSt7izB76x8zGjGmYSsm47S4pz4jh8WpA== X-Received: by 2002:a05:6a20:b227:b0:d8:fd3b:f1ba with SMTP id eh39-20020a056a20b22700b000d8fd3bf1bamr2583950pzb.3.1680780819185; Thu, 06 Apr 2023 04:33:39 -0700 (PDT) Received: from bft-2.. ([49.204.85.206]) by smtp.gmail.com with ESMTPSA id b6-20020aa78106000000b0062df30c7e7esm1178595pfi.136.2023.04.06.04.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Apr 2023 04:33:38 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: raj.khem@gmail.com, Yash.Shinde@windriver.com Subject: [PATCH] Add ssp_nonshared to link commandline for musl targets Date: Thu, 6 Apr 2023 17:03:22 +0530 Message-Id: <20230406113322.3182296-1-yashinde145@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yash Shinde via Gcc-patches From: Yash Shinde Reply-To: Yash Shinde Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762426476937026387?= X-GMAIL-MSGID: =?utf-8?q?1762426476937026387?= From: Khem Raj When -fstack-protector options are enabled we need to link with ssp_shared on musl since it does not provide the __stack_chk_fail_local() so essentially it provides libssp but not libssp_nonshared something like TARGET_LIBC_PROVIDES_SSP_BUT_NOT_SSP_NONSHARED where-as for glibc the needed symbols are already present in libc_nonshared library therefore we do not need any library helper on glibc based systems but musl needs the libssp_noshared from gcc Signed-off-by: Khem Raj Signed-off-by: Yash Shinde --- gcc/config/linux.h | 7 +++++++ gcc/config/rs6000/linux.h | 10 ++++++++++ gcc/config/rs6000/linux64.h | 10 ++++++++++ 3 files changed, 27 insertions(+) --- gcc/config/linux.h | 7 +++++++ gcc/config/rs6000/linux.h | 10 ++++++++++ gcc/config/rs6000/linux64.h | 10 ++++++++++ 3 files changed, 27 insertions(+) diff --git a/gcc/config/linux.h b/gcc/config/linux.h index e3aca79cccc..33f9265bb93 100644 --- a/gcc/config/linux.h +++ b/gcc/config/linux.h @@ -189,6 +189,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see } #endif +#ifdef TARGET_LIBC_PROVIDES_SSP +#undef LINK_SSP_SPEC +#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ + "|fstack-protector-strong|fstack-protector-explicit" \ + ":-lssp_nonshared}" +#endif + #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */ /* This is a *uclinux* target. We don't define below macros to normal linux versions, because doing so would require *uclinux* targets to include diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h index 5d21befe8e4..4fc17e781ba 100644 --- a/gcc/config/rs6000/linux.h +++ b/gcc/config/rs6000/linux.h @@ -99,6 +99,16 @@ " -m elf32ppclinux") #endif +/* link libssp_nonshared.a with musl */ +#if DEFAULT_LIBC == LIBC_MUSL +#ifdef TARGET_LIBC_PROVIDES_SSP +#undef LINK_SSP_SPEC +#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ + "|fstack-protector-strong|fstack-protector-explicit" \ + ":-lssp_nonshared}" +#endif +#endif + #undef LINK_OS_LINUX_SPEC #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \ %{!static-pie: \ diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h index 9e457033d11..49c9f6e2105 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -377,6 +377,16 @@ extern int dot_symbols; " -m elf64ppc") #endif +/* link libssp_nonshared.a with musl */ +#if DEFAULT_LIBC == LIBC_MUSL +#ifdef TARGET_LIBC_PROVIDES_SSP +#undef LINK_SSP_SPEC +#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ + "|fstack-protector-strong|fstack-protector-explicit" \ + ":-lssp_nonshared}" +#endif +#endif + #define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \ %{!static-pie: \ %{rdynamic:-export-dynamic} \