public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "ehunter at broadcom dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/15274] New: add-symbol-file loads symbols at wrong address
Date: Wed, 13 Mar 2013 05:53:00 -0000	[thread overview]
Message-ID: <bug-15274-4717@http.sourceware.org/bugzilla/> (raw)

http://sourceware.org/bugzilla/show_bug.cgi?id=15274

             Bug #: 15274
           Summary: add-symbol-file loads symbols at wrong address
           Product: gdb
           Version: 7.5
            Status: NEW
          Severity: normal
          Priority: P2
         Component: symtab
        AssignedTo: unassigned@sourceware.org
        ReportedBy: ehunter@broadcom.com
    Classification: Unclassified


Created attachment 6933
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6933
Demonstration code

I have found that GDB loads symbols at the wrong addresses in the following
case:

An ELF file loaded using the command "add-symbol-file xxx.elf 0"  where:
*  .text is not at address zero
*  There is another ELF section at a starting at a non-zero address that is
lower than the .text address.

The symbols are incorrectly offset from the correct locations by the start
address of the lower section.

The attached code demonstrates the problem. Simply unzip and run make.

Below is a patch that fixes the problem by commenting out the offending
function call that incorrectly offsets the ELF symbols.

diff -Naur gdb-7.4/gdb/gdb/symfile.c gdb-7.4-new/gdb/symfile.c
--- gdb-7.4/gdb/symfile.c    2013-03-13 13:12:25 +1100
+++ gdb-7.4-new/gdb/symfile.c    2013-03-13 13:11:54 +1100
@@ -986,8 +986,8 @@

      We no longer warn if the lowest section is not a text segment (as
      happens for the PA64 port.  */
-  if (addrs && addrs->other[0].name)
-    addr_info_make_relative (addrs, objfile->obfd);
+//  if (addrs && addrs->other[0].name)
+//    addr_info_make_relative (addrs, objfile->obfd);

   /* Initialize symbol reading routines for this objfile, allow complaints to
      appear for this new file, and record how verbose to be, then do the

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


             reply	other threads:[~2013-03-13  5:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-13  5:53 ehunter at broadcom dot com [this message]
2013-03-13  5:55 ` [Bug symtab/15274] " ehunter at broadcom dot com

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=bug-15274-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).