linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yubin Ruan <ablacktshirt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: "Michael Kerrisk (man-pages)"
	<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-man <linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	vivek-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org
Subject: Re: dl_iterate_phdr(3) needs clarification
Date: Sat, 16 Sep 2017 20:39:31 +0800	[thread overview]
Message-ID: <20170916123930.GC13267@HP.internal.baidu.com> (raw)
In-Reply-To: <20170916123659.GB13267-BUpDV9vzqx74NUO8LpiZZi+1pv2Z1Xu3@public.gmane.org>

On Sat, Sep 16, 2017 at 08:37:01PM +0800, Yubin Ruan wrote:
> On Fri, Sep 15, 2017 at 10:33:09AM +0200, Michael Kerrisk (man-pages) wrote:
> > Hi Yubin,
> > 
> > On 15 September 2017 at 10:44, Yubin Ruan <ablacktshirt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > > i,
> > > I need some clarification on dl_iterate_phdr(3):
> > >
> > > it is claimed that the returned "struct dl_phdr_info" argument has the
> > > following structure:
> > >
> > >   struct dl_phdr_info {
> > >       ElfW(Addr)  dlpi_addr;  /* Base address of object */
> > >       const char *dlpi_name;  /* (Null-terminated) name of
> > >                                        object */
> > >       const ElfW(Phdr) *dlpi_phdr;  /* Pointer to array of
> > >                                        ELF program headers
> > >                                        for this object */
> > >       ElfW(Half)  dlpi_phnum; /* # of items in dlpi_phdr */
> > >
> > >       /* The following fields were added in glibc 2.4, after the first
> > >          version of this structure was available.  Check the size
> > >          argument passed to the dl_iterate_phdr callback to determine
> > >          whether or not each later member is available.  */
> > >
> > >       unsigned long long int dlpi_adds;
> > >                       /* Incremented when a new object may
> > >                          have been added */
> > >       unsigned long long int dlpi_subs;
> > >                       /* Incremented when an object may
> > >                          have been removed */
> > >       size_t dlpi_tls_modid;
> > >                       /* If there is a PT_TLS segment, its module
> > >                          ID as used in TLS relocations, else zero */
> > >       void  *dlpi_tls_data;
> > >                       /* The address of the calling thread's instance
> > >                          of this module's PT_TLS segment, if it has
> > >                          one and it has been allocated in the calling
> > >                          thread, otherwise a null pointer */
> > >   };
> > >
> > > and:
> > >
> > >   The dlpi_addr field indicates the base address of the shared object
> > >   (i.e., the difference between the virtual memory address of the
> > >   shared object and the offset of that object in the file from which it
> > >   was loaded).  The dlpi_name field is a null-terminated string giving
> > >   the pathname from which the shared object was loaded.
> > >
> > > What does it mean by "the offset of that object in the file from which it was
> > > loaded"??? For a shared object, can I assume that this value is always 0? And
> > > in what circumstance will it not be 0?
> > >
> > > The same statement has also been seen at the old man page[1], so I guess the
> > > author
> > 
> > (That would be me.)
> > 
> > > might have done some copy&paste and overlook this detail.
> > 
> > Can I suggest that as a first step to investigating that you modify
> > the example program in thepage to print out the values of these
> > fields?
> 
> Hmm..based on my understanding of the ELF format and linker/loader, that
> `p_vaddr' should be 0 for a executable, and should be the runtime address for a

sorry, with `p_vaddr', I mean `dlpi_addr'.

> share object. But I have to take some time and look into the source first. If
> that is indeed the case, I would suggest some modification to this man page...
> 
> Yubin
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-09-16 12:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170915084423.GB317@HP.internal.baidu.com>
     [not found] ` <20170915084423.GB317-BUpDV9vzqx74NUO8LpiZZi+1pv2Z1Xu3@public.gmane.org>
2017-09-15  8:33   ` dl_iterate_phdr(3) needs clarification Michael Kerrisk (man-pages)
     [not found]     ` <CAKgNAkhRo04hCoYX+SCKEr7Ai0zT9HcV_z-aZhCio+CQqO+eHw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-09-16 12:37       ` Yubin Ruan
     [not found]         ` <20170916123659.GB13267-BUpDV9vzqx74NUO8LpiZZi+1pv2Z1Xu3@public.gmane.org>
2017-09-16 12:39           ` Yubin Ruan [this message]
2017-09-16 15:00       ` Yubin Ruan
     [not found]         ` <20170916150053.GD13267-BUpDV9vzqx74NUO8LpiZZi+1pv2Z1Xu3@public.gmane.org>
2017-09-16  8:15           ` Florian Weimer
     [not found]             ` <480b07c2-b897-b175-036a-e304b2bba2d1-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-09-16 15:28               ` Yubin Ruan
     [not found]                 ` <20170916152842.GG13267-BUpDV9vzqx74NUO8LpiZZi+1pv2Z1Xu3@public.gmane.org>
2017-09-16  8:38                   ` Florian Weimer
     [not found]                     ` <45f4e59c-3be5-6edd-12a8-f158002dafc7-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-10-09  9:13                       ` Yubin Ruan
2017-09-16 15:09           ` Yubin Ruan
     [not found]             ` <20170916150900.GE13267-BUpDV9vzqx74NUO8LpiZZi+1pv2Z1Xu3@public.gmane.org>
2017-09-16 15:23               ` Yubin Ruan

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=20170916123930.GC13267@HP.internal.baidu.com \
    --to=ablacktshirt-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=vivek-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org \
    /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.
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).