This is the mail archive of the binutils@sourceware.cygnus.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]

SPARC patch to avoid optimizations in dynamic libraries enforce changes in binaries


Hi!

Without this patch, ld will hapilly set e.g. UltraSPARC-I extensions
EF in binaries eventhough the only place where it is used is some dynamic
library.
That makes it e.g. impossible to run any binaries linked on machine with
sparcv9-*-linux glibc on sparc32 boxes.

Cheers,
    Jakub
___________________________________________________________________
Jakub Jelinek | jakub@redhat.com | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.18 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________
1999-10-13  Jakub Jelinek  <jakub@redhat.com>

	* elf32-sparc.c (elf32_sparc_merge_private_bfd_data): Don't bump
	architecture if the object causing the bump is dynamic.
	* elf64-sparc.c (sparc64_elf_merge_private_bfd_data): Ditto,
	neither do it for memory ordering.

--- ./bfd/elf32-sparc.c.jj	Sat Sep  4 18:26:08 1999
+++ ./bfd/elf32-sparc.c	Mon Oct 11 11:15:13 1999
@@ -1871,7 +1871,8 @@ elf32_sparc_merge_private_bfd_data (ibfd
 	(_("%s: compiled for a 64 bit system and target is 32 bit"),
 	 bfd_get_filename (ibfd));
     }
-  else if (bfd_get_mach (obfd) < bfd_get_mach (ibfd))
+  else if (bfd_get_mach (obfd) < bfd_get_mach (ibfd)
+	   && !(ibfd->flags & DYNAMIC))
     bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd));
 #endif
 
--- ./bfd/elf64-sparc.c.jj	Mon Aug  9 17:07:32 1999
+++ ./bfd/elf64-sparc.c	Wed Oct 13 10:20:53 1999
@@ -2799,25 +2799,32 @@ sparc64_elf_merge_private_bfd_data (ibfd
     {
       error = false;
   
-      old_flags |= (new_flags & (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1));
-      new_flags |= (old_flags & (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1));
-      if ((old_flags & (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1)) ==
-           (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1))
-        {
-          error = true;
-          (*_bfd_error_handler)
-            (_("%s: linking UltraSPARC specific with HAL specific code"),
-             bfd_get_filename (ibfd));
-        }
-        
-      /* Choose the most restrictive memory ordering */
-      old_mm = (old_flags & EF_SPARCV9_MM);
-      new_mm = (new_flags & EF_SPARCV9_MM);
-      old_flags &= ~EF_SPARCV9_MM;
-      new_flags &= ~EF_SPARCV9_MM;
-      if (new_mm < old_mm) old_mm = new_mm;
-      old_flags |= old_mm;
-      new_flags |= old_mm;
+      if (ibfd->flags & DYNAMIC) {
+	/* We don't want dynamic objects memory ordering and architecture to
+	   have any role. That's what dynamic linker should do. */
+	old_flags &= ~(EF_SPARCV9_MM|EF_SPARC_SUN_US1|EF_SPARC_HAL_R1);
+	old_flags |= (new_flags & (EF_SPARCV9_MM|EF_SPARC_SUN_US1|EF_SPARC_HAL_R1));
+      } else {
+	/* Choose the highest architecture requirements */
+	old_flags |= (new_flags & (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1));
+	new_flags |= (old_flags & (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1));
+	if ((old_flags & (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1)) ==
+	    (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1))
+	  {
+	    error = true;
+	    (*_bfd_error_handler)
+	      (_("%s: linking UltraSPARC specific with HAL specific code"),
+	       bfd_get_filename (ibfd));
+	  }
+	/* Choose the most restrictive memory ordering */
+	old_mm = (old_flags & EF_SPARCV9_MM);
+	new_mm = (new_flags & EF_SPARCV9_MM);
+	old_flags &= ~EF_SPARCV9_MM;
+	new_flags &= ~EF_SPARCV9_MM;
+	if (new_mm < old_mm) old_mm = new_mm;
+	old_flags |= old_mm;
+	new_flags |= old_mm;
+      }
 
       /* Warn about any other mismatches */
       if (new_flags != old_flags)

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