bugs with binutils-2.11, target m68k-elf

amodra@one.net.au amodra@one.net.au
Tue May 22 01:56:00 GMT 2001


On Mon, May 21, 2001 at 08:25:16PM +0930, Alan Modra wrote:
> Some problems remain...
> 

This is the first and easiest change in the process of fixing these
problems.  We make tc_fix_adjustable agree with
md_estimate_size_before_relax so that anything that might be global
has the appropriate instruction size.  I also took the liberty of
changing the treatment of weak syms.  Previously, branches to a weak
sym on an embedded system (target m68k-*-elf) were treated as
relaxable, which means they couldn't safely have relocs and thus
destroys the usefulness of weak syms.

	* config/tc-m68k.c (relaxable_symbol): Only treat external symbols
	as relaxable if embedded system, make weak syms non-relaxable.
	Move definition..
	(tc_m68k_fix_adjustable): ..so it can be used here.
	(md_apply_fix_2): Sign extend without conditional.

Applying to mainline, branch a bit later after more people have had
a chance to break it.

-- 
Alan Modra

Index: gas/config/tc-m68k.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-m68k.c,v
retrieving revision 1.21
diff -u -p -r1.21 tc-m68k.c
--- tc-m68k.c	2001/05/08 18:03:27	1.21
+++ tc-m68k.c	2001/05/22 03:57:53
@@ -714,6 +714,19 @@ tc_coff_fix2rtype (fixP)
 
 #ifdef OBJ_ELF
 
+/* Return zero if the reference to SYMBOL from within the same segment may
+   be relaxed.  */
+
+/* On an ELF system, we can't relax an externally visible symbol,
+   because it may be overridden by a shared library.  However, if
+   TARGET_OS is "elf", then we presume that we are assembling for an
+   embedded system, in which case we don't have to worry about shared
+   libraries, and we can relax any external sym.  */
+
+#define relaxable_symbol(symbol) \
+  (!((S_IS_EXTERNAL (symbol) && strcmp (TARGET_OS, "elf") != 0)		\
+     || S_IS_WEAK (symbol)))
+
 /* Compute the relocation code for a fixup of SIZE bytes, using pc
    relative relocation if PCREL is non-zero.  PIC says whether a special
    pic relocation was requested.  */
@@ -832,8 +845,7 @@ tc_m68k_fix_adjustable (fixP)
      fixS *fixP;
 {
   /* Prevent all adjustments to global symbols.  */
-  if (S_IS_EXTERNAL (fixP->fx_addsy)
-      || S_IS_WEAK (fixP->fx_addsy))
+  if (! relaxable_symbol (fixP->fx_addsy))
     return 0;
 
   /* adjust_reloc_syms doesn't know about the GOT */
@@ -866,6 +878,8 @@ tc_m68k_fix_adjustable (fixP)
 
 #define get_reloc_code(SIZE,PCREL,OTHER) NO_RELOC
 
+#define relaxable_symbol(symbol) 1
+
 #endif /* OBJ_ELF */
 
 #ifdef BFD_ASSEMBLER
@@ -983,27 +997,6 @@ tc_gen_reloc (section, fixp)
 
 #endif /* BFD_ASSEMBLER */
 
-/* Return zero if the reference to SYMBOL from within the same segment may
-   be relaxed.  */
-#ifdef OBJ_ELF
-
-/* On an ELF system, we can't relax an externally visible symbol,
-   because it may be overridden by a shared library.  However, if
-   TARGET_OS is "elf", then we presume that we are assembling for an
-   embedded system, in which case we don't have to worry about shared
-   libraries, and we can relax anything.  */
-
-#define relaxable_symbol(symbol)		\
-  (strcmp (TARGET_OS, "elf") == 0		\
-   || (! S_IS_EXTERNAL (symbol)			\
-       && ! S_IS_WEAK (symbol)))
-
-#else
-
-#define relaxable_symbol(symbol) 1
-
-#endif
-
 /* Handle of the OPCODE hash table.  NULL means any use before
    m68k_ip_begin() will crash.  */
 static struct hash_control *op_hash;
@@ -4226,10 +4219,7 @@ md_apply_fix_2 (fixP, val)
   buf += fixP->fx_where;
   /* end ibm compiler workaround */
 
-  if (val & 0x80000000)
-    val |= ~(addressT)0x7fffffff;
-  else
-    val &= 0x7fffffff;
+  val = ((val & 0xffffffff) ^ 0x80000000) - 0x80000000;
 
 #ifdef OBJ_ELF
   if (fixP->fx_addsy)



More information about the Binutils mailing list