[PATCH, almost obvious] fix bogus ELF check in tc-mips.c

cgd@broadcom.com cgd@broadcom.com
Thu Feb 14 23:26:00 GMT 2002


Hi H.J.,

While looking for a fix for my embedded-PIC branch problems which Eric
and I can be happy with, i noticed a problem with your patch in:

	http://sources.redhat.com/ml/binutils/2001-07/msg00477.html

(The patch in which you added the ELF object format checks that I had
pointed out were missing.)  Anyway, in the first hunk, you did:

 #ifdef OBJ_ELF
                /* A global or weak symbol is treated as external.  */
-               && ! (S_IS_EXTERN (sym) || S_IS_WEAK (sym))
+               && (OUTPUT_FLAVOR == bfd_target_elf_flavour
+                   && ! (S_IS_EXTERN (sym) || S_IS_WEAK (sym)))
 #endif

It's fairly obvious that the test here should be true if not ELF, so
the same behaviour is seen as when OBJ_ELF is not defined.

That leads to the following change.  I've verified that binutils still
compiles and passes make check.  The rules of boolean logic say that
it should be OK given the intent, and it passes your elf-jal testcase
that you added when you put in the original patch that the msg quoted
above updated.

Any objection?  (I'm wanting to check this in to the branch and
trunk, and I'd like to be sure that it's OK w/ you since the original
changes were yours.)


thanks,

chris
===================================================================
[gas/ChangeLog]
2002-02-15  Chris Demetriou  <cgd@broadcom.com>

        * config/tc-mips.c (md_estimate_size_before_relax): Really
	make sure we treat weak like extern only for ELF.  (Fixes
	patch from 2001-07-25.)

Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.107.2.1
diff -u -p -r1.107.2.1 tc-mips.c
--- tc-mips.c	2002/02/14 07:31:11	1.107.2.1
+++ tc-mips.c	2002/02/15 06:58:22
@@ -12194,8 +12194,8 @@ md_estimate_size_before_relax (fragp, se
 		&& !linkonce
 #ifdef OBJ_ELF
 		/* A global or weak symbol is treated as external.  */
-	  	&& (OUTPUT_FLAVOR == bfd_target_elf_flavour
-		    && ! (S_IS_EXTERN (sym) || S_IS_WEAK (sym)))
+	  	&& (OUTPUT_FLAVOR != bfd_target_elf_flavour
+		    || (! S_IS_EXTERN (sym) && ! S_IS_WEAK (sym)))
 #endif
 		);
     }



More information about the Binutils mailing list