X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Fxcofflink.c;h=952297451b988566864332291124a71925df6b05;hb=209fed2decc3cbda86fdf0c2c7bf24ee14cd9fc8;hp=9841de6b07b18dae0ef44db677321473aa366c63;hpb=c72f2fb2bb6a3e1850b081dbfce4040970fae8e6;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c index 9841de6b07..952297451b 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -571,7 +571,22 @@ xcoff_link_hash_newfunc (struct bfd_hash_entry *entry, return (struct bfd_hash_entry *) ret; } -/* Create a XCOFF link hash table. */ +/* Destroy an XCOFF link hash table. */ + +static void +_bfd_xcoff_bfd_link_hash_table_free (bfd *obfd) +{ + struct xcoff_link_hash_table *ret; + + ret = (struct xcoff_link_hash_table *) obfd->link.hash; + if (ret->archive_info) + htab_delete (ret->archive_info); + if (ret->debug_strtab) + _bfd_stringtab_free (ret->debug_strtab); + _bfd_generic_link_hash_table_free (obfd); +} + +/* Create an XCOFF link hash table. */ struct bfd_link_hash_table * _bfd_xcoff_bfd_link_hash_table_create (bfd *abfd) @@ -592,6 +607,12 @@ _bfd_xcoff_bfd_link_hash_table_create (bfd *abfd) ret->debug_strtab = _bfd_xcoff_stringtab_init (); ret->archive_info = htab_create (37, xcoff_archive_info_hash, xcoff_archive_info_eq, NULL); + if (!ret->debug_strtab || !ret->archive_info) + { + _bfd_xcoff_bfd_link_hash_table_free (abfd); + return NULL; + } + ret->root.hash_table_free = _bfd_xcoff_bfd_link_hash_table_free; /* The linker will always generate a full a.out header. We need to record that fact now, before the sizeof_headers routine could be @@ -600,18 +621,6 @@ _bfd_xcoff_bfd_link_hash_table_create (bfd *abfd) return &ret->root; } - -/* Free a XCOFF link hash table. */ - -void -_bfd_xcoff_bfd_link_hash_table_free (struct bfd_link_hash_table *hash) -{ - struct xcoff_link_hash_table *ret = (struct xcoff_link_hash_table *) hash; - - _bfd_stringtab_free (ret->debug_strtab); - bfd_hash_table_free (&ret->root.table); - free (ret); -} /* Read internal relocs for an XCOFF csect. This is a wrapper around _bfd_coff_read_internal_relocs which tries to take advantage of any @@ -2375,6 +2384,8 @@ xcoff_link_check_ar_symbols (bfd *abfd, static bfd_boolean xcoff_link_check_archive_element (bfd *abfd, struct bfd_link_info *info, + struct bfd_link_hash_entry *h ATTRIBUTE_UNUSED, + const char *name ATTRIBUTE_UNUSED, bfd_boolean *pneeded) { bfd_boolean keep_syms_p; @@ -2454,7 +2465,7 @@ _bfd_xcoff_bfd_link_add_symbols (bfd *abfd, struct bfd_link_info *info) bfd_boolean needed; if (! xcoff_link_check_archive_element (member, info, - &needed)) + NULL, NULL, &needed)) return FALSE; if (needed) member->archive_pass = -1; @@ -4483,7 +4494,10 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo, if (strings == NULL) return FALSE; } - filename = strings + aux.x_file.x_n.x_offset; + if ((bfd_size_type) aux.x_file.x_n.x_offset >= obj_coff_strings_len (input_bfd)) + filename = _(""); + else + filename = strings + aux.x_file.x_n.x_offset; indx = _bfd_stringtab_add (flinfo->strtab, filename, hash, copy); if (indx == (bfd_size_type) -1)