This is the mail archive of the binutils@sourceware.cygnus.com 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]

patch to write.c



For the next step in the picoJava port, the linker sometimes has to do
some relaxing (to fix up some incompatible calling
conventions). Because of this, the assembler must leave some negative
relocations unresolved in the output (the jumptable instruction
contains pc relative displacements to locations within itself, and the
table can change size depending upon its alignment, which depends upon
how much relaxing has gone on before it).

This patch to write.c makes sure that all the relocations with
fx_subsys attached get marked so that there's no abort during
write_relocs.

The only other target which uses UNDEFINED_DIFFERENCE_OK is hppa.

1999-09-22  Steve Chamberlain  <sac@pobox.com>

	* write.c (adjust_reloc_syms): Change calls to symbol_mark_used_in_reloc
	into reloc_mark_symbols_used_in_reloc.
	(reloc_mark_symbols_used_in_reloc): New function.

Index: write.c
===================================================================
RCS file: /cvs/binutils/binutils/gas/write.c,v
retrieving revision 1.11
diff -u -p -r1.11 write.c
--- write.c	1999/09/12 03:44:41	1.11
+++ write.c	1999/09/22 16:28:22
@@ -681,6 +681,17 @@ dump_section_relocs (abfd, sec, stream_)
 #define EMIT_SECTION_SYMBOLS 1
 #endif
 
+static inline void 
+reloc_mark_symbols_used_in_reloc (fixp)
+     fixS *fixp;
+{
+  symbol_mark_used_in_reloc (fixp->fx_addsy);
+#ifdef UNDEFINED_DIFFERENCE_OK
+  if (fixp->fx_subsy != NULL)
+    symbol_mark_used_in_reloc (fixp->fx_subsy);
+#endif
+}
+
 static void
 adjust_reloc_syms (abfd, sec, xxx)
      bfd *abfd ATTRIBUTE_UNUSED;
@@ -747,11 +758,7 @@ adjust_reloc_syms (abfd, sec, xxx)
                relocation unless TC_FORCE_RELOCATION returns 1.  */
 	    if (TC_FORCE_RELOCATION (fixp))
 	      {
-		symbol_mark_used_in_reloc (fixp->fx_addsy);
-#ifdef UNDEFINED_DIFFERENCE_OK
-		if (fixp->fx_subsy != NULL)
-		  symbol_mark_used_in_reloc (fixp->fx_subsy);
-#endif
+		reloc_mark_symbols_used_in_reloc (fixp);
 	      }
 	    goto done;
 	  }
@@ -764,14 +771,7 @@ adjust_reloc_syms (abfd, sec, xxx)
 	if (bfd_is_und_section (symsec)
 	    || bfd_is_com_section (symsec))
 	  {
-	    symbol_mark_used_in_reloc (fixp->fx_addsy);
-#ifdef UNDEFINED_DIFFERENCE_OK
-	    /* We have the difference of an undefined symbol and some
-	       other symbol.  Make sure to mark the other symbol as used
-	       in a relocation so that it will always be output.  */
-	    if (fixp->fx_subsy)
-	      symbol_mark_used_in_reloc (fixp->fx_subsy);
-#endif
+	    reloc_mark_symbols_used_in_reloc (fixp);
 	    goto done;
 	  }
 
@@ -800,11 +800,7 @@ adjust_reloc_syms (abfd, sec, xxx)
 
 	    if (linkonce)
 	      {
-		symbol_mark_used_in_reloc (fixp->fx_addsy);
-#ifdef UNDEFINED_DIFFERENCE_OK
-		if (fixp->fx_subsy != NULL)
-		  symbol_mark_used_in_reloc (fixp->fx_subsy);
-#endif
+		reloc_mark_symbols_used_in_reloc (fixp);
 		goto done;
 	      }
 	  }
@@ -813,7 +809,7 @@ adjust_reloc_syms (abfd, sec, xxx)
 	   anything that's already using one.  */
 	if (symbol_section_p (sym))
 	  {
-	    symbol_mark_used_in_reloc (fixp->fx_addsy);
+	    reloc_mark_symbols_used_in_reloc (fixp);
 	    goto done;
 	  }
 
@@ -824,7 +820,7 @@ adjust_reloc_syms (abfd, sec, xxx)
            the wrong area of memory.  */
 	if (S_IS_WEAK (sym))
 	  {
-	    symbol_mark_used_in_reloc (fixp->fx_addsy);
+	    reloc_mark_symbols_used_in_reloc (fixp);
 	    goto done;
 	  }
 #endif
@@ -834,7 +830,7 @@ adjust_reloc_syms (abfd, sec, xxx)
 #ifdef obj_fix_adjustable
 	if (! obj_fix_adjustable (fixp))
 	  {
-	    symbol_mark_used_in_reloc (fixp->fx_addsy);
+	    reloc_mark_symbols_used_in_reloc (fixp);
 	    goto done;
 	  }
 #endif
@@ -845,7 +841,7 @@ adjust_reloc_syms (abfd, sec, xxx)
 #ifdef tc_fix_adjustable
 	if (! tc_fix_adjustable (fixp))
 	  {
-	    symbol_mark_used_in_reloc (fixp->fx_addsy);
+	    reloc_mark_symbols_used_in_reloc (fixp);
 	    goto done;
 	  }
 #endif
@@ -859,7 +855,7 @@ adjust_reloc_syms (abfd, sec, xxx)
 	   the section when it calls resolve_symbol_value. */
 	fixp->fx_offset += S_GET_VALUE (sym);
 	fixp->fx_addsy = section_symbol (S_GET_SEGMENT (sym));
-	symbol_mark_used_in_reloc (fixp->fx_addsy);
+	reloc_mark_symbols_used_in_reloc (fixp);
 #ifdef DEBUG5
 	fprintf (stderr, "\nadjusted fixup:\n");
 	print_fixup (fixp);
@@ -2705,7 +2701,7 @@ fixup_segment (fixP, this_segment_type)
 #else
 	      fixP->fx_addsy = section_symbol (absolute_section);
 #endif
-	      symbol_mark_used_in_reloc (fixP->fx_addsy);
+	      reloc_mark_symbols_used_in_reloc (fixP);
 	      ++seg_reloc_count;
 	    }
 	}

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