summaryrefslogtreecommitdiffstats
path: root/binutils-2.25/bfd/xcofflink.c
diff options
context:
space:
mode:
Diffstat (limited to 'binutils-2.25/bfd/xcofflink.c')
-rw-r--r--binutils-2.25/bfd/xcofflink.c61
1 files changed, 37 insertions, 24 deletions
diff --git a/binutils-2.25/bfd/xcofflink.c b/binutils-2.25/bfd/xcofflink.c
index d0bfd297..95229745 100644
--- a/binutils-2.25/bfd/xcofflink.c
+++ b/binutils-2.25/bfd/xcofflink.c
@@ -1,6 +1,5 @@
/* POWER/PowerPC XCOFF linker support.
- Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
+ Copyright (C) 1995-2014 Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
@@ -572,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)
@@ -593,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
@@ -601,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
@@ -2376,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;
@@ -2455,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;
@@ -2986,7 +2996,7 @@ xcoff_sweep (struct bfd_link_info *info)
{
bfd *sub;
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
{
asection *o;
@@ -3711,7 +3721,7 @@ bfd_xcoff_size_dynamic_sections (bfd *output_bfd,
/* We still need to call xcoff_mark, in order to set ldrel_count
correctly. */
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
{
asection *o;
@@ -3805,7 +3815,7 @@ bfd_xcoff_size_dynamic_sections (bfd *output_bfd,
and figure out the contents of the .debug section. */
debug_strtab = xcoff_hash_table (info)->debug_strtab;
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
{
asection *subdeb;
bfd_size_type symcount;
@@ -3974,7 +3984,7 @@ bfd_xcoff_link_generate_rtinit (bfd *abfd,
bim->size = 0;
bim->buffer = 0;
- abfd->link_next = 0;
+ abfd->link.next = 0;
abfd->format = bfd_object;
abfd->iostream = (void *) bim;
abfd->flags = BFD_IN_MEMORY;
@@ -4484,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 = _("<corrupt>");
+ 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)
@@ -5042,7 +5055,7 @@ xcoff_find_tc0 (bfd *output_bfd, struct xcoff_final_link_info *flinfo)
section_index = -1;
for (input_bfd = flinfo->info->input_bfds;
input_bfd != NULL;
- input_bfd = input_bfd->link_next)
+ input_bfd = input_bfd->link.next)
for (sec = input_bfd->sections; sec != NULL; sec = sec->next)
if ((sec->flags & SEC_MARK) != 0 && xcoff_toc_section_p (sec))
{
@@ -5074,7 +5087,7 @@ xcoff_find_tc0 (bfd *output_bfd, struct xcoff_final_link_info *flinfo)
best_address = toc_end;
for (input_bfd = flinfo->info->input_bfds;
input_bfd != NULL;
- input_bfd = input_bfd->link_next)
+ input_bfd = input_bfd->link.next)
for (sec = input_bfd->sections; sec != NULL; sec = sec->next)
if ((sec->flags & SEC_MARK) != 0 && xcoff_toc_section_p (sec))
{
@@ -6104,7 +6117,7 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
input BFD's. We want at least 6 symbols, since that is the
number which xcoff_write_global_symbol may need. */
max_sym_count = 6;
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
{
bfd_size_type sz;