public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: binutils@sourceware.org, Alan Modra <amodra@gmail.com>,
	 Florian Weimer <fweimer@redhat.com>,
	Kaylee Blake <klkblake@gmail.com>,
	 "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH v4 3/7] bfd: Improve nm and objdump without section header
Date: Fri, 7 Jul 2023 08:26:11 -0700	[thread overview]
Message-ID: <CAMe9rOr0fyuyBSscQ0jE05oJ5-q16dx1MBF5ib0neN4Z9VzAKw@mail.gmail.com> (raw)
In-Reply-To: <e7e469d3-d7a3-4076-0998-7341f4c55728@polymtl.ca>

On Fri, Jun 30, 2023 at 7:12 PM Simon Marchi <simon.marchi@polymtl.ca> wrote:
>
> On 6/6/23 13:58, H.J. Lu wrote:
> > When there is no section header in an executable or shared library, we
> > reconstruct dynamic symbol table from the PT_DYNAMIC segment, which
> > contains DT_HASH/DT_GNU_HASH/DT_MIPS_XHASH, DT_STRTAB, DT_SYMTAB,
> > DT_STRSZ, and DT_SYMENT entries, to improve nm and objdump.  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.  We can also get symbol version from DT_VERSYM, DT_VERDEF
> > and DT_VERNEED entries.
> >
> > dt_symtab, dt_versym, dt_verdef, dt_verneed, dt_symtab_count,
> > dt_verdef_count, dt_verneed_count and dt_strtab are added to
> > elf_obj_tdata to store dynamic symbol table information.
>
> Hi,
>
> This broke a GDB test:
>
>     gdb/ $ make check TESTS="gdb.base/eu-strip-infcall.exp"
>     FAIL: gdb.base/eu-strip-infcall.exp: gdb_breakpoint: set breakpoint at main
>
> Looking at gdb/testsuite/gdb.log, before:
>
>     (gdb) file /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/eu-strip-infcall/eu-strip-infcall
>
>     Reading symbols from /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/eu-strip-infcall/eu-strip-infcall...
>
>     Reading symbols from /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/eu-strip-infcall/eu-strip-infcall.debug...
>
>
> and after:
>
> (gdb) file /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/eu-strip-infcall/eu-strip-infcall
>
> Reading symbols from /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/eu-strip-infcall/eu-strip-infcall...
>
> warning: `/home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/eu-strip-infcall/eu-strip-infcall.debug': can't read symbols: file format not recognized.
>
> (No debugging symbols found in /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/eu-strip-infcall/eu-strip-infcall)
>
>
> Can you please check if it's a problem with your patch, or if it's really a malformed file?
>
> Thanks,
>
> Simon

It works for me:

$ make check TESTS="gdb.base/eu-strip-infcall.exp"
....
=== gdb Summary ===

# of expected passes 1

My change only impacts files without section header. eu-strip-infcall.exp does
"eu-strip -f ${binfile}.debug $binfile", which doesn't remove section header.

-- 
H.J.

  reply	other threads:[~2023-07-07 15:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06 17:58 [PATCH v4 0/7] ELF: Strip section header in ELF objects H.J. Lu
2023-06-06 17:58 ` [PATCH v4 1/7] " H.J. Lu
2023-06-06 17:58 ` [PATCH v4 2/7] ELF: Discard non-alloc sections without section header H.J. Lu
2023-06-06 17:58 ` [PATCH v4 3/7] bfd: Improve nm and objdump " H.J. Lu
2023-07-01  2:12   ` Simon Marchi
2023-07-07 15:26     ` H.J. Lu [this message]
2023-07-10  3:30       ` Simon Marchi
2023-07-13  5:02         ` Alan Modra
2023-07-13  5:34           ` Fangrui Song
2023-07-13 21:58           ` Mark Wielaard
2023-07-19  6:21             ` Alan Modra
2023-06-06 17:58 ` [PATCH v4 4/7] ld: Add simple tests for -z nosectionheader H.J. Lu
2023-06-06 17:58 ` [PATCH v4 5/7] binutils: Add a --strip-section-headers test H.J. Lu
2023-06-06 17:58 ` [PATCH v4 6/7] ld: Add tests for -z nosectionheader and --strip-section-headers H.J. Lu
2023-06-29 20:56   ` H.J. Lu
2023-07-06  1:27     ` Alan Modra
2023-06-06 17:58 ` [PATCH v4 7/7] ld: Add -z nosectionheader test to bootstrap.exp 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=CAMe9rOr0fyuyBSscQ0jE05oJ5-q16dx1MBF5ib0neN4Z9VzAKw@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=fweimer@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=klkblake@gmail.com \
    --cc=simon.marchi@polymtl.ca \
    /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).