From patchwork Sat Jul 15 18:23:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 120823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp297398vqt; Sat, 15 Jul 2023 11:54:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlHWhLIp6STsPmzn9N/tz+tPFOt0mb8CJ+ZW2Xo3I9H8T7U9m7O0PksJ6LSZD2wptXWn1zjA X-Received: by 2002:a17:903:11cc:b0:1b3:c4c1:ec4f with SMTP id q12-20020a17090311cc00b001b3c4c1ec4fmr10617665plh.37.1689447282042; Sat, 15 Jul 2023 11:54:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689447282; cv=none; d=google.com; s=arc-20160816; b=O+tGhUNRYH5DtU6Fh5h3lRJ+PJgp2Ynx9l7qXuzrBLeLydHATBqO0Ak2eaj00XVjXh Tscll19jebPjQ7d6zRgmDJEoSJIsOsLMO1kXyMC5E/99r6P5D3CkaZq3O5IEjbQyHbT4 6vFaTUacRNcofEsOIgBnyJgjQIBnqLk7ft/OKYmLVDUEoEXM8lrMzM3E7gnewxlneXHt 0pUugHCExvowv1JngjhSnCVifnhaP5gSRbx6usFGImxOnmzV/33ybXOSN5ZqALC86iDD MjKDHDSDgXzvdnws81CfyY/rrRmbq0Ufor81fE/e5XHlgS7aO5mXWOAzftSCTl3A2ogO TycA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kg14-20020a170903060e00b001b9d5e34e57si9042472plb.415.2023.07.15.11.54.17; Sat, 15 Jul 2023 11:54:42 -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 S229789AbjGOSXg (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_Wei?= =?utf-8?q?=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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771513872908575793 X-GMAIL-MSGID: 1771513872908575793 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()