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 6848 fix


This causes gas to emit a more useful error message for the PR 6848
test case.

	PR 6848
	* write.c (install_reloc): Check that reloc symbols have been
	written.
	(set_symtab): Mark symbols with BSF_KEEP.

Index: gas/write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.117
diff -u -p -r1.117 write.c
--- gas/write.c	30 Jul 2008 04:34:57 -0000	1.117
+++ gas/write.c	20 Aug 2008 13:40:50 -0000
@@ -1084,6 +1084,15 @@ install_reloc (asection *sec, arelent *r
 {
   char *err;
   bfd_reloc_status_type s;
+  asymbol *sym;
+
+  if (reloc->sym_ptr_ptr != NULL
+      && (sym = *reloc->sym_ptr_ptr) != NULL
+      && (sym->flags & BSF_KEEP) == 0
+      && ((sym->flags & BSF_SECTION_SYM) == 0
+	  || !EMIT_SECTION_SYMBOLS
+	  || !bfd_is_abs_section (sym->section)))
+    as_bad_where (file, line, _("redefined symbol cannot be used on reloc"));
 
   s = bfd_install_relocation (stdoutput, reloc,
 			      fragp->fr_literal, fragp->fr_address,
@@ -1377,6 +1386,10 @@ set_symtab (void)
       for (i = 0; i < nsyms; i++, symp = symbol_next (symp))
 	{
 	  asympp[i] = symbol_get_bfdsym (symp);
+	  if (asympp[i]->flags != BSF_SECTION_SYM
+	      || !(bfd_is_const_section (asympp[i]->section)
+		   && asympp[i]->section->symbol == asympp[i]))
+	    asympp[i]->flags |= BSF_KEEP;
 	  symbol_mark_written (symp);
 	}
     }

-- 
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]