Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <dan@codesourcery.com>
To: Nick Clifton <nickc@redhat.com>
Cc: Doug Evans <dje@google.com>,
	dgutson@codesourcery.com, 	gdb@sourceware.org,
	binutils@sourceware.org
Subject: Re: gdb segv in arm disassembler
Date: Thu, 28 Jan 2010 18:27:00 -0000	[thread overview]
Message-ID: <20100128182736.GA15693@caradoc.them.org> (raw)
In-Reply-To: <4B618767.30408@redhat.com>

On Thu, Jan 28, 2010 at 12:47:35PM +0000, Nick Clifton wrote:
> Hi Daniel,
> 
> >>On Mon, Jan 25, 2010 at 06:22:55PM -0800, Doug Evans wrote:
> >>I'm getting a segv in the arm disassembler when invoked from gdb,
> 
> >Yes.  Sorry - I have a patch for this but I have got stuck travelling
> >instead of finishing the patch series it's part of.
> >
> >I think this is the appropriate fix:
> >-  int           is_data = (bfd_asymbol_flavour (*info->symtab)
> >-			   == bfd_target_elf_flavour) ? TRUE : FALSE;
> >+  int           is_data = FALSE;
> 
> Unfortunately this introduces a new failure into the GAS testsuite.
> 
> How about this version instead ?

I looked at this a bit.  It's more complicated than I expected.

I thought our two patches would do the same thing.  It turns out that
the difference is caused by info->symtab != NULL but info->symtab_size
== 0.  In this case the test case has no symbols, but the caller does
claim to have provided the symbol table.  This gets the right result
for the gas test, but can lead to a crash depending on what happens to
be in info->symtab (I discovered that with a stripped binary).

There are a couple of cases.

* No symbols.  For instance, a stripped binary.  IMO the most useful
thing to do is to default to code; objdump will already not call the
disassembler for sections without SEC_CODE.  Unfortunately, we can not
distinguish that situation from the current gas test case.

* Symbols, but no mapping symbols.  Produced by an old assembler.
Again, I think defaulting to code is reasonable; we expect that most
of a code section / symbol will be code.  Adding a label or function
symbol to the existing gas testsuite will simulate this.  The existing
code does not behave as intended when there is a function symbol,
but no mapping symbol; the function symbol overrides.

* Mapping symbols.  If there are any mapping symbols in the section
(or object), then we should obey them.  This is the only case in which
we can detect leading data with the default-$d omitted mapping symbol.

The best compromise I've thought of is:

* If there are any mapping symbols in the symbol table, honor them.
Ignore other symbols.

* If there are no mapping symbols, default to code using the existing
legacy search.  This will mishandle recent files iff they have a code
section containing only literal pools.  Outside of test cases, this
is unlikely.

I'm working on this (it's taking me a while...).

-- 
Daniel Jacobowitz
CodeSourcery


  reply	other threads:[~2010-01-28 18:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-26  2:23 Doug Evans
2010-01-26  2:37 ` Daniel Jacobowitz
2010-01-28 12:48   ` Nick Clifton
2010-01-28 18:27     ` Daniel Jacobowitz [this message]
2010-01-28 19:30       ` Daniel Jacobowitz
2010-01-29 10:21         ` Nick Clifton
2010-02-23 12:14       ` Paul Brook

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=20100128182736.GA15693@caradoc.them.org \
    --to=dan@codesourcery.com \
    --cc=binutils@sourceware.org \
    --cc=dgutson@codesourcery.com \
    --cc=dje@google.com \
    --cc=gdb@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