From: Jeffrey Walton <noloader@gmail.com>
To: musl@lists.openwall.com
Cc: Colin Cross <ccross@google.com>
Subject: Re: [musl] [PATCH] dl_iterate_phdr: return empty string for the name of the main program
Date: Mon, 11 Apr 2022 08:24:21 -0400 [thread overview]
Message-ID: <CAH8yC8kkiOdjt1TOGgt=Jo9u=mpvzCJ9vw=FG5ZF80urtJNhXg@mail.gmail.com> (raw)
In-Reply-To: <CAGw6cBstQ772esFVYaOrH2w-M2u8CU+qFh3WviV7cEHN5XfSdw@mail.gmail.com>
On Mon, Apr 4, 2022 at 11:57 PM Michael Forney <mforney@mforney.org> wrote:
>
> On 2022-04-04, Colin Cross <ccross@google.com> wrote:
> > The glibc man page for dl_iterate_phdr states:
> > The first object visited by callback is the main program. For the main
> > program, the
> > dlpi_name field will be an empty string.
> >
> > This is relied upon by the LLVM ASAN runtime:
> > https://github.com/llvm/llvm-project/blob/72ec2f76396fe5de5397bfb898993fdb22e2b0da/compiler-rt/lib/asan/asan_linux.cpp#L135
> >
> > Without this patch, running a binary that has been instrumented with
> > ASAN fails with:
> > ==4156919==ASan runtime does not come first in initial library list; you
> > should either link runtime to your application or manually preload it with
> > LD_PRELOAD.
> >
> > Use a constant empty string instead of the DSO name field for the first
> > entry in the DSO list.
>
> I believe glibc is the exception here, not musl. When I looked at
> this, every other operating system I tried used the program name for
> the first object.
I may be splitting hairs, but the dl_iterate_phdr(3) man page does not
say a program is returned during the enumeration. It says shared
objects are returned.
$ man 3 dl_iterate_phdr
DL_ITERATE_PHDR(3) Linux Programmer's Manual
DL_ITERATE_PHDR(3)
NAME
dl_iterate_phdr - walk through list of shared objects
SYNOPSIS
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <link.h>
int dl_iterate_phdr(
int (*callback) (struct dl_phdr_info *info,
size_t size, void *data),
void *data);
DESCRIPTION
The dl_iterate_phdr() function allows an application to
inquire at run time to
find out which shared objects it has loaded, and the order in
which they were
loaded.
The dl_iterate_phdr() function walks through the list of an
application's shared
objects and calls the function callback once for each object,
until either all
shared objects have been processed or callback returns a nonzero value.
...
Jeff
next prev parent reply other threads:[~2022-04-11 12:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-05 3:18 Colin Cross
2022-04-05 3:57 ` Michael Forney
2022-04-11 12:24 ` Jeffrey Walton [this message]
2022-04-11 12:42 ` Rich Felker
2022-04-11 14:03 ` Jeffrey Walton
2022-04-11 14:58 ` Rich Felker
2022-04-11 15:52 ` Colin Cross
2022-04-11 12:46 ` Florian Weimer
2022-04-05 4:43 ` Markus Wichmann
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='CAH8yC8kkiOdjt1TOGgt=Jo9u=mpvzCJ9vw=FG5ZF80urtJNhXg@mail.gmail.com' \
--to=noloader@gmail.com \
--cc=ccross@google.com \
--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).