From patchwork Sat Jul 15 18:32:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 120828 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp297460vqt; Sat, 15 Jul 2023 11:54:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlHy5b6UhlC/ldJ9KJt9P6o2JLLgXs+ZPzLTnVvK4PLziaxgujY0veFbKEzx45nrKLQiohXJ X-Received: by 2002:a05:6a21:6d9b:b0:134:4003:3ed2 with SMTP id wl27-20020a056a216d9b00b0013440033ed2mr2799786pzb.47.1689447293724; Sat, 15 Jul 2023 11:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689447293; cv=none; d=google.com; s=arc-20160816; b=uD3cJj2KvWP1u1jlt4egWeN25XrS9SNPta6cv79B27e121CbTP1kUiAVGNWIBPb0Ly mXrnZ+vIxmqMio6lZZSgCmmqVrBkphmo7D7a6ektAlrbbYimlRZH4cXHWHwJPqpqJztG wSFYap7MsizrJxbU7DGzBOeb0gEIkUYTWiEHNxHA7B96kkLArV+kDdEXTn3JtnaJsc4r YaCn9jEc9+BQ0szJv5haENn+CiwXDzzOWNCXiYR3WqBf73kI28x72fOsz6ljYf8MCmfU cHEadnwaW0cz5rlYebG8FaMeBX+HW04KLQCWabg5MoXju22HhXtsLU3Hwbk2zhS2GdZO +iYg== 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=p/0edMe811760LLInD2SnbYhnXgb9BDnYwYGoq8T7so=; fh=sXngqCw1oXONrSSImRxZmGyzcK67QhJYp1RgY40tBsg=; b=o5MU7wIkKByW3LmHTyisZUj8kAC8zFWJ0gx2hloLaYwaO7Uf+UwlnJYHSqkt75dH4o QyLaYnXfIr5Gxd3IAElWZzM/xBmyauAX6kqjTolUuQVI326O3jRC1ljrkB8H13HUGrdn 2l5/NwKvDSoQsn+scvAw1gU/iv2PC+MatS7LHoWSgPvag3f7QavkK8khXximQQCa16y1 M4O4j7UtrhZpkmn2Y333sOpbYU9ltBQpgXUwu66ndJmThnmTL28dGzxLwamPc2a2D0Wa E1NXUkrlZyj/k+n/B1XuOUaYEl+DKQjnT/dxSflvnRh9lwo5zFuIs0UbfqBbN8NCRtnX JF7w== 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 s32-20020a632160000000b00557673fdd1asi8849070pgm.313.2023.07.15.11.54.39; Sat, 15 Jul 2023 11:54: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 S230251AbjGOScc (ORCPT + 99 others); Sat, 15 Jul 2023 14:32:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbjGOScb (ORCPT ); Sat, 15 Jul 2023 14:32:31 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F5C3128; Sat, 15 Jul 2023 11:32:29 -0700 (PDT) X-QQ-mid: bizesmtp81t1689445940t49g9iqv Received: from linux-lab-host.localdomain ( [119.123.131.162]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 16 Jul 2023 02:32:19 +0800 (CST) X-QQ-SSF: 01200000002000D0W000B00A0000000 X-QQ-FEAT: cbck7jzG4wYaptTQhwzZFthYKAzk5jPcBUHuTClY8xYh5acSDs8WuXVfLRvL+ /avhl2UfJP/XzZsUK1omAOUr5CrMEao6kdRmxzPsY1s70sGqwxUZcPyk6zU9OKyczEwxiM6 g3I132Lkvu/9eVk/zoMaY4pUcjAxwHJLUnLC2oiD1q3XcsC1M5VOFsY6f2brfAfzBZtGgLB 1td7aXmrQvNBx9A+Ii+eRlhenUpi9SZPPaDjkc8DIdCReqVvFzbtqXYkDEtqK4e7fdACpzZ VwTUEB/fgbaj4B+bSPhYBnbIRIU3ll5m2A34dYZVWxw13GhL4rq2qqu7KgRkGXROuCwEYTU NVKbwR5vwz7MAdF1l+Yn8unvNpBFSBnQDgQoSSeUvK1F9wexsB8ikB0bQLoF/xDFTTuNZ3T X-QQ-GoodBg: 0 X-BIZMAIL-ID: 18280837454231615752 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 Subject: [PATCH v4 14/18] tools/nolibc: s390: shrink _start with _start_c Date: Sun, 16 Jul 2023 02:32:19 +0800 Message-Id: <2d87c72b6957f678944b858f6f1fc703cf18d5fa.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: 1771513885341401802 X-GMAIL-MSGID: 1771513885341401802 move most of the _start operations to _start_c(), include the stackprotector initialization. Signed-off-by: Zhangjin Wu --- tools/include/nolibc/arch-s390.h | 36 +++++--------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s390.h index 3b94ae0cb1d1..5d60fd43f883 100644 --- a/tools/include/nolibc/arch-s390.h +++ b/tools/include/nolibc/arch-s390.h @@ -9,6 +9,7 @@ #include #include "compiler.h" +#include "crt.h" /* Syscalls for s390: * - registers are 64-bit @@ -137,41 +138,14 @@ _arg1; \ }) -char **environ __attribute__((weak)); -const unsigned long *_auxv __attribute__((weak)); - /* startup code */ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_stack_protector _start(void) { __asm__ volatile ( - "lg %r2,0(%r15)\n" /* argument count */ - "la %r3,8(%r15)\n" /* argument pointers */ - - "xgr %r0,%r0\n" /* r0 will be our NULL value */ - /* search for envp */ - "lgr %r4,%r3\n" /* start at argv */ - "0:\n" - "clg %r0,0(%r4)\n" /* entry zero? */ - "la %r4,8(%r4)\n" /* advance pointer */ - "jnz 0b\n" /* no -> test next pointer */ - /* yes -> r4 now contains start of envp */ - "larl %r1,environ\n" - "stg %r4,0(%r1)\n" - - /* search for auxv */ - "lgr %r5,%r4\n" /* start at envp */ - "1:\n" - "clg %r0,0(%r5)\n" /* entry zero? */ - "la %r5,8(%r5)\n" /* advance pointer */ - "jnz 1b\n" /* no -> test next pointer */ - "larl %r1,_auxv\n" /* yes -> store value in _auxv */ - "stg %r5,0(%r1)\n" - - "aghi %r15,-160\n" /* allocate new stackframe */ - "xc 0(8,%r15),0(%r15)\n" /* clear backchain */ - "brasl %r14,main\n" /* ret value of main is arg to exit */ - "lghi %r1,1\n" /* __NR_exit */ - "svc 0\n" + "lgr %r2, %r15\n" /* save stack pointer to %r2, as arg1 of _start_c */ + "aghi %r15, -160\n" /* allocate new stackframe */ + "xc 0(8,%r15), 0(%r15)\n" /* clear backchain */ + "brasl %r14, _start_c\n" /* transfer to c runtime */ ); __builtin_unreachable(); }