|
Message-ID: <20180528223437.dhvas7q7sr32jkmp@ltop.local> Date: Tue, 29 May 2018 00:34:39 +0200 From: Luc Van Oostenryck <luc.vanoostenryck@...il.com> To: musl@...ts.openwall.com Subject: Re: dl_iterate_phdr() behaves differently on musl and glibc 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
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.