}
oso_el;
-/* Vector of object files to be read after the executable. This is one
- global variable but it's life-time is the one of macho_symfile_read. */
+/* Vector of object files to be read after the executable. */
DEF_VEC_O (oso_el);
-static VEC (oso_el) *oso_vector;
static void
macho_new_init (struct objfile *objfile)
/* Add a new OSO to the vector of OSO to load. */
static void
-macho_register_oso (struct objfile *objfile,
+macho_register_oso (VEC (oso_el) **oso_vector_ptr,
+ struct objfile *objfile,
asymbol **oso_sym, asymbol **end_sym,
unsigned int nbr_syms)
{
el.oso_sym = oso_sym;
el.end_sym = end_sym;
el.nbr_syms = nbr_syms;
- VEC_safe_push (oso_el, oso_vector, &el);
+ VEC_safe_push (oso_el, *oso_vector_ptr, &el);
}
/* Add symbol SYM to the minimal symbol table of OBJFILE. */
static void
macho_symtab_read (struct objfile *objfile,
- long number_of_symbols, asymbol **symbol_table)
+ long number_of_symbols, asymbol **symbol_table,
+ VEC (oso_el) **oso_vector_ptr)
{
long i;
const asymbol *dir_so = NULL;
{
/* End of file. */
if (state == S_DWARF_FILE)
- macho_register_oso (objfile, oso_file, symbol_table + i,
+ macho_register_oso (oso_vector_ptr, objfile,
+ oso_file, symbol_table + i,
nbr_syms);
state = S_NO_SO;
}
do_cleanups (cleanup);
}
-/* Read symbols from the vector of oso files. */
+/* Read symbols from the vector of oso files.
+
+ Note that this function sorts OSO_VECTOR_PTR. */
static void
-macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
+macho_symfile_read_all_oso (VEC (oso_el) **oso_vector_ptr,
+ struct objfile *main_objfile,
+ int symfile_flags)
{
int ix;
- VEC (oso_el) *vec;
+ VEC (oso_el) *vec = *oso_vector_ptr;
oso_el *oso;
struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
- vec = oso_vector;
- oso_vector = NULL;
-
/* Sort oso by name so that files from libraries are gathered. */
qsort (VEC_address (oso_el, vec), VEC_length (oso_el, vec),
sizeof (oso_el), oso_el_compare_name);
}
}
- VEC_free (oso_el, vec);
do_cleanups (cleanup);
}
CORE_ADDR offset;
long storage_needed;
bfd *dsym_bfd;
+ VEC (oso_el) *oso_vector = NULL;
+ struct cleanup *old_chain = make_cleanup (VEC_cleanup (oso_el), &oso_vector);
/* Get symbols from the symbol table only if the file is an executable.
The symbol table of object files is not relocated and is expected to
{
asymbol **symbol_table;
long symcount;
- struct cleanup *back_to;
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
init_minimal_symbol_collection ();
- back_to = make_cleanup_discard_minimal_symbols ();
+ make_cleanup_discard_minimal_symbols ();
symcount = bfd_canonicalize_symtab (objfile->obfd, symbol_table);
bfd_get_filename (objfile->obfd),
bfd_errmsg (bfd_get_error ()));
- macho_symtab_read (objfile, symcount, symbol_table);
+ macho_symtab_read (objfile, symcount, symbol_table, &oso_vector);
install_minimal_symbols (objfile);
- do_cleanups (back_to);
}
/* Try to read .eh_frame / .debug_frame. */
int ix;
oso_el *oso;
struct bfd_section *asect, *dsect;
- struct cleanup *cleanup;
if (mach_o_debug_level > 0)
printf_unfiltered (_("dsym file found\n"));
- /* Remove oso. They won't be used. */
- VEC_free (oso_el, oso_vector);
- oso_vector = NULL;
-
/* Set dsym section size. */
for (asect = objfile->obfd->sections, dsect = dsym_bfd->sections;
asect && dsect;
}
/* Add the dsym file as a separate file. */
- cleanup = make_cleanup_bfd_unref (dsym_bfd);
+ make_cleanup_bfd_unref (dsym_bfd);
symbol_file_add_separate (dsym_bfd, symfile_flags, objfile);
- do_cleanups (cleanup);
/* Don't try to read dwarf2 from main file or shared libraries. */
+ do_cleanups (old_chain);
return;
}
}
/* Then the oso. */
if (oso_vector != NULL)
- macho_symfile_read_all_oso (objfile, symfile_flags);
+ macho_symfile_read_all_oso (&oso_vector, objfile, symfile_flags);
+
+ do_cleanups (old_chain);
}
static bfd_byte *