1 2006-09-29 H.J. Lu <hongjiu.lu@intel.com>
4 * dwarf2.c (find_abstract_instance_name): Pass a pointer to
5 attribute instead of offset. For DW_FORM_ref_addr, get the
6 entry at the offset from the .debug_info section.
7 (scan_unit_for_symbols): Updated.
8 (_bfd_dwarf2_find_nearest_line): Adjust debug_info
9 section vma when needed.
11 --- bfd/dwarf2.c.ref_addr 2006-09-21 13:55:25.000000000 -0700
12 +++ bfd/dwarf2.c 2006-09-29 10:07:14.000000000 -0700
13 @@ -1556,16 +1556,30 @@ lookup_symbol_in_variable_table (struct
17 -find_abstract_instance_name (struct comp_unit *unit, bfd_uint64_t die_ref)
18 +find_abstract_instance_name (struct comp_unit *unit,
19 + struct attribute *attr_ptr)
21 bfd *abfd = unit->abfd;
23 unsigned int abbrev_number, bytes_read, i;
24 struct abbrev_info *abbrev;
25 + bfd_uint64_t die_ref = attr_ptr->u.val;
26 struct attribute attr;
29 - info_ptr = unit->info_ptr_unit + die_ref;
30 + /* DW_FORM_ref_addr can reference an entry in a different CU. It
31 + is an offset from the .debug_info section, not the current CU. */
32 + if (attr_ptr->form == DW_FORM_ref_addr)
34 + /* FIXME: How to handle DW_FORM_ref_addr references an entry in
35 + a different file? */
39 + info_ptr = unit->stash->sec_info_ptr + die_ref;
42 + info_ptr = unit->info_ptr_unit + die_ref;
43 abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
44 info_ptr += bytes_read;
46 @@ -1591,7 +1605,7 @@ find_abstract_instance_name (struct comp
49 case DW_AT_specification:
50 - name = find_abstract_instance_name (unit, attr.u.val);
51 + name = find_abstract_instance_name (unit, &attr);
53 case DW_AT_MIPS_linkage_name:
55 @@ -1751,7 +1765,7 @@ scan_unit_for_symbols (struct comp_unit
58 case DW_AT_abstract_origin:
59 - func->name = find_abstract_instance_name (unit, attr.u.val);
60 + func->name = find_abstract_instance_name (unit, &attr);
64 @@ -2375,6 +2389,11 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
66 bfd_size_type total_size;
70 + asection *first_msec;
71 + asection **msecs = NULL;
72 + unsigned int i, count;
76 @@ -2389,9 +2408,28 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
77 Read them all in and produce one large stash. We do this in two
78 passes - in the first pass we just accumulate the section sizes.
79 In the second pass we read in the section's contents. The allows
80 - us to avoid reallocing the data as we add sections to the stash. */
81 + us to avoid reallocing the data as we add sections to the stash.
83 + We may need to adjust debug_info section vmas since we will
84 + concatenate them together. Otherwise relocations may be
89 for (total_size = 0; msec; msec = find_debug_info (abfd, msec))
90 - total_size += msec->size;
98 + BFD_ASSERT (msec->vma == 0 && msec->alignment_power == 0);
100 + msec->vma = last_vma;
105 stash->info_ptr = bfd_alloc (abfd, total_size);
106 if (stash->info_ptr == NULL)
107 @@ -2399,17 +2437,27 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
109 stash->info_ptr_end = stash->info_ptr;
111 - for (msec = find_debug_info (abfd, NULL);
115 + msecs = (asection **) bfd_malloc2 (count, sizeof (*msecs));
118 + for (i = 0, msec = first_msec;
120 msec = find_debug_info (abfd, msec))
122 - bfd_size_type size;
130 + msecs [i - 1] = msec;
134 start = stash->info_ptr_end - stash->info_ptr;
136 if ((bfd_simple_get_relocated_section_contents
137 @@ -2419,9 +2467,27 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
138 stash->info_ptr_end = stash->info_ptr + start + size;
141 + /* Restore section vma. */
146 + for (i = 0; i < count; i++)
147 + msecs [i]->vma = 0;
152 + for (msec = find_debug_info (abfd, first_msec);
154 + msec = find_debug_info (abfd, msec))
159 BFD_ASSERT (stash->info_ptr_end == stash->info_ptr + total_size);
161 - stash->sec = find_debug_info (abfd, NULL);
162 + stash->sec = first_msec;
163 stash->sec_info_ptr = stash->info_ptr;
164 stash->syms = symbols;