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]

Re: more on ARM ELF flag merging


Hi Nick,

Here's an updated version of this patch.  I've reinstated the quick check for 
identical flags and implemented the behaviour for PIC that I mentioned in my 
first mail.  This still won't give correct results in all cases (linking an 
object with default, non-PIC flags followed by a PIC object will result in the 
output file being labelled PIC) but I think it's better than what we had 
before.

If you're happy with this I will check it in to both the mainline and the 2.10 
branches.  That's the last issue I want to see fixed for 2.10.1, so I will 
make a first release candidate tarball when I'm back in the office on Monday 
unless anybody raises an objection over the weekend.

p.

2000-10-27  Philip Blundell  <philb@gnu.org>

	* elf32-arm.h (elf32_arm_copy_private_bfd_data): Don't refuse
	attempts to mix PIC code with non-PIC, just mark the output as
	being position dependent.
	(elf32_arm_merge_private_bfd_data): Likewise.  Print an error 
	message for EF_SOFT_FLOAT mismatches.  Display diagnostics for 
	all mismatches, not just the first one.
	
Index: elf32-arm.h
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.h,v
retrieving revision 1.25.2.2
diff -u -p -u -r1.25.2.2 elf32-arm.h
--- elf32-arm.h	2000/10/22 15:19:56	1.25.2.2
+++ elf32-arm.h	2000/10/27 17:09:56
@@ -1933,10 +1933,6 @@ elf32_arm_copy_private_bfd_data (ibfd, o
 
   if (elf_flags_init (obfd) && in_flags != out_flags)
     {
-      /* Cannot mix PIC and non-PIC code.  */
-      if ((in_flags & EF_PIC) != (out_flags & EF_PIC))
-	return false;
-
       /* Cannot mix APCS26 and APCS32 code.  */
       if ((in_flags & EF_APCS_26) != (out_flags & EF_APCS_26))
 	return false;
@@ -1956,6 +1952,10 @@ Warning: Clearing the interwork flag in 
 
 	  in_flags &= ~EF_INTERWORK;
 	}
+
+      /* Likewise for PIC, though don't warn for this case.  */
+      if ((in_flags & EF_PIC) != (out_flags & EF_PIC))
+	in_flags &= ~EF_PIC;
     }
 
   elf_elfheader (obfd)->e_flags = in_flags;
@@ -1973,6 +1973,7 @@ elf32_arm_merge_private_bfd_data (ibfd, 
 {
   flagword out_flags;
   flagword in_flags;
+  boolean flags_compatible = true;
 
   if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
@@ -2024,48 +2025,60 @@ elf32_arm_merge_private_bfd_data (ibfd, 
       return true;
     }
 
-  /* Check flag compatibility.  */
+  /* Identical flags must be compatible.  */
   if (in_flags == out_flags)
     return true;
 
+  /* If any of the input BFDs is non-PIC, the output is also position 
+     dependent.  */
+  if (!(in_flags & EF_PIC))
+    elf_elfheader (obfd)->e_flags &= ~EF_PIC;
+
   /* Complain about various flag mismatches.  */
 
   if ((in_flags & EF_APCS_26) != (out_flags & EF_APCS_26))
-    _bfd_error_handler (_ ("\
+    {
+      _bfd_error_handler (_ ("\
 Error: %s compiled for APCS-%d, whereas %s is compiled for APCS-%d"),
 			bfd_get_filename (ibfd),
 			in_flags & EF_APCS_26 ? 26 : 32,
 			bfd_get_filename (obfd),
 			out_flags & EF_APCS_26 ? 26 : 32);
+      flags_compatible = false;
+    }
 
   if ((in_flags & EF_APCS_FLOAT) != (out_flags & EF_APCS_FLOAT))
-    _bfd_error_handler (_ ("\
+    {
+      _bfd_error_handler (_ ("\
 Error: %s passes floats in %s registers, whereas %s passes them in %s registers"),
 			bfd_get_filename (ibfd),
 		     in_flags & EF_APCS_FLOAT ? _ ("float") : _ ("integer"),
 			bfd_get_filename (obfd),
 		      out_flags & EF_APCS_26 ? _ ("float") : _ ("integer"));
+      flags_compatible = false;
+    }
 
-  if ((in_flags & EF_PIC) != (out_flags & EF_PIC))
-    _bfd_error_handler (_ ("\
-Error: %s is compiled as position %s code, whereas %s is not"),
-			bfd_get_filename (ibfd),
-		    in_flags & EF_PIC ? _ ("independent") : _ ("dependent"),
-			bfd_get_filename (obfd));
+  if ((in_flags & EF_SOFT_FLOAT) != (out_flags & EF_SOFT_FLOAT))
+    {
+      _bfd_error_handler (_ ("\
+Error: %s uses %s floating point, whereas %s uses %s floating point"),
+			  bfd_get_filename (ibfd),
+			  in_flags & EF_SOFT_FLOAT ? _("soft") : _("hard"),
+			  bfd_get_filename (obfd),
+			  out_flags & EF_SOFT_FLOAT ? _("soft") : _("hard"));
+      flags_compatible = false;
+    }
 
   /* Interworking mismatch is only a warning. */
   if ((in_flags & EF_INTERWORK) != (out_flags & EF_INTERWORK))
-    {
-      _bfd_error_handler (_ ("\
+    _bfd_error_handler (_ ("\
 Warning: %s %s interworking, whereas %s %s"),
 			  bfd_get_filename (ibfd),
 	  in_flags & EF_INTERWORK ? _ ("supports") : _ ("does not support"),
 			  bfd_get_filename (obfd),
 		    out_flags & EF_INTERWORK ? _ ("does not") : _ ("does"));
-      return true;
-    }
 
-  return false;
+  return flags_compatible;
 }
 
 /* Display the flags field */



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