public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H. J. Lu" <hjl@lucon.org>
To: binutils@sources.redhat.com
Subject: Re: PATCH: PR ld/3191: Linker failed to handle DW_FORM_ref_addr properly
Date: Thu, 21 Sep 2006 02:10:00 -0000	[thread overview]
Message-ID: <20060921005411.GA3401@lucon.org> (raw)
In-Reply-To: <20060920221922.GA2385@lucon.org>

On Wed, Sep 20, 2006 at 03:19:22PM -0700, H. J. Lu wrote:
> On Tue, Sep 19, 2006 at 10:20:10PM -0700, H. J. Lu wrote:
> > On Tue, Sep 19, 2006 at 09:37:02PM -0700, H. J. Lu wrote:
> > > DW_FORM_ref_addr is offset_size according to DWARF3 and gcc follows
> > > DWARF3. This patch fixes
> > > 
> > > http://sourceware.org/bugzilla/show_bug.cgi?id=3191
> > > 
> > > 
> 
> It turns out that the problem is we didn't properly adjust debug_info
> section vmas when we put them together. I think this is a right fix.
> 
> 

Here is the updated patch. Can we assume debug section vma is 0 and
we don't need to reset it after adjustment and relocation?


H.J.
2006-09-19  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/3191
	* dwarf2.c (_bfd_dwarf2_find_nearest_line): Adjust debug_info
	section vma when needed.

--- bfd/dwarf2.c.ref_addr	2006-05-02 03:01:56.000000000 -0700
+++ bfd/dwarf2.c	2006-09-20 17:46:05.000000000 -0700
@@ -2354,6 +2354,9 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
     {
       bfd_size_type total_size;
       asection *msec;
+      bfd_vma last_vma;
+      bfd_size_type size;
+      asection *first_msec;
 
       *pinfo = stash;
 
@@ -2368,9 +2371,26 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
 	 Read them all in and produce one large stash.  We do this in two
 	 passes - in the first pass we just accumulate the section sizes.
 	 In the second pass we read in the section's contents.  The allows
-	 us to avoid reallocing the data as we add sections to the stash.  */
+	 us to avoid reallocing the data as we add sections to the stash.
+       
+	 We may need to adjust debug_info section vmas since we will
+	 concatenate them together.  Otherwise relocations may be
+	 incorrect.  */
+      first_msec = msec;
+      last_vma = 0;
       for (total_size = 0; msec; msec = find_debug_info (abfd, msec))
-	total_size += msec->size;
+	{
+	  size = msec->size;
+	  if (size == 0)
+	    continue;
+
+	  total_size += size;
+
+	  BFD_ASSERT (msec->alignment_power == 0);
+
+	  msec->vma = last_vma;
+	  last_vma += size;
+	}
 
       stash->info_ptr = bfd_alloc (abfd, total_size);
       if (stash->info_ptr == NULL)
@@ -2378,7 +2398,7 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
 
       stash->info_ptr_end = stash->info_ptr;
 
-      for (msec = find_debug_info (abfd, NULL);
+      for (msec = first_msec;
 	   msec;
 	   msec = find_debug_info (abfd, msec))
 	{
@@ -2400,7 +2420,7 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
 
       BFD_ASSERT (stash->info_ptr_end == stash->info_ptr + total_size);
 
-      stash->sec = find_debug_info (abfd, NULL);
+      stash->sec = first_msec;
       stash->sec_info_ptr = stash->info_ptr;
       stash->syms = symbols;
     }

  reply	other threads:[~2006-09-21  0:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-20  6:16 H. J. Lu
2006-09-20 11:40 ` H. J. Lu
2006-09-20 14:48   ` Daniel Jacobowitz
2006-09-20 19:15   ` Jim Wilson
2006-09-20 22:32   ` H. J. Lu
2006-09-21  2:10     ` H. J. Lu [this message]
2006-09-21 16:23       ` H. J. Lu
2006-09-28  7:45         ` Jim Wilson
2006-09-28  9:08           ` H. J. Lu
2006-09-20 19:59 ` Jim Wilson
2006-09-20 20:02   ` 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=20060921005411.GA3401@lucon.org \
    --to=hjl@lucon.org \
    --cc=binutils@sources.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).