From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: musl@lists.openwall.com
Subject: Re: dl_iterate_phdr() behaves differently on musl and glibc
Date: Tue, 29 May 2018 00:34:39 +0200 [thread overview]
Message-ID: <20180528223437.dhvas7q7sr32jkmp@ltop.local> (raw)
In-Reply-To: <20180528200243.GH1392@brightrain.aerifal.cx>
On Mon, May 28, 2018 at 04:02:43PM -0400, Rich Felker wrote:
> On Mon, May 28, 2018 at 03:44:15PM +0200, Bob B. wrote:
> > Hi list.
> >
> > I noticed a difference in behavior of dl_iterate_phdr() when playing with musl and glibc.
> > The program I tried was the example on the bottom of the page: https://linux.die.net/man/3/dl_iterate_phdr
> >
> > What happens is that musl returns the program itself when run + shared objects.
> > glibc only returns the shared objects.
> >
> > Not sure which one is right. Or if both are acceptable.
> > Any light to clear why the different behavior is appreciated.
>
> I was unaware of that difference, but omitting the main program seems
> like a serious limitation that makes the interface a lot less useful.
> I'm not sure if there's any other way to get the information.
>
> The manual page documents the function as enumerating the "shared
> objects", which one could interpret only as libraries, but I usually
> consider a dynamic program as a "shared object" itself.
>
On a recent Ubuntu, the example in the manpage clearly shows that
the entry for the program itself is also present. And I confirm
it effective does:
Name: "" (9 segments)
0: [0x5582f02f5040; memsz: 1f8] flags: 0x4; PT_PHDR
1: [0x5582f02f5238; memsz: 1c] flags: 0x4; PT_INTERP
2: [0x5582f02f5000; memsz: bf8] flags: 0x5; PT_LOAD
3: [0x5582f04f5da0; memsz: 278] flags: 0x6; PT_LOAD
4: [0x5582f04f5db0; memsz: 1f0] flags: 0x6; PT_DYNAMIC
5: [0x5582f02f5254; memsz: 44] flags: 0x4; PT_NOTE
6: [0x5582f02f5a8c; memsz: 44] flags: 0x4; PT_GNU_EH_FRAME
7: [0x5582f02f5000; memsz: 0] flags: 0x6; PT_GNU_STACK
8: [0x5582f04f5da0; memsz: 260] flags: 0x4; PT_GNU_RELRO
Name: "linux-vdso.so.1" (4 segments)
0: [0x7ffc899fe000; memsz: 100b] flags: 0x5; PT_LOAD
1: [0x7ffc899fe348; memsz: 120] flags: 0x4; PT_DYNAMIC
2: [0x7ffc899fe7a8; memsz: 3c] flags: 0x4; PT_NOTE
3: [0x7ffc899fe7e4; memsz: 3c] flags: 0x4; PT_GNU_EH_FRAME
Name: "/lib/x86_64-linux-gnu/libc.so.6" (10 segments)
0: [0x7f552960a040; memsz: 230] flags: 0x4; PT_PHDR
1: [0x7f55297c7d50; memsz: 1c] flags: 0x4; PT_INTERP
2: [0x7f552960a000; memsz: 1e6aa0] flags: 0x5; PT_LOAD
3: [0x7f55299f1620; memsz: 94c0] flags: 0x6; PT_LOAD
4: [0x7f55299f4b80; memsz: 1e0] flags: 0x6; PT_DYNAMIC
5: [0x7f552960a270; memsz: 44] flags: 0x4; PT_NOTE
6: [0x7f55299f1620; memsz: 90] flags: 0x4; PT_TLS
7: [0x7f55297c7d6c; memsz: 59dc] flags: 0x4; PT_GNU_EH_FRAME
8: [0x7f552960a000; memsz: 0] flags: 0x6; PT_GNU_STACK
9: [0x7f55299f1620; memsz: 39e0] flags: 0x4; PT_GNU_RELRO
Name: "/lib64/ld-linux-x86-64.so.2" (7 segments)
0: [0x7f55299fb000; memsz: 26c24] flags: 0x5; PT_LOAD
1: [0x7f5529c22680; memsz: 1af0] flags: 0x6; PT_LOAD
2: [0x7f5529c22e68; memsz: 170] flags: 0x6; PT_DYNAMIC
3: [0x7f55299fb1c8; memsz: 24] flags: 0x4; PT_NOTE
4: [0x7f5529a1f144; memsz: 66c] flags: 0x4; PT_GNU_EH_FRAME
5: [0x7f55299fb000; memsz: 0] flags: 0x6; PT_GNU_STACK
6: [0x7f5529c22680; memsz: 980] flags: 0x4; PT_GNU_RELRO
The same manpage can be found at:
http://man7.org/linux/man-pages/man3/dl_iterate_phdr.3.html
-- Luc
prev parent reply other threads:[~2018-05-28 22:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-28 13:44 Bob B.
2018-05-28 20:02 ` Rich Felker
2018-05-28 21:39 ` Bob B.
2018-05-28 22:16 ` Rich Felker
2018-05-28 22:31 ` Bob B.
2018-05-28 23:16 ` Jameson Nash
2018-05-30 12:33 ` Bob B.
2018-05-28 22:34 ` Luc Van Oostenryck [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=20180528223437.dhvas7q7sr32jkmp@ltop.local \
--to=luc.vanoostenryck@gmail.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).