Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp84112rwb; Fri, 4 Aug 2023 09:29:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHcj/VTUQVvAMC4l+STFpkNg6Xl85ghL3XcC493/s3EJ7W2BCkAeuwmlbAO52pr0PDE6fIw X-Received: by 2002:a17:906:53c2:b0:989:34a0:45b0 with SMTP id p2-20020a17090653c200b0098934a045b0mr2059809ejo.49.1691166574263; Fri, 04 Aug 2023 09:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691166574; cv=none; d=google.com; s=arc-20160816; b=c93O5CL19Ma49vC0N1udAV/m1tfnQ1LEIyCtgwO3d3hMxCvXyB3lZrfDeZK4lDH9m2 GoFIU7Kgu/Jztvc3xnx3zVxLXk8PCkDL61yC8UKbBCrxq6ku50Vusf6RyQSRtHk0veXm YBQP3ugF2o4yK4Kp3A6tbkIC/My3SNydk0+n6FqB7LI8YJ4SWIdGOHBhywFqhKoeIV1Z NallA2UPiL7iZLH89KoLSmCV+aNbH3NuotBoBzraCBVKHnQrFGZcMF3BKTnsTaOiAeoH iDwWVWd1l1FE9pT/s07m80Apv59FGGuTOop3TcrOURZAJrPvhdVV8N+JxcV8MHLLbzoT K6uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=AsZ64ICTqiJZ+hw5OAJ6Nof+103qx3mD5IXC7mB1vPg=; fh=M3AUAxTUWNYFeFNWqthPIoGyYOSXDZNP5pK0PgGhcBA=; b=XGDED09WS5HwUa4tpvcGKC/yz/kbAU1l4xDV1MyaIsGaEmeKJwOe+XLVDiR/XFcEej yKp22koC0ituQXvruM08JTyovFIqSDdf5wb/RRIBMQ/op5wOM1ai1NmQYqaeVXZbP8YF HbIzvBSmOm1rSYvU5xAwPBtOMACcyK1sN9r4wkJbbZimH6EWW54VrdJ6h/qGxEQsqWRa /QxXTVi5tuaL1rZWAe/ZIqkRfltg2bObk7DXWMwrPhfsMLNj1jTCN1cRa1z2OuR7x6+A v/88RbdBVEWYIRTFQgNI54yLJxQmBWzXJF9BIlvqFAAWXGHnf4SWNkVsS2Ro3vhjehZ3 bu2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@t-8ch.de header.s=mail header.b=lfUcUpnH; 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 p26-20020a1709061b5a00b00992dcae7002si1955898ejg.365.2023.08.04.09.29.09; Fri, 04 Aug 2023 09:29:34 -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; dkim=pass header.i=@t-8ch.de header.s=mail header.b=lfUcUpnH; 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 S229751AbjHDPiO (ORCPT + 99 others); Fri, 4 Aug 2023 11:38:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232179AbjHDPiH (ORCPT ); Fri, 4 Aug 2023 11:38:07 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 339D73C3D; Fri, 4 Aug 2023 08:38:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1691163484; bh=YCbKHizJ+96nxExfEuzM8vhUtwP+5zZPbpekUwhOb7M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lfUcUpnH3shhL1FXfjVogI81OKWhvuhs7Ruut8ydPey3oxsL/M99hKz75DNWtZeCD 2ciDYSG78xRw+3tJi2yFcuidBrpdCXJ2dFWioGSmVFftMC4yAs4+A/WUyaLBak4lH3 Wqx74oplKu68ERNBAp5PBRmkUFqtCdXbXcM0dS9k= Date: Fri, 4 Aug 2023 17:38:03 +0200 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Zhangjin Wu Cc: w@1wt.eu, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tanyuan@tinylab.org Subject: Re: [PATCH v1 3/3] tools/nolibc: stackprotector.h: make __stack_chk_init static Message-ID: <34bf8710-0571-4f69-87bc-b3776264744b@t-8ch.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham 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 On 2023-08-03 22:47:01+0800, Zhangjin Wu wrote: > 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 Reviewed-by: Thomas Weißschuh > --- > 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 >