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]

make use of backend swap reloc


Hi,

We really want to use the backend functions to swap out relocations, they're a
bit different in mips64.

Ulf


2005-05-03  Ulf Carlsson  <ulfc@engr.sgi.com>

	* elflink.h (elf_link_adjust_relocs): Make use of backend functions to
	swap relocations in and out.
	(elf_link_output_relocs): Likewise.


Index: elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.52
diff -u -p -r1.52 elflink.h
--- elflink.h	2000/04/27 00:31:16	1.52
+++ elflink.h	2000/05/03 11:13:12
@@ -3960,7 +3960,10 @@ elf_link_adjust_relocs (abfd, rel_hdr, c
      struct elf_link_hash_entry **rel_hash;
 {
   unsigned int i;
+  struct elf_backend_data *bed;
 
+  bed = get_elf_backend_data (abfd);
+
   for (i = 0; i < count; i++, rel_hash++)
     {
       if (*rel_hash == NULL)
@@ -3974,10 +3977,16 @@ elf_link_adjust_relocs (abfd, rel_hdr, c
 	  Elf_Internal_Rel irel;
 	  
 	  erel = (Elf_External_Rel *) rel_hdr->contents + i;
-	  elf_swap_reloc_in (abfd, erel, &irel);
+	  if (bed->s->swap_reloc_in)
+	    (*bed->s->swap_reloc_in) (abfd, (bfd_byte *) erel, &irel);
+	  else
+	    elf_swap_reloc_in (abfd, erel, &irel);
 	  irel.r_info = ELF_R_INFO ((*rel_hash)->indx,
 				    ELF_R_TYPE (irel.r_info));
-	  elf_swap_reloc_out (abfd, &irel, erel);
+	  if (bed->s->swap_reloc_out)
+	    (*bed->s->swap_reloc_out) (abfd, &irel, (bfd_byte *) erel);
+	  else
+	    elf_swap_reloc_out (abfd, &irel, erel);
 	}
       else
 	{
@@ -3988,10 +3997,16 @@ elf_link_adjust_relocs (abfd, rel_hdr, c
 		      == sizeof (Elf_External_Rela));
 	  
 	  erela = (Elf_External_Rela *) rel_hdr->contents + i;
-	  elf_swap_reloca_in (abfd, erela, &irela);
+	  if (bed->s->swap_reloca_in)
+	    (*bed->s->swap_reloca_in) (abfd, (bfd_byte *) erela, &irela);
+	  else
+	    elf_swap_reloca_in (abfd, erela, &irela);
 	  irela.r_info = ELF_R_INFO ((*rel_hash)->indx,
 				     ELF_R_TYPE (irela.r_info));
-	  elf_swap_reloca_out (abfd, &irela, erela);
+	  if (bed->s->swap_reloca_out)
+	    (*bed->s->swap_reloca_out) (abfd, &irela, (bfd_byte *) erela);
+	  else
+	    elf_swap_reloca_out (abfd, &irela, erela);
 	}
     }
 }
@@ -5163,6 +5178,7 @@ elf_link_output_relocs (output_bfd, inpu
   Elf_Internal_Rela *irela;
   Elf_Internal_Rela *irelaend;
   Elf_Internal_Shdr *output_rel_hdr;
+  struct elf_backend_data *bed;
   asection *output_section;
   unsigned int *rel_countp = NULL;
 
@@ -5184,6 +5200,8 @@ elf_link_output_relocs (output_bfd, inpu
     }
 
   BFD_ASSERT (output_rel_hdr != NULL);
+
+  bed = get_elf_backend_data (output_bfd);
   
   irela = internal_relocs;
   irelaend = irela + input_rel_hdr->sh_size / input_rel_hdr->sh_entsize;
@@ -5199,7 +5217,10 @@ elf_link_output_relocs (output_bfd, inpu
 	  irel.r_offset = irela->r_offset;
 	  irel.r_info = irela->r_info;
 	  BFD_ASSERT (irela->r_addend == 0);
-	  elf_swap_reloc_out (output_bfd, &irel, erel);
+	  if (bed->s->swap_reloc_out)
+	    (*bed->s->swap_reloc_out) (output_bfd, &irel, (PTR) erel);
+	  else
+	    elf_swap_reloc_out (output_bfd, &irel, erel);
 	}
     }
   else
@@ -5210,7 +5231,10 @@ elf_link_output_relocs (output_bfd, inpu
 		  == sizeof (Elf_External_Rela));
       erela = ((Elf_External_Rela *) output_rel_hdr->contents + *rel_countp);
       for (; irela < irelaend; irela++, erela++)
-	elf_swap_reloca_out (output_bfd, irela, erela);
+	if (bed->s->swap_reloca_out)
+	  (*bed->s->swap_reloca_out) (output_bfd, irela, (PTR) erela);
+	else
+	  elf_swap_reloca_out (output_bfd, irela, erela);
     }
 
   /* Bump the counter, so that we know where to add the next set of


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