1 2006-09-21 H.J. Lu <hongjiu.lu@intel.com>
4 * dwarf2.c (_bfd_dwarf2_find_nearest_line): Adjust debug_info
5 section vma when needed.
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
11 bfd_size_type total_size;
15 + asection *first_msec;
16 + asection **msecs = NULL;
17 + unsigned int i, count;
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.
28 + We may need to adjust debug_info section vmas since we will
29 + concatenate them together. Otherwise relocations may be
34 for (total_size = 0; msec; msec = find_debug_info (abfd, msec))
35 - total_size += msec->size;
43 + BFD_ASSERT (msec->vma == 0 && msec->alignment_power == 0);
45 + msec->vma = last_vma;
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
54 stash->info_ptr_end = stash->info_ptr;
56 - for (msec = find_debug_info (abfd, NULL);
60 + msecs = (asection **) bfd_malloc2 (count, sizeof (*msecs));
63 + for (i = 0, msec = first_msec;
65 msec = find_debug_info (abfd, msec))
75 + msecs [i - 1] = msec;
79 start = stash->info_ptr_end - stash->info_ptr;
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;
86 + /* Restore section vma. */
91 + for (i = 0; i < count; i++)
97 + for (msec = find_debug_info (abfd, first_msec);
99 + msec = find_debug_info (abfd, msec))
104 BFD_ASSERT (stash->info_ptr_end == stash->info_ptr + total_size);
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;