mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Fangrui Song <i@maskray.me>
To: musl@lists.openwall.com
Cc: Farid Zakaria <fmzakari@ucsc.edu>
Subject: Re: [musl] dynlink.c tests
Date: Sun, 5 Nov 2023 09:01:59 -0800	[thread overview]
Message-ID: <DS7PR12MB5765A1DDBB4CC5E8C96A1B2DCBABA@DS7PR12MB5765.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20231024000358.GP4163@brightrain.aerifal.cx>

> Is there a dynamic-loader test suite anyone is familiar with ?

FreeBSD rtld-elf has very few test
https://github.com/freebsd/freebsd-src/tree/main/libexec/rtld-elf/tests

glibc/elf contains extensive rtld tests. The Makefile-based test
system may be a bit tricky to deal with... but the coverage is quite
decent.
`configure --enable-hardcoded-path-in-tests` makes it easy to invoke a test.

On Mon, Oct 23, 2023 at 5:04 PM Rich Felker <dalias@libc.org> wrote:
>
> On Mon, Oct 23, 2023 at 11:08:31AM -0700, Farid Zakaria wrote:
> > Just to be pedantic, few ideas come to mind:
> > - One could change the symbol count method to only use DT_HASH and it
> > would succeed until GCC removed it ;)
>
> There are already distros building with GNU-hash-only, so one of them
> would catch such breakage.

Yes.

(For the curious, https://maskray.me/blog/2023-04-12-elf-hash-function
describes a bug in *BSD that dlsym(dl, "ZZZZZW9p") returned NULL for a
DSO linked with -shared -fuse-ld=lld -Wl,--hash-style=sysv.)

> > - The order of resolution for dependencies
>
> This has changed before from whatever-it-was to something very
> intentional, and basic testing of the intended order was done at the
> time, but we don't have regularly run tests for it. While future
> changes here would come with manual testing like that again, it would
> be nice to have an automated framework for this.

Absolutely! Things like the path precedence, constructor order, etc
will be very useful to have test coverage.

> > - $ORIGIN replacement
>
> This is probably under-tested but I'm not aware of any reported bugs,
> and it's not code that's churning.
>
> > I am very appreciative of the codebase.
> > I'm going through it at the moment "stripping it down" a bit to be for
> > x86-64 and adding some comments to help me better understand the
> > process.
>
> I'm not sure that makes much sense. The code as it is isn't overly
> general or using any expensive abstraction layers to support all
> archs. It's very intentionally designed around the concept that all
> archs are basically the same in regards to how dynamic linking works.
> Trying to specialize to just supporting one *obscures* that property
> and makes the arch-specific naming/numbering of relocation types, etc.
> look like a relevant difference when it's not.
>
> > I was going to look at whether I can take on a C++ standard as a
> > dependency as well.
>
> I mean you can do whatever you like in your own hacking around, but
> without being really intentional about what parts of C++ you do and
> don't use, it's easy to pull in circular dependencies, dependencies on
> things that depend on stuff before it has been (and before it's
> possible to have been) initialized, etc.
>
> Also, of course, C and C++ are different languages -- in particular,
> C++ is a not a superset of C. There's no guarantee that any of the
> code in musl behaves as intended when compiled as C++, because it's
> not C++. This wouldn't matter if you're working with separate C++ TUs
> but it would possibly matter if you started trying to put C++ in
> existing C files.
>
> Rich

      parent reply	other threads:[~2023-11-05 17:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-20 18:18 Farid Zakaria
2023-10-21  0:00 ` Rich Felker
2023-10-23 17:08   ` Farid Zakaria
2023-10-23 17:57     ` Rich Felker
2023-10-23 18:08       ` Farid Zakaria
2023-10-24  0:03         ` Rich Felker
2023-10-24  1:23           ` Farid Zakaria
2023-11-05 17:01           ` Fangrui Song [this message]

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=DS7PR12MB5765A1DDBB4CC5E8C96A1B2DCBABA@DS7PR12MB5765.namprd12.prod.outlook.com \
    --to=i@maskray.me \
    --cc=fmzakari@ucsc.edu \
    --cc=musl@lists.openwall.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).