+2011-12-13 Shinichiro Hamaji <shinichiro.hamaji@gmail.com>
+
+ * dwarf2.c (bfd_dwarf2_cleanup_debug_info): Accept stash as an
+ argument like other functions to support formats other than ELF.
+ * elf-bfd.h (bfd_dwarf2_cleanup_debug_info): Move to bfd-in.h.
+ * elf.c (_bfd_elf_close_and_cleanup): Pass dwarf2_find_line_info
+ in tdata as a parameter.
+ * libbfd-in.h (bfd_dwarf2_cleanup_debug_info): Move from
+ elf-bfd.h.
+ * libbfd.h (bfd_dwarf2_cleanup_debug_info): Regenerate.
+ * mach-o-target.c (bfd_mach_o_close_and_cleanup): Remove the
+ fallback macro.
+ (bfd_mach_o_find_nearest_line): Likewise.
+ * mach-o.c (bfd_mach_o_find_nearest_line): Add the definition
+ which calls _bfd_dwarf2_find_nearest_line.
+ (bfd_mach_o_close_and_cleanup): Likewise.
+ * mach-o.h (mach_o_data_struct): Add dwarf2_find_line_info.
+ (bfd_mach_o_find_nearest_line): Add declaration.
+ (bfd_mach_o_close_and_cleanup): Add declaration.
+
2011-12-13 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_read_symtab_symbols): Make global. Remove
}
void
-_bfd_dwarf2_cleanup_debug_info (bfd *abfd)
+_bfd_dwarf2_cleanup_debug_info (bfd *abfd, void **pinfo)
{
+ struct dwarf2_debug *stash = (struct dwarf2_debug *) *pinfo;;
struct comp_unit *each;
- struct dwarf2_debug *stash;
-
- if (abfd == NULL || elf_tdata (abfd) == NULL)
- return;
-
- stash = (struct dwarf2_debug *) elf_tdata (abfd)->dwarf2_find_line_info;
- if (stash == NULL)
+ if (abfd == NULL || stash == NULL)
return;
for (each = stash->all_comp_units; each; each = each->next_unit)
extern asection *_bfd_elf_common_section
(asection *);
-extern void _bfd_dwarf2_cleanup_debug_info
- (bfd *);
-
extern bfd_vma _bfd_elf_default_got_elt_size
(bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, bfd *,
unsigned long);
bfd_boolean
_bfd_elf_close_and_cleanup (bfd *abfd)
{
- if (bfd_get_format (abfd) == bfd_object)
+ struct elf_obj_tdata *tdata = elf_tdata (abfd);
+ if (bfd_get_format (abfd) == bfd_object && tdata != NULL)
{
- if (elf_tdata (abfd) != NULL && elf_shstrtab (abfd) != NULL)
+ if (elf_shstrtab (abfd) != NULL)
_bfd_elf_strtab_free (elf_shstrtab (abfd));
- _bfd_dwarf2_cleanup_debug_info (abfd);
+ _bfd_dwarf2_cleanup_debug_info (abfd, &tdata->dwarf2_find_line_info);
}
return _bfd_generic_close_and_cleanup (abfd);
/* Find inliner info after calling bfd_find_nearest_line. */
extern bfd_boolean _bfd_dwarf2_find_inliner_info
(bfd *, const char **, const char **, unsigned int *, void **);
-
+
+/* Clean up the data used to handle DWARF 2 debugging information. */
+extern void _bfd_dwarf2_cleanup_debug_info
+ (bfd *, void **);
+
/* Create a new section entry. */
extern struct bfd_hash_entry *bfd_section_hash_newfunc
(struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
/* Find inliner info after calling bfd_find_nearest_line. */
extern bfd_boolean _bfd_dwarf2_find_inliner_info
(bfd *, const char **, const char **, unsigned int *, void **);
-
+
+/* Clean up the data used to handle DWARF 2 debugging information. */
+extern void _bfd_dwarf2_cleanup_debug_info
+ (bfd *, void **);
+
/* Create a new section entry. */
extern struct bfd_hash_entry *bfd_section_hash_newfunc
(struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
#ifndef MACH_O_TARGET_COMMON_DEFINED
#define MACH_O_TARGET_COMMON_DEFINED
-#define bfd_mach_o_close_and_cleanup _bfd_generic_close_and_cleanup
#define bfd_mach_o_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
#define bfd_mach_o_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
#define bfd_mach_o_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
#define bfd_mach_o_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
#define bfd_mach_o_bfd_is_local_label_name bfd_generic_is_local_label_name
#define bfd_mach_o_get_lineno _bfd_nosymbols_get_lineno
-#define bfd_mach_o_find_nearest_line _bfd_nosymbols_find_nearest_line
#define bfd_mach_o_find_inliner_info _bfd_nosymbols_find_inliner_info
#define bfd_mach_o_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
#define bfd_mach_o_read_minisymbols _bfd_generic_read_minisymbols
return 0;
}
+bfd_boolean
+bfd_mach_o_find_nearest_line (bfd *abfd,
+ asection *section,
+ asymbol **symbols,
+ bfd_vma offset,
+ const char **filename_ptr,
+ const char **functionname_ptr,
+ unsigned int *line_ptr)
+{
+ bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
+ /* TODO: Handle executables and dylibs by using dSYMs. */
+ if (mdata->header.filetype != BFD_MACH_O_MH_OBJECT)
+ return FALSE;
+ if (_bfd_dwarf2_find_nearest_line (abfd, dwarf_debug_sections,
+ section, symbols, offset,
+ filename_ptr, functionname_ptr,
+ line_ptr, 0,
+ &mdata->dwarf2_find_line_info))
+ return TRUE;
+ return FALSE;
+}
+
+bfd_boolean
+bfd_mach_o_close_and_cleanup (bfd *abfd)
+{
+ bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
+ if (bfd_get_format (abfd) == bfd_object && mdata != NULL)
+ _bfd_dwarf2_cleanup_debug_info (abfd, &mdata->dwarf2_find_line_info);
+
+ return _bfd_generic_close_and_cleanup (abfd);
+}
+
#define bfd_mach_o_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
#define bfd_mach_o_bfd_reloc_name_lookup _bfd_norelocs_bfd_reloc_name_lookup
is expected. */
bfd_mach_o_symtab_command *symtab;
bfd_mach_o_dysymtab_command *dysymtab;
+
+ /* A place to stash dwarf2 info for this bfd. */
+ void *dwarf2_find_line_info;
}
bfd_mach_o_data_struct;
unsigned int bfd_mach_o_get_section_attribute_from_name (const char *);
void bfd_mach_o_normalize_section_name (const char *, const char *,
const char **, flagword *);
+bfd_boolean bfd_mach_o_find_nearest_line (bfd *, asection *, asymbol **,
+ bfd_vma, const char **,
+ const char **, unsigned int *);
+bfd_boolean bfd_mach_o_close_and_cleanup (bfd *);
unsigned int bfd_mach_o_section_get_nbr_indirect (bfd *, bfd_mach_o_section *);
unsigned int bfd_mach_o_section_get_entry_size (bfd *, bfd_mach_o_section *);