OLD | NEW |
1 /* GDB routines for manipulating objfiles. | 1 /* GDB routines for manipulating objfiles. |
2 | 2 |
3 Copyright (C) 1992-2004, 2007-2012 Free Software Foundation, Inc. | 3 Copyright (C) 1992-2004, 2007-2012 Free Software Foundation, Inc. |
4 | 4 |
5 Contributed by Cygnus Support, using pieces from other GDB modules. | 5 Contributed by Cygnus Support, using pieces from other GDB modules. |
6 | 6 |
7 This file is part of GDB. | 7 This file is part of GDB. |
8 | 8 |
9 This program is free software; you can redistribute it and/or modify | 9 This program is free software; you can redistribute it and/or modify |
10 it under the terms of the GNU General Public License as published by | 10 it under the terms of the GNU General Public License as published by |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 info = program_space_data (pspace, objfiles_pspace_data); | 98 info = program_space_data (pspace, objfiles_pspace_data); |
99 if (info == NULL) | 99 if (info == NULL) |
100 { | 100 { |
101 info = XZALLOC (struct objfile_pspace_info); | 101 info = XZALLOC (struct objfile_pspace_info); |
102 set_program_space_data (pspace, objfiles_pspace_data, info); | 102 set_program_space_data (pspace, objfiles_pspace_data, info); |
103 } | 103 } |
104 | 104 |
105 return info; | 105 return info; |
106 } | 106 } |
107 | 107 |
108 /* Records whether any objfiles appeared or disappeared since we last updated | |
109 address to obj section map. */ | |
110 | |
111 /* Locate all mappable sections of a BFD file. | |
112 objfile_p_char is a char * to get it through | |
113 bfd_map_over_sections; we cast it back to its proper type. */ | |
114 | |
115 /* Called via bfd_map_over_sections to build up the section table that | 108 /* Called via bfd_map_over_sections to build up the section table that |
116 the objfile references. The objfile contains pointers to the start | 109 the objfile references. The objfile contains pointers to the start |
117 of the table (objfile->sections) and to the first location after | 110 of the table (objfile->sections) and to the first location after |
118 the end of the table (objfile->sections_end). */ | 111 the end of the table (objfile->sections_end). */ |
119 | 112 |
120 static void | 113 static void |
121 add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect, | 114 add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect, |
122 » » » void *objfile_p_char) | 115 » » » void *objfilep) |
123 { | 116 { |
124 struct objfile *objfile = (struct objfile *) objfile_p_char; | 117 struct objfile *objfile = (struct objfile *) objfilep; |
125 struct obj_section section; | 118 struct obj_section section; |
126 flagword aflag; | 119 flagword aflag; |
127 | 120 |
128 aflag = bfd_get_section_flags (abfd, asect); | 121 aflag = bfd_get_section_flags (abfd, asect); |
129 | |
130 if (!(aflag & SEC_ALLOC)) | 122 if (!(aflag & SEC_ALLOC)) |
131 return; | 123 return; |
| 124 if (bfd_section_size (abfd, asect) == 0) |
| 125 return; |
132 | 126 |
133 if (0 == bfd_section_size (abfd, asect)) | |
134 return; | |
135 section.objfile = objfile; | 127 section.objfile = objfile; |
136 section.the_bfd_section = asect; | 128 section.the_bfd_section = asect; |
137 section.ovly_mapped = 0; | 129 section.ovly_mapped = 0; |
138 obstack_grow (&objfile->objfile_obstack, | 130 obstack_grow (&objfile->objfile_obstack, |
139 (char *) §ion, sizeof (section)); | 131 (char *) §ion, sizeof (section)); |
140 objfile->sections_end | 132 objfile->sections_end |
141 = (struct obj_section *) (((size_t) objfile->sections_end) + 1); | 133 = (struct obj_section *) (((size_t) objfile->sections_end) + 1); |
142 } | 134 } |
143 | 135 |
144 /* Builds a section table for OBJFILE. | 136 /* Builds a section table for OBJFILE. |
145 Returns 0 if OK, 1 on error (in which case bfd_error contains the | |
146 error). | |
147 | 137 |
148 Note that while we are building the table, which goes into the | 138 Note that while we are building the table, which goes into the |
149 psymbol obstack, we hijack the sections_end pointer to instead hold | 139 objfile obstack, we hijack the sections_end pointer to instead hold |
150 a count of the number of sections. When bfd_map_over_sections | 140 a count of the number of sections. When bfd_map_over_sections |
151 returns, this count is used to compute the pointer to the end of | 141 returns, this count is used to compute the pointer to the end of |
152 the sections table, which then overwrites the count. | 142 the sections table, which then overwrites the count. |
153 | 143 |
154 Also note that the OFFSET and OVLY_MAPPED in each table entry | 144 Also note that the OFFSET and OVLY_MAPPED in each table entry |
155 are initialized to zero. | 145 are initialized to zero. |
156 | 146 |
157 Also note that if anything else writes to the psymbol obstack while | 147 Also note that if anything else writes to the objfile obstack while |
158 we are building the table, we're pretty much hosed. */ | 148 we are building the table, we're pretty much hosed. */ |
159 | 149 |
160 int | 150 void |
161 build_objfile_section_table (struct objfile *objfile) | 151 build_objfile_section_table (struct objfile *objfile) |
162 { | 152 { |
163 objfile->sections_end = 0; | 153 objfile->sections_end = 0; |
164 bfd_map_over_sections (objfile->obfd, | 154 bfd_map_over_sections (objfile->obfd, |
165 add_to_objfile_sections, (void *) objfile); | 155 add_to_objfile_sections, (void *) objfile); |
166 objfile->sections = obstack_finish (&objfile->objfile_obstack); | 156 objfile->sections = obstack_finish (&objfile->objfile_obstack); |
167 objfile->sections_end = objfile->sections + (size_t) objfile->sections_end; | 157 objfile->sections_end = objfile->sections + (size_t) objfile->sections_end; |
168 return (0); | |
169 } | 158 } |
170 | 159 |
171 /* Given a pointer to an initialized bfd (ABFD) and some flag bits | 160 /* Given a pointer to an initialized bfd (ABFD) and some flag bits |
172 allocate a new objfile struct, fill it in as best we can, link it | 161 allocate a new objfile struct, fill it in as best we can, link it |
173 into the list of all known objfiles, and return a pointer to the | 162 into the list of all known objfiles, and return a pointer to the |
174 new objfile struct. | 163 new objfile struct. |
175 | 164 |
176 The FLAGS word contains various bits (OBJF_*) that can be taken as | 165 The FLAGS word contains various bits (OBJF_*) that can be taken as |
177 requests for specific operations. Other bits like OBJF_SHARED are | 166 requests for specific operations. Other bits like OBJF_SHARED are |
178 simply copied through to the new objfile flags member. */ | 167 simply copied through to the new objfile flags member. */ |
(...skipping 30 matching lines...) Expand all Loading... |
209 objfile->obfd = gdb_bfd_ref (abfd); | 198 objfile->obfd = gdb_bfd_ref (abfd); |
210 if (abfd != NULL) | 199 if (abfd != NULL) |
211 { | 200 { |
212 /* Look up the gdbarch associated with the BFD. */ | 201 /* Look up the gdbarch associated with the BFD. */ |
213 objfile->gdbarch = gdbarch_from_bfd (abfd); | 202 objfile->gdbarch = gdbarch_from_bfd (abfd); |
214 | 203 |
215 objfile->name = xstrdup (bfd_get_filename (abfd)); | 204 objfile->name = xstrdup (bfd_get_filename (abfd)); |
216 objfile->mtime = bfd_get_mtime (abfd); | 205 objfile->mtime = bfd_get_mtime (abfd); |
217 | 206 |
218 /* Build section table. */ | 207 /* Build section table. */ |
219 | 208 build_objfile_section_table (objfile); |
220 if (build_objfile_section_table (objfile)) | |
221 » { | |
222 » error (_("Can't find the file sections in `%s': %s"), | |
223 » » objfile->name, bfd_errmsg (bfd_get_error ())); | |
224 » } | |
225 } | 209 } |
226 else | 210 else |
227 { | 211 { |
228 objfile->name = xstrdup ("<<anonymous objfile>>"); | 212 objfile->name = xstrdup ("<<anonymous objfile>>"); |
229 } | 213 } |
230 | 214 |
231 objfile->pspace = current_program_space; | 215 objfile->pspace = current_program_space; |
232 | 216 |
233 /* Initialize the section indexes for this objfile, so that we can | 217 /* Initialize the section indexes for this objfile, so that we can |
234 later detect if they are used w/o being properly assigned to. */ | 218 later detect if they are used w/o being properly assigned to. */ |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 entry_point_address (void) | 319 entry_point_address (void) |
336 { | 320 { |
337 CORE_ADDR retval; | 321 CORE_ADDR retval; |
338 | 322 |
339 if (!entry_point_address_query (&retval)) | 323 if (!entry_point_address_query (&retval)) |
340 error (_("Entry point address is not known.")); | 324 error (_("Entry point address is not known.")); |
341 | 325 |
342 return retval; | 326 return retval; |
343 } | 327 } |
344 | 328 |
345 /* Create the terminating entry of OBJFILE's minimal symbol table. | |
346 If OBJFILE->msymbols is zero, allocate a single entry from | |
347 OBJFILE->objfile_obstack; otherwise, just initialize | |
348 OBJFILE->msymbols[OBJFILE->minimal_symbol_count]. */ | |
349 void | |
350 terminate_minimal_symbol_table (struct objfile *objfile) | |
351 { | |
352 if (! objfile->msymbols) | |
353 objfile->msymbols = ((struct minimal_symbol *) | |
354 obstack_alloc (&objfile->objfile_obstack, | |
355 sizeof (objfile->msymbols[0]))); | |
356 | |
357 { | |
358 struct minimal_symbol *m | |
359 = &objfile->msymbols[objfile->minimal_symbol_count]; | |
360 | |
361 memset (m, 0, sizeof (*m)); | |
362 /* Don't rely on these enumeration values being 0's. */ | |
363 MSYMBOL_TYPE (m) = mst_unknown; | |
364 SYMBOL_SET_LANGUAGE (m, language_unknown); | |
365 } | |
366 } | |
367 | |
368 /* Iterator on PARENT and every separate debug objfile of PARENT. | 329 /* Iterator on PARENT and every separate debug objfile of PARENT. |
369 The usage pattern is: | 330 The usage pattern is: |
370 for (objfile = parent; | 331 for (objfile = parent; |
371 objfile; | 332 objfile; |
372 objfile = objfile_separate_debug_iterate (parent, objfile)) | 333 objfile = objfile_separate_debug_iterate (parent, objfile)) |
373 ... | 334 ... |
374 */ | 335 */ |
375 | 336 |
376 struct objfile * | 337 struct objfile * |
377 objfile_separate_debug_iterate (const struct objfile *parent, | 338 objfile_separate_debug_iterate (const struct objfile *parent, |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 if (BLOCKVECTOR_MAP (bv)) | 720 if (BLOCKVECTOR_MAP (bv)) |
760 addrmap_relocate (BLOCKVECTOR_MAP (bv), | 721 addrmap_relocate (BLOCKVECTOR_MAP (bv), |
761 ANOFFSET (delta, s->block_line_section)); | 722 ANOFFSET (delta, s->block_line_section)); |
762 | 723 |
763 for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i) | 724 for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i) |
764 { | 725 { |
765 struct block *b; | 726 struct block *b; |
766 struct symbol *sym; | 727 struct symbol *sym; |
767 struct dict_iterator iter; | 728 struct dict_iterator iter; |
768 | 729 |
error: old chunk mismatch |
None
OLD | NEW |