[mach-o] get rid of current_oso global
This current_oso global was used to store the OSO's symbol table
in order to relocate common symbols. But it is also making the
assumption that all sections are going to be immediately relocated
as macho_add_oso_symfile does:
- Initialize the current_oso
- Use it through symbol_file_add_from_bfd
- Reset the current_oso (to all fields NULL)
What actually happens is that the .debug_frame section gets read
lazily, and thus relocated at a later time. This relocation causes
current_oso.symbol_table to be initialized (see macho_symfile_relocate)
again. And this eventually causes to trip the...
gdb_assert (current_oso.symbol_table == NULL);
...assertion to fail because the symbol_table was never free'ed.
To be complete, this happens because macho_symfile_relocate was
called outside of macho_add_oso_symfile's control, where the
set-global/use/unset-global dance happens.
But it looks like keeping this global around is not necessary, as
this symbol table is only used to relocate the common symbols.
We can do that prior to relocating the rest of the symbols.
gdb/ChangeLog:
* machoread.c (struct macho_oso_data): Delete.
(current_oso): Delete.
(macho_relocate_common_syms): New function, mostly extracted
out of
(macho_add_oso_symfile): Call macho_relocate_common_syms.
Remove code that sets and unset current_oso.
(macho_symfile_relocate): Delete handling of common symbols,
now moved to macho_relocate_common_syms.