]> git.pld-linux.org Git - packages/binutils.git/blob - binutils-pr3191.patch
- PR ld/3191 patch updated, release 2.3.
[packages/binutils.git] / binutils-pr3191.patch
1 2006-09-21  H.J. Lu  <hongjiu.lu@intel.com>
2
3         PR ld/3191
4         * dwarf2.c (_bfd_dwarf2_find_nearest_line): Adjust debug_info
5         section vma when needed.
6
7 --- bfd/dwarf2.c.ref_addr       2006-09-16 19:44:38.000000000 -0700
8 +++ bfd/dwarf2.c        2006-09-21 08:01:13.000000000 -0700
9 @@ -2375,6 +2375,11 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
10      {
11        bfd_size_type total_size;
12        asection *msec;
13 +      bfd_vma last_vma;
14 +      bfd_size_type size;
15 +      asection *first_msec;
16 +      asection **msecs = NULL;
17 +      unsigned int i, count;
18  
19        *pinfo = stash;
20  
21 @@ -2389,9 +2394,28 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
22          Read them all in and produce one large stash.  We do this in two
23          passes - in the first pass we just accumulate the section sizes.
24          In the second pass we read in the section's contents.  The allows
25 -        us to avoid reallocing the data as we add sections to the stash.  */
26 +        us to avoid reallocing the data as we add sections to the stash.
27 +       
28 +        We may need to adjust debug_info section vmas since we will
29 +        concatenate them together.  Otherwise relocations may be
30 +        incorrect.  */
31 +      first_msec = msec;
32 +      last_vma = 0;
33 +      count = 0;
34        for (total_size = 0; msec; msec = find_debug_info (abfd, msec))
35 -       total_size += msec->size;
36 +       {
37 +         size = msec->size;
38 +         if (size == 0)
39 +           continue;
40 +
41 +         total_size += size;
42 +
43 +         BFD_ASSERT (msec->vma == 0 && msec->alignment_power == 0);
44 +
45 +         msec->vma = last_vma;
46 +         last_vma += size;
47 +         count++;
48 +       }
49  
50        stash->info_ptr = bfd_alloc (abfd, total_size);
51        if (stash->info_ptr == NULL)
52 @@ -2399,17 +2423,27 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
53  
54        stash->info_ptr_end = stash->info_ptr;
55  
56 -      for (msec = find_debug_info (abfd, NULL);
57 +      if (count > 1)
58 +       {
59 +         count--;
60 +         msecs = (asection **) bfd_malloc2 (count, sizeof (*msecs));
61 +       }
62 +
63 +      for (i = 0, msec = first_msec;
64            msec;
65            msec = find_debug_info (abfd, msec))
66         {
67 -         bfd_size_type size;
68           bfd_size_type start;
69  
70           size = msec->size;
71           if (size == 0)
72             continue;
73  
74 +         if (i && msecs)
75 +           msecs [i - 1] = msec;
76 +
77 +         i++;
78 +
79           start = stash->info_ptr_end - stash->info_ptr;
80  
81           if ((bfd_simple_get_relocated_section_contents
82 @@ -2419,9 +2453,27 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
83           stash->info_ptr_end = stash->info_ptr + start + size;
84         }
85  
86 +      /* Restore section vma. */
87 +      if (count)
88 +       {
89 +         if (msecs)
90 +           {
91 +             for (i = 0; i < count; i++)
92 +               msecs [i]->vma = 0;
93 +             free (msecs);
94 +           }
95 +         else
96 +           {
97 +             for (msec = find_debug_info (abfd, first_msec);
98 +                  msec;
99 +                  msec = find_debug_info (abfd, msec))
100 +               msec->vma = 0;
101 +           }
102 +       }
103 +
104        BFD_ASSERT (stash->info_ptr_end == stash->info_ptr + total_size);
105  
106 -      stash->sec = find_debug_info (abfd, NULL);
107 +      stash->sec = first_msec;
108        stash->sec_info_ptr = stash->info_ptr;
109        stash->syms = symbols;
110      }
This page took 0.031857 seconds and 3 git commands to generate.