From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,T_SCC_BODY_TEXT_LINE,URIBL_BLACK autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 31204 invoked from network); 23 Aug 2022 08:18:20 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 23 Aug 2022 08:18:20 -0000 Received: (qmail 26550 invoked by uid 550); 23 Aug 2022 08:18:16 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 26515 invoked from network); 23 Aug 2022 08:18:15 -0000 Date: Tue, 23 Aug 2022 10:18:02 +0200 From: Szabolcs Nagy To: Colin Cross Cc: musl@lists.openwall.com, Ryan Prichard Message-ID: <20220823081802.GM1320090@port70.net> Mail-Followup-To: Colin Cross , musl@lists.openwall.com, Ryan Prichard References: <20220820094308.GK1320090@port70.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [musl] Running musl executables without a preinstalled dynamic linker * Colin Cross [2022-08-22 17:22:06 -0700]: > On Sat, Aug 20, 2022 at 2:43 AM Szabolcs Nagy wrote: > > i would not use Scrt1.o though, the same toolchain should be > > usable for normal linking and relinterp linking, just use a > > different name like Xcrt1.o. > > Is there some way to get gcc/clang to use Xcrt1.o without using > -nostdlib and passing all the crtbegin/end objects manually? this requires compiler changes (new cmdline flag) but then i think the code is upstreamable. > > i would make Xcrt1.o self-contained and size optimized: it only > > runs at start up, this is a different requirement from the -O3 > > build of normal string functions. and then there is no dependency > > on libc internals (which may have various instrumentations that > > does not work in Xcrt1.o). > > Doesn't this same logic apply to most of the code in dynlink.c? My > main worry with a self contained implementation is that it requires > reimplementations of various string functions that are easy to get > wrong. The current prototype reuses the C versions of musl's string > functions, but implements its own syscall wrappers to avoid > interactions with musl internals like errno. dynlink is in libc.so so it can use code from there. but moving libc code into the executable has different constraints. so you will have to make random decisions that string functions are in but errno is out, wrt which libc internal makes sense in the exe. i would just keep a separate implementation (or at least compile the code separately). string functions are easy to implement if you dont try to optimize them imo. then you have full control over what is going on in the exe entry code.