aboutsummaryrefslogtreecommitdiff
path: root/gdb/elfread.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2003-06-06 23:33:00 +0000
committerMark Mitchell <mark@codesourcery.com>2003-06-06 23:33:00 +0000
commita39a16c41b7a27c34abdf6f5c32c4a89b5ac35c6 (patch)
tree02417c41a9e7e49238d9178d45173cfd6ae8c6dc /gdb/elfread.c
parent539ee71a87838a10f843d7b1ef64975afba1b20e (diff)
downloadgdb-a39a16c41b7a27c34abdf6f5c32c4a89b5ac35c6.zip
gdb-a39a16c41b7a27c34abdf6f5c32c4a89b5ac35c6.tar.gz
gdb-a39a16c41b7a27c34abdf6f5c32c4a89b5ac35c6.tar.bz2
* elfread.c (elf_symtab_read): Avoid use of SECT_OFF_MAX.
(elfstab_offset_sections): Likewise. * gdb-stabs.h (stab_section_info): Likewise. * i386-interix-tdep.c (pei_adjust_objfile_offsets): Likewise. * objfiles.c (objfile_relocate): Likewise. * pa64solib.c (pa64_solib_add_solib_objfile): Likewise. * remote.c (get_offsets): Likewise. (remote_cisco_objfile_relocate): Likewise. * somread.c (som_symfile_offsets): Likewise. * symfile.c (alloc_section_addr_info): New function. (build_section_addr_info_from_section_tab): Use it. (free_section_addr_info): Adjust. (default_symfile_offsets): Avoid use of SECT_OFF_MAX. (syms_from_objfile): Allocate local_addr dynamically. (symbol_file_add_with_addrs_or_offsets): Allocate orig_addrs dynamically. (add_symbol_file_command): Allocate sect_opts dynamically. (reread_symbols): Avoid use of SECT_OFF_MAX. * symfile.h (section_addr_info): Do not use MAX_SECTIONS. (alloc_section_addr_info): Declare it. * symtab.h (SIZEOF_SECTION_OFFSETS): Remove. * win32-nat.c (solib_symbols_add): Allocate section_addrs dynamically. * xcoffread.c (xcoff_symfile_offsets): Avoid use of SECT_OFF_MAX.
Diffstat (limited to 'gdb/elfread.c')
-rw-r--r--gdb/elfread.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 7aee37c..cecae42 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -372,34 +372,47 @@ elf_symtab_read (struct objfile *objfile, int dynamic)
}
else if (sym->flags & BSF_LOCAL)
{
+ int special_local_sym_p = 0;
/* Named Local variable in a Data section. Check its
name for stabs-in-elf. The STREQ macro checks the
first character inline, so we only actually do a
strcmp function call on names that start with 'B'
or 'D' */
- index = SECT_OFF_MAX;
if (STREQ ("Bbss.bss", sym->name))
{
index = SECT_OFF_BSS (objfile);
+ special_local_sym_p = 1;
}
else if (STREQ ("Ddata.data", sym->name))
{
index = SECT_OFF_DATA (objfile);
+ special_local_sym_p = 1;
}
else if (STREQ ("Drodata.rodata", sym->name))
{
index = SECT_OFF_RODATA (objfile);
+ special_local_sym_p = 1;
}
- if (index != SECT_OFF_MAX)
+ if (special_local_sym_p)
{
/* Found a special local symbol. Allocate a
sectinfo, if needed, and fill it in. */
if (sectinfo == NULL)
{
+ int max_index;
+ size_t size;
+
+ max_index
+ = max (SECT_OFF_BSS (objfile),
+ max (SECT_OFF_DATA (objfile),
+ SECT_OFF_RODATA (objfile)));
+ size = (sizeof (struct stab_section_info)
+ + (sizeof (CORE_ADDR)
+ * (max_index - 1)));
sectinfo = (struct stab_section_info *)
- xmmalloc (objfile->md, sizeof (*sectinfo));
- memset (sectinfo, 0,
- sizeof (*sectinfo));
+ xmmalloc (objfile->md, size);
+ memset (sectinfo, 0, size);
+ sectinfo->num_sections = max_index;
if (filesym == NULL)
{
complaint (&symfile_complaints,
@@ -740,8 +753,9 @@ elfstab_offset_sections (struct objfile *objfile, struct partial_symtab *pst)
/* Found it! Allocate a new psymtab struct, and fill it in. */
maybe->found++;
pst->section_offsets = (struct section_offsets *)
- obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS);
- for (i = 0; i < SECT_OFF_MAX; i++)
+ obstack_alloc (&objfile->psymbol_obstack,
+ SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
+ for (i = 0; i < maybe->num_sections; i++)
(pst->section_offsets)->offsets[i] = maybe->sections[i];
return;
}