[mach-o] get rid of current_oso global
authorJoel Brobecker <brobecker@gnat.com>
Fri, 1 Jul 2011 18:36:36 +0000 (18:36 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Fri, 1 Jul 2011 18:36:36 +0000 (18:36 +0000)
commit38947ccadc949e3c90dd3c676db78eb1741d02bf
tree83c8a07bce832b473117fc17b2fa8dfea6dff486
parenta7aa0d73a26241ba616f42563bfe19bd0077312c
[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.
gdb/ChangeLog
gdb/machoread.c
This page took 0.025243 seconds and 4 git commands to generate.