This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PR 6478 fix


PR 6478 is caused by the generic linker using a different set of
symbols to ones used by the ELF linker on relocs.  A warning symbol
causes the linker to read relocs and symbols early, before symbols
have been merged.  These relocs and their symbols are cached by the
ELF linker backend.  Later, the generic linker reads the symbols again
and merges them properly with symbols from other object files, but
doesn't touch the symbols on the cached relocs.  So the reloc symbols
are left undefined.

We already had code in the linker that was supposed to keep just one
copy of the symbols, but these weren't made available to the generic
linker.  Fixed by caching the symbols in the generic linker.

bfd/
	* bfd.c (struct _bfd): Correct outsymbols comment.
	* bfd-in2.h: Regenerate.
	* linker.c (bfd_generic_link_read_symbols): Renamed from..
	(generic_link_read_symbols): ..this, and made global.

include/
	* bfdlink.h (bfd_generic_link_read_symbols): Declare.
ld/
	PR 6478
	* ldcref.c (check_local_sym_xref): Use bfd_generic_link_read_symbols.
	Don't free symbol pointer array.
	(check_refs): Likewise.
	* ldmain.c (warning_callback): Likewise.
	* ldmisc.c (vfinfo): Likewise.
	* pe-dll.c (process_def_file): Likewise.
	(pe_walk_relocs_of_symbol, generate_reloc): Likewise.
	* emultempl/pe.em (pe_find_data_imports): Likewise.
	(gld_${EMULATION_NAME}_after_open): Likewise.
	* emultempl/pep.em (pep_find_data_imports): Likewise.
	(gld_${EMULATION_NAME}_after_open): Likewise.
	* ldlang.h (lang_input_statement_type): Delete asymbols, symbol_count,
	passive_position, closed.
	* ldlang.c (new_afile): Don't set asymbols and symbol_count.
	* ldmain.c (add_archive_element): xcalloc lang_input_statement_type.

Index: bfd/bfd.c
===================================================================
RCS file: /cvs/src/src/bfd/bfd.c,v
retrieving revision 1.103
diff -u -p -r1.103 bfd.c
--- bfd/bfd.c	7 Jul 2008 11:48:27 -0000	1.103
+++ bfd/bfd.c	16 Aug 2008 10:55:20 -0000
@@ -176,7 +176,8 @@ CODE_FRAGMENT
 .  {* Used for input and output.  *}
 .  unsigned int symcount;
 .
-.  {* Symbol table for output BFD (with symcount entries).  *}
+.  {* Symbol table for output BFD (with symcount entries).
+.     Also used by the linker to cache input BFD symbols.  *}
 .  struct bfd_symbol  **outsymbols;
 .
 .  {* Used for slurped dynamic symbol tables.  *}
Index: bfd/linker.c
===================================================================
RCS file: /cvs/src/src/bfd/linker.c,v
retrieving revision 1.64
diff -u -p -r1.64 linker.c
--- bfd/linker.c	15 Feb 2008 03:35:52 -0000	1.64
+++ bfd/linker.c	16 Aug 2008 10:55:35 -0000
@@ -737,8 +737,8 @@ _bfd_generic_link_hash_table_free (struc
    the hash table pointing to different instances of the symbol
    structure.  */
 
-static bfd_boolean
-generic_link_read_symbols (bfd *abfd)
+bfd_boolean
+bfd_generic_link_read_symbols (bfd *abfd)
 {
   if (bfd_get_outsymbols (abfd) == NULL)
     {
@@ -834,7 +834,7 @@ generic_link_add_object_symbols (bfd *ab
   bfd_size_type symcount;
   struct bfd_symbol **outsyms;
 
-  if (! generic_link_read_symbols (abfd))
+  if (!bfd_generic_link_read_symbols (abfd))
     return FALSE;
   symcount = _bfd_generic_link_get_symcount (abfd);
   outsyms = _bfd_generic_link_get_symbols (abfd);
@@ -1164,7 +1164,7 @@ generic_link_check_archive_element (bfd 
 
   *pneeded = FALSE;
 
-  if (! generic_link_read_symbols (abfd))
+  if (!bfd_generic_link_read_symbols (abfd))
     return FALSE;
 
   pp = _bfd_generic_link_get_symbols (abfd);
@@ -2159,7 +2159,7 @@ _bfd_generic_link_output_symbols (bfd *o
   asymbol **sym_ptr;
   asymbol **sym_end;
 
-  if (! generic_link_read_symbols (input_bfd))
+  if (!bfd_generic_link_read_symbols (input_bfd))
     return FALSE;
 
   /* Create a filename symbol if we are supposed to.  */
@@ -2752,7 +2752,7 @@ default_indirect_link_order (bfd *output
 	 have retrieved them by this point, but we are being called by
 	 a specific linker, presumably because we are linking
 	 different types of object files together.  */
-      if (! generic_link_read_symbols (input_bfd))
+      if (!bfd_generic_link_read_symbols (input_bfd))
 	return FALSE;
 
       /* Since we have been called by a specific linker, rather than
Index: include/bfdlink.h
===================================================================
RCS file: /cvs/src/src/include/bfdlink.h,v
retrieving revision 1.74
diff -u -p -r1.74 bfdlink.h
--- include/bfdlink.h	12 Jul 2008 08:54:12 -0000	1.74
+++ include/bfdlink.h	16 Aug 2008 10:56:08 -0000
@@ -198,6 +198,9 @@ extern void bfd_link_add_undef
 extern void bfd_link_repair_undef_list
   (struct bfd_link_hash_table *table);
 
+/* Read symbols and cache symbol pointer array in outsymbols.  */
+extern bfd_boolean bfd_generic_link_read_symbols (bfd *);
+
 struct bfd_sym_chain
 {
   struct bfd_sym_chain *next;
Index: ld/ldcref.c
===================================================================
RCS file: /cvs/src/src/ld/ldcref.c,v
retrieving revision 1.21
diff -u -p -r1.21 ldcref.c
--- ld/ldcref.c	15 Feb 2008 03:35:53 -0000	1.21
+++ ld/ldcref.c	16 Aug 2008 10:56:10 -0000
@@ -478,36 +478,16 @@ static void
 check_local_sym_xref (lang_input_statement_type *statement)
 {
   bfd *abfd;
-  lang_input_statement_type *li;
-  asymbol **asymbols, **syms;
+  asymbol **syms;
 
   abfd = statement->the_bfd;
   if (abfd == NULL)
     return;
 
-  li = abfd->usrdata;
-  if (li != NULL && li->asymbols != NULL)
-    asymbols = li->asymbols;
-  else
-    {
-      long symsize;
-      long symbol_count;
+  if (!bfd_generic_link_read_symbols (abfd))
+    einfo (_("%B%F: could not read symbols: %E\n"), abfd);
 
-      symsize = bfd_get_symtab_upper_bound (abfd);
-      if (symsize < 0)
-	einfo (_("%B%F: could not read symbols; %E\n"), abfd);
-      asymbols = xmalloc (symsize);
-      symbol_count = bfd_canonicalize_symtab (abfd, asymbols);
-      if (symbol_count < 0)
-	einfo (_("%B%F: could not read symbols: %E\n"), abfd);
-      if (li != NULL)
-	{
-	  li->asymbols = asymbols;
-	  li->symbol_count = symbol_count;
-	}
-    }
-
-  for (syms = asymbols; *syms; ++syms)
+  for (syms = bfd_get_outsymbols (abfd); *syms; ++syms)
     {
       asymbol *sym = *syms;
       if (sym->flags & (BSF_GLOBAL | BSF_WARNING | BSF_INDIRECT | BSF_FILE))
@@ -529,9 +509,6 @@ check_local_sym_xref (lang_input_stateme
 		check_refs (symname, FALSE, sym->section, abfd, ncrs);
 	}
     }
-
-  if (li == NULL)
-    free (asymbols);
 }
 
 /* Check one symbol to see if it is a prohibited cross reference.  */
@@ -597,8 +574,6 @@ check_refs (const char *name,
 	    bfd *abfd,
 	    struct lang_nocrossrefs *ncrs)
 {
-  lang_input_statement_type *li;
-  asymbol **asymbols;
   struct check_refs_info info;
 
   /* We need to look through the relocations for this BFD, to see
@@ -607,37 +582,15 @@ check_refs (const char *name,
      the BFD in which the symbol is defined, since even a single
      BFD might contain a prohibited cross reference.  */
 
-  li = abfd->usrdata;
-  if (li != NULL && li->asymbols != NULL)
-    asymbols = li->asymbols;
-  else
-    {
-      long symsize;
-      long symbol_count;
-
-      symsize = bfd_get_symtab_upper_bound (abfd);
-      if (symsize < 0)
-	einfo (_("%B%F: could not read symbols; %E\n"), abfd);
-      asymbols = xmalloc (symsize);
-      symbol_count = bfd_canonicalize_symtab (abfd, asymbols);
-      if (symbol_count < 0)
-	einfo (_("%B%F: could not read symbols: %E\n"), abfd);
-      if (li != NULL)
-	{
-	  li->asymbols = asymbols;
-	  li->symbol_count = symbol_count;
-	}
-    }
+  if (!bfd_generic_link_read_symbols (abfd))
+    einfo (_("%B%F: could not read symbols: %E\n"), abfd);
 
   info.sym_name = name;
   info.global = global;
   info.defsec = sec;
   info.ncrs = ncrs;
-  info.asymbols = asymbols;
+  info.asymbols = bfd_get_outsymbols (abfd);
   bfd_map_over_sections (abfd, check_reloc_refs, &info);
-
-  if (li == NULL)
-    free (asymbols);
 }
 
 /* This is called via bfd_map_over_sections.  INFO->SYM_NAME is a symbol
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.289
diff -u -p -r1.289 ldlang.c
--- ld/ldlang.c	12 Jun 2008 11:27:38 -0000	1.289
+++ ld/ldlang.c	16 Aug 2008 10:56:14 -0000
@@ -1033,10 +1033,8 @@ new_afile (const char *name,
       FAIL ();
     }
   p->the_bfd = NULL;
-  p->asymbols = NULL;
   p->next_real_file = NULL;
   p->next = NULL;
-  p->symbol_count = 0;
   p->dynamic = config.dynamic_link;
   p->add_needed = add_needed;
   p->as_needed = as_needed;
Index: ld/ldlang.h
===================================================================
RCS file: /cvs/src/src/ld/ldlang.h,v
retrieving revision 1.77
diff -u -p -r1.77 ldlang.h
--- ld/ldlang.h	25 Jan 2008 12:03:37 -0000	1.77
+++ ld/ldlang.h	16 Aug 2008 10:56:14 -0000
@@ -232,12 +232,6 @@ typedef struct lang_input_statement_stru
 
   bfd *the_bfd;
 
-  file_ptr passive_position;
-
-  /* Symbol table of the file.  */
-  asymbol **asymbols;
-  unsigned int symbol_count;
-
   /* Point to the next file - whatever it is, wanders up and down
      archives */
   union lang_statement_union *next;
@@ -247,7 +241,6 @@ typedef struct lang_input_statement_stru
 
   const char *target;
 
-  unsigned int closed : 1;
   unsigned int is_archive : 1;
 
   /* 1 means search a set of directories for this file.  */
Index: ld/ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.132
diff -u -p -r1.132 ldmain.c
--- ld/ldmain.c	9 Aug 2008 10:15:38 -0000	1.132
+++ ld/ldmain.c	16 Aug 2008 10:56:15 -0000
@@ -778,21 +778,10 @@ add_archive_element (struct bfd_link_inf
 {
   lang_input_statement_type *input;
 
-  input = xmalloc (sizeof (lang_input_statement_type));
+  input = xcalloc (1, sizeof (lang_input_statement_type));
   input->filename = abfd->filename;
   input->local_sym_name = abfd->filename;
   input->the_bfd = abfd;
-  input->asymbols = NULL;
-  input->next = NULL;
-  input->just_syms_flag = FALSE;
-  input->loaded = FALSE;
-  input->search_dirs_flag = FALSE;
-
-  /* FIXME: The following fields are not set: header.next,
-     header.type, closed, passive_position, symbol_count,
-     next_real_file, is_archive, target, real.  This bit of code is
-     from the old decode_library_subfile function.  I don't know
-     whether any of those fields matters.  */
 
   ldlang_add_file (input);
 
@@ -1107,45 +1096,22 @@ warning_callback (struct bfd_link_info *
     einfo ("%B: %s%s\n", abfd, _("warning: "), warning);
   else
     {
-      lang_input_statement_type *entry;
-      asymbol **asymbols;
       struct warning_callback_info info;
 
       /* Look through the relocs to see if we can find a plausible
 	 address.  */
-      entry = (lang_input_statement_type *) abfd->usrdata;
-      if (entry != NULL && entry->asymbols != NULL)
-	asymbols = entry->asymbols;
-      else
-	{
-	  long symsize;
-	  long symbol_count;
 
-	  symsize = bfd_get_symtab_upper_bound (abfd);
-	  if (symsize < 0)
-	    einfo (_("%B%F: could not read symbols: %E\n"), abfd);
-	  asymbols = xmalloc (symsize);
-	  symbol_count = bfd_canonicalize_symtab (abfd, asymbols);
-	  if (symbol_count < 0)
-	    einfo (_("%B%F: could not read symbols: %E\n"), abfd);
-	  if (entry != NULL)
-	    {
-	      entry->asymbols = asymbols;
-	      entry->symbol_count = symbol_count;
-	    }
-	}
+      if (!bfd_generic_link_read_symbols (abfd))
+	einfo (_("%B%F: could not read symbols: %E\n"), abfd);
 
       info.found = FALSE;
       info.warning = warning;
       info.symbol = symbol;
-      info.asymbols = asymbols;
+      info.asymbols = bfd_get_outsymbols (abfd);
       bfd_map_over_sections (abfd, warning_find_reloc, &info);
 
       if (! info.found)
 	einfo ("%B: %s%s\n", abfd, _("warning: "), warning);
-
-      if (entry == NULL)
-	free (asymbols);
     }
 
   return TRUE;
Index: ld/ldmisc.c
===================================================================
RCS file: /cvs/src/src/ld/ldmisc.c,v
retrieving revision 1.35
diff -u -p -r1.35 ldmisc.c
--- ld/ldmisc.c	15 Feb 2008 03:35:53 -0000	1.35
+++ ld/ldmisc.c	16 Aug 2008 10:56:15 -0000
@@ -269,8 +269,7 @@ vfinfo (FILE *fp, const char *fmt, va_li
 		bfd *abfd;
 		asection *section;
 		bfd_vma offset;
-		lang_input_statement_type *entry;
-		asymbol **asymbols;
+		asymbol **asymbols = NULL;
 		const char *filename;
 		const char *functionname;
 		unsigned int linenumber;
@@ -280,35 +279,12 @@ vfinfo (FILE *fp, const char *fmt, va_li
 		section = va_arg (arg, asection *);
 		offset = va_arg (arg, bfd_vma);
 
-		if (abfd == NULL)
+		if (abfd != NULL)
 		  {
-		    entry = NULL;
-		    asymbols = NULL;
-		  }
-		else
-		  {
-		    entry = (lang_input_statement_type *) abfd->usrdata;
-		    if (entry != (lang_input_statement_type *) NULL
-			&& entry->asymbols != (asymbol **) NULL)
-		      asymbols = entry->asymbols;
-		    else
-		      {
-			long symsize;
-			long sym_count;
+		    if (!bfd_generic_link_read_symbols (abfd))
+		      einfo (_("%B%F: could not read symbols: %E\n"), abfd);
 
-			symsize = bfd_get_symtab_upper_bound (abfd);
-			if (symsize < 0)
-			  einfo (_("%B%F: could not read symbols\n"), abfd);
-			asymbols = xmalloc (symsize);
-			sym_count = bfd_canonicalize_symtab (abfd, asymbols);
-			if (sym_count < 0)
-			  einfo (_("%B%F: could not read symbols\n"), abfd);
-			if (entry != (lang_input_statement_type *) NULL)
-			  {
-			    entry->asymbols = asymbols;
-			    entry->symbol_count = sym_count;
-			  }
-		      }
+		    asymbols = bfd_get_outsymbols (abfd);
 		  }
 
 		/* The GNU Coding Standard requires that error messages
@@ -375,9 +351,6 @@ vfinfo (FILE *fp, const char *fmt, va_li
 		else
 		  lfinfo (fp, "%B:(%A+0x%v)", abfd, section, offset);
 
-		if (asymbols != NULL && entry == NULL)
-		  free (asymbols);
-
 		if (discard_last)
 		  {
 		    last_bfd = NULL;
Index: ld/pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.107
diff -u -p -r1.107 pe-dll.c
--- ld/pe-dll.c	31 Jul 2008 07:27:52 -0000	1.107
+++ ld/pe-dll.c	16 Aug 2008 10:56:16 -0000
@@ -615,11 +615,16 @@ process_def_file (bfd *abfd ATTRIBUTE_UN
       for (b = info->input_bfds; b; b = b->link_next)
 	{
 	  asymbol **symbols;
-	  int nsyms, symsize;
+	  int nsyms;
 
-	  symsize = bfd_get_symtab_upper_bound (b);
-	  symbols = xmalloc (symsize);
-	  nsyms = bfd_canonicalize_symtab (b, symbols);
+	  if (!bfd_generic_link_read_symbols (b))
+	    {
+	      einfo (_("%B%F: could not read symbols: %E\n"), b);
+	      return;
+	    }
+
+	  symbols = bfd_get_outsymbols (b);
+	  nsyms = bfd_get_symcount (b);
 
 	  for (j = 0; j < nsyms; j++)
 	    {
@@ -1141,11 +1146,16 @@ pe_walk_relocs_of_symbol (struct bfd_lin
   for (b = info->input_bfds; b; b = b->link_next)
     {
       asymbol **symbols;
-      int nsyms, symsize;
+      int nsyms;
 
-      symsize = bfd_get_symtab_upper_bound (b);
-      symbols = xmalloc (symsize);
-      nsyms   = bfd_canonicalize_symtab (b, symbols);
+      if (!bfd_generic_link_read_symbols (b))
+	{
+	  einfo (_("%B%F: could not read symbols: %E\n"), b);
+	  return;
+	}
+
+      symbols = bfd_get_outsymbols (b);
+      nsyms = bfd_get_symcount (b);
 
       for (s = b->sections; s; s = s->next)
 	{
@@ -1215,7 +1225,7 @@ generate_reloc (bfd *abfd, struct bfd_li
 	{
 	  bfd_vma sec_vma = s->output_section->vma + s->output_offset;
 	  asymbol **symbols;
-	  int nsyms, symsize;
+	  int nsyms;
 
 	  /* If it's not loaded, we don't need to relocate it this way.  */
 	  if (!(s->output_section->flags & SEC_LOAD))
@@ -1235,10 +1245,14 @@ generate_reloc (bfd *abfd, struct bfd_li
 	      continue;
 	    }
 
-	  symsize = bfd_get_symtab_upper_bound (b);
-	  symbols = xmalloc (symsize);
-	  nsyms = bfd_canonicalize_symtab (b, symbols);
+	  if (!bfd_generic_link_read_symbols (b))
+	    {
+	      einfo (_("%B%F: could not read symbols: %E\n"), b);
+	      return;
+	    }
 
+	  symbols = bfd_get_outsymbols (b);
+	  nsyms = bfd_get_symcount (b);
 	  relsize = bfd_get_reloc_upper_bound (b, s);
 	  relocs = xmalloc (relsize);
 	  nrelocs = bfd_canonicalize_reloc (b, s, relocs, symbols);
Index: ld/emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.132
diff -u -p -r1.132 pe.em
--- ld/emultempl/pe.em	30 Jul 2008 04:34:57 -0000	1.132
+++ ld/emultempl/pe.em	16 Aug 2008 10:56:17 -0000
@@ -922,7 +922,7 @@ pe_find_data_imports (void)
 	    {
 	      bfd *b = sym->u.def.section->owner;
 	      asymbol **symbols;
-	      int nsyms, symsize, i;
+	      int nsyms, i;
 
 	      if (link_info.pei386_auto_import == -1)
 		{
@@ -940,9 +940,14 @@ This should work unless it involves cons
 		    }
 		}
 
-	      symsize = bfd_get_symtab_upper_bound (b);
-	      symbols = (asymbol **) xmalloc (symsize);
-	      nsyms = bfd_canonicalize_symtab (b, symbols);
+	      if (!bfd_generic_link_read_symbols (b))
+		{
+		  einfo (_("%B%F: could not read symbols: %E\n"), b);
+		  return;
+		}
+
+	      symbols = bfd_get_outsymbols (b);
+	      nsyms = bfd_get_symcount (b);
 
 	      for (i = 0; i < nsyms; i++)
 		{
@@ -1094,26 +1099,22 @@ gld_${EMULATION_NAME}_after_open (void)
 		for (sec = is->the_bfd->sections; sec; sec = sec->next)
 		  {
 		    int i;
-		    long symsize;
 		    long relsize;
 		    asymbol **symbols;
 		    arelent **relocs;
 		    int nrelocs;
 
-		    symsize = bfd_get_symtab_upper_bound (is->the_bfd);
-		    if (symsize < 1)
-		      break;
 		    relsize = bfd_get_reloc_upper_bound (is->the_bfd, sec);
 		    if (relsize < 1)
 		      break;
 
-		    symbols = (asymbol **) xmalloc (symsize);
-		    symsize = bfd_canonicalize_symtab (is->the_bfd, symbols);
-		    if (symsize < 0)
+		    if (!bfd_generic_link_read_symbols (is->the_bfd))
 		      {
-			einfo ("%X%P: unable to process symbols: %E");
+			einfo (_("%B%F: could not read symbols: %E\n"),
+			       is->the_bfd);
 			return;
 		      }
+		    symbols = bfd_get_outsymbols (is->the_bfd);
 
 		    relocs = (arelent **) xmalloc ((size_t) relsize);
 		    nrelocs = bfd_canonicalize_reloc (is->the_bfd, sec,
@@ -1309,16 +1310,20 @@ gld_${EMULATION_NAME}_after_open (void)
 
 	    if (is_imp && stub_sec)
 	      {
-		long symsize;
 		asymbol **symbols;
-		long src_count;
+		long nsyms, src_count;
 		struct bfd_link_hash_entry * blhe;
 
-		symsize = bfd_get_symtab_upper_bound (is->the_bfd);
-		symbols = xmalloc (symsize);
-		symsize = bfd_canonicalize_symtab (is->the_bfd, symbols);
+		if (!bfd_generic_link_read_symbols (is->the_bfd))
+		  {
+		    einfo (_("%B%F: could not read symbols: %E\n"),
+			   is->the_bfd);
+		    return;
+		  }
+		symbols = bfd_get_outsymbols (is->the_bfd);
+		nsyms = bfd_get_symcount (is->the_bfd);
 
-		for (src_count = 0; src_count < symsize; src_count++)
+		for (src_count = 0; src_count < nsyms; src_count++)
 		  {
 		    if (symbols[src_count]->section->id == stub_sec->id)
 		      {
@@ -1335,7 +1340,6 @@ gld_${EMULATION_NAME}_after_open (void)
 			  stub_sec->flags |= SEC_EXCLUDE;
 		      }
 		  }
-		free (symbols);
 	      }
 	  }
       }
Index: ld/emultempl/pep.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pep.em,v
retrieving revision 1.11
diff -u -p -r1.11 pep.em
--- ld/emultempl/pep.em	30 Jul 2008 04:34:57 -0000	1.11
+++ ld/emultempl/pep.em	16 Aug 2008 10:56:19 -0000
@@ -881,7 +881,7 @@ pep_find_data_imports (void)
 	    {
 	      bfd *b = sym->u.def.section->owner;
 	      asymbol **symbols;
-	      int nsyms, symsize, i;
+	      int nsyms, i;
 
 	      if (link_info.pei386_auto_import == -1)
 		{
@@ -899,9 +899,14 @@ This should work unless it involves cons
 		    }
 		}
 
-	      symsize = bfd_get_symtab_upper_bound (b);
-	      symbols = xmalloc (symsize);
-	      nsyms = bfd_canonicalize_symtab (b, symbols);
+	      if (!bfd_generic_link_read_symbols (b))
+		{
+		  einfo (_("%B%F: could not read symbols: %E\n"), b);
+		  return;
+		}
+
+	      symbols = bfd_get_outsymbols (b);
+	      nsyms = bfd_get_symcount (b);
 
 	      for (i = 0; i < nsyms; i++)
 		{
@@ -1032,26 +1037,22 @@ gld_${EMULATION_NAME}_after_open (void)
 		for (sec = is->the_bfd->sections; sec; sec = sec->next)
 		  {
 		    int i;
-		    long symsize;
 		    long relsize;
 		    asymbol **symbols;
 		    arelent **relocs;
 		    int nrelocs;
 
-		    symsize = bfd_get_symtab_upper_bound (is->the_bfd);
-		    if (symsize < 1)
-		      break;
 		    relsize = bfd_get_reloc_upper_bound (is->the_bfd, sec);
 		    if (relsize < 1)
 		      break;
 
-		    symbols = xmalloc (symsize);
-		    symsize = bfd_canonicalize_symtab (is->the_bfd, symbols);
-		    if (symsize < 0)
+		    if (!bfd_generic_link_read_symbols (is->the_bfd))
 		      {
-			einfo ("%X%P: unable to process symbols: %E");
+			einfo (_("%B%F: could not read symbols: %E\n"),
+			       is->the_bfd);
 			return;
 		      }
+		    symbols = bfd_get_outsymbols (is->the_bfd);
 
 		    relocs = xmalloc ((size_t) relsize);
 		    nrelocs = bfd_canonicalize_reloc (is->the_bfd, sec,

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]