From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12852 Path: news.gmane.org!.POSTED!not-for-mail From: Luc Van Oostenryck Newsgroups: gmane.linux.lib.musl.general Subject: Re: dl_iterate_phdr() behaves differently on musl and glibc Date: Tue, 29 May 2018 00:34:39 +0200 Message-ID: <20180528223437.dhvas7q7sr32jkmp@ltop.local> References: <20180528200243.GH1392@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1527547009 30026 195.159.176.226 (28 May 2018 22:36:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 28 May 2018 22:36:49 +0000 (UTC) User-Agent: NeoMutt/20180323 To: musl@lists.openwall.com Original-X-From: musl-return-12868-gllmg-musl=m.gmane.org@lists.openwall.com Tue May 29 00:36:45 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1fNQku-0007k4-Rs for gllmg-musl@m.gmane.org; Tue, 29 May 2018 00:36:44 +0200 Original-Received: (qmail 21952 invoked by uid 550); 28 May 2018 22:38:53 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 17692 invoked from network); 28 May 2018 22:34:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=MPJZKoNX9ExHe6AubnMRad1RjdDHNF5+yD5vCT6Wxjk=; b=dbdg730j4aVx6IZ/BE/oMTbMd0fXMZLPk/CmLJ0UngU0CKRq7pXMDYnZIZV0kJISZ4 dY+gszC1EtSTwP8TtOZao4xpnnetJ8i63wA+mLzccm1ydhe2rEhwpAS0DjtiLCHubKBt 68JWemz2UGfh/nI/HtOSlTW2ZwOyRPylcAZAuvqklBs+M1rPCyODrSND0QiKLOPWHxPc 8zBfkOgLsTt+6PgUhmpGPZw1bPJfXwhKOFfLbTnBCiiEEJdTJSIh7/9N6deA6SMndF22 pHyQt+T1Ju1oNjdjoLNJfz8vjMwEfP4m9rmm/TpzUnfzg/dTvt1JEJ7Hu+wcC4ys6in/ dJ4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=MPJZKoNX9ExHe6AubnMRad1RjdDHNF5+yD5vCT6Wxjk=; b=CPaYMupArBosUmNtnho0NKQCAQ3M2r7/38A3h2WBwPr1EWrD6y4marWFtlXpUYdFs5 hk+nOlfUB/+9+NYZ9aGoN+UFNlFgjXH/9Zp+F99e1jfxoJ+kKzcupYOLQrTieM8GaU47 +OTaRZjKiynm4f8l5Z6qwru2KAk2kNDLhEbVBAij/Fxogor/fezx36zIsyR9gkV61HAa TG9yPEg1tLOAIdUZe96vXJAOik4VFkCBWyd5fDN64STYFzsDfNuHyrVuc2t4NwqWJMNX nD1+btHp3GLbj8HJaQHbgEksPcurHt55CgVQMJH7Fa8fCy1uJxMdP3G8OSPly9PJXjxA TDfg== X-Gm-Message-State: ALKqPwcPw532TiwUb70pkVv63gaeGM4HV+5K8zpShMPsb+nYT/phH4wY KJU6jha7JHHJ0OJOaR1E4uw39gpR X-Google-Smtp-Source: AB8JxZrR61MVAuqe99JUoldy2PSMX4SCipZCBfm3uSSb00F1kre1wXxr6I97nOLD5PMAh137BK+76g== X-Received: by 2002:a50:ba10:: with SMTP id g16-v6mr16364406edc.85.1527546881308; Mon, 28 May 2018 15:34:41 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20180528200243.GH1392@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:12852 Archived-At: 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