PR 6848
authorAlan Modra <amodra@gmail.com>
Wed, 20 Aug 2008 13:43:32 +0000 (13:43 +0000)
committerAlan Modra <amodra@gmail.com>
Wed, 20 Aug 2008 13:43:32 +0000 (13:43 +0000)
* write.c (install_reloc): Check that reloc symbols have been
written.
(set_symtab): Mark symbols with BSF_KEEP.

gas/ChangeLog
gas/write.c

index 8ba707f66cb58c9ade08ec3f7506fb8a319a66eb..0b2468ee19bd0b0cedd4b8b534669f145c65672e 100644 (file)
@@ -1,3 +1,10 @@
+2008-08-20  Alan Modra  <amodra@bigpond.net.au>
+
+       PR 6848
+       * write.c (install_reloc): Check that reloc symbols have been
+       written.
+       (set_symtab): Mark symbols with BSF_KEEP.
+
 2008-08-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        * config/tc-i386.c (i386_align_code): Fix a comment typo.
index 660df811b668dd957ed20091f58a1da9d57c4980..55c757d3562ff844bbd13c0ee1e972a7681a6d4f 100644 (file)
@@ -1084,6 +1084,15 @@ install_reloc (asection *sec, arelent *reloc, fragS *fragp,
 {
   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);
        }
     }