Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35647094rwd; Mon, 10 Jul 2023 10:19:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlEXXO9ppYtKCFDhLIw30YL8n2t0424cW0foNC/aCfhVx01vqnzkgGqYl3Y7qxPmExsVPN8x X-Received: by 2002:a17:906:5308:b0:994:9ed:300b with SMTP id h8-20020a170906530800b0099409ed300bmr3348176ejo.16.1689009558763; Mon, 10 Jul 2023 10:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689009558; cv=none; d=google.com; s=arc-20160816; b=rUJwMN6N1Mm10+2NIrn1qpdcpLvGy7KxlLU6jWHW7H9DBeHbQwbX5OEOLir95ywzSI ZA870PXmojl7O8b6xlVptkn6wONF+oIyJWJJDXcvuFfVLiUV90JFK1P6kKAt7hFeZ0Wa pQBdTjMM3kLw9XmSacTcZXTYLv+RR9FXF9fiVpoC0WJLjl47MrTCtEIlahDXeEll4iN3 lBfX0Oe7bPCgSHCN4daLSyfwgPFo8GVO7pcPHxTT7VeYDpWVbxDkxP43H2EUD+b43XVf JWUmBXQImdFDIcIJcYCa3KbAAufjviykuCIscHIF6FIsnyg9tzgnegU01Sb+7cTcMDqq Tz0Q== 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=ja7s/uWMtZxv8YWg1f8/mxmAAWYb7q2i/Pyv3T637Qs=; fh=vs4UAhjsqOR6YINwX+Rc6iaEZOnGwtAYSpGexnX2DnE=; b=JQZc+fyKBN3uO0ASQkS2t8sy5WkC1ebFIpwyVX36uS2u/0TQscvr6VbMOi/eKp2CFc RZ+QqbYBXOxSbRa3mdOS3idnDww7JUS0RLzPxIu+1wZ1m2OA9/JvLZFLMBshcAU8kis1 QUYZ6FlHVNEYgYOBm6R2oOZkZCdvT/79+D6Z60cjMNoT0JAr+O8tToqRRMVhqOxsMDBs He46lx1Ql6IdDM2icXI0otGkOq3xrstWJc94NnzsGXHU5mhRt0aZAIUw/IO9ujtHHnkA 5AwrWZEShzBxVSHqZY+F9oQGO3ZbcIbtTqgKb9PH2Xn4YiICzpQ2QLbVwFLFyMVbz6FT quEw== 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 gh23-20020a170906e09700b00992b75d594csi17741ejb.317.2023.07.10.10.18.52; Mon, 10 Jul 2023 10:19:18 -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 S230273AbjGJQqA (ORCPT + 99 others); Mon, 10 Jul 2023 12:46:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbjGJQp7 (ORCPT ); Mon, 10 Jul 2023 12:45:59 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DA93F4; Mon, 10 Jul 2023 09:45:56 -0700 (PDT) X-QQ-mid: bizesmtp82t1689007545tbaedb4v Received: from linux-lab-host.localdomain ( [116.30.126.249]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 11 Jul 2023 00:45:44 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: Lc4bMlOoZUFbRFKipiqts0TvmsJAMcFxqII+5IdR+oOiXLeiNhln7Mh30GDGA tjJBIIKTMmHa9uTxTjXqHzdRPbv0r7b/foWfvRj13r8YfV2jN207PeP8t5P3As/t/d2lVOq qgXdZqFDhdX1WVfZJzebVzp/fJt3iTdR6EBQjZdF4JCW2/xQ7gg4ut/3cyeJ1Bust1Z1fY0 e5sjnXX+csYHdmU66n3qqXtR0fQpYRXcBDgz/KjMAWifUAmY2GdyZejTzH7nUfGW8BpNf3j oTAiuhLayvFn0s1SfR7iNqm9cv3UYG3a+G6oXUe93kB3D7uW7MjTPpoKcA7AnFuBi4B44Sv TeAp8Dteuy/2hVdoSGwesX+CBo3EA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 4750259835239617674 From: Zhangjin Wu To: thomas@t-8ch.de Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, w@1wt.eu Subject: Re: [PATCH v2 04/12] tools/nolibc: crt.h: add _start_c Date: Tue, 11 Jul 2023 00:45:43 +0800 Message-Id: <20230710164543.6284-1-falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <195a189b-b9d5-45a1-8901-c9bdb52da2f3@t-8ch.de> References: <195a189b-b9d5-45a1-8901-c9bdb52da2f3@t-8ch.de> 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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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 Hi, Thomas > On 2023-07-10 17:26:43+0800, Zhangjin Wu wrote: > > > On 2023-07-08 23:29:58+0800, Zhangjin Wu wrote: [...] > > > > It also seems like a good opportunity to add some tests for > > > argv/environment variable passing. > > > > Yes, and even further, we can do more on auxv, just like musl does in > > src/env/__libc_start_main.c, not that urgent currently: > > With tests I mean nolibc-test.c to make sure we don't introduce any > regressions. > Only some tiny testcases to validate that argv and environ are picked > up correctly by the startup code on all arches. > Thomas, seems we already have some testcases for argv, environ and auxv currently: run_syscall: chmod_argv0 <-- argv[0] chdir_root <-- chdir(getenv("PWD")) getpagesize <-- getauxval(AT_PAGESZ) run_stdlib : getenv_TERM <-- getenv > > [...] > > > > > > > Ok, welcome to discuss more in this thread: > > > > https://lore.kernel.org/lkml/20230710072340.10798-1-falcon@tinylab.org/ > > > > and let's choose a better method as possible as we can, Just replied Willy to > > explain more. > > Will do. > > > > > Signed-off-by: Zhangjin Wu > > > > --- > > > > tools/include/nolibc/crt.h | 44 ++++++++++++++++++++++++++++++++++++++ > > > > 1 file changed, 44 insertions(+) > > > > > > > > diff --git a/tools/include/nolibc/crt.h b/tools/include/nolibc/crt.h > > > > index 221b7c5346ca..b269294e9664 100644 > > > > --- a/tools/include/nolibc/crt.h > > > > +++ b/tools/include/nolibc/crt.h > > > > @@ -13,4 +13,48 @@ > > > > char **environ __attribute__((weak)); > > > > > > The old code seems to avoid putting "environ" into the global symbol > > > namespace. Could this declaration be moved into the function like in > > > getenv()? > > > > > > > ok, do you mean just move it to stdlib.h like this? I moved _auxv (used > > by getauxv()) to stdlib.h too: > > Nevermind, I got confused by the in-function declaration of > "extern char **environ" inside "getenv()". > Actually this in-function declaration doesn't do anything and can be > dropped. > Yes. for nolibc application is in one-file style, let's remove it. > > [...] > > > > > > This will lead to conflicting declarations if the users use a different > > > signature. I'm not (yet?) sure how to work around this. > > > > > > > Ah yes, I forgot this critical case, people may use something like: > > > > int main(void) > > int main(int argc, char *argv[]) > > > [..] > > I thought about this general problem and it turns out that there is > nothing that any libc can do to distinguish these special cases. > So it has to be handled in the compiler and we do not have to care. Ok. Thanks, Zhangjin > > Thomas