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]

Update SPARC binutils patch


Hi!

This is a repost of the patch from Oct, 11th (without which ld will hapilly
set e.g. UltraSPARC-I extensions EF in binaries eventhough the only place
where it is used is some dynamic library), plus a bugfix for OLO10
relocations. Could you please put this in?

Thanks,
    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-29  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.
	(sparc64_elf_write_relocs): Fix relocation when OLO10 comes
	into play.

--- binutils/bfd/elf32-sparc.c.jj	Sat Sep  4 18:26:08 1999
+++ binutils/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
 
--- binutils/bfd/elf64-sparc.c.jj	Mon Aug  9 17:07:32 1999
+++ binutils/bfd/elf64-sparc.c	Sat Oct 23 22:53:21 1999
@@ -474,7 +474,7 @@ sparc64_elf_write_relocs (abfd, sec, dat
 {
   boolean *failedp = (boolean *) data;
   Elf_Internal_Shdr *rela_hdr;
-  Elf64_External_Rela *outbound_relocas;
+  Elf64_External_Rela *outbound_relocas, *src_rela;
   unsigned int idx, count;
   asymbol *last_sym = 0;
   int last_sym_idx = 0;
@@ -534,17 +534,16 @@ sparc64_elf_write_relocs (abfd, sec, dat
 
   /* orelocation has the data, reloc_count has the count... */
   outbound_relocas = (Elf64_External_Rela *) rela_hdr->contents;
+  src_rela = outbound_relocas;
 
   for (idx = 0; idx < sec->reloc_count; idx++)
     {
       Elf_Internal_Rela dst_rela;
-      Elf64_External_Rela *src_rela;
       arelent *ptr;
       asymbol *sym;
       int n;
 
       ptr = sec->orelocation[idx];
-      src_rela = outbound_relocas + idx;
 
       /* The address of an ELF reloc is section relative for an object
 	 file, and absolute for an executable file or shared library.
@@ -601,7 +600,7 @@ sparc64_elf_write_relocs (abfd, sec, dat
 	dst_rela.r_info = ELF64_R_INFO (n, ptr->howto->type);
 
       dst_rela.r_addend = ptr->addend;
-      bfd_elf64_swap_reloca_out (abfd, &dst_rela, src_rela);
+      bfd_elf64_swap_reloca_out (abfd, &dst_rela, src_rela++);
     }
 }
 
@@ -2799,25 +2798,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]