Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2357129rwo; Thu, 3 Aug 2023 08:16:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlEZZa4doElbt4chL+4B+OKn1YQw1GjkLk2XtU5l/XOjsdo41j+34O2QiAEMfipGzaAvKPwr X-Received: by 2002:a17:906:18b1:b0:970:71c:df58 with SMTP id c17-20020a17090618b100b00970071cdf58mr6564390ejf.42.1691075813082; Thu, 03 Aug 2023 08:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691075813; cv=none; d=google.com; s=arc-20160816; b=0RQmoj0wsDucLKyTC/3nntagcJi8dJ9EJLOhI7tWkK2viPv0FjYrlckxzyQHswAxLO 1XJ7mjguppkQvoXDoiZMECCgoCqBE/rtlE+YLBdVnBf9Hqvc8TqFKjZ0a2OB//7UN3hA 7ly8s0REgxUKu+nWi7S2xPDZvm90DT8McI/oc8Om9WhzEU8BUzb1wwN6zh22g7B4i+5L HB0i6OC2DffOQTT0iPsojRYE9gy8Cg46S8VZtlQbOSL/pm16JF7HF3nDnA4OqYb793GY SIAZOsunfxAvHaEE4DRSgLlHet5xF55bix7hWahtFR3yiO/vjcrf12T9mKD+mRU4Mbjg C38Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=ILOHCNzNBBkYKpEbkk9GIDEnfu4YmboN1NtOd42o4Vc=; fh=TsKNe/ZSymFDLfCGQokP79s6S6Z9FKHYw1KoAUSYM0Y=; b=kcxDQ3gWqkfX2MWH0+A09ux8eUrpnIuKWpD7T+hSvgcRE+6LTWIN3KlKJWXSQkpwto 8Y1+J5UMXKnbLxBlFylIG1uQAXCtyWshMPV4GZ5rVGf8Etr70SbGt5I9FHxFbkuXZhZY ovKpguepRexZ1XboVRNG9h/vSoRT0yb7Wc4f6tXlATLHXpvLJdM6PzwvuKc8Y8L1gj90 Yemg9ndTRTcEFrLt/40EnYu3Ujd7K0Zf/Z7rOvTX81N9MxSIVvhCH5BIiGCK7hGKpnkz 8VgCFxb7CVkcQvQrdvzThS6mOFEUdOhDx5gNgbMOlFEol3UcopEO0jkeIgaNtRTu9p+2 0Wrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qt8-20020a170906ece800b0099ba1cf9543si1354665ejb.460.2023.08.03.08.16.26; Thu, 03 Aug 2023 08:16:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236022AbjHCOrl (ORCPT + 99 others); Thu, 3 Aug 2023 10:47:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235671AbjHCOrh (ORCPT ); Thu, 3 Aug 2023 10:47:37 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E93C1BE4; Thu, 3 Aug 2023 07:47:15 -0700 (PDT) X-QQ-mid: bizesmtp78t1691074025tkmonxr9 Received: from linux-lab-host.localdomain ( [116.30.131.233]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 03 Aug 2023 22:47:04 +0800 (CST) X-QQ-SSF: 01200000000000E0X000000A0000000 X-QQ-FEAT: EKa9/5zJOSjEdzda4qaDuVCtg7Ilp8g7uMOnt2Znfu3gOhN23U58dt8i2H0rQ wL7+pkiMzvAKuxsqW+rE00MFBYMdyTnHePlHshxwQ/zl6vI/IyQEfs3kKI6VG8Pff13TJaR u6BakN1cnrbLslooXXrsyYGIH3Rm+CWvRrE+96D7kdTdSW2e/5zi4nLM1QZ4PKmo3kMkX8B nQH69mtUKZEDlygzHvq2A0U2IDAC3ah9yya5qGoNb4Iw0+zV76LxZvO71ZhHTIIWBMMFrwM GTpRKl1iVuvFCe24lsUjoJj4X7KgSO7qiaYw/6yt/R4BHwq8FCFA+YyRtEMi7qCfrzh0yTd LyIg4XeReqzeXtfo1EZnnMMpLDvrtk8KXiZLihozj35AoYe6/sApd8Ipv+6xpiBeRtF4nU6 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 9459210872236914971 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tanyuan@tinylab.org Subject: [PATCH v1 3/3] tools/nolibc: stackprotector.h: make __stack_chk_init static Date: Thu, 3 Aug 2023 22:47:01 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This allows to generate smaller text/data/dec size. As the _start_c() function added by crt.h, __stack_chk_init() is called from _start_c() instead of the assembly _start. So, it is able to mark it with static now. Signed-off-by: Zhangjin Wu --- tools/include/nolibc/crt.h | 2 +- tools/include/nolibc/stackprotector.h | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/include/nolibc/crt.h b/tools/include/nolibc/crt.h index 32e128b0fb62..a5f33fef1672 100644 --- a/tools/include/nolibc/crt.h +++ b/tools/include/nolibc/crt.h @@ -10,7 +10,7 @@ char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); -void __stack_chk_init(void); +static void __stack_chk_init(void); static void exit(int); void _start_c(long *sp) diff --git a/tools/include/nolibc/stackprotector.h b/tools/include/nolibc/stackprotector.h index b620f2b9578d..13f1d0e60387 100644 --- a/tools/include/nolibc/stackprotector.h +++ b/tools/include/nolibc/stackprotector.h @@ -37,8 +37,7 @@ void __stack_chk_fail_local(void) __attribute__((weak,section(".data.nolibc_stack_chk"))) uintptr_t __stack_chk_guard; -__attribute__((weak,section(".text.nolibc_stack_chk"))) __no_stack_protector -void __stack_chk_init(void) +static __no_stack_protector void __stack_chk_init(void) { my_syscall3(__NR_getrandom, &__stack_chk_guard, sizeof(__stack_chk_guard), 0); /* a bit more randomness in case getrandom() fails, ensure the guard is never 0 */ @@ -46,7 +45,7 @@ void __stack_chk_init(void) __stack_chk_guard ^= (uintptr_t) &__stack_chk_guard; } #else /* !defined(_NOLIBC_STACKPROTECTOR) */ -__inline__ void __stack_chk_init(void) {} +static void __stack_chk_init(void) {} #endif /* defined(_NOLIBC_STACKPROTECTOR) */ #endif /* _NOLIBC_STACKPROTECTOR_H */ -- 2.25.1