mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: Colin Cross <ccross@android.com>
Cc: musl@lists.openwall.com, Ryan Prichard <rprichard@google.com>
Subject: Re: [musl] Running musl executables without a preinstalled dynamic linker
Date: Tue, 23 Aug 2022 10:18:02 +0200	[thread overview]
Message-ID: <20220823081802.GM1320090@port70.net> (raw)
In-Reply-To: <CAMbhsRQQkmxbyxYhsjJoCs2Opv970vpvA5qpGQ9CmGdAPwgOtQ@mail.gmail.com>

* Colin Cross <ccross@android.com> [2022-08-22 17:22:06 -0700]:
> On Sat, Aug 20, 2022 at 2:43 AM Szabolcs Nagy <nsz@port70.net> 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.

  reply	other threads:[~2022-08-23  8:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 21:35 Colin Cross
2022-08-20  9:43 ` Szabolcs Nagy
2022-08-23  0:22   ` Colin Cross
2022-08-23  8:18     ` Szabolcs Nagy [this message]
2022-09-26 22:38       ` Colin Cross
2022-09-26 22:42         ` Colin Cross
2022-09-26 23:02           ` Rich Felker
2022-09-26 23:12             ` Colin Cross
2022-09-27  4:33               ` Colin Cross
2022-09-27  5:09                 ` Ridley Combs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220823081802.GM1320090@port70.net \
    --to=nsz@port70.net \
    --cc=ccross@android.com \
    --cc=musl@lists.openwall.com \
    --cc=rprichard@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).