This is the mail archive of the binutils@sources.redhat.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 fix extern/weak symbols for mips/ELF


I checked in the following patch to fix the extern/weak symbols for
mips/ELF.


H.J.
---
2001-06-08  H.J. Lu  <hjl@gnu.org>

	* config/tc-mips.c (md_apply_fix): Don't adjust common
	extern/weak symbols for ELF.
	(md_estimate_size_before_relax): Treat weak like extern for
	ELF.
	(mips_fix_adjustable): Don't adjust extern/weak symbols for
	ELF.

--- gas/config/tc-mips.c.elf	Thu Jun  7 23:53:33 2001
+++ gas/config/tc-mips.c	Thu Jun  7 23:55:17 2001
@@ -9705,7 +9705,9 @@ md_apply_fix (fixP, valueP)
   if (fixP->fx_addsy != NULL && OUTPUT_FLAVOR == bfd_target_elf_flavour)
     {
       if (S_GET_OTHER (fixP->fx_addsy) == STO_MIPS16
-	  || S_IS_WEAK (fixP->fx_addsy)
+	  || ((S_IS_WEAK (fixP->fx_addsy)
+	       || S_IS_EXTERN (fixP->fx_addsy))
+	      && !S_IS_COMMON (fixP->fx_addsy))
 	  || (symbol_used_in_reloc_p (fixP->fx_addsy)
 	      && (((bfd_get_section_flags (stdoutput,
 					   S_GET_SEGMENT (fixP->fx_addsy))
@@ -11204,8 +11206,8 @@ md_estimate_size_before_relax (fragp, se
 		&& ! bfd_is_com_section (symsec)
 		&& !linkonce
 #ifdef OBJ_ELF
-		/* A weak symbol is treated as external.  */
-		&& ! S_IS_WEAK (sym)
+		/* A global or weak symbol is treated as external.  */
+		&& ! (S_IS_EXTERN (sym) || S_IS_WEAK (sym))
 #endif
 		);
     }
@@ -11243,6 +11245,11 @@ int
 mips_fix_adjustable (fixp)
      fixS *fixp;
 {
+#ifdef OBJ_ELF
+  /* Prevent all adjustments to global symbols.  */
+  if (S_IS_EXTERN (fixp->fx_addsy) || S_IS_WEAK (fixp->fx_addsy))
+    return 0;
+#endif
   if (fixp->fx_r_type == BFD_RELOC_MIPS16_JMP)
     return 0;
   if (fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT

2001-06-08  H.J. Lu  <hjl@gnu.org>

	* gas/mips/elf-jal.d: New file.

	* gas/mips/mips.exp: Run "elf-jal" instead of
	"jal" for ELF.

Index: testsuite/gas/mips/mips.exp
===================================================================
RCS file: /work/cvs/gnu/binutils/gas/testsuite/gas/mips/mips.exp,v
retrieving revision 1.1.1.8
diff -u -p -r1.1.1.8 mips.exp
--- gas/testsuite/gas/mips/mips.exp	2001/05/25 19:07:01	1.1.1.8
+++ gas/testsuite/gas/mips/mips.exp	2001/06/06 15:52:59
@@ -28,7 +28,11 @@ if { [istarget mips*-*-*] } then {
     run_dump_test "bltu"
     if !$ilocks { run_dump_test "div" } else { run_dump_test "div-ilocks" }
     run_dump_test "dli"
-    run_dump_test "jal"
+    if $svr4pic {
+	run_dump_test "elf-jal"
+    } else {
+	run_dump_test "jal"
+    }
     if $svr4pic { run_dump_test "jal-svr4pic" }
     if $svr4pic { run_dump_test "jal-xgot" }
     if $empic { run_dump_test "jal-empic" }
--- /dev/null	Fri Mar 23 20:37:44 2001
+++ gas/testsuite/gas/mips/elf-jal.d	Wed Jun  6 08:52:59 2001
@@ -0,0 +1,25 @@
+#objdump: -dr --prefix-addresses -mmips:4000
+#name: MIPS jal
+#source: jal.s
+
+# Test the jal macro.
+
+.*: +file format .*mips.*
+
+Disassembly of section .text:
+0+0000 <[^>]*> jalr	t9
+0+0004 <[^>]*> nop
+0+0008 <[^>]*> jalr	a0,t9
+0+000c <[^>]*> nop
+0+0010 <[^>]*> jal	0+ <text_label>
+[ 	]*10: (MIPS_JMP|MIPS_JMP|JMPADDR|R_MIPS_26)	text_label
+0+0014 <[^>]*> nop
+0+0018 <[^>]*> jal	0+ <text_label>
+[ 	]*18: (MIPS_JMP|JMPADDR|R_MIPS_26)	external_text_label
+0+001c <[^>]*> nop
+0+0020 <[^>]*> j	0+ <text_label>
+[ 	]*20: (MIPS_JMP|JMPADDR|R_MIPS_26)	text_label
+0+0024 <[^>]*> nop
+0+0028 <[^>]*> j	0+ <text_label>
+[ 	]*28: (MIPS_JMP|JMPADDR|R_MIPS_26)	external_text_label
+0+002c <[^>]*> nop


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