From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by gnuweeb.org (Postfix) with ESMTP id 327C57E2BC for ; Tue, 22 Mar 2022 17:26:05 +0000 (UTC) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 22MHPomx011663; Tue, 22 Mar 2022 18:25:50 +0100 Date: Tue, 22 Mar 2022 18:25:50 +0100 From: Willy Tarreau To: Nick Desaulniers Cc: Ammar Faizi , "Paul E. McKenney" , Alviro Iskandar Setiawan , Nugraha , Linux Kernel Mailing List , GNU/Weeb Mailing List , llvm@lists.linux.dev Subject: Re: [RFC PATCH v2 2/8] tools/nolibc: Remove .global _start from the entry point code Message-ID: <20220322172550.GL10306@1wt.eu> References: <20220322102115.186179-1-ammarfaizi2@gnuweeb.org> <20220322102115.186179-3-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: Hi Nick, On Tue, Mar 22, 2022 at 10:09:18AM -0700, Nick Desaulniers wrote: > On Tue, Mar 22, 2022 at 3:21 AM Ammar Faizi wrote: > > > > Building with clang yields the following error: > > ``` > > :3:1: error: _start changed binding to STB_GLOBAL > > .global _start > > ^ > > 1 error generated. > > ``` > > Make sure only specify one between `.global _start` and `.weak _start`. > > Removing `.global _start`. > > Reviewed-by: Nick Desaulniers > > Yes, symbols should either be `.weak` or `.global`. The warning from > Clang's integrated assembler is meant to flush out funny business. > > I assume there's a good reason _why_ _start is weak and not strong? Yes, the issue appears when you start to build programs made of more than one C file. That's why we have a few weak symbols here and there (others like errno are static and the lack of inter-unit portability is assumed). > Then again, I'm not familiar with nolibc. No problem. The purpose is clearly *not* to implement a libc, but to have something very lightweight that allows to compile trivial programs. A good example of this is tools/testing/selftests/rcutorture/bin/mkinitrd.sh. I'm personally using a tiny pre-init shell that I always package with my kernels and that builds with them [1]. It will never do big things but the balance between ease of use and coding effort is pretty good in my experience. And I'm also careful not to make it complicated to use nor to maintain, pragmatism is important and the effort should remain on the program developer if some arbitration is needed. Regards, Willy [1] https://github.com/formilux/flxutils/tree/master/init