public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Binutils <binutils@sourceware.org>,
	Nick Clifton <nickc@redhat.com>,  Alan Modra <amodra@gmail.com>
Subject: PING [PATCH] readelf: Consolidate --syms --use-dynamic with --dyn-syms table
Date: Thu, 9 Apr 2020 06:01:35 -0700	[thread overview]
Message-ID: <CAMe9rOpbCPXtMcU351vuSTABB52AKJCQuOPJSLq8ds3Hj_5tQA@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOqCsvK31Bt2Xmop5L+kb-Cdr+N+OTt815d-Ku6x5e+hpw@mail.gmail.com>

On Sun, Mar 22, 2020 at 5:34 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Thu, Mar 19, 2020 at 5:51 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Thu, Mar 12, 2020 at 06:23:34AM -0700, H.J. Lu wrote:
> > > When reconstructing dynamic symbol table from the PT_DYNAMIC segment,
> > > compute dynamic symbol table size from hash table.  For DT_HASH, the
> > > number of dynamic symbol table entries equals the number of chains.
> > > For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols with non-STB_LOCAL
> > > indings are in hash table.  Since DT_GNU_HASH/DT_MIPS_XHASH place all
> > > symbols with STB_LOCAL binding before symbols with other bindings and
> > > all undefined symbols defined ones in dynamic symbol table, the highest
> > > symbol index in DT_GNU_HASH/DT_MIPS_XHASH is the highest dynamic symbol
> > > table index.
> > >
> > > Also iterate dynamic symbol table to print each entry so that output
> > > of "readelf -D -s" without section header is similar to "readelf -s"
> > > with section header.
> > > `
> >
> > Here is the updated patch to make --syms --use-dynamic output almost
> > identical with --dyn-syms.  On Linux/x86-64, I got
> >
> > [hjl@gnu-cfl-2 pr25617]$ ./readelf -D -s /lib64/libc.so.6 > 1
> > [hjl@gnu-cfl-2 pr25617]$ ./readelf --dyn-syms /lib64/libc.so.6 > 2
> > [hjl@gnu-cfl-2 pr25617]$ diff -up 1 2
> > --- 1   2020-03-19 05:50:11.367432099 -0700
> > +++ 2   2020-03-19 05:50:20.265739131 -0700
> > @@ -1,5 +1,5 @@
> >
> > -Symbol table for image contains 2369 entries:
> > +Symbol table '.dynsym' contains 2369 entries:
> >     Num:    Value          Size Type    Bind   Vis      Ndx Name
> >       0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
> >       1: 0000000000000000     0 OBJECT  WEAK   DEFAULT  UND _dl_starting_up@GLIBC_PRIVATE (33)
> > [hjl@gnu-cfl-2 pr25617]$
> >
> > Any comments, objections?
> >
> > Thanks.
> >
> > H.J.
> > ---
> > When reconstructing dynamic symbol table from the PT_DYNAMIC segment,
> > compute dynamic symbol table size from hash table.  For DT_HASH, the
> > number of dynamic symbol table entries equals the number of chains.
> > For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols with non-STB_LOCAL
> > indings are in hash table.  Since DT_GNU_HASH/DT_MIPS_XHASH place all
> > symbols with STB_LOCAL binding before symbols with other bindings and
> > all undefined symbols defined ones in dynamic symbol table, the highest
> > symbol index in DT_GNU_HASH/DT_MIPS_XHASH is the highest dynamic symbol
> > table index.
> >
> > Rewrite print_dynamic_symbol to dump dynamic symbol table for --dyn-syms
> > and --syms --use-dynamic.
> >
> > binutils/
> >
> >         * readelf.c (nbuckets): New.
> >         (nchains): Likewise.
> >         (buckets): Likewise.
> >         (chains): Likewise.
> >         (ngnubuckets): Likewise.
> >         (gnubuckets): Likewise.
> >         (gnuchains): Likewise.
> >         (mipsxlat): Likewise.
> >         (ngnuchains): Likewise.
> >         (gnusymidx): Likewise.
> >         (VALID_SYMBOL_NAME): Likewise.
> >         (VALID_DYNAMIC_NAME): Use it.
> >         (get_dynamic_data): Moved before process_dynamic_section.
> >         (get_num_dynamic_syms): New function.
> >         (process_dynamic_section): Use DT_SYMTAB, DT_SYMENT, DT_HASH,
> >         DT_GNU_HASH and DT_MIPS_XHASH to reconstruct dynamic symbol
> >         table.  Use DT_STRTAB and DT_STRSZ to reconstruct dynamic string
> >         table.
> >         (get_symbol_index_type): Don't print "bad section index" when
> >         there is no section header.
> >         (print_dynamic_symbol): Rewrite.
> >         (process_symbol_table): Call print_dynamic_symbol to dump dynamic
> >         symbol table.
> >
> > ld/
> >
> >         * testsuite/ld-elf/hash.d: Updated.
> >         * testsuite/ld-elf/pr13195.d: Likewise.
> >         * testsuite/ld-elfvsb/hidden2.d: Likewise.
> >         * testsuite/ld-mips-elf/hash2.d: Likewise.
>
> I opened:
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=25707
>

Hi Nick, Alan,

Can you take a look at

https://sourceware.org/pipermail/binutils/2020-March/000234.html

Thanks.

-- 
H.J.

  reply	other threads:[~2020-04-09 13:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 13:23 [PATCH] readelf: Compute dynamic symbol table size from hash table H.J. Lu
2020-03-19 12:51 ` [PATCH] readelf: Consolidate --syms --use-dynamic with --dyn-syms table H.J. Lu
2020-03-22 12:34   ` H.J. Lu
2020-04-09 13:01     ` H.J. Lu [this message]
2020-04-09 14:43       ` PING " Nick Clifton
2020-04-09 17:35         ` Fangrui Song
2020-04-09 17:52           ` H.J. Lu
2020-04-09 17:51         ` V2 " H.J. Lu
2020-04-14 10:47           ` Nick Clifton
2020-04-15  3:18           ` Alan Modra
2020-04-15 12:04             ` H.J. Lu

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=CAMe9rOpbCPXtMcU351vuSTABB52AKJCQuOPJSLq8ds3Hj_5tQA@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=nickc@redhat.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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).