From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1031.google.com with SMTP id j14-20020a17090a7e8e00b002448c0a8813so1536126pjl.0 for ; Thu, 06 Apr 2023 04:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680780819; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yWKQYbULAifYoEFdJHvqPLOU7QTkIsAUpx/P4V84Gq4=; b=kl05hVPG0kJ3m7oVW5D8kDoFWn/+EOB5grErddRWfenjde5cQkntcHmUJvHSAGu1BR SjU/l5jZS8t1nHsVll40bedWnV5mK/F2aw7qAj1I02cgw9NDTocTrZZ+kisAQDEN6Div QMUrCZvn+NRH3L5A42L4xX4abmaJCq8kt4keQqfQQbIDYcVIYzcYHRVXO/yRG3CSdcJ9 pbWKTMqbAfbxmHsxKaIbgD7AyVZQgcVzicHB70uTSzKKJfiV/LfUH70PIsGIljFjKSup m+db6P+4RgGplVSE8LdRPMphXliw/5vzD74vypAQNhLNV7WBG2dPe8pjAHnU4Njf42nJ HGTg== 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-Google-Smtp-Source: AKy350beUhBf7x3cAzPYJERkyK0ZTI255qSBFMRpur2O7dsU4Q4K8a7lD8EdZFaJJ0GYfFhYGEBUcw== 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) From: Yash Shinde 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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} \ -- 2.34.1