+2013-03-21 Tom Tromey <tromey@redhat.com>
+
+ * symfile.c (alloc_section_addr_info): Update header. Don't set
+ 'num_sections' field.
+ (build_section_addr_info_from_section_table): Set 'num_sections'.
+ (build_section_addr_info_from_bfd): Likewise.
+ (build_section_addr_info_from_objfile): Remove dead loop
+ condition.
+ (free_section_addr_info): Unconditionally call xfree.
+ (relative_addr_info_to_section_offsets, addrs_section_sort)
+ (addr_info_make_relative, syms_from_objfile_1): Remove dead loop
+ condition.
+ (syms_from_objfile_1): Remove dead 'if' condition. Check
+ 'num_sections'.
+ (add_symbol_file_command): Set 'num_sections'.
+ * symfile-mem.c (symbol_file_add_from_memory): Set
+ 'num_sections'.
+ * somread.c (som_symfile_offsets): Remove dead loop condition.
+ * machoread.c (macho_symfile_offsets): Remove dead 'if'.
+ * jit.c (jit_bfd_try_read_symtab): Set 'num_sections'.
+
2013-03-21 Tom Tromey <tromey@redhat.com>
* tracepoint.h (decode_agent_options): Add 'trace_string'
*lowest = sect;
}
-/* Create a new section_addr_info, with room for NUM_SECTIONS. */
+/* Create a new section_addr_info, with room for NUM_SECTIONS. The
+ new object's 'num_sections' field is set to 0; it must be updated
+ by the caller. */
struct section_addr_info *
alloc_section_addr_info (size_t num_sections)
+ sizeof (struct other_sections) * (num_sections - 1));
sap = (struct section_addr_info *) xmalloc (size);
memset (sap, 0, size);
- sap->num_sections = num_sections;
return sap;
}
}
}
+ sap->num_sections = oidx;
+
return sap;
}
sap->other[i].sectindex = sec->index;
i++;
}
+
+ sap->num_sections = i;
+
return sap;
}
gdb_assert (objfile->num_sections == bfd_count_sections (objfile->obfd));
*/
sap = build_section_addr_info_from_bfd (objfile->obfd);
- for (i = 0; i < sap->num_sections && sap->other[i].name; i++)
+ for (i = 0; i < sap->num_sections; i++)
{
int sectindex = sap->other[i].sectindex;
int idx;
for (idx = 0; idx < sap->num_sections; idx++)
- if (sap->other[idx].name)
- xfree (sap->other[idx].name);
+ xfree (sap->other[idx].name);
xfree (sap);
}
memset (section_offsets, 0, SIZEOF_N_SECTION_OFFSETS (num_sections));
/* Now calculate offsets for section that were specified by the caller. */
- for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
+ for (i = 0; i < addrs->num_sections; i++)
{
struct other_sections *osp;
/* `+ 1' for the NULL terminator. */
array = xmalloc (sizeof (*array) * (addrs->num_sections + 1));
- for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
+ for (i = 0; i < addrs->num_sections; i++)
array[i] = &addrs->other[i];
array[i] = NULL;
(the loadable section directly below it in memory).
this_offset = lower_offset = lower_addr - lower_orig_addr */
- for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
+ for (i = 0; i < addrs->num_sections; i++)
{
struct other_sections *sect = addrs_to_abfd_addrs[i];
We no longer warn if the lowest section is not a text segment (as
happens for the PA64 port. */
- if (addrs && addrs->other[0].name)
+ if (addrs && addrs->num_sections > 0)
addr_info_make_relative (addrs, objfile->obfd);
/* Initialize symbol reading routines for this objfile, allow complaints to
At this point, we don't know what file type this is,
so we can't determine what section names are valid. */
}
+ section_addrs->num_sections = sec_num;
if (from_tty && (!query ("%s", "")))
error (_("Not confirmed."));