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]
Other format: [Raw text]

[RFC PATCH] MIPS allow branch to undefined symbol...


I have been hacking around in my boot monitor (MMON) and was not able to build because gas (at least in thebinutils-2_15-branch) currently does not allow branches to undefined symbols or to symbols in other sections.

The attached patch adds a command line option that turns off this behavior. This should be OK, because if there are real problems, the linker complains about it.

Comments (other than it needs to be documented)?

David Daney.
2004-04-20  David Daney  <ddaney@avtrex.com>

	* config/tc-mips.c (mips_allow_branch_to_undefined): New.
	(md_longopts): Add option to set it.
	(md_parse_option): Set it if option passed.
	(mips_validate_fix): Use it.
	(tc_gen_reloc): Use it.


Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.253.4.3
diff -u -r1.253.4.3 tc-mips.c
--- gas/config/tc-mips.c	19 Apr 2004 21:07:44 -0000	1.253.4.3
+++ gas/config/tc-mips.c	20 Apr 2004 22:40:08 -0000
@@ -394,6 +394,10 @@
 
 enum mips_pic_level mips_pic;
 
+/* 1 if we should allow branching to undefined symbols or symbols
+   defined in other sections */
+static int mips_allow_branch_to_undefined = 0;
+
 /* 1 if we should generate 32 bit offsets from the $gp register in
    SVR4_PIC mode.  Currently has no meaning in other modes.  */
 static int mips_big_got = 0;
@@ -10289,10 +10293,12 @@
 #define OPTION_NO_RELAX_BRANCH (OPTION_MISC_BASE + 12)
   {"relax-branch", no_argument, NULL, OPTION_RELAX_BRANCH},
   {"no-relax-branch", no_argument, NULL, OPTION_NO_RELAX_BRANCH},
+#define OPTION_ALLOW_BRANCH_TO_UNDEFINED (OPTION_MISC_BASE + 13)
+  {"allow_branch_to_undefined", no_argument, NULL, OPTION_ALLOW_BRANCH_TO_UNDEFINED},
 
   /* ELF-specific options.  */
 #ifdef OBJ_ELF
-#define OPTION_ELF_BASE    (OPTION_MISC_BASE + 13)
+#define OPTION_ELF_BASE    (OPTION_MISC_BASE + 14)
 #define OPTION_CALL_SHARED (OPTION_ELF_BASE + 0)
   {"KPIC",        no_argument, NULL, OPTION_CALL_SHARED},
   {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
@@ -10515,6 +10521,10 @@
       mips_relax_branch = 0;
       break;
 
+    case OPTION_ALLOW_BRANCH_TO_UNDEFINED:
+      mips_allow_branch_to_undefined = 1;
+      break;
+
 #ifdef OBJ_ELF
       /* When generating ELF code, we permit -KPIC and -call_shared to
 	 select SVR4_PIC, and -non_shared to select no PIC.  This is
@@ -11038,7 +11048,8 @@
      targets, this entire block should go away (and probably the
      whole function).  */
 
-  if (fixP->fx_r_type == BFD_RELOC_16_PCREL_S2
+  if (!mips_allow_branch_to_undefined
+      && fixP->fx_r_type == BFD_RELOC_16_PCREL_S2
       && (((OUTPUT_FLAVOR == bfd_target_ecoff_flavour
 	    || OUTPUT_FLAVOR == bfd_target_elf_flavour)
 	   && mips_pic != EMBEDDED_PIC)
@@ -13151,7 +13162,8 @@
   if ((OUTPUT_FLAVOR == bfd_target_ecoff_flavour
        || OUTPUT_FLAVOR == bfd_target_elf_flavour)
       && code == BFD_RELOC_16_PCREL_S2
-      && mips_pic != EMBEDDED_PIC)
+      && mips_pic != EMBEDDED_PIC
+      && !mips_allow_branch_to_undefined)
     reloc->howto = NULL;
   else
     reloc->howto = bfd_reloc_type_lookup (stdoutput, code);

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