Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp3907762rwp; Sat, 15 Jul 2023 11:54:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlGrRXbXGbXd+S0WxyARNgVCJr/qQ0pY6gz7/UpRn/c3euJBcwr3vRMpBX8sLR7PYI4OoIz4 X-Received: by 2002:a17:903:2305:b0:1b8:b55d:4cff with SMTP id d5-20020a170903230500b001b8b55d4cffmr2913535plh.2.1689447294089; Sat, 15 Jul 2023 11:54:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689447294; cv=none; d=google.com; s=arc-20160816; b=udal/4fIIMNa5lbRdxMm0F8l/o9TwD3gZZu4q1P/tyk9GtrhtBB/0SSj5mtJQwj22F p3Kni63vBJrDSH7rR3N8Tq0zwrIRHIQfgRnHW+Amt64IjO4FNXX25tlKAJ/xre05/k2j 4PVwssPcV/XqyJedbq45D0e5agTBbtwdmcc6MtxBk7gXA9BMkV4RtWxDg7LUgTN6gxwX SwRK7nTzInc3BxkoSm+z3S5IfrcG6FsgcLB8rTQxuyU6QEpD5uOFh+IwxN5baRmejI9B pyQxqe9c22kqQ3UvwW8fD4dlgZTo0NRwZq5p9465MFKpRfzVPXkToLpRTEjQb32ozyml N/GQ== 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=7GmEyQJA9FCUITPw3DRSJ410vIiuYEVq1gSqfOYATF8=; fh=gMOegYQP2NYJlMRryxqVkjdc16YOKj1hjFCkzY6Wkow=; b=l14hgJicPggn556A8OvLGEFMskTH2nHRDQtgJDA/HWwttpfydHoWIeem4e2ZMOx3Zp N8We9bgypqXX6PAer/dnq/f9BRQI9sOJl8HC2tVPV9UVTtjXkuILHzpT2R3Se4nNxmdt M+umDyxfoQBM2TGVgIfGnYPEh+dSwtIl4gUpcEh1eHy9GlXDlyvtMp1MBoV0b8xOisgV /b23AdWj18NifYTGElW1vq+7N1WV9HZHVt/Qd5KoQRF/9j2nrHKODaVUipl8vB6EzZec BmdW/1qmQcD6gJIHqMjusVt+ekAjwMxTXzDzyRquXQVF/FP6peYTam+mnXL4iRWhih8v QX1g== 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 la16-20020a170902fa1000b001b8c3bfd02esi4010047plb.204.2023.07.15.11.54.40; Sat, 15 Jul 2023 11:54:54 -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 S230092AbjGOSXg (ORCPT + 99 others); Sat, 15 Jul 2023 14:23:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbjGOSXf (ORCPT ); Sat, 15 Jul 2023 14:23:35 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D0FE26AF; Sat, 15 Jul 2023 11:23:33 -0700 (PDT) X-QQ-mid: bizesmtp74t1689445403tdi2n85s Received: from linux-lab-host.localdomain ( [119.123.131.162]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 16 Jul 2023 02:23:21 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: aRJAvSRewFZh1UoATmMpA0iwFRanbp2F60/aVC49NkfTvP7x0J/z/gdxkXHge vY1xI9vDDBjjW77K2GoiDV40/WdGKKXYBmjWQK2QLuCmNdAX1eF6eSeBtQFDpIlkuCxz676 WRFG3BSpwpOEi4GyAFAONeMD7YxiGjpvAIynYQKjdH1FDY1LfAzSnX2f0y3zz11DSwFvamB opIi6gVA62ZlDUHarOihZvXREhPD6vRJfwy5kpmosIq++AVdmwgA4kRrKLIgzVLshHoVINy KHnCfmQ0jeV2iEhU7QOS2c/3ddumrHmvWTvx8Qsdz4p9G6xvPMKTTGSg3Iv2xdbdCAfxvn0 +BmCMGH1MA9ov65bYvh8JIBHgEa2H4MB907Ek/gdhyZCUMTk3zVVHyZ0UvByr6PA8CN+OuL X-QQ-GoodBg: 0 X-BIZMAIL-ID: 3644606421767073713 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, thomas@t-8ch.de, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [PATCH v4 06/18] tools/nolibc: crt.h: initialize stack protector Date: Sun, 16 Jul 2023 02:23:21 +0800 Message-Id: <2d286a88c325ab7e445029be6ab99eb810003e62.1689444638.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 As suggested by Thomas, It is able to move the stackprotector initialization from the assembly _start to the beginning of the new _start_c(). Let's call __stack_chk_init() in _start_c() as a preparation. Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/lkml/a00284a6-54b1-498c-92aa-44997fa78403@t-8ch.de/ Signed-off-by: Zhangjin Wu --- tools/include/nolibc/crt.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/include/nolibc/crt.h b/tools/include/nolibc/crt.h index 92a2a0478cb1..32e128b0fb62 100644 --- a/tools/include/nolibc/crt.h +++ b/tools/include/nolibc/crt.h @@ -10,6 +10,7 @@ char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); +void __stack_chk_init(void); static void exit(int); void _start_c(long *sp) @@ -21,6 +22,9 @@ void _start_c(long *sp) /* silence potential warning: conflicting types for 'main' */ int _nolibc_main(int, char **, char **) __asm__ ("main"); + /* initialize stack protector */ + __stack_chk_init(); + /* * sp : argc <-- argument count, required by main() * argv: argv[0] <-- argument vector, required by main() -- 2.25.1