ELF reloc code tidy

Alan Modra amodra@bigpond.net.au
Thu Nov 28 03:52:00 GMT 2002


This probably should be broken into a number of separate patches,
but the changes are all related.

o Remove all Elf32_Internal_* and Elf64_Internal defines.  They just
  obscure the fact that the 32 and 64 bit variants are identical.
  A couple of files even used the "wrong" one in some places.

o Get rid of Elf_Internal_Rel, and use Elf_Internal_Rela everywhere.
  This allows some code simplification, and is the way I think we
  should move in reloc handling.  ie. treat all relocs internally
  as RELA, and only convert to REL when writing out relocs.  The
  change admittedly comes at a space penalty for REL targets, but
  some existing code already allocates for rela, eg.
  _bfd_elfxx_link_read_relocs.

o Always set the reloc swap entries in elf_size_info.  So instead of

	  if (bed->s->swap_reloca_in)
	    (*bed->s->swap_reloca_in) (abfd, erela, irela);
	  else
	    elf_swap_reloca_in (abfd, erela, irela);

  we just do

	  (*bed->s->swap_reloca_in) (abfd, erela, irela);

  This simple little change caused more editing than it was worth
  really, as the elf_size_info functions are declared to take
  "bfd_byte *" external reloc args, while bfd_elf32_swap_reloc* takes
  the appropriate Elf{32,64}_External_Rel* arg.  So practically all
  swap_reloc calls needed an arg cast or changed to use a "bfd_byte *"
  temp var.

o Consolidate code handling both REL and RELA relocs.

o Fix memory over-allocation in elf_link_sort_relocs.

include/elf/ChangeLog
	* internal.h (elf32_internal_ehdr, Elf32_Internal_Ehdr,
	elf64_internal_ehdr, Elf64_Internal_Ehdr, elf32_internal_phdr,
	Elf32_Internal_Phdr, elf64_internal_phdr, Elf64_Internal_Phdr,
	elf32_internal_shdr, Elf32_Internal_Shdr, elf64_internal_shdr,
	Elf64_Internal_Shdr, elf32_internal_sym, elf64_internal_sym,
	Elf32_Internal_Sym, Elf64_Internal_Sym, Elf32_Internal_Note,
	elf32_internal_note, elf32_internal_rel, Elf32_Internal_Rel,
	elf64_internal_rel, Elf64_Internal_Rel, elf32_internal_rela,
	elf64_internal_rela, Elf32_Internal_Rela, Elf64_Internal_Rela,
	elf32_internal_dyn, elf64_internal_dyn, Elf32_Internal_Dyn,
	Elf64_Internal_Dyn, elf32_internal_verdef, elf64_internal_verdef,
	elf32_internal_verdaux, elf64_internal_verdaux, elf32_internal_verneed,
	elf64_internal_verneed, elf32_internal_vernaux, elf64_internal_vernaux,
	elf32_internal_versym, elf64_internal_versym, Elf32_Internal_Verdef,
	Elf64_Internal_Verdef, Elf32_Internal_Verdaux, Elf64_Internal_Verdaux,
	Elf32_Internal_Verneed, Elf64_Internal_Verneed, Elf32_Internal_Vernaux,
	Elf64_Internal_Vernaux, Elf32_Internal_Versym, Elf64_Internal_Versym,
	Elf32_Internal_Syminfo, Elf64_Internal_Syminfo): Delete.
	(Elf_Internal_Rel): Delete.

bfd/ChangeLog
	* elf-bfd.h: Replace occurrences of Elf32_Internal_* and
	Elf64_Internal_* with Elf_Internal_*.  Replace Elf_Internal_Rel
	with Elf_Internal_Rela.
	* elf-hppa.h, elf-m10200.c, elf-m10300.c, elf32-arc.c, elf32-arm.h,
	elf32-avr.c, elf32-cris.c, elf32-d10v.c, elf32-d30v.c, elf32-dlx.c,
	elf32-fr30.c, elf32-frv.c, elf32-gen.c, elf32-h8300.c, elf32-hppa.c,
	elf32-i370.c, elf32-i386.c, elf32-i860.c, elf32-i960.c, elf32-ip2k.c,
	elf32-m32r.c, elf32-m68hc11.c, elf32-m68hc12.c, elf32-m68k.c,
	elf32-mcore.c, elf32-mips.c, elf32-openrisc.c, elf32-or32.c,
	elf32-ppc.c, elf32-s390.c, elf32-sh.c, elf32-v850.c, elf32-vax.c,
	elf32-xstormy16.c, elf64-alpha.c, elf64-gen.c, elf64-hppa.c,
	elf64-mips.c, elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
	elf64-sparc.c, elf64-x86-64.c, elfarm-nabi.c, elfarm-oabi.c,
	elfcode.h, elflink.h, elfn32-mips.c, elfxx-ia64.c, elfxx-mips.c: Ditto.
	* elf-hppa.h (elf_hppa_internal_shdr): Delete.  Use Elf_Internal_Shdr
	throughout instead.
	* elf.c (_bfd_elf_no_info_to_howto_rel): Delete.
	* elfcode.h (elf_swap_reloca_in): Pass source operand as a bfd_byte *.
	Remove INLINE keyword.
	(elf_swap_reloc_in): Likewise.  Also clear r_addend.
	(elf_swap_reloc_out, elf_swap_reloca_out): Pass destination operand
	as a bfd_byte *.
	(elf_write_relocs): Consolidate REL and RELA code.
	(elf_slurp_reloc_table_from_section): Simplify REL code.
	(NAME(_bfd_elf,size_info)): Populate reloc swap entries.
	* elf-bfd.h (MAX_INT_RELS_PER_EXT_REL): Define.
	* elflink.h (elf_link_read_relocs_from_section): Consolidate REL and
	RELA code.
	(elf_link_adjust_relocs): Likewise.  Don't malloc space for temp
	reloc array, use a fixed size of MAX_INT_RELS_PER_EXT_REL.
	(elf_link_output_relocs): Likewise.
	(elf_reloc_link_order): Likewise.
	(elf_finish_pointer_linker_section): Likewise.
	(struct elf_link_sort_rela): Remove union.
	(elf_link_sort_cmp1): Update to suit.
	(elf_link_sort_cmp2): Here too.
	(elf_link_sort_relocs): Consolidate REL and RELA code.  Fix memory
	over-allocation for int_rels_per_ext_rel != 1 case.
	* elf32-arm.h: Update all bfd_elf32_swap_reloc_out calls.
	* elf32-i386.c: Likewise.
	* elf32-cris.c: Likewise for bfd_elf32_swap_reloca_out.
	* elf32-hppa.c, elf32-i370.c, elf32-m68k.c, elf32-ppc.c, elf32-s390.c,
	elf32-sh.c, elf32-vax.c, elfxx-mips.c: Likewise.
	* elf64-alpha.c: Likewise for bfd_elf64_swap_reloca_out.
	* elf64-hppa.c, elf64-mips.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c,
	elf64-sparc.c, elf64-x86-64.c: Likewise.
	* elfxx-ia64.c: Likewise for bfd_elfNN_swap_reloca_out.
	* elfxx-mips.c (sort_dynamic_relocs): Likewise for
	bfd_elf32_swap_reloc_in.

	* elf32-arm.h: Update elf32_arm_info_to_howto calls.
	* elf32-mips.c: Likewise for mips_info_to_howto_rel.
	(mips_elf64_swap_reloc_in): Zero r_addend.
	(mips_elf64_be_swap_reloc_in): Likewise.
	(mips_elf64_slurp_one_reloc_table): Simplify.

	* elf64-alpha.c (alpha_elf_size_info): Populate reloc swap entries.
	* elf64-hppa.c (hppa64_elf_size_info): Likewise.
	* elf64-sparc.c (sparc64_elf_size_info): Likewise.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

Index: include/elf/internal.h
===================================================================
RCS file: /cvs/src/src/include/elf/internal.h,v
retrieving revision 1.8
diff -u -p -r1.8 internal.h
--- include/elf/internal.h	17 Dec 2001 00:52:34 -0000	1.8
+++ include/elf/internal.h	28 Nov 2002 01:56:23 -0000
@@ -58,11 +58,6 @@ typedef struct elf_internal_ehdr {
   unsigned int		e_shstrndx;	/* Section header string table index */
 } Elf_Internal_Ehdr;
 
-#define elf32_internal_ehdr elf_internal_ehdr
-#define Elf32_Internal_Ehdr Elf_Internal_Ehdr
-#define elf64_internal_ehdr elf_internal_ehdr
-#define Elf64_Internal_Ehdr Elf_Internal_Ehdr
-
 /* Program header */
 
 struct elf_internal_phdr {
@@ -77,10 +72,6 @@ struct elf_internal_phdr {
 };
 
 typedef struct elf_internal_phdr Elf_Internal_Phdr;
-#define elf32_internal_phdr elf_internal_phdr
-#define Elf32_Internal_Phdr Elf_Internal_Phdr
-#define elf64_internal_phdr elf_internal_phdr
-#define Elf64_Internal_Phdr Elf_Internal_Phdr
 
 /* Section header */
 
@@ -101,11 +92,6 @@ typedef struct elf_internal_shdr {
   unsigned char *contents;		/* Section contents.  */
 } Elf_Internal_Shdr;
 
-#define elf32_internal_shdr elf_internal_shdr
-#define Elf32_Internal_Shdr Elf_Internal_Shdr
-#define elf64_internal_shdr elf_internal_shdr
-#define Elf64_Internal_Shdr Elf_Internal_Shdr
-
 /* Symbol table entry */
 
 struct elf_internal_sym {
@@ -119,11 +105,6 @@ struct elf_internal_sym {
 
 typedef struct elf_internal_sym Elf_Internal_Sym;
 
-#define elf32_internal_sym elf_internal_sym
-#define elf64_internal_sym elf_internal_sym
-#define Elf32_Internal_Sym Elf_Internal_Sym
-#define Elf64_Internal_Sym Elf_Internal_Sym
-
 /* Note segments */
 
 typedef struct elf_internal_note {
@@ -134,33 +115,15 @@ typedef struct elf_internal_note {
   char *	descdata;		/* Start of the desc data */
   bfd_vma	descpos;		/* File offset of the descdata */
 } Elf_Internal_Note;
-#define Elf32_Internal_Note	Elf_Internal_Note
-#define elf32_internal_note	elf_internal_note
 
 /* Relocation Entries */
 
-typedef struct elf_internal_rel {
-  bfd_vma	r_offset;	/* Location at which to apply the action */
-  /* This needs to support 64-bit values in elf64.  */
-  bfd_vma	r_info;		/* index and type of relocation */
-} Elf_Internal_Rel;
-
-#define elf32_internal_rel elf_internal_rel
-#define Elf32_Internal_Rel Elf_Internal_Rel
-#define elf64_internal_rel elf_internal_rel
-#define Elf64_Internal_Rel Elf_Internal_Rel
-
 typedef struct elf_internal_rela {
   bfd_vma	r_offset;	/* Location at which to apply the action */
   bfd_vma	r_info;		/* Index and Type of relocation */
   bfd_vma	r_addend;	/* Constant addend used to compute value */
 } Elf_Internal_Rela;
 
-#define elf32_internal_rela elf_internal_rela
-#define elf64_internal_rela elf_internal_rela
-#define Elf32_Internal_Rela Elf_Internal_Rela
-#define Elf64_Internal_Rela Elf_Internal_Rela
-
 /* dynamic section structure */
 
 typedef struct elf_internal_dyn {
@@ -173,11 +136,6 @@ typedef struct elf_internal_dyn {
   } d_un;
 } Elf_Internal_Dyn;
 
-#define elf32_internal_dyn elf_internal_dyn
-#define elf64_internal_dyn elf_internal_dyn
-#define Elf32_Internal_Dyn Elf_Internal_Dyn
-#define Elf64_Internal_Dyn Elf_Internal_Dyn
-
 /* This structure appears in a SHT_GNU_verdef section.  */
 
 typedef struct elf_internal_verdef {
@@ -256,30 +214,6 @@ typedef struct
   unsigned short int	si_flags;
 } Elf_Internal_Syminfo;
 
-
-#define elf32_internal_verdef elf_internal_verdef
-#define elf64_internal_verdef elf_internal_verdef
-#define elf32_internal_verdaux elf_internal_verdaux
-#define elf64_internal_verdaux elf_internal_verdaux
-#define elf32_internal_verneed elf_internal_verneed
-#define elf64_internal_verneed elf_internal_verneed
-#define elf32_internal_vernaux elf_internal_vernaux
-#define elf64_internal_vernaux elf_internal_vernaux
-#define elf32_internal_versym elf_internal_versym
-#define elf64_internal_versym elf_internal_versym
-
-#define Elf32_Internal_Verdef Elf_Internal_Verdef
-#define Elf64_Internal_Verdef Elf_Internal_Verdef
-#define Elf32_Internal_Verdaux Elf_Internal_Verdaux
-#define Elf64_Internal_Verdaux Elf_Internal_Verdaux
-#define Elf32_Internal_Verneed Elf_Internal_Verneed
-#define Elf64_Internal_Verneed Elf_Internal_Verneed
-#define Elf32_Internal_Vernaux Elf_Internal_Vernaux
-#define Elf64_Internal_Vernaux Elf_Internal_Vernaux
-#define Elf32_Internal_Versym Elf_Internal_Versym
-#define Elf64_Internal_Versym Elf_Internal_Versym
-#define Elf32_Internal_Syminfo Elf_Internal_Syminfo
-#define Elf64_Internal_Syminfo Elf_Internal_Syminfo
 
 /* This structure is used to describe how sections should be assigned
    to program segments.  */
Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.88
diff -u -p -r1.88 elf-bfd.h
--- bfd/elf-bfd.h	12 Nov 2002 07:35:26 -0000	1.88
+++ bfd/elf-bfd.h	28 Nov 2002 10:30:09 -0000
@@ -424,6 +424,9 @@ struct elf_size_info {
   /* The number of internal relocations to allocate per external
      relocation entry.  */
   unsigned char int_rels_per_ext_rel;
+  /* We use some fixed size arrays.  This should be large enough to
+     handle all back-ends.  */
+#define MAX_INT_RELS_PER_EXT_REL 3
 
   unsigned char arch_size, file_align;
   unsigned char elfclass, ev_current;
@@ -446,30 +449,25 @@ struct elf_size_info {
   void (*swap_dyn_out)
     PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
 
-  /* This function, if defined, is called to swap in a REL
-     relocation.  If an external relocation corresponds to more than
-     one internal relocation, then all relocations are swapped in at
-     once.  */
+  /* This function is called to swap in a REL relocation.  If an
+     external relocation corresponds to more than one internal
+     relocation, then all relocations are swapped in at once.  */
   void (*swap_reloc_in)
-    PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rel *));
+    PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
 
-  /* This function, if defined, is called to swap out a REL
-     relocation.  */
+  /* This function is called to swap out a REL relocation.  */
   void (*swap_reloc_out)
-    PARAMS ((bfd *, const Elf_Internal_Rel *, bfd_byte *));
+    PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
 
-  /* This function, if defined, is called to swap in a RELA
-     relocation.  If an external relocation corresponds to more than
-     one internal relocation, then all relocations are swapped in at
-     once.  */
+  /* This function is called to swap in a RELA relocation.  If an
+     external relocation corresponds to more than one internal
+     relocation, then all relocations are swapped in at once.  */
   void (*swap_reloca_in)
     PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
 
-  /* This function, if defined, is called to swap out a RELA
-     relocation.  */
+  /* This function is called to swap out a RELA relocation.  */
   void (*swap_reloca_out)
     PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
-
 };
 
 #define elf_symbol_from(ABFD,S) \
@@ -523,7 +521,7 @@ struct elf_backend_data
   /* A function to translate an ELF REL relocation to a BFD arelent
      structure.  */
   void (*elf_info_to_howto_rel)
-    PARAMS ((bfd *, arelent *, Elf_Internal_Rel *));
+    PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 
   /* A function to determine whether a symbol is global when
      partitioning the symbol table into local and global symbols.
@@ -566,28 +564,28 @@ struct elf_backend_data
      type fields for some sections, or to actually write out data for
      unusual sections.  */
   boolean (*elf_backend_section_processing)
-    PARAMS ((bfd *, Elf32_Internal_Shdr *));
+    PARAMS ((bfd *, Elf_Internal_Shdr *));
 
   /* A function to handle unusual section types when creating BFD
      sections from ELF sections.  */
   boolean (*elf_backend_section_from_shdr)
-    PARAMS ((bfd *, Elf32_Internal_Shdr *, const char *));
+    PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 
   /* A function to convert machine dependent section header flags to
      BFD internal section header flags.  */
   boolean (*elf_backend_section_flags)
-    PARAMS ((flagword *, Elf32_Internal_Shdr *));
+    PARAMS ((flagword *, Elf_Internal_Shdr *));
 
   /* A function to handle unusual program segment types when creating BFD
      sections from ELF program segments.  */
   boolean (*elf_backend_section_from_phdr)
-    PARAMS ((bfd *, Elf32_Internal_Phdr *, int));
+    PARAMS ((bfd *, Elf_Internal_Phdr *, int));
 
   /* A function to set up the ELF section header for a BFD section in
      preparation for writing it out.  This is where the flags and type
      fields are set for unusual sections.  */
   boolean (*elf_backend_fake_sections)
-    PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *));
+    PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
 
   /* A function to get the ELF section index for a BFD section.  If
      this returns true, the section was found.  If it is a normal ELF
@@ -1486,21 +1484,21 @@ extern elf_linker_section_pointers_t *_b
 
 extern boolean bfd_elf32_create_pointer_linker_section
   PARAMS ((bfd *, struct bfd_link_info *, elf_linker_section_t *,
-	   struct elf_link_hash_entry *, const Elf32_Internal_Rela *));
+	   struct elf_link_hash_entry *, const Elf_Internal_Rela *));
 
 extern bfd_vma bfd_elf32_finish_pointer_linker_section
   PARAMS ((bfd *, bfd *, struct bfd_link_info *, elf_linker_section_t *,
 	   struct elf_link_hash_entry *, bfd_vma,
-	   const Elf32_Internal_Rela *, int));
+	   const Elf_Internal_Rela *, int));
 
 extern boolean bfd_elf64_create_pointer_linker_section
   PARAMS ((bfd *, struct bfd_link_info *, elf_linker_section_t *,
-	   struct elf_link_hash_entry *, const Elf64_Internal_Rela *));
+	   struct elf_link_hash_entry *, const Elf_Internal_Rela *));
 
 extern bfd_vma bfd_elf64_finish_pointer_linker_section
   PARAMS ((bfd *, bfd *, struct bfd_link_info *, elf_linker_section_t *,
 	   struct elf_link_hash_entry *, bfd_vma,
-	   const Elf64_Internal_Rela *, int));
+	   const Elf_Internal_Rela *, int));
 
 extern boolean _bfd_elf_make_linker_section_rela
   PARAMS ((bfd *, elf_linker_section_t *, int));
@@ -1526,13 +1524,13 @@ extern void bfd_elf32_swap_symbol_in
 extern void bfd_elf32_swap_symbol_out
   PARAMS ((bfd *, const Elf_Internal_Sym *, PTR, PTR));
 extern void bfd_elf32_swap_reloc_in
-  PARAMS ((bfd *, const Elf32_External_Rel *, Elf_Internal_Rel *));
+  PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
 extern void bfd_elf32_swap_reloc_out
-  PARAMS ((bfd *, const Elf_Internal_Rel *, Elf32_External_Rel *));
+  PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
 extern void bfd_elf32_swap_reloca_in
-  PARAMS ((bfd *, const Elf32_External_Rela *, Elf_Internal_Rela *));
+  PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
 extern void bfd_elf32_swap_reloca_out
-  PARAMS ((bfd *, const Elf_Internal_Rela *, Elf32_External_Rela *));
+  PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
 extern void bfd_elf32_swap_phdr_in
   PARAMS ((bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *));
 extern void bfd_elf32_swap_phdr_out
@@ -1578,13 +1576,13 @@ extern void bfd_elf64_swap_symbol_in
 extern void bfd_elf64_swap_symbol_out
   PARAMS ((bfd *, const Elf_Internal_Sym *, PTR, PTR));
 extern void bfd_elf64_swap_reloc_in
-  PARAMS ((bfd *, const Elf64_External_Rel *, Elf_Internal_Rel *));
+  PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
 extern void bfd_elf64_swap_reloc_out
-  PARAMS ((bfd *, const Elf_Internal_Rel *, Elf64_External_Rel *));
+  PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
 extern void bfd_elf64_swap_reloca_in
-  PARAMS ((bfd *, const Elf64_External_Rela *, Elf_Internal_Rela *));
+  PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
 extern void bfd_elf64_swap_reloca_out
-  PARAMS ((bfd *, const Elf_Internal_Rela *, Elf64_External_Rela *));
+  PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
 extern void bfd_elf64_swap_phdr_in
   PARAMS ((bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *));
 extern void bfd_elf64_swap_phdr_out
Index: bfd/elf-hppa.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-hppa.h,v
retrieving revision 1.59
diff -u -p -r1.59 elf-hppa.h
--- bfd/elf-hppa.h	23 Jul 2002 12:29:32 -0000	1.59
+++ bfd/elf-hppa.h	27 Nov 2002 15:52:08 -0000
@@ -28,7 +28,6 @@ Foundation, Inc., 59 Temple Place - Suit
 #if ARCH_SIZE == 64
 #define ELF_R_TYPE(X)   ELF64_R_TYPE(X)
 #define ELF_R_SYM(X)   ELF64_R_SYM(X)
-#define elf_hppa_internal_shdr Elf64_Internal_Shdr
 #define elf_hppa_reloc_final_type elf64_hppa_reloc_final_type
 #define _bfd_elf_hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type
 #define elf_hppa_relocate_section elf64_hppa_relocate_section
@@ -38,7 +37,6 @@ Foundation, Inc., 59 Temple Place - Suit
 #if ARCH_SIZE == 32
 #define ELF_R_TYPE(X)   ELF32_R_TYPE(X)
 #define ELF_R_SYM(X)   ELF32_R_SYM(X)
-#define elf_hppa_internal_shdr Elf32_Internal_Shdr
 #define elf_hppa_reloc_final_type elf32_hppa_reloc_final_type
 #define _bfd_elf_hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type
 #define elf_hppa_relocate_section elf32_hppa_relocate_section
@@ -50,7 +48,7 @@ static void elf_hppa_info_to_howto
   PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 
 static void elf_hppa_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 
 static reloc_howto_type * elf_hppa_reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
@@ -59,7 +57,7 @@ static boolean elf_hppa_is_local_label_n
   PARAMS ((bfd *, const char *));
 
 static boolean elf_hppa_fake_sections
-  PARAMS ((bfd *abfd, elf_hppa_internal_shdr *, asection *));
+  PARAMS ((bfd *abfd, Elf_Internal_Shdr *, asection *));
 
 static void elf_hppa_final_write_processing
   PARAMS ((bfd *, boolean));
@@ -937,7 +935,7 @@ static void
 elf_hppa_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *bfd_reloc;
-     Elf_Internal_Rel *elf_reloc;
+     Elf_Internal_Rela *elf_reloc;
 {
   BFD_ASSERT (ELF_R_TYPE(elf_reloc->r_info)
 	      < (unsigned int) R_PARISC_UNIMPLEMENTED);
@@ -978,7 +976,7 @@ elf_hppa_is_local_label_name (abfd, name
 static boolean
 elf_hppa_fake_sections (abfd, hdr, sec)
      bfd *abfd;
-     elf_hppa_internal_shdr *hdr;
+     Elf_Internal_Shdr *hdr;
      asection *sec;
 {
   register const char *name;
Index: bfd/elf-m10200.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-m10200.c,v
retrieving revision 1.18
diff -u -p -r1.18 elf-m10200.c
--- bfd/elf-m10200.c	23 Jul 2002 12:29:32 -0000	1.18
+++ bfd/elf-m10200.c	27 Nov 2002 15:52:09 -0000
@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suit
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 static void mn10200_info_to_howto
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static boolean mn10200_elf_relax_delete_bytes
   PARAMS ((bfd *, asection *, bfd_vma, int));
 static boolean mn10200_elf_symbol_address_p
@@ -213,7 +213,7 @@ static void
 mn10200_info_to_howto (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rela *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
Index: bfd/elf-m10300.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-m10300.c,v
retrieving revision 1.29
diff -u -p -r1.29 elf-m10300.c
--- bfd/elf-m10300.c	23 Jul 2002 12:29:32 -0000	1.29
+++ bfd/elf-m10300.c	27 Nov 2002 15:52:10 -0000
@@ -117,7 +117,7 @@ static void elf32_mn10300_link_hash_tabl
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 static void mn10300_info_to_howto
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static boolean mn10300_elf_check_relocs
   PARAMS ((bfd *, struct bfd_link_info *, asection *,
 	   const Elf_Internal_Rela *));
@@ -322,7 +322,7 @@ static void
 mn10300_info_to_howto (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rela *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.170
diff -u -p -r1.170 elf.c
--- bfd/elf.c	26 Nov 2002 11:53:59 -0000	1.170
+++ bfd/elf.c	27 Nov 2002 15:52:14 -0000
@@ -6081,17 +6081,6 @@ _bfd_elf_no_info_to_howto (abfd, cache_p
   abort ();
 }
 
-#if 0
-void
-_bfd_elf_no_info_to_howto_rel (abfd, cache_ptr, dst)
-     bfd *abfd;
-     arelent *cache_ptr;
-     Elf_Internal_Rel *dst;
-{
-  abort ();
-}
-#endif
-
 /* Try to convert a non-ELF reloc into an ELF one.  */
 
 boolean
Index: bfd/elf32-arc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arc.c,v
retrieving revision 1.12
diff -u -p -r1.12 elf32-arc.c
--- bfd/elf32-arc.c	17 Oct 2002 02:59:15 -0000	1.12
+++ bfd/elf32-arc.c	27 Nov 2002 15:52:14 -0000
@@ -29,7 +29,7 @@
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 static void arc_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static boolean arc_elf_object_p
   PARAMS ((bfd *));
 static void arc_elf_final_write_processing
@@ -142,7 +142,7 @@ static void
 arc_info_to_howto_rel (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rel *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
Index: bfd/elf32-arm.h
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.h,v
retrieving revision 1.98
diff -u -p -r1.98 elf32-arm.h
--- bfd/elf32-arm.h	9 Nov 2002 00:52:27 -0000	1.98
+++ bfd/elf32-arm.h	27 Nov 2002 15:52:16 -0000
@@ -1128,7 +1128,8 @@ elf32_arm_final_link_relocate (howto, in
 		      || (h->elf_link_hash_flags
 			  & ELF_LINK_HASH_DEF_REGULAR) == 0))))
 	{
-	  Elf_Internal_Rel outrel;
+	  Elf_Internal_Rela outrel;
+	  bfd_byte *loc;
 	  boolean skip, relocate;
 
 	  if (sreloc == NULL)
@@ -1192,11 +1193,9 @@ elf32_arm_final_link_relocate (howto, in
 		}
 	    }
 
-	  bfd_elf32_swap_reloc_out (output_bfd, &outrel,
-				    (((Elf32_External_Rel *)
-				      sreloc->contents)
-				     + sreloc->reloc_count));
-	  ++sreloc->reloc_count;
+	  loc = sreloc->contents;
+	  loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
+	  bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
 
 	  /* If this reloc is against an external symbol, we do not want to
 	     fiddle with the addend.  Otherwise, we need to include the symbol
@@ -1657,7 +1656,8 @@ elf32_arm_final_link_relocate (howto, in
 	      if (info->shared)
 		{
 		  asection * srelgot;
-		  Elf_Internal_Rel outrel;
+		  Elf_Internal_Rela outrel;
+		  bfd_byte *loc;
 
 		  srelgot = bfd_get_section_by_name (dynobj, ".rel.got");
 		  BFD_ASSERT (srelgot != NULL);
@@ -1666,11 +1666,9 @@ elf32_arm_final_link_relocate (howto, in
 				     + sgot->output_offset
 				     + off);
 		  outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE);
-		  bfd_elf32_swap_reloc_out (output_bfd, &outrel,
-					    (((Elf32_External_Rel *)
-					      srelgot->contents)
-					     + srelgot->reloc_count));
-		  ++srelgot->reloc_count;
+		  loc = srelgot->contents;
+		  loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rel);
+		  bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
 		}
 
 	      local_got_offsets[r_symndx] |= 1;
@@ -1863,12 +1861,7 @@ elf32_arm_relocate_section (output_bfd, 
           || r_type == R_ARM_GNU_VTINHERIT)
         continue;
 
-#if USE_REL
-      elf32_arm_info_to_howto (input_bfd, & bfd_reloc,
-			       (Elf_Internal_Rel *) rel);
-#else
       elf32_arm_info_to_howto (input_bfd, & bfd_reloc, rel);
-#endif
       howto = bfd_reloc.howto;
 
 #if USE_REL
@@ -3321,7 +3314,8 @@ elf32_arm_finish_dynamic_symbol (output_
       asection * srel;
       bfd_vma plt_index;
       bfd_vma got_offset;
-      Elf_Internal_Rel rel;
+      Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the procedure linkage table.  Set
 	 it up.  */
@@ -3371,9 +3365,8 @@ elf32_arm_finish_dynamic_symbol (output_
 		      + sgot->output_offset
 		      + got_offset);
       rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_JUMP_SLOT);
-      bfd_elf32_swap_reloc_out (output_bfd, &rel,
-				((Elf32_External_Rel *) srel->contents
-				 + plt_index));
+      loc = srel->contents + plt_index * sizeof (Elf32_External_Rel);
+      bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
 
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
 	{
@@ -3394,7 +3387,8 @@ elf32_arm_finish_dynamic_symbol (output_
     {
       asection * sgot;
       asection * srel;
-      Elf_Internal_Rel rel;
+      Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
@@ -3420,16 +3414,15 @@ elf32_arm_finish_dynamic_symbol (output_
 	  rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_GLOB_DAT);
 	}
 
-      bfd_elf32_swap_reloc_out (output_bfd, &rel,
-				((Elf32_External_Rel *) srel->contents
-				 + srel->reloc_count));
-      ++srel->reloc_count;
+      loc = srel->contents + srel->reloc_count++ * sizeof (Elf32_External_Rel);
+      bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
     }
 
   if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
     {
       asection * s;
-      Elf_Internal_Rel rel;
+      Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol needs a copy reloc.  Set it up.  */
       BFD_ASSERT (h->dynindx != -1
@@ -3444,10 +3437,8 @@ elf32_arm_finish_dynamic_symbol (output_
 		      + h->root.u.def.section->output_section->vma
 		      + h->root.u.def.section->output_offset);
       rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_COPY);
-      bfd_elf32_swap_reloc_out (output_bfd, &rel,
-				((Elf32_External_Rel *) s->contents
-				 + s->reloc_count));
-      ++s->reloc_count;
+      loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rel);
+      bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
Index: bfd/elf32-avr.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-avr.c,v
retrieving revision 1.11
diff -u -p -r1.11 elf32-avr.c
--- bfd/elf32-avr.c	23 Jul 2002 12:29:32 -0000	1.11
+++ bfd/elf32-avr.c	27 Nov 2002 15:52:17 -0000
@@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suit
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 static void avr_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static asection *elf32_avr_gc_mark_hook
   PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
 	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
@@ -386,7 +386,7 @@ static void
 avr_info_to_howto_rela (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rela *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
Index: bfd/elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.37
diff -u -p -r1.37 elf32-cris.c
--- bfd/elf32-cris.c	7 Nov 2002 13:28:04 -0000	1.37
+++ bfd/elf32-cris.c	27 Nov 2002 15:52:18 -0000
@@ -31,7 +31,7 @@ static reloc_howto_type * cris_reloc_typ
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 
 static void cris_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 
 static boolean cris_elf_grok_prstatus
   PARAMS ((bfd *abfd, Elf_Internal_Note *note));
@@ -458,7 +458,7 @@ static void
 cris_info_to_howto_rela (abfd, cache_ptr, dst)
      bfd * abfd ATTRIBUTE_UNUSED;
      arelent * cache_ptr;
-     Elf32_Internal_Rela * dst;
+     Elf_Internal_Rela * dst;
 {
   unsigned int r_type;
 
@@ -1079,22 +1079,21 @@ cris_elf_relocate_section (output_bfd, i
 
 		    if (info->shared)
 		      {
-			asection *srelgot;
+			asection *s;
 			Elf_Internal_Rela outrel;
+			bfd_byte *loc;
 
-			srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
-			BFD_ASSERT (srelgot != NULL);
+			s = bfd_get_section_by_name (dynobj, ".rela.got");
+			BFD_ASSERT (s != NULL);
 
 			outrel.r_offset = (sgot->output_section->vma
 					   + sgot->output_offset
 					   + off);
 			outrel.r_info = ELF32_R_INFO (0, R_CRIS_RELATIVE);
 			outrel.r_addend = relocation;
-			bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-						   (((Elf32_External_Rela *)
-						     srelgot->contents)
-						    + srelgot->reloc_count));
-			++srelgot->reloc_count;
+			loc = s->contents;
+			loc += s->reloc_count++ * sizeof (Elf32_External_Rela);
+			bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 		      }
 
 		    local_got_offsets[r_symndx] |= 1;
@@ -1237,6 +1236,7 @@ cris_elf_relocate_section (output_bfd, i
 			  & ELF_LINK_HASH_DEF_REGULAR) == 0)))
 	    {
 	      Elf_Internal_Rela outrel;
+	      bfd_byte *loc;
 	      boolean skip, relocate;
 
 	      /* When generating a shared object, these relocations
@@ -1345,11 +1345,9 @@ cris_elf_relocate_section (output_bfd, i
 		    }
 		}
 
-	      bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-					 (((Elf32_External_Rela *)
-					   sreloc->contents)
-					  + sreloc->reloc_count));
-	      ++sreloc->reloc_count;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
+	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 
 	      /* This reloc will be computed at runtime, so there's no
                  need to do anything now, except for R_CRIS_32 relocations
@@ -1437,6 +1435,7 @@ elf_cris_finish_dynamic_symbol (output_b
       bfd_vma gotplt_offset
 	= ((struct elf_cris_link_hash_entry *) h)->gotplt_offset;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
       boolean has_gotplt = gotplt_offset != 0;
 
       /* Get the index in the procedure linkage table which
@@ -1517,9 +1516,8 @@ elf_cris_finish_dynamic_symbol (output_b
 			   + got_offset);
 	  rela.r_info = ELF32_R_INFO (h->dynindx, R_CRIS_JUMP_SLOT);
 	  rela.r_addend = 0;
-	  bfd_elf32_swap_reloca_out (output_bfd, &rela,
-				     ((Elf32_External_Rela *) srela->contents
-				      + gotplt_index));
+	  loc = srela->contents + gotplt_index * sizeof (Elf32_External_Rela);
+	  bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
 	}
 
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
@@ -1554,6 +1552,7 @@ elf_cris_finish_dynamic_symbol (output_b
       asection *sgot;
       asection *srela;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
       bfd_byte *where;
 
       /* This symbol has an entry in the global offset table.  Set it up.  */
@@ -1587,16 +1586,16 @@ elf_cris_finish_dynamic_symbol (output_b
 	  rela.r_addend = 0;
 	}
 
-      bfd_elf32_swap_reloca_out (output_bfd, &rela,
-				 ((Elf32_External_Rela *) srela->contents
-				  + srela->reloc_count));
-      ++srela->reloc_count;
+      loc = srela->contents;
+      loc += srela->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
     {
       asection *s;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
 
       /* This symbol needs a copy reloc.  Set it up.  */
 
@@ -1613,10 +1612,8 @@ elf_cris_finish_dynamic_symbol (output_b
 		       + h->root.u.def.section->output_offset);
       rela.r_info = ELF32_R_INFO (h->dynindx, R_CRIS_COPY);
       rela.r_addend = 0;
-      bfd_elf32_swap_reloca_out (output_bfd, &rela,
-				 ((Elf32_External_Rela *) s->contents
-				  + s->reloc_count));
-      ++s->reloc_count;
+      loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
Index: bfd/elf32-d10v.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-d10v.c,v
retrieving revision 1.17
diff -u -p -r1.17 elf32-d10v.c
--- bfd/elf32-d10v.c	17 Oct 2002 02:59:15 -0000	1.17
+++ bfd/elf32-d10v.c	27 Nov 2002 15:52:19 -0000
@@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suit
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 static void d10v_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static asection * elf32_d10v_gc_mark_hook
   PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
 	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
@@ -230,7 +234,7 @@ static void
 d10v_info_to_howto_rel (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rel *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
Index: bfd/elf32-d30v.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-d30v.c,v
retrieving revision 1.9
diff -u -p -r1.9 elf32-d30v.c
--- bfd/elf32-d30v.c	25 Jun 2002 06:21:51 -0000	1.9
+++ bfd/elf32-d30v.c	27 Nov 2002 15:52:19 -0000
@@ -28,9 +28,9 @@ Foundation, Inc., 59 Temple Place - Suit
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 static void d30v_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static void d30v_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static bfd_reloc_status_type bfd_elf_d30v_reloc PARAMS ((
      bfd *abfd,
      arelent *reloc_entry,
@@ -522,7 +522,7 @@ static void
 d30v_info_to_howto_rel (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rel *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
@@ -537,7 +537,7 @@ static void
 d30v_info_to_howto_rela (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rela *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
Index: bfd/elf32-dlx.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-dlx.c,v
retrieving revision 1.3
diff -u -p -r1.3 elf32-dlx.c
--- bfd/elf32-dlx.c	8 Jun 2002 07:27:52 -0000	1.3
+++ bfd/elf32-dlx.c	27 Nov 2002 15:52:19 -0000
@@ -28,9 +28,9 @@ int    set_dlx_skip_hi16_flag PARAMS ((i
 static boolean elf32_dlx_check_relocs
   PARAMS ((bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *));
 static void elf32_dlx_info_to_howto
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static void elf32_dlx_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static bfd_reloc_status_type elf32_dlx_relocate16
   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
 static bfd_reloc_status_type elf32_dlx_relocate26
@@ -632,7 +632,7 @@ static void
 elf32_dlx_info_to_howto (abfd, cache_ptr, dst)
      bfd * abfd ATTRIBUTE_UNUSED;
      arelent * cache_ptr ATTRIBUTE_UNUSED;
-     Elf32_Internal_Rela * dst ATTRIBUTE_UNUSED;
+     Elf_Internal_Rela * dst ATTRIBUTE_UNUSED;
 {
   abort ();
 }
@@ -641,7 +641,7 @@ static void
 elf32_dlx_info_to_howto_rel (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rel *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
Index: bfd/elf32-fr30.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-fr30.c,v
retrieving revision 1.17
diff -u -p -r1.17 elf32-fr30.c
--- bfd/elf32-fr30.c	23 Jul 2002 12:29:32 -0000	1.17
+++ bfd/elf32-fr30.c	27 Nov 2002 15:52:19 -0000
@@ -31,7 +31,7 @@ static bfd_reloc_status_type fr30_elf_i3
 static reloc_howto_type * fr30_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 static void fr30_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static boolean fr30_elf_relocate_section
   PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
 	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
@@ -377,7 +377,7 @@ static void
 fr30_info_to_howto_rela (abfd, cache_ptr, dst)
      bfd * abfd ATTRIBUTE_UNUSED;
      arelent * cache_ptr;
-     Elf32_Internal_Rela * dst;
+     Elf_Internal_Rela * dst;
 {
   unsigned int r_type;
 
Index: bfd/elf32-frv.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-frv.c,v
retrieving revision 1.3
diff -u -p -r1.3 elf32-frv.c
--- bfd/elf32-frv.c	23 Jul 2002 12:34:35 -0000	1.3
+++ bfd/elf32-frv.c	27 Nov 2002 15:52:20 -0000
@@ -41,7 +41,7 @@ static bfd_reloc_status_type elf32_frv_r
 static reloc_howto_type *frv_reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
 static void frv_info_to_howto_rela 
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static boolean elf32_frv_relocate_section 
   PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
 static boolean elf32_frv_add_symbol_hook
@@ -581,7 +581,7 @@ static void
 frv_info_to_howto_rela (abfd, cache_ptr, dst)
      bfd * abfd ATTRIBUTE_UNUSED;
      arelent * cache_ptr;
-     Elf32_Internal_Rela * dst;
+     Elf_Internal_Rela * dst;
 {
   unsigned int r_type;
 
Index: bfd/elf32-gen.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-gen.c,v
retrieving revision 1.8
diff -u -p -r1.8 elf32-gen.c
--- bfd/elf32-gen.c	20 Sep 2001 23:30:35 -0000	1.8
+++ bfd/elf32-gen.c	27 Nov 2002 15:52:20 -0000
@@ -41,9 +41,9 @@ static reloc_howto_type dummy =
 	 false);		/* pcrel_offset */
 
 static void elf_generic_info_to_howto
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static void elf_generic_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static boolean elf32_generic_link_add_symbols
   PARAMS ((bfd *, struct bfd_link_info *));
 
@@ -51,7 +51,7 @@ static void
 elf_generic_info_to_howto (abfd, bfd_reloc, elf_reloc)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *bfd_reloc;
-     Elf32_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED;
+     Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED;
 {
   bfd_reloc->howto = &dummy;
 }
@@ -60,7 +60,7 @@ static void
 elf_generic_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *bfd_reloc;
-     Elf32_Internal_Rel *elf_reloc ATTRIBUTE_UNUSED;
+     Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED;
 {
   bfd_reloc->howto = &dummy;
 }
Index: bfd/elf32-h8300.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-h8300.c,v
retrieving revision 1.18
diff -u -p -r1.18 elf32-h8300.c
--- bfd/elf32-h8300.c	15 Nov 2002 11:18:47 -0000	1.18
+++ bfd/elf32-h8300.c	27 Nov 2002 15:52:20 -0000
@@ -29,7 +29,7 @@ static reloc_howto_type *elf32_h8_reloc_
 static void elf32_h8_info_to_howto
   PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static void elf32_h8_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static unsigned long elf32_h8_mach
   PARAMS ((flagword));
 static void elf32_h8_final_write_processing
@@ -261,7 +261,7 @@ static void
 elf32_h8_info_to_howto (abfd, bfd_reloc, elf_reloc)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *bfd_reloc;
-     Elf32_Internal_Rela *elf_reloc;
+     Elf_Internal_Rela *elf_reloc;
 {
   unsigned int r;
   unsigned int i;
@@ -280,7 +280,7 @@ static void
 elf32_h8_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *bfd_reloc;
-     Elf32_Internal_Rel *elf_reloc ATTRIBUTE_UNUSED;
+     Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED;
 {
   unsigned int r;
 
Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.89
diff -u -p -r1.89 elf32-hppa.c
--- bfd/elf32-hppa.c	22 Aug 2002 01:27:19 -0000	1.89
+++ bfd/elf32-hppa.c	27 Nov 2002 15:52:23 -0000
@@ -3774,16 +3774,16 @@ elf32_hppa_relocate_section (output_bfd,
 		       In this case it is relative to the base of the
 		       object because the symbol index is zero.  */
 		    Elf_Internal_Rela outrel;
-		    asection *srelgot = htab->srelgot;
-		    Elf32_External_Rela *loc;
+		    bfd_byte *loc;
+		    asection *s = htab->srelgot;
 
 		    outrel.r_offset = (off
 				       + htab->sgot->output_offset
 				       + htab->sgot->output_section->vma);
 		    outrel.r_info = ELF32_R_INFO (0, R_PARISC_DIR32);
 		    outrel.r_addend = relocation;
-		    loc = (Elf32_External_Rela *) srelgot->contents;
-		    loc += srelgot->reloc_count++;
+		    loc = s->contents;
+		    loc += s->reloc_count++ * sizeof (Elf32_External_Rela);
 		    bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 		  }
 		else
@@ -3864,16 +3864,16 @@ elf32_hppa_relocate_section (output_bfd,
 		      /* Output a dynamic IPLT relocation for this
 			 PLT entry.  */
 		      Elf_Internal_Rela outrel;
-		      asection *srelplt = htab->srelplt;
-		      Elf32_External_Rela *loc;
+		      bfd_byte *loc;
+		      asection *s = htab->srelplt;
 
 		      outrel.r_offset = (off
 					 + htab->splt->output_offset
 					 + htab->splt->output_section->vma);
 		      outrel.r_info = ELF32_R_INFO (0, R_PARISC_IPLT);
 		      outrel.r_addend = relocation;
-		      loc = (Elf32_External_Rela *) srelplt->contents;
-		      loc += srelplt->reloc_count++;
+		      loc = s->contents;
+		      loc += s->reloc_count++ * sizeof (Elf32_External_Rela);
 		      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 		    }
 		  else
@@ -3958,7 +3958,7 @@ elf32_hppa_relocate_section (output_bfd,
 	      Elf_Internal_Rela outrel;
 	      boolean skip;
 	      asection *sreloc;
-	      Elf32_External_Rela *loc;
+	      bfd_byte *loc;
 
 	      /* When generating a shared object, these relocations
 		 are copied into the output file to be resolved at run
@@ -4027,8 +4027,8 @@ elf32_hppa_relocate_section (output_bfd,
 	      if (sreloc == NULL)
 		abort ();
 
-	      loc = (Elf32_External_Rela *) sreloc->contents;
-	      loc += sreloc->reloc_count++;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
 	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 	    }
 	  break;
@@ -4126,7 +4126,7 @@ elf32_hppa_finish_dynamic_symbol (output
       if (! ((struct elf32_hppa_link_hash_entry *) h)->pic_call)
 	{
 	  Elf_Internal_Rela rel;
-	  Elf32_External_Rela *loc;
+	  bfd_byte *loc;
 
 	  /* Create a dynamic IPLT relocation for this entry.  */
 	  rel.r_offset = (h->plt.offset
@@ -4145,8 +4145,8 @@ elf32_hppa_finish_dynamic_symbol (output
 	      rel.r_addend = value;
 	    }
 
-	  loc = (Elf32_External_Rela *) htab->srelplt->contents;
-	  loc += htab->srelplt->reloc_count++;
+	  loc = htab->srelplt->contents;
+	  loc += htab->srelplt->reloc_count++ * sizeof (Elf32_External_Rela);
 	  bfd_elf32_swap_reloca_out (htab->splt->output_section->owner,
 				     &rel, loc);
 	}
@@ -4171,7 +4171,7 @@ elf32_hppa_finish_dynamic_symbol (output
   if (h->got.offset != (bfd_vma) -1)
     {
       Elf_Internal_Rela rel;
-      Elf32_External_Rela *loc;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
@@ -4204,8 +4204,8 @@ elf32_hppa_finish_dynamic_symbol (output
 	  rel.r_addend = 0;
 	}
 
-      loc = (Elf32_External_Rela *) htab->srelgot->contents;
-      loc += htab->srelgot->reloc_count++;
+      loc = htab->srelgot->contents;
+      loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
       bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
     }
 
@@ -4213,7 +4213,7 @@ elf32_hppa_finish_dynamic_symbol (output
     {
       asection *s;
       Elf_Internal_Rela rel;
-      Elf32_External_Rela *loc;
+      bfd_byte *loc;
 
       /* This symbol needs a copy reloc.  Set it up.  */
 
@@ -4229,7 +4229,7 @@ elf32_hppa_finish_dynamic_symbol (output
 		      + h->root.u.def.section->output_section->vma);
       rel.r_addend = 0;
       rel.r_info = ELF32_R_INFO (h->dynindx, R_PARISC_COPY);
-      loc = (Elf32_External_Rela *) s->contents + s->reloc_count++;
+      loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
       bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
     }
 
Index: bfd/elf32-i370.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i370.c,v
retrieving revision 1.24
diff -u -p -r1.24 elf32-i370.c
--- bfd/elf32-i370.c	15 Aug 2002 12:21:39 -0000	1.24
+++ bfd/elf32-i370.c	27 Nov 2002 15:52:24 -0000
@@ -231,7 +231,7 @@ static reloc_howto_type *i370_elf_reloc_
   PARAMS ((bfd *, bfd_reloc_code_real_type));
 
 static void i370_elf_info_to_howto PARAMS ((bfd *abfd, arelent *cache_ptr,
-					    Elf32_Internal_Rela *dst));
+					    Elf_Internal_Rela *dst));
 static boolean i370_elf_set_private_flags PARAMS ((bfd *, flagword));
 
 /* Initialize the i370_elf_howto_table, so that linear accesses can be done.  */
@@ -292,10 +292,10 @@ static boolean i370_elf_create_dynamic_s
 							 struct bfd_link_info *));
 
 static boolean i370_elf_section_from_shdr PARAMS ((bfd *,
-						   Elf32_Internal_Shdr *,
+						   Elf_Internal_Shdr *,
 						   const char *));
 static boolean i370_elf_fake_sections PARAMS ((bfd *,
-					       Elf32_Internal_Shdr *,
+					       Elf_Internal_Shdr *,
 					       asection *));
 #if 0
 static elf_linker_section_t *i370_elf_create_linker_section
@@ -328,7 +328,7 @@ static void
 i370_elf_info_to_howto (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rela *dst;
+     Elf_Internal_Rela *dst;
 {
   if (!i370_elf_howto_table[ R_I370_ADDR31 ])	/* Initialize howto table */
     i370_elf_howto_init ();
@@ -402,7 +402,7 @@ i370_elf_merge_private_bfd_data (ibfd, o
 static boolean
 i370_elf_section_from_shdr (abfd, hdr, name)
      bfd *abfd;
-     Elf32_Internal_Shdr *hdr;
+     Elf_Internal_Shdr *hdr;
      const char *name;
 {
   asection *newsect;
@@ -432,7 +432,7 @@ i370_elf_section_from_shdr (abfd, hdr, n
 static boolean
 i370_elf_fake_sections (abfd, shdr, asect)
      bfd *abfd ATTRIBUTE_UNUSED;
-     Elf32_Internal_Shdr *shdr;
+     Elf_Internal_Shdr *shdr;
      asection *asect;
 {
   if ((asect->flags & SEC_EXCLUDE) != 0)
@@ -1388,6 +1388,7 @@ i370_elf_relocate_section (output_bfd, i
 	      && r_symndx != 0)
 	    {
 	      Elf_Internal_Rela outrel;
+	      bfd_byte *loc;
 	      int skip;
 
 #ifdef DEBUG
@@ -1493,11 +1494,9 @@ i370_elf_relocate_section (output_bfd, i
 		    }
 		}
 
-	      bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-					 (((Elf32_External_Rela *)
-					   sreloc->contents)
-					  + sreloc->reloc_count));
-	      ++sreloc->reloc_count;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
+	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 
 	      /* This reloc will be computed at runtime, so there's no
                  need to do anything now, unless this is a RELATIVE
Index: bfd/elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.89
diff -u -p -r1.89 elf32-i386.c
--- bfd/elf32-i386.c	6 Nov 2002 11:38:35 -0000	1.89
+++ bfd/elf32-i386.c	27 Nov 2002 15:52:26 -0000
@@ -27,9 +27,9 @@ Foundation, Inc., 59 Temple Place - Suit
 static reloc_howto_type *elf_i386_reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
 static void elf_i386_info_to_howto
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static void elf_i386_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static boolean elf_i386_is_local_label_name
   PARAMS ((bfd *, const char *));
 static boolean elf_i386_grok_prstatus
@@ -70,7 +70,7 @@ static boolean allocate_dynrelocs
 static boolean readonly_dynrelocs
   PARAMS ((struct elf_link_hash_entry *, PTR));
 static boolean elf_i386_fake_sections
-  PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *));
+  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
 static boolean elf_i386_size_dynamic_sections
   PARAMS ((bfd *, struct bfd_link_info *));
 static bfd_vma dtpoff_base
@@ -374,9 +374,9 @@ elf_i386_reloc_type_lookup (abfd, code)
 
 static void
 elf_i386_info_to_howto (abfd, cache_ptr, dst)
-     bfd		*abfd ATTRIBUTE_UNUSED;
-     arelent		*cache_ptr ATTRIBUTE_UNUSED;
-     Elf32_Internal_Rela *dst ATTRIBUTE_UNUSED;
+     bfd *abfd ATTRIBUTE_UNUSED;
+     arelent *cache_ptr ATTRIBUTE_UNUSED;
+     Elf_Internal_Rela *dst ATTRIBUTE_UNUSED;
 {
   abort ();
 }
@@ -385,7 +385,7 @@ static void
 elf_i386_info_to_howto_rel (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rel *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type = ELF32_R_TYPE (dst->r_info);
   unsigned int indx;
@@ -1995,7 +1995,7 @@ elf_i386_size_dynamic_sections (output_b
 static boolean
 elf_i386_fake_sections (abfd, hdr, sec)
      bfd *abfd ATTRIBUTE_UNUSED;
-     Elf32_Internal_Shdr *hdr;
+     Elf_Internal_Shdr *hdr;
      asection *sec;
 {
   register const char *name;
@@ -2340,20 +2340,20 @@ elf_i386_relocate_section (output_bfd, i
 
 		  if (info->shared)
 		    {
-		      asection *srelgot;
-		      Elf_Internal_Rel outrel;
-		      Elf32_External_Rel *loc;
+		      asection *s;
+		      Elf_Internal_Rela outrel;
+		      bfd_byte *loc;
 
-		      srelgot = htab->srelgot;
-		      if (srelgot == NULL)
+		      s = htab->srelgot;
+		      if (s == NULL)
 			abort ();
 
 		      outrel.r_offset = (htab->sgot->output_section->vma
 					 + htab->sgot->output_offset
 					 + off);
 		      outrel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
-		      loc = (Elf32_External_Rel *) srelgot->contents;
-		      loc += srelgot->reloc_count++;
+		      loc = s->contents;
+		      loc += s->reloc_count++ * sizeof (Elf32_External_Rel);
 		      bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
 		    }
 
@@ -2436,10 +2436,10 @@ elf_i386_relocate_section (output_bfd, i
 		      || h->root.type == bfd_link_hash_undefweak
 		      || h->root.type == bfd_link_hash_undefined)))
 	    {
-	      Elf_Internal_Rel outrel;
+	      Elf_Internal_Rela outrel;
+	      bfd_byte *loc;
 	      boolean skip, relocate;
 	      asection *sreloc;
-	      Elf32_External_Rel *loc;
 
 	      /* When generating a shared object, these relocations
 		 are copied into the output file to be resolved at run
@@ -2479,8 +2479,8 @@ elf_i386_relocate_section (output_bfd, i
 	      if (sreloc == NULL)
 		abort ();
 
-	      loc = (Elf32_External_Rel *) sreloc->contents;
-	      loc += sreloc->reloc_count++;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
 	      bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
 
 	      /* If this reloc is against an external symbol, we do
@@ -2495,9 +2495,9 @@ elf_i386_relocate_section (output_bfd, i
 	case R_386_TLS_IE:
 	  if (info->shared)
 	    {
-	      Elf_Internal_Rel outrel;
+	      Elf_Internal_Rela outrel;
+	      bfd_byte *loc;
 	      asection *sreloc;
-	      Elf32_External_Rel *loc;
 
 	      outrel.r_offset = rel->r_offset
 				+ input_section->output_section->vma
@@ -2506,8 +2506,8 @@ elf_i386_relocate_section (output_bfd, i
 	      sreloc = elf_section_data (input_section)->sreloc;
 	      if (sreloc == NULL)
 		abort ();
-	      loc = (Elf32_External_Rel *) sreloc->contents;
-	      loc += sreloc->reloc_count++;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
 	      bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
 	    }
 	  /* Fall through */
@@ -2726,8 +2726,8 @@ elf_i386_relocate_section (output_bfd, i
 	    off &= ~1;
           else
 	    {
-	      Elf_Internal_Rel outrel;
-	      Elf32_External_Rel *loc;
+	      Elf_Internal_Rela outrel;
+	      bfd_byte *loc;
 	      int dr_type, indx;
 
 	      if (htab->srelgot == NULL)
@@ -2753,8 +2753,8 @@ elf_i386_relocate_section (output_bfd, i
 		bfd_put_32 (output_bfd, 0,
 			    htab->sgot->contents + off);
 	      outrel.r_info = ELF32_R_INFO (indx, dr_type);
-	      loc = (Elf32_External_Rel *) htab->srelgot->contents;
-	      loc += htab->srelgot->reloc_count++;
+	      loc = htab->srelgot->contents;
+	      loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rel);
 	      bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
 
 	      if (r_type == R_386_TLS_GD)
@@ -2774,9 +2774,8 @@ elf_i386_relocate_section (output_bfd, i
 						    R_386_TLS_DTPOFF32);
 		      outrel.r_offset += 4;
 		      htab->srelgot->reloc_count++;
-		      loc++;
-		      bfd_elf32_swap_reloc_out (output_bfd, &outrel,
-						loc);
+		      loc += sizeof (Elf32_External_Rel);
+		      bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
 		    }
 		}
 	      else if (tls_type == GOT_TLS_IE_BOTH)
@@ -2787,7 +2786,7 @@ elf_i386_relocate_section (output_bfd, i
 		  outrel.r_info = ELF32_R_INFO (indx, R_386_TLS_TPOFF);
 		  outrel.r_offset += 4;
 		  htab->srelgot->reloc_count++;
-		  loc++;
+		  loc += sizeof (Elf32_External_Rel);
 		  bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
 		}
 
@@ -2906,8 +2905,8 @@ elf_i386_relocate_section (output_bfd, i
 	    off &= ~1;
 	  else
 	    {
-	      Elf_Internal_Rel outrel;
-	      Elf32_External_Rel *loc;
+	      Elf_Internal_Rela outrel;
+	      bfd_byte *loc;
 
 	      if (htab->srelgot == NULL)
 		abort ();
@@ -2920,8 +2919,8 @@ elf_i386_relocate_section (output_bfd, i
 	      bfd_put_32 (output_bfd, 0,
 			  htab->sgot->contents + off + 4);
 	      outrel.r_info = ELF32_R_INFO (0, R_386_TLS_DTPMOD32);
-	      loc = (Elf32_External_Rel *) htab->srelgot->contents;
-	      loc += htab->srelgot->reloc_count++;
+	      loc = htab->srelgot->contents;
+	      loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rel);
 	      bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
 	      htab->tls_ldm_got.offset |= 1;
 	    }
@@ -2941,9 +2940,9 @@ elf_i386_relocate_section (output_bfd, i
 	case R_386_TLS_LE:
 	  if (info->shared)
 	    {
-	      Elf_Internal_Rel outrel;
+	      Elf_Internal_Rela outrel;
 	      asection *sreloc;
-	      Elf32_External_Rel *loc;
+	      bfd_byte *loc;
 	      int indx;
 
 	      outrel.r_offset = rel->r_offset
@@ -2960,8 +2959,8 @@ elf_i386_relocate_section (output_bfd, i
 	      sreloc = elf_section_data (input_section)->sreloc;
 	      if (sreloc == NULL)
 		abort ();
-	      loc = (Elf32_External_Rel *) sreloc->contents;
-	      loc += sreloc->reloc_count++;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
 	      bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
 	      if (indx)
 		continue;
@@ -3057,8 +3056,8 @@ elf_i386_finish_dynamic_symbol (output_b
     {
       bfd_vma plt_index;
       bfd_vma got_offset;
-      Elf_Internal_Rel rel;
-      Elf32_External_Rel *loc;
+      Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the procedure linkage table.  Set
 	 it up.  */
@@ -3117,7 +3116,7 @@ elf_i386_finish_dynamic_symbol (output_b
 		      + htab->sgotplt->output_offset
 		      + got_offset);
       rel.r_info = ELF32_R_INFO (h->dynindx, R_386_JUMP_SLOT);
-      loc = (Elf32_External_Rel *) htab->srelplt->contents + plt_index;
+      loc = htab->srelplt->contents + plt_index * sizeof (Elf32_External_Rel);
       bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
 
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
@@ -3135,8 +3134,8 @@ elf_i386_finish_dynamic_symbol (output_b
       && elf_i386_hash_entry(h)->tls_type != GOT_TLS_GD
       && (elf_i386_hash_entry(h)->tls_type & GOT_TLS_IE) == 0)
     {
-      Elf_Internal_Rel rel;
-      Elf32_External_Rel *loc;
+      Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
@@ -3170,15 +3169,15 @@ elf_i386_finish_dynamic_symbol (output_b
 	  rel.r_info = ELF32_R_INFO (h->dynindx, R_386_GLOB_DAT);
 	}
 
-      loc = (Elf32_External_Rel *) htab->srelgot->contents;
-      loc += htab->srelgot->reloc_count++;
+      loc = htab->srelgot->contents;
+      loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rel);
       bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
     }
 
   if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
     {
-      Elf_Internal_Rel rel;
-      Elf32_External_Rel *loc;
+      Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol needs a copy reloc.  Set it up.  */
 
@@ -3192,8 +3191,8 @@ elf_i386_finish_dynamic_symbol (output_b
 		      + h->root.u.def.section->output_section->vma
 		      + h->root.u.def.section->output_offset);
       rel.r_info = ELF32_R_INFO (h->dynindx, R_386_COPY);
-      loc = (Elf32_External_Rel *) htab->srelbss->contents;
-      loc += htab->srelbss->reloc_count++;
+      loc = htab->srelbss->contents;
+      loc += htab->srelbss->reloc_count++ * sizeof (Elf32_External_Rel);
       bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
     }
 
Index: bfd/elf32-i860.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i860.c,v
retrieving revision 1.17
diff -u -p -r1.17 elf32-i860.c
--- bfd/elf32-i860.c	23 Jul 2002 12:29:32 -0000	1.17
+++ bfd/elf32-i860.c	27 Nov 2002 15:52:26 -0000
@@ -34,7 +34,7 @@ static reloc_howto_type *elf32_i860_relo
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 
 static void elf32_i860_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 
 static bfd_reloc_status_type elf32_i860_relocate_splitn
   PARAMS ((bfd *,  Elf_Internal_Rela *, bfd_byte *, bfd_vma));
@@ -694,7 +694,7 @@ static void
 elf32_i860_info_to_howto_rela (abfd, bfd_reloc, elf_reloc)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *bfd_reloc;
-     Elf64_Internal_Rela *elf_reloc;
+     Elf_Internal_Rela *elf_reloc;
 {
   bfd_reloc->howto
     = lookup_howto ((unsigned) ELF32_R_TYPE (elf_reloc->r_info));
Index: bfd/elf32-i960.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i960.c,v
retrieving revision 1.7
diff -u -p -r1.7 elf32-i960.c
--- bfd/elf32-i960.c	21 Aug 2001 08:40:23 -0000	1.7
+++ bfd/elf32-i960.c	27 Nov 2002 15:52:27 -0000
@@ -28,9 +28,9 @@ static bfd_reloc_status_type elf32_i960_
 static reloc_howto_type *elf32_i960_reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
 static void elf32_i960_info_to_howto
-  PARAMS ((bfd *, arelent *cache_ptr, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *cache_ptr, Elf_Internal_Rela *));
 static void elf32_i960_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 
 #define USE_REL 1
 
@@ -77,7 +77,7 @@ static void
 elf32_i960_info_to_howto (abfd, cache_ptr, dst)
      bfd		*abfd ATTRIBUTE_UNUSED;
      arelent		*cache_ptr ATTRIBUTE_UNUSED;
-     Elf32_Internal_Rela *dst ATTRIBUTE_UNUSED;
+     Elf_Internal_Rela *dst ATTRIBUTE_UNUSED;
 {
   abort ();
 }
@@ -86,7 +86,7 @@ static void
 elf32_i960_info_to_howto_rel (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rel *dst;
+     Elf_Internal_Rela *dst;
 {
   enum elf_i960_reloc_type type;
 
Index: bfd/elf32-ip2k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ip2k.c,v
retrieving revision 1.4
diff -u -p -r1.4 elf32-ip2k.c
--- bfd/elf32-ip2k.c	17 Oct 2002 18:27:01 -0000	1.4
+++ bfd/elf32-ip2k.c	27 Nov 2002 15:52:27 -0000
@@ -35,10 +35,10 @@ struct misc
 
 /* Prototypes.  */
 static reloc_howto_type *    ip2k_reloc_type_lookup               PARAMS ((bfd *, bfd_reloc_code_real_type));
-static void                  ip2k_info_to_howto_rela              PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+static void                  ip2k_info_to_howto_rela              PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static asection *            ip2k_elf_gc_mark_hook                PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym *));
 static boolean               ip2k_elf_gc_sweep_hook               PARAMS ((bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *));
-static bfd_vma               symbol_value                         PARAMS ((bfd *, Elf_Internal_Shdr *, Elf32_Internal_Sym *, Elf_Internal_Rela *));
+static bfd_vma               symbol_value                         PARAMS ((bfd *, Elf_Internal_Shdr *, Elf_Internal_Sym *, Elf_Internal_Rela *));
 static void                  adjust_all_relocations               PARAMS ((bfd *, asection *, bfd_vma, bfd_vma, int, int));
 static boolean               ip2k_elf_relax_delete_bytes          PARAMS ((bfd *, asection *, bfd_vma, int));
 static boolean               ip2k_elf_relax_add_bytes             PARAMS ((bfd *, asection *, bfd_vma, const bfd_byte *, int, int));
@@ -256,7 +256,7 @@ static bfd_vma
 symbol_value (abfd, symtab_hdr, isymbuf, irel)
      bfd *abfd;
      Elf_Internal_Shdr *symtab_hdr;
-     Elf32_Internal_Sym *isymbuf;
+     Elf_Internal_Sym *isymbuf;
      Elf_Internal_Rela *irel;   
 {
   if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
@@ -1164,7 +1164,7 @@ adjust_all_relocations (abfd, sec, addr,
   unsigned int symcount;
     
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
-  isymbuf = (Elf32_Internal_Sym *) symtab_hdr->contents;
+  isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
 
   shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
 
@@ -1265,7 +1265,7 @@ add_page_insn (abfd, sec, irel, misc)
     return false;
   else
     {
-       Elf32_Internal_Rela * jrel = irel - 1;
+       Elf_Internal_Rela * jrel = irel - 1;
 
        /* Add relocation for PAGE insn added.  */
        if (ELF32_R_TYPE (jrel->r_info) != R_IP2K_NONE)
@@ -1360,7 +1360,7 @@ static void
 ip2k_info_to_howto_rela (abfd, cache_ptr, dst)
      bfd * abfd ATTRIBUTE_UNUSED;
      arelent * cache_ptr;
-     Elf32_Internal_Rela * dst;
+     Elf_Internal_Rela * dst;
 {
   unsigned int r_type;
 
Index: bfd/elf32-m32r.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m32r.c,v
retrieving revision 1.28
diff -u -p -r1.28 elf32-m32r.c
--- bfd/elf32-m32r.c	17 Oct 2002 02:59:15 -0000	1.28
+++ bfd/elf32-m32r.c	27 Nov 2002 15:52:28 -0000
@@ -43,7 +43,7 @@ static bfd_reloc_status_type m32r_elf_sd
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 static void m32r_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 boolean _bfd_m32r_elf_section_from_bfd_section
   PARAMS ((bfd *, asection *, int *));
 void _bfd_m32r_elf_symbol_processing
@@ -756,7 +756,7 @@ static void
 m32r_info_to_howto_rel (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rel *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
Index: bfd/elf32-m68hc11.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68hc11.c,v
retrieving revision 1.12
diff -u -p -r1.12 elf32-m68hc11.c
--- bfd/elf32-m68hc11.c	17 Oct 2002 02:59:15 -0000	1.12
+++ bfd/elf32-m68hc11.c	27 Nov 2002 15:52:29 -0000
@@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suit
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
 static void m68hc11_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 
 static bfd_reloc_status_type m68hc11_elf_ignore_reloc
   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
@@ -392,7 +392,7 @@ static void
 m68hc11_info_to_howto_rel (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rel *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
Index: bfd/elf32-m68hc12.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68hc12.c,v
retrieving revision 1.9
diff -u -p -r1.9 elf32-m68hc12.c
--- bfd/elf32-m68hc12.c	17 Oct 2002 02:59:15 -0000	1.9
+++ bfd/elf32-m68hc12.c	27 Nov 2002 15:52:29 -0000
@@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suit
 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
 static void m68hc11_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 
 static bfd_reloc_status_type m68hc11_elf_ignore_reloc
   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
@@ -579,7 +579,7 @@ static void
 m68hc11_info_to_howto_rel (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rel *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
Index: bfd/elf32-m68k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68k.c,v
retrieving revision 1.46
diff -u -p -r1.46 elf32-m68k.c
--- bfd/elf32-m68k.c	23 Jul 2002 12:29:32 -0000	1.46
+++ bfd/elf32-m68k.c	27 Nov 2002 15:52:31 -0000
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suit
 static reloc_howto_type *reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
 static void rtype_to_howto
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static struct bfd_hash_entry *elf_m68k_link_hash_newfunc
   PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
 static struct bfd_link_hash_table *elf_m68k_link_hash_table_create
@@ -1503,22 +1503,21 @@ elf_m68k_relocate_section (output_bfd, i
 
 		    if (info->shared)
 		      {
-			asection *srelgot;
+			asection *s;
 			Elf_Internal_Rela outrel;
+			bfd_byte *loc;
 
-			srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
-			BFD_ASSERT (srelgot != NULL);
+			s = bfd_get_section_by_name (dynobj, ".rela.got");
+			BFD_ASSERT (s != NULL);
 
 			outrel.r_offset = (sgot->output_section->vma
 					   + sgot->output_offset
 					   + off);
 			outrel.r_info = ELF32_R_INFO (0, R_68K_RELATIVE);
 			outrel.r_addend = relocation;
-			bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-						   (((Elf32_External_Rela *)
-						     srelgot->contents)
-						    + srelgot->reloc_count));
-			++srelgot->reloc_count;
+			loc = s->contents;
+			loc += s->reloc_count++ * sizeof (Elf32_External_Rela);
+			bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 		      }
 
 		    local_got_offsets[r_symndx] |= 1;
@@ -1609,6 +1608,7 @@ elf_m68k_relocate_section (output_bfd, i
 			  & ELF_LINK_HASH_DEF_REGULAR) == 0)))
 	    {
 	      Elf_Internal_Rela outrel;
+	      bfd_byte *loc;
 	      boolean skip, relocate;
 
 	      /* When generating a shared object, these relocations
@@ -1703,11 +1703,9 @@ elf_m68k_relocate_section (output_bfd, i
 		    }
 		}
 
-	      bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-					 (((Elf32_External_Rela *)
-					   sreloc->contents)
-					  + sreloc->reloc_count));
-	      ++sreloc->reloc_count;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
+	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 
 	      /* This reloc will be computed at runtime, so there's no
                  need to do anything now, except for R_68K_32
@@ -1791,6 +1789,7 @@ elf_m68k_finish_dynamic_symbol (output_b
       bfd_vma plt_index;
       bfd_vma got_offset;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the procedure linkage table.  Set
 	 it up.  */
@@ -1863,9 +1862,8 @@ elf_m68k_finish_dynamic_symbol (output_b
 		       + got_offset);
       rela.r_info = ELF32_R_INFO (h->dynindx, R_68K_JMP_SLOT);
       rela.r_addend = 0;
-      bfd_elf32_swap_reloca_out (output_bfd, &rela,
-				 ((Elf32_External_Rela *) srela->contents
-				  + plt_index));
+      loc = srela->contents + plt_index * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
 
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
 	{
@@ -1880,6 +1878,7 @@ elf_m68k_finish_dynamic_symbol (output_b
       asection *sgot;
       asection *srela;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
@@ -1914,16 +1913,16 @@ elf_m68k_finish_dynamic_symbol (output_b
 	  rela.r_addend = 0;
 	}
 
-      bfd_elf32_swap_reloca_out (output_bfd, &rela,
-				 ((Elf32_External_Rela *) srela->contents
-				  + srela->reloc_count));
-      ++srela->reloc_count;
+      loc = srela->contents;
+      loc += srela->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
     {
       asection *s;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
 
       /* This symbol needs a copy reloc.  Set it up.  */
 
@@ -1940,10 +1939,8 @@ elf_m68k_finish_dynamic_symbol (output_b
 		       + h->root.u.def.section->output_offset);
       rela.r_info = ELF32_R_INFO (h->dynindx, R_68K_COPY);
       rela.r_addend = 0;
-      bfd_elf32_swap_reloca_out (output_bfd, &rela,
-				 ((Elf32_External_Rela *) s->contents
-				  + s->reloc_count));
-      ++s->reloc_count;
+      loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
Index: bfd/elf32-mcore.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mcore.c,v
retrieving revision 1.24
diff -u -p -r1.24 elf32-mcore.c
--- bfd/elf32-mcore.c	23 Jul 2002 12:29:32 -0000	1.24
+++ bfd/elf32-mcore.c	27 Nov 2002 15:52:31 -0000
@@ -36,7 +36,7 @@ static void mcore_elf_howto_init
 static reloc_howto_type * mcore_elf_reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
 static void mcore_elf_info_to_howto
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static boolean mcore_elf_set_private_flags
   PARAMS ((bfd *, flagword));
 static boolean mcore_elf_merge_private_bfd_data
@@ -275,7 +275,7 @@ static void
 mcore_elf_info_to_howto (abfd, cache_ptr, dst)
      bfd * abfd ATTRIBUTE_UNUSED;
      arelent * cache_ptr;
-     Elf32_Internal_Rela * dst;
+     Elf_Internal_Rela * dst;
 {
   if (! mcore_elf_howto_table [R_MCORE_PCRELIMM8BY4])	/* Initialize howto table if needed */
     mcore_elf_howto_init ();
Index: bfd/elf32-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mips.c,v
retrieving revision 1.158
diff -u -p -r1.158 elf32-mips.c
--- bfd/elf32-mips.c	7 Aug 2002 04:32:14 -0000	1.158
+++ bfd/elf32-mips.c	27 Nov 2002 15:52:32 -0000
@@ -62,9 +62,9 @@ static reloc_howto_type *bfd_elf32_bfd_r
 static reloc_howto_type *mips_elf32_rtype_to_howto
   PARAMS ((unsigned int, boolean));
 static void mips_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static void mips_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static boolean mips_elf_sym_is_global PARAMS ((bfd *, asymbol *));
 static boolean mips_elf32_object_p PARAMS ((bfd *));
 static boolean mips_elf_is_local_label_name
@@ -1464,7 +1464,7 @@ bfd_elf32_bfd_reloc_type_lookup (abfd, c
     }
 }
 
-/* Given a MIPS Elf32_Internal_Rel, fill in an arelent structure.  */
+/* Given a MIPS Elf_Internal_Rel, fill in an arelent structure.  */
 
 static reloc_howto_type *
 mips_elf32_rtype_to_howto (r_type, rela_p)
@@ -1497,13 +1497,13 @@ mips_elf32_rtype_to_howto (r_type, rela_
     }
 }
 
-/* Given a MIPS Elf32_Internal_Rel, fill in an arelent structure.  */
+/* Given a MIPS Elf_Internal_Rel, fill in an arelent structure.  */
 
 static void
 mips_info_to_howto_rel (abfd, cache_ptr, dst)
      bfd *abfd;
      arelent *cache_ptr;
-     Elf32_Internal_Rel *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
@@ -1520,21 +1520,18 @@ mips_info_to_howto_rel (abfd, cache_ptr,
     cache_ptr->addend = elf_gp (abfd);
 }
 
-/* Given a MIPS Elf32_Internal_Rela, fill in an arelent structure.  */
+/* Given a MIPS Elf_Internal_Rela, fill in an arelent structure.  */
 
 static void
 mips_info_to_howto_rela (abfd, cache_ptr, dst)
      bfd *abfd;
      arelent *cache_ptr;
-     Elf32_Internal_Rela *dst;
+     Elf_Internal_Rela *dst;
 {
-  /* Since an Elf32_Internal_Rel is an initial prefix of an
-     Elf32_Internal_Rela, we can just use mips_info_to_howto_rel
-     above.  */
-  mips_info_to_howto_rel (abfd, cache_ptr, (Elf32_Internal_Rel *) dst);
+  mips_info_to_howto_rel (abfd, cache_ptr, dst);
 
   /* If we ever need to do any extra processing with dst->r_addend
-     (the field omitted in an Elf32_Internal_Rel) we can do it here.  */
+     (the field omitted in an Elf_Internal_Rel) we can do it here.  */
 }
 
 /* Determine whether a symbol is global for the purposes of splitting
Index: bfd/elf32-openrisc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-openrisc.c,v
retrieving revision 1.11
diff -u -p -r1.11 elf32-openrisc.c
--- bfd/elf32-openrisc.c	23 Jul 2002 12:29:32 -0000	1.11
+++ bfd/elf32-openrisc.c	27 Nov 2002 15:52:32 -0000
@@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suit
 static reloc_howto_type *openrisc_reloc_type_lookup
   PARAMS ((bfd * , bfd_reloc_code_real_type));
 static void openrisc_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static boolean openrisc_elf_relocate_section
   PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
 	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
@@ -246,7 +246,7 @@ static void
 openrisc_info_to_howto_rela (abfd, cache_ptr, dst)
      bfd * abfd ATTRIBUTE_UNUSED;
      arelent * cache_ptr;
-     Elf32_Internal_Rela * dst;
+     Elf_Internal_Rela * dst;
 {
   unsigned int r_type;
 
Index: bfd/elf32-or32.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-or32.c,v
retrieving revision 1.3
diff -u -p -r1.3 elf32-or32.c
--- bfd/elf32-or32.c	17 Oct 2002 02:59:15 -0000	1.3
+++ bfd/elf32-or32.c	27 Nov 2002 15:52:32 -0000
@@ -26,7 +26,7 @@
 #include "libiberty.h"
 
 static reloc_howto_type *     bfd_elf32_bfd_reloc_type_lookup  PARAMS ((bfd *, bfd_reloc_code_real_type));
-static void                   or32_info_to_howto_rel           PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+static void                   or32_info_to_howto_rel           PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static boolean                or32_elf_object_p                PARAMS ((bfd *));
 static void                   or32_elf_final_write_processing  PARAMS ((bfd *, boolean));
 static bfd_reloc_status_type  or32_elf_32_reloc                PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
@@ -221,7 +218,7 @@ static void
 or32_info_to_howto_rel (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rel *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.54
diff -u -p -r1.54 elf32-ppc.c
--- bfd/elf32-ppc.c	6 Nov 2002 11:38:35 -0000	1.54
+++ bfd/elf32-ppc.c	27 Nov 2002 15:52:34 -0000
@@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place - Suit
 static reloc_howto_type *ppc_elf_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 static void ppc_elf_info_to_howto
-  PARAMS ((bfd *abfd, arelent *cache_ptr, Elf32_Internal_Rela *dst));
+  PARAMS ((bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst));
 static void ppc_elf_howto_init PARAMS ((void));
 static int ppc_elf_sort_rela PARAMS ((const PTR, const PTR));
 static boolean ppc_elf_relax_section
@@ -56,10 +56,10 @@ static boolean ppc_elf_create_dynamic_se
   PARAMS ((bfd *, struct bfd_link_info *));
 
 static boolean ppc_elf_section_from_shdr PARAMS ((bfd *,
-						  Elf32_Internal_Shdr *,
+						  Elf_Internal_Shdr *,
 						  const char *));
 static boolean ppc_elf_fake_sections
-  PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *));
+  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
 
 static elf_linker_section_t *ppc_elf_create_linker_section
   PARAMS ((bfd *abfd,
@@ -1333,7 +1333,7 @@ static void
 ppc_elf_info_to_howto (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rela *dst;
+     Elf_Internal_Rela *dst;
 {
   if (!ppc_elf_howto_table[R_PPC_ADDR32])
     /* Initialize howto table if needed.  */
@@ -1511,7 +1511,7 @@ ppc_elf_merge_private_bfd_data (ibfd, ob
 static boolean
 ppc_elf_section_from_shdr (abfd, hdr, name)
      bfd *abfd;
-     Elf32_Internal_Shdr *hdr;
+     Elf_Internal_Shdr *hdr;
      const char *name;
 {
   asection *newsect;
@@ -1537,7 +1537,7 @@ ppc_elf_section_from_shdr (abfd, hdr, na
 static boolean
 ppc_elf_fake_sections (abfd, shdr, asect)
      bfd *abfd ATTRIBUTE_UNUSED;
-     Elf32_Internal_Shdr *shdr;
+     Elf_Internal_Shdr *shdr;
      asection *asect;
 {
   if ((asect->flags & SEC_EXCLUDE) != 0)
@@ -2664,6 +2664,7 @@ ppc_elf_finish_dynamic_symbol (output_bf
       asection *splt;
       asection *srela;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
       bfd_vma reloc_index;
 
 #ifdef DEBUG
@@ -2692,9 +2693,8 @@ ppc_elf_finish_dynamic_symbol (output_bf
       reloc_index = (h->plt.offset - PLT_INITIAL_ENTRY_SIZE) / PLT_SLOT_SIZE;
       if (reloc_index > PLT_NUM_SINGLE_ENTRIES)
 	reloc_index -= (reloc_index - PLT_NUM_SINGLE_ENTRIES) / 2;
-      bfd_elf32_swap_reloca_out (output_bfd, &rela,
-				 ((Elf32_External_Rela *) srela->contents
-				  + reloc_index));
+      loc = srela->contents + reloc_index * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
 
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
 	{
@@ -2716,6 +2716,7 @@ ppc_elf_finish_dynamic_symbol (output_bf
       asection *sgot;
       asection *srela;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
          up.  */
@@ -2748,16 +2749,16 @@ ppc_elf_finish_dynamic_symbol (output_bf
 	}
 
       bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
-      bfd_elf32_swap_reloca_out (output_bfd, &rela,
-				 ((Elf32_External_Rela *) srela->contents
-				  + srela->reloc_count));
-      ++srela->reloc_count;
+      loc = srela->contents;
+      loc += srela->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
     {
       asection *s;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
 
       /* This symbols needs a copy reloc.  Set it up.  */
 
@@ -2780,10 +2781,8 @@ ppc_elf_finish_dynamic_symbol (output_bf
 		       + h->root.u.def.section->output_offset);
       rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_COPY);
       rela.r_addend = 0;
-      bfd_elf32_swap_reloca_out (output_bfd, &rela,
-				 ((Elf32_External_Rela *) s->contents
-				  + s->reloc_count));
-      ++s->reloc_count;
+      loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
 #ifdef DEBUG
@@ -3181,6 +3180,7 @@ ppc_elf_relocate_section (output_bfd, in
 	  if (info->shared && r_symndx != 0)
 	    {
 	      Elf_Internal_Rela outrel;
+	      bfd_byte *loc;
 	      int skip;
 
 #ifdef DEBUG
@@ -3281,11 +3281,9 @@ ppc_elf_relocate_section (output_bfd, in
 		    }
 		}
 
-	      bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-					 (((Elf32_External_Rela *)
-					   sreloc->contents)
-					  + sreloc->reloc_count));
-	      ++sreloc->reloc_count;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
+	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 
 	      if (skip == -1)
 		continue;
@@ -3401,6 +3399,7 @@ ppc_elf_relocate_section (output_bfd, in
 		    {
 		      asection *srelgot;
 		      Elf_Internal_Rela outrel;
+		      bfd_byte *loc;
 
 		      /* We need to generate a R_PPC_RELATIVE reloc
 			 for the dynamic linker.  */
@@ -3412,11 +3411,9 @@ ppc_elf_relocate_section (output_bfd, in
 					 + off);
 		      outrel.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE);
 		      outrel.r_addend = relocation;
-		      bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-						 (((Elf32_External_Rela *)
-						   srelgot->contents)
-						  + srelgot->reloc_count));
-		      ++srelgot->reloc_count;
+		      loc = srelgot->contents;
+		      loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
+		      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 		      relocation = 0;
 		    }
 
Index: bfd/elf32-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-s390.c,v
retrieving revision 1.30
diff -u -p -r1.30 elf32-s390.c
--- bfd/elf32-s390.c	22 Aug 2002 01:27:19 -0000	1.30
+++ bfd/elf32-s390.c	27 Nov 2002 15:52:36 -0000
@@ -1788,7 +1788,7 @@ elf_s390_relocate_section (output_bfd, i
                     {
                       asection *srelgot;
                       Elf_Internal_Rela outrel;
-		      Elf32_External_Rela *loc;
+		      bfd_byte *loc;
 
                       srelgot = htab->srelgot;
 		      if (srelgot == NULL)
@@ -1799,8 +1799,8 @@ elf_s390_relocate_section (output_bfd, i
                                          + off);
                       outrel.r_info = ELF32_R_INFO (0, R_390_RELATIVE);
 		      outrel.r_addend = relocation;
-		      loc = (Elf32_External_Rela *) srelgot->contents;
-		      loc += srelgot->reloc_count++;
+		      loc = srelgot->contents;
+		      loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
                       bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
                     }
 
@@ -1907,7 +1907,7 @@ elf_s390_relocate_section (output_bfd, i
               Elf_Internal_Rela outrel;
               boolean skip, relocate;
 	      asection *sreloc;
-	      Elf32_External_Rela *loc;
+	      bfd_byte *loc;
 
 	      /* When generating a shared object, these relocations
 		 are copied into the output file to be resolved at run
@@ -1954,8 +1954,8 @@ elf_s390_relocate_section (output_bfd, i
 	      if (sreloc == NULL)
 		abort ();
 
-	      loc = (Elf32_External_Rela *) sreloc->contents;
-	      loc += sreloc->reloc_count++;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
 	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 
               /* If this reloc is against an external symbol, we do
@@ -2047,7 +2047,7 @@ elf_s390_finish_dynamic_symbol (output_b
       bfd_vma plt_index;
       bfd_vma got_offset;
       Elf_Internal_Rela rela;
-      Elf32_External_Rela *loc;
+      bfd_byte *loc;
       bfd_vma relative_offset;
 
       /* This symbol has an entry in the procedure linkage table.  Set
@@ -2167,7 +2167,7 @@ elf_s390_finish_dynamic_symbol (output_b
 		       + got_offset);
       rela.r_info = ELF32_R_INFO (h->dynindx, R_390_JMP_SLOT);
       rela.r_addend = 0;
-      loc = (Elf32_External_Rela *) htab->srelplt->contents + plt_index;
+      loc = htab->srelplt->contents + plt_index * sizeof (Elf32_External_Rela);
       bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
 
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
@@ -2184,7 +2184,7 @@ elf_s390_finish_dynamic_symbol (output_b
   if (h->got.offset != (bfd_vma) -1)
     {
       Elf_Internal_Rela rela;
-      Elf32_External_Rela *loc;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
          up.  */
@@ -2221,15 +2221,15 @@ elf_s390_finish_dynamic_symbol (output_b
           rela.r_addend = 0;
         }
 
-      loc = (Elf32_External_Rela *) htab->srelgot->contents;
-      loc += htab->srelgot->reloc_count++;
+      loc = htab->srelgot->contents;
+      loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
       bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
     {
       Elf_Internal_Rela rela;
-      Elf32_External_Rela *loc;
+      bfd_byte *loc;
 
       /* This symbols needs a copy reloc.  Set it up.  */
 
@@ -2244,8 +2244,8 @@ elf_s390_finish_dynamic_symbol (output_b
 		       + h->root.u.def.section->output_offset);
       rela.r_info = ELF32_R_INFO (h->dynindx, R_390_COPY);
       rela.r_addend = 0;
-      loc = (Elf32_External_Rela *) htab->srelbss->contents;
-      loc += htab->srelbss->reloc_count++;
+      loc = htab->srelbss->contents;
+      loc += htab->srelbss->reloc_count++ * sizeof (Elf32_External_Rela);
       bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
Index: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.65
diff -u -p -r1.65 elf32-sh.c
--- bfd/elf32-sh.c	6 Nov 2002 11:38:35 -0000	1.65
+++ bfd/elf32-sh.c	27 Nov 2002 15:52:39 -0000
@@ -4868,6 +4868,7 @@ sh_elf_relocate_section (output_bfd, inf
 			      & ELF_LINK_HASH_DEF_REGULAR) == 0))))
 	    {
 	      Elf_Internal_Rela outrel;
+	      bfd_byte *loc;
 	      boolean skip, relocate;
 
 	      /* When generating a shared object, these relocations
@@ -4941,11 +4942,9 @@ sh_elf_relocate_section (output_bfd, inf
 		    }
 		}
 
-	      bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-					 (((Elf32_External_Rela *)
-					   sreloc->contents)
-					  + sreloc->reloc_count));
-	      ++sreloc->reloc_count;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
+	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 
 	      /* If this reloc is against an external symbol, we do
 		 not want to fiddle with the addend.  Otherwise, we
@@ -5099,6 +5098,7 @@ sh_elf_relocate_section (output_bfd, inf
 		  if (info->shared)
 		    {
 		      Elf_Internal_Rela outrel;
+		      bfd_byte *loc;
 
 		      if (srelgot == NULL)
 			{
@@ -5112,11 +5112,9 @@ sh_elf_relocate_section (output_bfd, inf
 					 + off);
 		      outrel.r_info = ELF32_R_INFO (0, R_SH_RELATIVE);
 		      outrel.r_addend = relocation;
-		      bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-						(((Elf32_External_Rela *)
-						  srelgot->contents)
-						 + srelgot->reloc_count));
-		      ++srelgot->reloc_count;
+		      loc = srelgot->contents;
+		      loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
+		      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 		    }
 
 #ifdef INCLUDE_SHMEDIA
@@ -5266,6 +5264,7 @@ sh_elf_relocate_section (output_bfd, inf
 	      unsigned short insn;
 	      int indx;
 	      Elf_Internal_Rela outrel;
+	      bfd_byte *loc;
 
 	      if (ELF32_R_TYPE (rel->r_info) == R_SH_TLS_GD_32)
 		{
@@ -5371,12 +5370,10 @@ sh_elf_relocate_section (output_bfd, inf
 		outrel.r_addend = relocation - dtpoff_base (info);
 	      else
 		outrel.r_addend = 0;
-	      bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-					 (((Elf32_External_Rela *)
-					   sreloc->contents)
-					  + sreloc->reloc_count));
-	      ++sreloc->reloc_count;
 
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
+	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 	      continue;
 	    }
 
@@ -5399,7 +5396,7 @@ sh_elf_relocate_section (output_bfd, inf
           else
 	    {
 	      Elf_Internal_Rela outrel;
-	      Elf32_External_Rela *loc;
+	      bfd_byte *loc;
 	      int dr_type, indx;
 
 	      if (srelgot == NULL)
@@ -5419,8 +5416,8 @@ sh_elf_relocate_section (output_bfd, inf
 	      else
 		outrel.r_addend = 0;
 	      outrel.r_info = ELF32_R_INFO (indx, dr_type);
-	      loc = (Elf32_External_Rela *) srelgot->contents;
-	      loc += srelgot->reloc_count++;
+	      loc = srelgot->contents;
+	      loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
 	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 
 	      if (r_type == R_SH_TLS_GD_32)
@@ -5438,9 +5435,8 @@ sh_elf_relocate_section (output_bfd, inf
 		      outrel.r_offset += 4;
 		      outrel.r_addend = 0;
 		      srelgot->reloc_count++;
-		      loc++;
-		      bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-						loc);
+		      loc += sizeof (Elf32_External_Rela);
+		      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 		    }
 		}
 
@@ -5571,7 +5567,7 @@ sh_elf_relocate_section (output_bfd, inf
 	  else
 	    {
 	      Elf_Internal_Rela outrel;
-	      Elf32_External_Rela *loc;
+	      bfd_byte *loc;
 
 	      srelgot = htab->srelgot;
 	      if (srelgot == NULL)
@@ -5581,8 +5577,8 @@ sh_elf_relocate_section (output_bfd, inf
 				 + sgot->output_offset + off);
 	      outrel.r_addend = 0;
 	      outrel.r_info = ELF32_R_INFO (0, R_SH_TLS_DTPMOD32);
-	      loc = (Elf32_External_Rela *) srelgot->contents;
-	      loc += srelgot->reloc_count++;
+	      loc = srelgot->contents;
+	      loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
 	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 	      htab->tls_ldm_got.offset |= 1;
 	    }
@@ -5597,6 +5593,7 @@ sh_elf_relocate_section (output_bfd, inf
 	    {
 	      int indx;
 	      Elf_Internal_Rela outrel;
+	      bfd_byte *loc;
 
 	      if (sreloc == NULL)
 		{
@@ -5627,12 +5624,10 @@ sh_elf_relocate_section (output_bfd, inf
 		outrel.r_addend = relocation - dtpoff_base (info);
 	      else
 		outrel.r_addend = 0;
-	      bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-					 (((Elf32_External_Rela *)
-					   sreloc->contents)
-					  + sreloc->reloc_count));
-	      ++sreloc->reloc_count;
 
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
+	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 	      continue;
 	    }
 	  else
@@ -5645,6 +5640,7 @@ sh_elf_relocate_section (output_bfd, inf
 	  {
 	    int indx;
 	    Elf_Internal_Rela outrel;
+	    bfd_byte *loc;
 
 	    if (sreloc == NULL)
 	      {
@@ -5675,12 +5671,10 @@ sh_elf_relocate_section (output_bfd, inf
 	      outrel.r_addend = relocation - dtpoff_base (info);
 	    else
 	      outrel.r_addend = 0;
-	    bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-				       (((Elf32_External_Rela *)
-					 sreloc->contents)
-					+ sreloc->reloc_count));
-	    ++sreloc->reloc_count;
 
+	    loc = sreloc->contents;
+	    loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
+	    bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 	    continue;
 	  }
 	}
@@ -6870,6 +6864,7 @@ sh_elf_finish_dynamic_symbol (output_bfd
       bfd_vma plt_index;
       bfd_vma got_offset;
       Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the procedure linkage table.  Set
 	 it up.  */
@@ -6989,9 +6984,8 @@ sh_elf_finish_dynamic_symbol (output_bfd
 #ifdef GOT_BIAS
       rel.r_addend = GOT_BIAS;
 #endif
-      bfd_elf32_swap_reloca_out (output_bfd, &rel,
-				((Elf32_External_Rela *) srel->contents
-				 + plt_index));
+      loc = srel->contents + plt_index * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
 
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
 	{
@@ -7008,6 +7002,7 @@ sh_elf_finish_dynamic_symbol (output_bfd
       asection *sgot;
       asection *srel;
       Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
@@ -7043,10 +7038,9 @@ sh_elf_finish_dynamic_symbol (output_bfd
 	  rel.r_addend = 0;
 	}
 
-      bfd_elf32_swap_reloca_out (output_bfd, &rel,
-				 ((Elf32_External_Rela *) srel->contents
-				  + srel->reloc_count));
-      ++srel->reloc_count;
+      loc = srel->contents;
+      loc += srel->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
     }
 
 #ifdef INCLUDE_SHMEDIA
@@ -7059,6 +7053,7 @@ sh_elf_finish_dynamic_symbol (output_bfd
 	asection *sgot;
 	asection *srel;
 	Elf_Internal_Rela rel;
+	bfd_byte *loc;
 
 	/* This symbol has a datalabel entry in the global offset table.
 	   Set it up.  */
@@ -7095,10 +7090,9 @@ sh_elf_finish_dynamic_symbol (output_bfd
 	    rel.r_addend = 0;
 	  }
 
-	bfd_elf32_swap_reloca_out (output_bfd, &rel,
-				   ((Elf32_External_Rela *) srel->contents
-				    + srel->reloc_count));
-	++srel->reloc_count;
+	loc = srel->contents;
+	loc += srel->reloc_count++ * sizeof (Elf32_External_Rela);
+	bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
       }
   }
 #endif
@@ -7107,6 +7101,7 @@ sh_elf_finish_dynamic_symbol (output_bfd
     {
       asection *s;
       Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol needs a copy reloc.  Set it up.  */
 
@@ -7123,10 +7118,8 @@ sh_elf_finish_dynamic_symbol (output_bfd
 		      + h->root.u.def.section->output_offset);
       rel.r_info = ELF32_R_INFO (h->dynindx, R_SH_COPY);
       rel.r_addend = 0;
-      bfd_elf32_swap_reloca_out (output_bfd, &rel,
-				 ((Elf32_External_Rela *) s->contents
-				  + s->reloc_count));
-      ++s->reloc_count;
+      loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
Index: bfd/elf32-v850.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-v850.c,v
retrieving revision 1.28
diff -u -p -r1.28 elf32-v850.c
--- bfd/elf32-v850.c	3 Nov 2002 10:43:44 -0000	1.28
+++ bfd/elf32-v850.c	27 Nov 2002 15:52:41 -0000
@@ -35,9 +35,9 @@
 static reloc_howto_type *v850_elf_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 static void v850_elf_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static void v850_elf_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static bfd_reloc_status_type v850_elf_reloc
   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
 static boolean v850_elf_is_local_label_name
@@ -59,7 +59,7 @@ static bfd_reloc_status_type v850_elf_fi
 static boolean v850_elf_object_p
   PARAMS ((bfd *));
 static boolean v850_elf_fake_sections
-  PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *));
+  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
 static void v850_elf_final_write_processing
   PARAMS ((bfd *, boolean));
 static boolean v850_elf_set_private_flags
@@ -589,9 +589,9 @@ v850_elf_reloc_type_lookup (abfd, code)
 
 static void
 v850_elf_info_to_howto_rel (abfd, cache_ptr, dst)
-     bfd *                 abfd ATTRIBUTE_UNUSED;
-     arelent *             cache_ptr;
-     Elf32_Internal_Rel *  dst;
+     bfd *               abfd ATTRIBUTE_UNUSED;
+     arelent *           cache_ptr;
+     Elf_Internal_Rela * dst;
 {
   unsigned int r_type;
 
@@ -603,9 +603,9 @@ v850_elf_info_to_howto_rel (abfd, cache_
 /* Set the howto pointer for a V850 ELF reloc (type RELA).  */
 static void
 v850_elf_info_to_howto_rela (abfd, cache_ptr, dst)
-     bfd *                 abfd ATTRIBUTE_UNUSED;
-     arelent *             cache_ptr;
-     Elf32_Internal_Rela   *dst;
+     bfd *               abfd ATTRIBUTE_UNUSED;
+     arelent *           cache_ptr;
+     Elf_Internal_Rela * dst;
 {
   unsigned int r_type;
 
@@ -2225,9 +2225,9 @@ v850_elf_section_from_shdr (abfd, hdr, n
 
 static boolean
 v850_elf_fake_sections (abfd, hdr, sec)
-     bfd *                 abfd ATTRIBUTE_UNUSED;
-     Elf32_Internal_Shdr * hdr;
-     asection *            sec;
+     bfd *               abfd ATTRIBUTE_UNUSED;
+     Elf_Internal_Shdr * hdr;
+     asection *          sec;
 {
   register const char * name;
 
Index: bfd/elf32-vax.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-vax.c,v
retrieving revision 1.8
diff -u -p -r1.8 elf32-vax.c
--- bfd/elf32-vax.c	28 Sep 2002 23:15:50 -0000	1.8
+++ bfd/elf32-vax.c	27 Nov 2002 15:52:42 -0000
@@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suit
 static reloc_howto_type *reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
 static void rtype_to_howto
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static struct bfd_hash_entry *elf_vax_link_hash_newfunc
   PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
 static struct bfd_link_hash_table *elf_vax_link_hash_table_create
@@ -1693,6 +1693,7 @@ elf_vax_relocate_section (output_bfd, in
 			  & ELF_LINK_HASH_DEF_REGULAR) == 0)))
 	    {
 	      Elf_Internal_Rela outrel;
+	      bfd_byte *loc;
 	      boolean skip, relocate;
 
 	      /* When generating a shared object, these relocations
@@ -1811,11 +1812,9 @@ elf_vax_relocate_section (output_bfd, in
 		      outrel.r_addend,
 		      bfd_get_section_name (input_bfd, input_section));
 		}
-	      bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-					 (((Elf32_External_Rela *)
-					   sreloc->contents)
-					  + sreloc->reloc_count));
-	      ++sreloc->reloc_count;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
+	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 
 	      /* This reloc will be computed at runtime, so there's no
                  need to do anything now, except for R_VAX_32
@@ -1905,6 +1904,7 @@ elf_vax_finish_dynamic_symbol (output_bf
       bfd_vma got_offset;
       bfd_vma addend;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the procedure linkage table.  Set
 	 it up.  */
@@ -1955,9 +1955,8 @@ elf_vax_finish_dynamic_symbol (output_bf
 		       + got_offset);
       rela.r_info = ELF32_R_INFO (h->dynindx, R_VAX_JMP_SLOT);
       rela.r_addend = addend;
-      bfd_elf32_swap_reloca_out (output_bfd, &rela,
-				 ((Elf32_External_Rela *) srela->contents
-				  + plt_index));
+      loc = srela->contents + plt_index * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
 
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
 	{
@@ -1972,6 +1971,7 @@ elf_vax_finish_dynamic_symbol (output_bf
       asection *sgot;
       asection *srela;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
@@ -2002,16 +2002,16 @@ elf_vax_finish_dynamic_symbol (output_bf
 					 (sgot->contents
 					  + (h->got.offset & ~1)));
 
-      bfd_elf32_swap_reloca_out (output_bfd, &rela,
-				 ((Elf32_External_Rela *) srela->contents
-				  + srela->reloc_count));
-      ++srela->reloc_count;
+      loc = srela->contents;
+      loc += srela->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
     {
       asection *s;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
 
       /* This symbol needs a copy reloc.  Set it up.  */
 
@@ -2028,10 +2028,8 @@ elf_vax_finish_dynamic_symbol (output_bf
 		       + h->root.u.def.section->output_offset);
       rela.r_info = ELF32_R_INFO (h->dynindx, R_VAX_COPY);
       rela.r_addend = 0;
-      bfd_elf32_swap_reloca_out (output_bfd, &rela,
-				 ((Elf32_External_Rela *) s->contents
-				  + s->reloc_count));
-      ++s->reloc_count;
+      loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
Index: bfd/elf32-xstormy16.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xstormy16.c,v
retrieving revision 1.11
diff -u -p -r1.11 elf32-xstormy16.c
--- bfd/elf32-xstormy16.c	23 Jul 2002 12:29:33 -0000	1.11
+++ bfd/elf32-xstormy16.c	27 Nov 2002 15:52:42 -0000
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suit
 static reloc_howto_type * xstormy16_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 static void xstormy16_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static bfd_reloc_status_type xstormy16_elf_24_reloc
   PARAMS ((bfd *abfd, arelent *reloc_entry, asymbol *symbol,
 	   PTR data, asection *input_section, bfd *output_bfd,
@@ -296,7 +296,7 @@ static void
 xstormy16_info_to_howto_rela (abfd, cache_ptr, dst)
      bfd * abfd ATTRIBUTE_UNUSED;
      arelent * cache_ptr;
-     Elf32_Internal_Rela * dst;
+     Elf_Internal_Rela * dst;
 {
   unsigned int r_type = ELF32_R_TYPE (dst->r_info);
 
Index: bfd/elf64-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-alpha.c,v
retrieving revision 1.85
diff -u -p -r1.85 elf64-alpha.c
--- bfd/elf64-alpha.c	23 Oct 2002 20:21:21 -0000	1.85
+++ bfd/elf64-alpha.c	27 Nov 2002 15:52:45 -0000
@@ -66,18 +66,18 @@ static bfd_reloc_status_type elf64_alpha
 static reloc_howto_type * elf64_alpha_bfd_reloc_type_lookup
   PARAMS((bfd *, bfd_reloc_code_real_type));
 static void elf64_alpha_info_to_howto
-  PARAMS((bfd *, arelent *, Elf64_Internal_Rela *));
+  PARAMS((bfd *, arelent *, Elf_Internal_Rela *));
 
 static boolean elf64_alpha_mkobject
   PARAMS((bfd *));
 static boolean elf64_alpha_object_p
   PARAMS((bfd *));
 static boolean elf64_alpha_section_from_shdr
-  PARAMS((bfd *, Elf64_Internal_Shdr *, const char *));
+  PARAMS((bfd *, Elf_Internal_Shdr *, const char *));
 static boolean elf64_alpha_section_flags
-  PARAMS((flagword *, Elf64_Internal_Shdr *));
+  PARAMS((flagword *, Elf_Internal_Shdr *));
 static boolean elf64_alpha_fake_sections
-  PARAMS((bfd *, Elf64_Internal_Shdr *, asection *));
+  PARAMS((bfd *, Elf_Internal_Shdr *, asection *));
 static boolean elf64_alpha_create_got_section
   PARAMS((bfd *, struct bfd_link_info *));
 static boolean elf64_alpha_create_dynamic_sections
@@ -1165,7 +1165,7 @@ static void
 elf64_alpha_info_to_howto (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf64_Internal_Rela *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned r_type;
 
@@ -2325,7 +2325,7 @@ elf64_alpha_relax_section (abfd, sec, li
 static boolean
 elf64_alpha_section_from_shdr (abfd, hdr, name)
      bfd *abfd;
-     Elf64_Internal_Shdr *hdr;
+     Elf_Internal_Shdr *hdr;
      const char *name;
 {
   asection *newsect;
@@ -2365,7 +2365,7 @@ elf64_alpha_section_from_shdr (abfd, hdr
 static boolean
 elf64_alpha_section_flags (flags, hdr)
      flagword *flags;
-     Elf64_Internal_Shdr *hdr;
+     Elf_Internal_Shdr *hdr;
 {
   if (hdr->sh_flags & SHF_ALPHA_GPREL)
     *flags |= SEC_SMALL_DATA;
@@ -2379,7 +2379,7 @@ elf64_alpha_section_flags (flags, hdr)
 static boolean
 elf64_alpha_fake_sections (abfd, hdr, sec)
      bfd *abfd;
-     Elf64_Internal_Shdr *hdr;
+     Elf_Internal_Shdr *hdr;
      asection *sec;
 {
   register const char *name;
@@ -4465,6 +4465,7 @@ elf64_alpha_relocate_section (output_bfd
 	      if (info->shared && !dynamic_symbol_p)
 		{
 		  Elf_Internal_Rela outrel;
+		  bfd_byte *loc;
 
 		  BFD_ASSERT(srelgot != NULL);
 
@@ -4474,10 +4475,9 @@ elf64_alpha_relocate_section (output_bfd
 		  outrel.r_info = ELF64_R_INFO (0, R_ALPHA_RELATIVE);
 		  outrel.r_addend = value;
 
-		  bfd_elf64_swap_reloca_out (output_bfd, &outrel,
-					     ((Elf64_External_Rela *)
-					      srelgot->contents)
-					     + srelgot->reloc_count++);
+		  loc = srelgot->contents;
+		  loc += srelgot->reloc_count++ * sizeof (Elf64_External_Rela);
+		  bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 		  BFD_ASSERT (sizeof (Elf64_External_Rela)
 			      * srelgot->reloc_count
 			      <= srelgot->_cooked_size);
@@ -4607,6 +4607,7 @@ elf64_alpha_relocate_section (output_bfd
 	case R_ALPHA_TPREL64:
 	  {
 	    Elf_Internal_Rela outrel;
+	    bfd_byte *loc;
 
 	    /* Careful here to remember RELATIVE relocations for global
 	       variables for symbolic shared objects.  */
@@ -4659,10 +4660,9 @@ elf64_alpha_relocate_section (output_bfd
 	    else
 	      memset (&outrel, 0, sizeof outrel);
 
-	    bfd_elf64_swap_reloca_out (output_bfd, &outrel,
-				       ((Elf64_External_Rela *)
-					srel->contents)
-				       + srel->reloc_count++);
+	    loc = srel->contents;
+	    loc += srel->reloc_count++ * sizeof (Elf64_External_Rela);
+	    bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 	    BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count
 			<= srel->_cooked_size);
 	  }
@@ -4708,6 +4708,7 @@ elf64_alpha_relocate_section (output_bfd
 	      if (info->shared && !dynamic_symbol_p)
 		{
 		  Elf_Internal_Rela outrel;
+		  bfd_byte *loc;
 
 		  BFD_ASSERT(srelgot != NULL);
 
@@ -4718,10 +4719,9 @@ elf64_alpha_relocate_section (output_bfd
 		  outrel.r_info = ELF64_R_INFO (0, R_ALPHA_DTPMOD64);
 		  outrel.r_addend = 0;
 
-		  bfd_elf64_swap_reloca_out (output_bfd, &outrel,
-					     ((Elf64_External_Rela *)
-					      srelgot->contents)
-					     + srelgot->reloc_count++);
+		  loc = srelgot->contents;
+		  loc += srelgot->reloc_count++ * sizeof (Elf64_External_Rela);
+		  bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 		  BFD_ASSERT (sizeof (Elf64_External_Rela)
 			      * srelgot->reloc_count
 			      <= srelgot->_cooked_size);
@@ -4880,6 +4880,7 @@ elf64_alpha_finish_dynamic_symbol (outpu
       /* Fill in the .plt entry for this symbol.  */
       asection *splt, *sgot, *srel;
       Elf_Internal_Rela outrel;
+      bfd_byte *loc;
       bfd_vma got_addr, plt_addr;
       bfd_vma plt_index;
       struct alpha_elf_got_entry *gotent;
@@ -4925,9 +4926,8 @@ elf64_alpha_finish_dynamic_symbol (outpu
       outrel.r_info = ELF64_R_INFO(h->dynindx, R_ALPHA_JMP_SLOT);
       outrel.r_addend = 0;
 
-      bfd_elf64_swap_reloca_out (output_bfd, &outrel,
-				 ((Elf64_External_Rela *)srel->contents
-				  + plt_index));
+      loc = srel->contents + plt_index * sizeof (Elf64_External_Rela);
+      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 
       if (!(h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
 	{
@@ -4963,10 +4963,9 @@ elf64_alpha_finish_dynamic_symbol (outpu
 		  outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE);
 		  outrel.r_addend = plt_addr;
 
-		  bfd_elf64_swap_reloca_out (output_bfd, &outrel,
-					     ((Elf64_External_Rela *)
-					      srel->contents)
-					     + srel->reloc_count++);
+		  loc = srel->contents;
+		  loc += srel->reloc_count++ * sizeof (Elf64_External_Rela);
+		  bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 		  BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count
 			      <= srel->_cooked_size);
 		}
@@ -4981,6 +4980,7 @@ elf64_alpha_finish_dynamic_symbol (outpu
       /* Fill in the dynamic relocations for this symbol's .got entries.  */
       asection *srel;
       Elf_Internal_Rela outrel;
+      bfd_byte *loc;
       struct alpha_elf_got_entry *gotent;
 
       srel = bfd_get_section_by_name (dynobj, ".rela.got");
@@ -5024,18 +5024,18 @@ elf64_alpha_finish_dynamic_symbol (outpu
 	  outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
 	  outrel.r_addend = gotent->addend;
 
-	  bfd_elf64_swap_reloca_out (output_bfd, &outrel,
-				     ((Elf64_External_Rela *)srel->contents
-				      + srel->reloc_count++));
+	  loc = srel->contents;
+	  loc += srel->reloc_count++ * sizeof (Elf64_External_Rela);
+	  bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 
 	  if (gotent->reloc_type == R_ALPHA_TLSGD)
 	    {
 	      outrel.r_offset += 8;
 	      outrel.r_info = ELF64_R_INFO (h->dynindx, R_ALPHA_DTPREL64);
 
-	      bfd_elf64_swap_reloca_out (output_bfd, &outrel,
-				         ((Elf64_External_Rela *)srel->contents
-				          + srel->reloc_count++));
+	      loc = srel->contents;
+	      loc += srel->reloc_count++ * sizeof (Elf64_External_Rela);
+	      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 	    }
 
 	  BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count
@@ -5504,10 +5504,10 @@ static const struct elf_size_info alpha_
   bfd_elf64_slurp_symbol_table,
   bfd_elf64_swap_dyn_in,
   bfd_elf64_swap_dyn_out,
-  NULL,
-  NULL,
-  NULL,
-  NULL
+  bfd_elf64_swap_reloc_in,
+  bfd_elf64_swap_reloc_out,
+  bfd_elf64_swap_reloca_in,
+  bfd_elf64_swap_reloca_out
 };
 
 #define TARGET_LITTLE_SYM	bfd_elf64_alpha_vec
Index: bfd/elf64-gen.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-gen.c,v
retrieving revision 1.8
diff -u -p -r1.8 elf64-gen.c
--- bfd/elf64-gen.c	20 Sep 2001 23:30:36 -0000	1.8
+++ bfd/elf64-gen.c	27 Nov 2002 15:52:45 -0000
@@ -41,9 +41,9 @@ static reloc_howto_type dummy =
 	 false);		/* pcrel_offset */
 
 static void elf_generic_info_to_howto
-  PARAMS ((bfd *, arelent *, Elf64_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static void elf_generic_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf64_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static boolean elf64_generic_link_add_symbols
   PARAMS ((bfd *, struct bfd_link_info *));
 
@@ -51,7 +51,7 @@ static void
 elf_generic_info_to_howto (abfd, bfd_reloc, elf_reloc)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *bfd_reloc;
-     Elf64_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED;
+     Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED;
 {
   bfd_reloc->howto = &dummy;
 }
@@ -60,7 +60,7 @@ static void
 elf_generic_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *bfd_reloc;
-     Elf64_Internal_Rel *elf_reloc ATTRIBUTE_UNUSED;
+     Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED;
 {
   bfd_reloc->howto = &dummy;
 }
Index: bfd/elf64-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.c,v
retrieving revision 1.28
diff -u -p -r1.28 elf64-hppa.c
--- bfd/elf64-hppa.c	23 Oct 2002 12:34:57 -0000	1.28
+++ bfd/elf64-hppa.c	27 Nov 2002 15:52:46 -0000
@@ -184,7 +184,7 @@ static boolean elf64_hppa_object_p
   PARAMS ((bfd *));
 
 static boolean elf64_hppa_section_from_shdr
-  PARAMS ((bfd *, Elf64_Internal_Shdr *, const char *));
+  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 
 static void elf64_hppa_post_process_headers
   PARAMS ((bfd *, struct bfd_link_info *));
@@ -408,7 +408,7 @@ elf64_hppa_object_p (abfd)
 static boolean
 elf64_hppa_section_from_shdr (abfd, hdr, name)
      bfd *abfd;
-     Elf64_Internal_Shdr *hdr;
+     Elf_Internal_Shdr *hdr;
      const char *name;
 {
   asection *newsect;
@@ -1991,6 +1991,7 @@ elf64_hppa_finish_dynamic_symbol (output
     {
       bfd_vma value;
       Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       BFD_ASSERT (splt != NULL && spltrel != NULL)
 
@@ -2029,11 +2030,9 @@ elf64_hppa_finish_dynamic_symbol (output
       rel.r_info = ELF64_R_INFO (h->dynindx, R_PARISC_IPLT);
       rel.r_addend = 0;
 
-      bfd_elf64_swap_reloca_out (splt->output_section->owner, &rel,
-				 (((Elf64_External_Rela *)
-				   spltrel->contents)
-				  + spltrel->reloc_count));
-      spltrel->reloc_count++;
+      loc = spltrel->contents;
+      loc += spltrel->reloc_count++ * sizeof (Elf64_External_Rela);
+      bfd_elf64_swap_reloca_out (splt->output_section->owner, &rel, loc);
     }
 
   /* Initialize an external call stub entry if requested.  */
@@ -2156,7 +2155,8 @@ elf64_hppa_finalize_opd (dyn_h, data)
      had their address taken).  */
   if (info->shared && dyn_h && dyn_h->want_opd)
     {
-      Elf64_Internal_Rela rel;
+      Elf_Internal_Rela rel;
+      bfd_byte *loc;
       int dynindx;
 
       /* We may need to do a relocation against a local symbol, in
@@ -2221,11 +2221,9 @@ elf64_hppa_finalize_opd (dyn_h, data)
       rel.r_addend = 0;
       rel.r_info = ELF64_R_INFO (dynindx, R_PARISC_EPLT);
 
-      bfd_elf64_swap_reloca_out (sopd->output_section->owner, &rel,
-				 (((Elf64_External_Rela *)
-				   sopdrel->contents)
-				  + sopdrel->reloc_count));
-      sopdrel->reloc_count++;
+      loc = sopdrel->contents;
+      loc += sopdrel->reloc_count++ * sizeof (Elf64_External_Rela);
+      bfd_elf64_swap_reloca_out (sopd->output_section->owner, &rel, loc);
     }
   return true;
 }
@@ -2291,7 +2289,8 @@ elf64_hppa_finalize_dlt (dyn_h, data)
   if (dyn_h->want_dlt
       && (elf64_hppa_dynamic_symbol_p (dyn_h->h, info) || info->shared))
     {
-      Elf64_Internal_Rela rel;
+      Elf_Internal_Rela rel;
+      bfd_byte *loc;
       int dynindx;
 
       /* We may need to do a relocation against a local symbol, in
@@ -2315,11 +2314,9 @@ elf64_hppa_finalize_dlt (dyn_h, data)
 	  rel.r_info = ELF64_R_INFO (dynindx, R_PARISC_DIR64);
       rel.r_addend = 0;
 
-      bfd_elf64_swap_reloca_out (sdlt->output_section->owner, &rel,
-				 (((Elf64_External_Rela *)
-				   sdltrel->contents)
-				  + sdltrel->reloc_count));
-      sdltrel->reloc_count++;
+      loc = sdltrel->contents;
+      loc += sdltrel->reloc_count++ * sizeof (Elf64_External_Rela);
+      bfd_elf64_swap_reloca_out (sdlt->output_section->owner, &rel, loc);
     }
   return true;
 }
@@ -2362,7 +2359,8 @@ elf64_hppa_finalize_dynreloc (dyn_h, dat
 
       for (rent = dyn_h->reloc_entries; rent; rent = rent->next)
 	{
-	  Elf64_Internal_Rela rel;
+	  Elf_Internal_Rela rel;
+	  bfd_byte *loc;
 
 	  /* Allocate one iff we are building a shared library, the relocation
 	     isn't a R_PARISC_FPTR64, or we don't want an opd entry.  */
@@ -2429,12 +2427,11 @@ elf64_hppa_finalize_dynreloc (dyn_h, dat
 
 	  rel.r_info = ELF64_R_INFO (dynindx, rent->type);
 
+	  loc = hppa_info->other_rel_sec->contents;
+	  loc += (hppa_info->other_rel_sec->reloc_count++
+		  * sizeof (Elf64_External_Rela));
 	  bfd_elf64_swap_reloca_out (hppa_info->other_rel_sec->output_section->owner,
-				     &rel,
-				     (((Elf64_External_Rela *)
-				      hppa_info->other_rel_sec->contents)
-				      + hppa_info->other_rel_sec->reloc_count));
-	  hppa_info->other_rel_sec->reloc_count++;
+				     &rel, loc);
 	}
     }
 
@@ -2704,10 +2701,10 @@ const struct elf_size_info hppa64_elf_si
   bfd_elf64_slurp_symbol_table,
   bfd_elf64_swap_dyn_in,
   bfd_elf64_swap_dyn_out,
-  NULL,
-  NULL,
-  NULL,
-  NULL
+  bfd_elf64_swap_reloc_in,
+  bfd_elf64_swap_reloc_out,
+  bfd_elf64_swap_reloca_in,
+  bfd_elf64_swap_reloca_out
 };
 
 #define TARGET_BIG_SYM			bfd_elf64_hppa_vec
Index: bfd/elf64-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-mips.c,v
retrieving revision 1.39
diff -u -p -r1.39 elf64-mips.c
--- bfd/elf64-mips.c	6 Nov 2002 21:56:05 -0000	1.39
+++ bfd/elf64-mips.c	27 Nov 2002 15:52:48 -0000
@@ -63,20 +63,20 @@ Foundation, Inc., 59 Temple Place - Suit
 
 static void mips_elf64_swap_reloc_in
   PARAMS ((bfd *, const Elf64_Mips_External_Rel *,
-	   Elf64_Mips_Internal_Rel *));
+	   Elf64_Mips_Internal_Rela *));
 static void mips_elf64_swap_reloca_in
   PARAMS ((bfd *, const Elf64_Mips_External_Rela *,
 	   Elf64_Mips_Internal_Rela *));
 static void mips_elf64_swap_reloc_out
-  PARAMS ((bfd *, const Elf64_Mips_Internal_Rel *,
+  PARAMS ((bfd *, const Elf64_Mips_Internal_Rela *,
 	   Elf64_Mips_External_Rel *));
 static void mips_elf64_swap_reloca_out
   PARAMS ((bfd *, const Elf64_Mips_Internal_Rela *,
 	   Elf64_Mips_External_Rela *));
 static void mips_elf64_be_swap_reloc_in
-  PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rel *));
+  PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
 static void mips_elf64_be_swap_reloc_out
-  PARAMS ((bfd *, const Elf_Internal_Rel *, bfd_byte *));
+  PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
 static void mips_elf64_be_swap_reloca_in
   PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
 static void mips_elf64_be_swap_reloca_out
@@ -86,9 +86,9 @@ static reloc_howto_type *bfd_elf64_bfd_r
 static reloc_howto_type *mips_elf64_rtype_to_howto
   PARAMS ((unsigned int, boolean));
 static void mips_elf64_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf64_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static void mips_elf64_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf64_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static long mips_elf64_get_reloc_upper_bound PARAMS ((bfd *, asection *));
 static boolean mips_elf64_slurp_one_reloc_table
   PARAMS ((bfd *, asection *, asymbol **, const Elf_Internal_Shdr *));
@@ -1218,7 +1218,7 @@ static void
 mips_elf64_swap_reloc_in (abfd, src, dst)
      bfd *abfd;
      const Elf64_Mips_External_Rel *src;
-     Elf64_Mips_Internal_Rel *dst;
+     Elf64_Mips_Internal_Rela *dst;
 {
   dst->r_offset = H_GET_64 (abfd, src->r_offset);
   dst->r_sym = H_GET_32 (abfd, src->r_sym);
@@ -1226,6 +1226,7 @@ mips_elf64_swap_reloc_in (abfd, src, dst
   dst->r_type3 = H_GET_8 (abfd, src->r_type3);
   dst->r_type2 = H_GET_8 (abfd, src->r_type2);
   dst->r_type = H_GET_8 (abfd, src->r_type);
+  dst->r_addend = 0;
 }
 
 /* Swap in a MIPS 64-bit Rela reloc.  */
@@ -1250,7 +1251,7 @@ mips_elf64_swap_reloca_in (abfd, src, ds
 static void
 mips_elf64_swap_reloc_out (abfd, src, dst)
      bfd *abfd;
-     const Elf64_Mips_Internal_Rel *src;
+     const Elf64_Mips_Internal_Rela *src;
      Elf64_Mips_External_Rel *dst;
 {
   H_PUT_64 (abfd, src->r_offset, dst->r_offset);
@@ -1284,9 +1285,9 @@ static void
 mips_elf64_be_swap_reloc_in (abfd, src, dst)
      bfd *abfd;
      const bfd_byte *src;
-     Elf_Internal_Rel *dst;
+     Elf_Internal_Rela *dst;
 {
-  Elf64_Mips_Internal_Rel mirel;
+  Elf64_Mips_Internal_Rela mirel;
 
   mips_elf64_swap_reloc_in (abfd,
 			    (const Elf64_Mips_External_Rel *) src,
@@ -1294,10 +1295,13 @@ mips_elf64_be_swap_reloc_in (abfd, src, 
 
   dst[0].r_offset = mirel.r_offset;
   dst[0].r_info = ELF64_R_INFO (mirel.r_sym, mirel.r_type);
+  dst[0].r_addend = 0;
   dst[1].r_offset = mirel.r_offset;
   dst[1].r_info = ELF64_R_INFO (mirel.r_ssym, mirel.r_type2);
+  dst[1].r_addend = 0;
   dst[2].r_offset = mirel.r_offset;
   dst[2].r_info = ELF64_R_INFO (STN_UNDEF, mirel.r_type3);
+  dst[2].r_addend = 0;
 }
 
 /* Swap in a MIPS 64-bit Rela reloc.  */
@@ -1330,10 +1334,10 @@ mips_elf64_be_swap_reloca_in (abfd, src,
 static void
 mips_elf64_be_swap_reloc_out (abfd, src, dst)
      bfd *abfd;
-     const Elf_Internal_Rel *src;
+     const Elf_Internal_Rela *src;
      bfd_byte *dst;
 {
-  Elf64_Mips_Internal_Rel mirel;
+  Elf64_Mips_Internal_Rela mirel;
 
   mirel.r_offset = src[0].r_offset;
   BFD_ASSERT(src[0].r_offset == src[1].r_offset);
@@ -1947,7 +1951,7 @@ bfd_elf64_bfd_reloc_type_lookup (abfd, c
     }
 }
 
-/* Given a MIPS Elf64_Internal_Rel, fill in an arelent structure.  */
+/* Given a MIPS Elf_Internal_Rel, fill in an arelent structure.  */
 
 static reloc_howto_type *
 mips_elf64_rtype_to_howto (r_type, rela_p)
@@ -1980,7 +1984,7 @@ static void
 mips_elf64_info_to_howto_rel (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr ATTRIBUTE_UNUSED;
-     Elf64_Internal_Rel *dst ATTRIBUTE_UNUSED;
+     Elf_Internal_Rela *dst ATTRIBUTE_UNUSED;
 {
   BFD_ASSERT (0);
 }
@@ -1989,7 +1993,7 @@ static void
 mips_elf64_info_to_howto_rela (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr ATTRIBUTE_UNUSED;
-     Elf64_Internal_Rela *dst ATTRIBUTE_UNUSED;
+     Elf_Internal_Rela *dst ATTRIBUTE_UNUSED;
 {
   BFD_ASSERT (0);
 }
@@ -2058,20 +2062,9 @@ mips_elf64_slurp_one_reloc_table (abfd, 
 				   (Elf64_Mips_External_Rela *) native_relocs,
 				   &rela);
       else
-	{
-	  Elf64_Mips_Internal_Rel rel;
-
-	  mips_elf64_swap_reloc_in (abfd,
-				    (Elf64_Mips_External_Rel *) native_relocs,
-				    &rel);
-	  rela.r_offset = rel.r_offset;
-	  rela.r_sym = rel.r_sym;
-	  rela.r_ssym = rel.r_ssym;
-	  rela.r_type3 = rel.r_type3;
-	  rela.r_type2 = rel.r_type2;
-	  rela.r_type = rel.r_type;
-	  rela.r_addend = 0;
-	}
+	mips_elf64_swap_reloc_in (abfd,
+				  (Elf64_Mips_External_Rel *) native_relocs,
+				  &rela);
 
       /* Each entry represents exactly three actual relocations.  */
 
@@ -2326,7 +2319,7 @@ mips_elf64_write_rel (abfd, sec, rel_hdr
   for (idx = 0; idx < sec->reloc_count; idx++, ext_rel++)
     {
       arelent *ptr;
-      Elf64_Mips_Internal_Rel int_rel;
+      Elf64_Mips_Internal_Rela int_rel;
       asymbol *sym;
       int n;
       unsigned int i;
Index: bfd/elf64-mmix.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-mmix.c,v
retrieving revision 1.18
diff -u -p -r1.18 elf64-mmix.c
--- bfd/elf64-mmix.c	14 Nov 2002 01:32:28 -0000	1.18
+++ bfd/elf64-mmix.c	27 Nov 2002 15:52:49 -0000
@@ -131,7 +131,7 @@ static reloc_howto_type *bfd_elf64_bfd_r
   PARAMS ((bfd *, bfd_reloc_code_real_type));
 
 static void mmix_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf64_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 
 static int mmix_elf_sort_relocs PARAMS ((const PTR, const PTR));
 
@@ -1063,7 +1063,7 @@ static void
 mmix_info_to_howto_rela (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf64_Internal_Rela *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.72
diff -u -p -r1.72 elf64-ppc.c
--- bfd/elf64-ppc.c	19 Nov 2002 06:32:35 -0000	1.72
+++ bfd/elf64-ppc.c	27 Nov 2002 15:52:52 -0000
@@ -35,7 +35,7 @@ static void ppc_howto_init
 static reloc_howto_type *ppc64_elf_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
 static void ppc64_elf_info_to_howto
-  PARAMS ((bfd *abfd, arelent *cache_ptr, Elf64_Internal_Rela *dst));
+  PARAMS ((bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst));
 static bfd_reloc_status_type ppc64_elf_ha_reloc
   PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
 static bfd_reloc_status_type ppc64_elf_brtaken_reloc
@@ -1351,7 +1351,7 @@ static void
 ppc64_elf_info_to_howto (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf64_Internal_Rela *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int type;
 
@@ -4471,7 +4471,7 @@ ppc_build_one_stub (gen_entry, in_arg)
 	{
 	  /* Create a reloc for the branch lookup table entry.  */
 	  Elf_Internal_Rela rela;
-	  Elf64_External_Rela *r;
+	  bfd_byte *loc;
 
 	  rela.r_offset = (br_entry->offset
 			   + htab->sbrlt->output_offset
@@ -4479,9 +4479,9 @@ ppc_build_one_stub (gen_entry, in_arg)
 	  rela.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE);
 	  rela.r_addend = off;
 
-	  r = (Elf64_External_Rela *) htab->srelbrlt->contents;
-	  r += htab->srelbrlt->reloc_count++;
-	  bfd_elf64_swap_reloca_out (htab->srelbrlt->owner, &rela, r);
+	  loc = htab->srelbrlt->contents;
+	  loc += htab->srelbrlt->reloc_count++ * sizeof (Elf64_External_Rela);
+	  bfd_elf64_swap_reloca_out (htab->srelbrlt->owner, &rela, loc);
 	}
 
       off = (br_entry->offset
@@ -5618,7 +5618,7 @@ ppc64_elf_relocate_section (output_bfd, 
 		    if (info->shared)
 		      {
 			Elf_Internal_Rela outrel;
-			Elf64_External_Rela *loc;
+			bfd_byte *loc;
 
 			/* We need to generate a R_PPC64_RELATIVE reloc
 			   for the dynamic linker.  */
@@ -5627,8 +5627,9 @@ ppc64_elf_relocate_section (output_bfd, 
 					   + off);
 			outrel.r_info = ELF64_R_INFO (0, R_PPC64_RELATIVE);
 			outrel.r_addend = relocation;
-			loc = (Elf64_External_Rela *) htab->srelgot->contents;
-			loc += htab->srelgot->reloc_count++;
+			loc = htab->srelgot->contents;
+			loc += (htab->srelgot->reloc_count++
+				* sizeof (Elf64_External_Rela));
 			bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 		      }
 
@@ -5763,7 +5764,7 @@ ppc64_elf_relocate_section (output_bfd, 
 	      Elf_Internal_Rela outrel;
 	      boolean skip, relocate;
 	      asection *sreloc;
-	      Elf64_External_Rela *loc;
+	      bfd_byte *loc;
 
 	      /* When generating a dynamic object, these relocations
 		 are copied into the output file to be resolved at run
@@ -5853,8 +5854,8 @@ ppc64_elf_relocate_section (output_bfd, 
 	      if (sreloc == NULL)
 		abort ();
 
-	      loc = (Elf64_External_Rela *) sreloc->contents;
-	      loc += sreloc->reloc_count++;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela);
 	      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 
 	      /* If this reloc is against an external symbol, it will
@@ -6065,7 +6066,7 @@ ppc64_elf_finish_dynamic_symbol (output_
       && ((struct ppc_link_hash_entry *) h)->is_func_descriptor)
     {
       Elf_Internal_Rela rela;
-      Elf64_External_Rela *loc;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the procedure linkage table.  Set
 	 it up.  */
@@ -6084,15 +6085,16 @@ ppc64_elf_finish_dynamic_symbol (output_
       rela.r_info = ELF64_R_INFO (h->dynindx, R_PPC64_JMP_SLOT);
       rela.r_addend = 0;
 
-      loc = (Elf64_External_Rela *) htab->srelplt->contents;
-      loc += (h->plt.offset - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE;
+      loc = htab->srelplt->contents;
+      loc += ((h->plt.offset - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE
+	      * sizeof (Elf64_External_Rela));
       bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   if (h->got.offset != (bfd_vma) -1)
     {
       Elf_Internal_Rela rela;
-      Elf64_External_Rela *loc;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
@@ -6130,15 +6132,15 @@ ppc64_elf_finish_dynamic_symbol (output_
 	  rela.r_addend = 0;
 	}
 
-      loc = (Elf64_External_Rela *) htab->srelgot->contents;
-      loc += htab->srelgot->reloc_count++;
+      loc = htab->srelgot->contents;
+      loc += htab->srelgot->reloc_count++ * sizeof (Elf64_External_Rela);
       bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
     {
       Elf_Internal_Rela rela;
-      Elf64_External_Rela *loc;
+      bfd_byte *loc;
 
       /* This symbol needs a copy reloc.  Set it up.  */
 
@@ -6153,8 +6155,8 @@ ppc64_elf_finish_dynamic_symbol (output_
 		       + h->root.u.def.section->output_offset);
       rela.r_info = ELF64_R_INFO (h->dynindx, R_PPC64_COPY);
       rela.r_addend = 0;
-      loc = (Elf64_External_Rela *) htab->srelbss->contents;
-      loc += htab->srelbss->reloc_count++;
+      loc = htab->srelbss->contents;
+      loc += htab->srelbss->reloc_count++ * sizeof (Elf64_External_Rela);
       bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
     }
 
Index: bfd/elf64-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-s390.c,v
retrieving revision 1.31
diff -u -p -r1.31 elf64-s390.c
--- bfd/elf64-s390.c	22 Aug 2002 01:27:20 -0000	1.31
+++ bfd/elf64-s390.c	27 Nov 2002 15:52:53 -0000
@@ -1742,12 +1742,12 @@ elf_s390_relocate_section (output_bfd, i
 
                   if (info->shared)
                     {
-                      asection *srelgot;
+                      asection *s;
                       Elf_Internal_Rela outrel;
-		      Elf64_External_Rela *loc;
+		      bfd_byte *loc;
 
-                      srelgot = htab->srelgot;
-		      if (srelgot == NULL)
+                      s = htab->srelgot;
+		      if (s == NULL)
 			abort ();
 
                       outrel.r_offset = (htab->sgot->output_section->vma
@@ -1755,8 +1755,8 @@ elf_s390_relocate_section (output_bfd, i
                                          + off);
                       outrel.r_info = ELF64_R_INFO (0, R_390_RELATIVE);
 		      outrel.r_addend = relocation;
-		      loc = (Elf64_External_Rela *) srelgot->contents;
-		      loc += srelgot->reloc_count++;
+		      loc = s->contents;
+		      loc += s->reloc_count++ * sizeof (Elf64_External_Rela);
                       bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
                     }
 
@@ -1868,7 +1868,7 @@ elf_s390_relocate_section (output_bfd, i
               Elf_Internal_Rela outrel;
               boolean skip, relocate;
 	      asection *sreloc;
-	      Elf64_External_Rela *loc;
+	      bfd_byte *loc;
 
               /* When generating a shared object, these relocations
                  are copied into the output file to be resolved at run
@@ -1917,8 +1917,8 @@ elf_s390_relocate_section (output_bfd, i
 	      if (sreloc == NULL)
 		abort ();
 
-	      loc = (Elf64_External_Rela *) sreloc->contents;
-	      loc += sreloc->reloc_count++;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela);
               bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 
               /* If this reloc is against an external symbol, we do
@@ -2011,7 +2011,7 @@ elf_s390_finish_dynamic_symbol (output_b
       bfd_vma plt_index;
       bfd_vma got_offset;
       Elf_Internal_Rela rela;
-      Elf64_External_Rela *loc;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the procedure linkage table.  Set
          it up.  */
@@ -2076,7 +2076,7 @@ elf_s390_finish_dynamic_symbol (output_b
 		       + got_offset);
       rela.r_info = ELF64_R_INFO (h->dynindx, R_390_JMP_SLOT);
       rela.r_addend = 0;
-      loc = (Elf64_External_Rela *) htab->srelplt->contents + plt_index;
+      loc = htab->srelplt->contents + plt_index * sizeof (Elf64_External_Rela);
       bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
 
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
@@ -2093,7 +2093,7 @@ elf_s390_finish_dynamic_symbol (output_b
   if (h->got.offset != (bfd_vma) -1)
     {
       Elf_Internal_Rela rela;
-      Elf64_External_Rela *loc;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
          up.  */
@@ -2130,15 +2130,15 @@ elf_s390_finish_dynamic_symbol (output_b
           rela.r_addend = 0;
         }
 
-      loc = (Elf64_External_Rela *) htab->srelgot->contents;
-      loc += htab->srelgot->reloc_count++;
+      loc = htab->srelgot->contents;
+      loc += htab->srelgot->reloc_count++ * sizeof (Elf64_External_Rela);
       bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
     {
       Elf_Internal_Rela rela;
-      Elf64_External_Rela *loc;
+      bfd_byte *loc;
 
       /* This symbols needs a copy reloc.  Set it up.  */
 
@@ -2153,8 +2153,8 @@ elf_s390_finish_dynamic_symbol (output_b
 		       + h->root.u.def.section->output_offset);
       rela.r_info = ELF64_R_INFO (h->dynindx, R_390_COPY);
       rela.r_addend = 0;
-      loc = (Elf64_External_Rela *) htab->srelbss->contents;
-      loc += htab->srelbss->reloc_count++;
+      loc = htab->srelbss->contents;
+      loc += htab->srelbss->reloc_count++ * sizeof (Elf64_External_Rela);
       bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
     }
 
@@ -2345,10 +2345,10 @@ const struct elf_size_info s390_elf64_si
   bfd_elf64_slurp_symbol_table,
   bfd_elf64_swap_dyn_in,
   bfd_elf64_swap_dyn_out,
-  NULL,
-  NULL,
-  NULL,
-  NULL
+  bfd_elf64_swap_reloc_in,
+  bfd_elf64_swap_reloc_out,
+  bfd_elf64_swap_reloca_in,
+  bfd_elf64_swap_reloca_out
 };
 
 #define TARGET_BIG_SYM	bfd_elf64_s390_vec
Index: bfd/elf64-sh64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sh64.c,v
retrieving revision 1.23
diff -u -p -r1.23 elf64-sh64.c
--- bfd/elf64-sh64.c	25 Oct 2002 18:55:22 -0000	1.23
+++ bfd/elf64-sh64.c	27 Nov 2002 15:52:56 -0000
@@ -1748,6 +1748,7 @@ sh_elf64_relocate_section (output_bfd, i
 			      & ELF_LINK_HASH_DEF_REGULAR) == 0))))
 	    {
 	      Elf_Internal_Rela outrel;
+	      bfd_byte *loc;
 	      boolean skip, relocate;
 
 	      /* When generating a shared object, these relocations
@@ -1818,11 +1819,9 @@ sh_elf64_relocate_section (output_bfd, i
 		    }
 		}
 
-	      bfd_elf64_swap_reloca_out (output_bfd, &outrel,
-					 (((Elf64_External_Rela *)
-					   sreloc->contents)
-					  + sreloc->reloc_count));
-	      ++sreloc->reloc_count;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela);
+	      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 
 	      /* If this reloc is against an external symbol, we do
 		 not want to fiddle with the addend.  Otherwise, we
@@ -1971,22 +1970,21 @@ sh_elf64_relocate_section (output_bfd, i
 
 		  if (info->shared)
 		    {
-		      asection *srelgot;
+		      asection *s;
 		      Elf_Internal_Rela outrel;
+		      bfd_byte *loc;
 
-		      srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
-		      BFD_ASSERT (srelgot != NULL);
+		      s = bfd_get_section_by_name (dynobj, ".rela.got");
+		      BFD_ASSERT (s != NULL);
 
 		      outrel.r_offset = (sgot->output_section->vma
 					 + sgot->output_offset
 					 + off);
 		      outrel.r_info = ELF64_R_INFO (0, R_SH_RELATIVE64);
 		      outrel.r_addend = relocation;
-		      bfd_elf64_swap_reloca_out (output_bfd, &outrel,
-						(((Elf64_External_Rela *)
-						  srelgot->contents)
-						 + srelgot->reloc_count));
-		      ++srelgot->reloc_count;
+		      loc = s->contents;
+		      loc += s->reloc_count++ * sizeof (Elf64_External_Rela);
+		      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 		    }
 
 		  if (rel->r_addend)
@@ -3820,6 +3818,7 @@ sh64_elf64_finish_dynamic_symbol (output
       bfd_vma plt_index;
       bfd_vma got_offset;
       Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the procedure linkage table.  Set
 	 it up.  */
@@ -3908,9 +3907,8 @@ sh64_elf64_finish_dynamic_symbol (output
       rel.r_info = ELF64_R_INFO (h->dynindx, R_SH_JMP_SLOT64);
       rel.r_addend = 0;
       rel.r_addend = GOT_BIAS;
-      bfd_elf64_swap_reloca_out (output_bfd, &rel,
-				((Elf64_External_Rela *) srel->contents
-				 + plt_index));
+      loc = srel->contents + plt_index * sizeof (Elf64_External_Rela);
+      bfd_elf64_swap_reloca_out (output_bfd, &rel, loc);
 
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
 	{
@@ -3925,6 +3923,7 @@ sh64_elf64_finish_dynamic_symbol (output
       asection *sgot;
       asection *srel;
       Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
@@ -3958,16 +3957,16 @@ sh64_elf64_finish_dynamic_symbol (output
 	  rel.r_addend = 0;
 	}
 
-      bfd_elf64_swap_reloca_out (output_bfd, &rel,
-				 ((Elf64_External_Rela *) srel->contents
-				  + srel->reloc_count));
-      ++srel->reloc_count;
+      loc = srel->contents;
+      loc += srel->reloc_count++ * sizeof (Elf64_External_Rela);
+      bfd_elf64_swap_reloca_out (output_bfd, &rel, loc);
     }
 
   if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
     {
       asection *s;
       Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol needs a copy reloc.  Set it up.  */
 
@@ -3984,10 +3983,9 @@ sh64_elf64_finish_dynamic_symbol (output
 		      + h->root.u.def.section->output_offset);
       rel.r_info = ELF64_R_INFO (h->dynindx, R_SH_COPY64);
       rel.r_addend = 0;
-      bfd_elf64_swap_reloca_out (output_bfd, &rel,
-				 ((Elf64_External_Rela *) s->contents
-				  + s->reloc_count));
-      ++s->reloc_count;
+      loc = s->contents;
+      loc += s->reloc_count++ * sizeof (Elf64_External_Rela);
+      bfd_elf64_swap_reloca_out (output_bfd, &rel, loc);
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
Index: bfd/elf64-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sparc.c,v
retrieving revision 1.63
diff -u -p -r1.63 elf64-sparc.c
--- bfd/elf64-sparc.c	12 Nov 2002 06:21:05 -0000	1.63
+++ bfd/elf64-sparc.c	27 Nov 2002 15:52:57 -0000
@@ -73,7 +73,7 @@ static boolean sparc64_elf_merge_private
   PARAMS ((bfd *, bfd *));
 
 static boolean sparc64_elf_fake_sections
-  PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *));
+  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
 
 static const char *sparc64_elf_print_symbol_all
   PARAMS ((bfd *, PTR, asymbol *));
@@ -255,7 +255,7 @@ static void
 sparc64_elf_info_to_howto (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf64_Internal_Rela *dst;
+     Elf_Internal_Rela *dst;
 {
   BFD_ASSERT (ELF64_R_TYPE_ID (dst->r_info) < (unsigned int) R_SPARC_max_std);
   cache_ptr->howto = &sparc64_elf_howto_table[ELF64_R_TYPE_ID (dst->r_info)];
@@ -323,7 +323,7 @@ sparc64_elf_slurp_one_reloc_table (abfd,
     {
       Elf_Internal_Rela rela;
 
-      bfd_elf64_swap_reloca_in (abfd, (Elf64_External_Rela *) native_relocs, &rela);
+      bfd_elf64_swap_reloca_in (abfd, native_relocs, &rela);
 
       /* The address of an ELF reloc is section relative for an object
 	 file, and absolute for an executable file or shared library.
@@ -626,7 +626,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, (bfd_byte *) src_rela);
       ++src_rela;
     }
 }
@@ -2073,6 +2073,7 @@ sparc64_elf_relocate_section (output_bfd
 	    case R_SPARC_UA16:
 	      {
 		Elf_Internal_Rela outrel;
+		bfd_byte *loc;
 		boolean skip, relocate;
 
 		if (sreloc == NULL)
@@ -2224,11 +2225,9 @@ sparc64_elf_relocate_section (output_bfd
 		      }
 		  }
 
-		bfd_elf64_swap_reloca_out (output_bfd, &outrel,
-					   (((Elf64_External_Rela *)
-					     sreloc->contents)
-					    + sreloc->reloc_count));
-		++sreloc->reloc_count;
+		loc = sreloc->contents;
+		loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela);
+		bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 
 		/* This reloc will be computed at runtime, so there's no
 		   need to do anything now.  */
@@ -2308,8 +2307,9 @@ sparc64_elf_relocate_section (output_bfd
 
 		  if (info->shared)
 		    {
-		      asection *srelgot;
+		      asection *s;
 		      Elf_Internal_Rela outrel;
+		      bfd_byte *loc;
 
 		      /* The Solaris 2.7 64-bit linker adds the contents
 			 of the location to the value of the reloc.
@@ -2321,19 +2321,17 @@ sparc64_elf_relocate_section (output_bfd
 
 		      /* We need to generate a R_SPARC_RELATIVE reloc
 			 for the dynamic linker.  */
-		      srelgot = bfd_get_section_by_name(dynobj, ".rela.got");
-		      BFD_ASSERT (srelgot != NULL);
+		      s = bfd_get_section_by_name(dynobj, ".rela.got");
+		      BFD_ASSERT (s != NULL);
 
 		      outrel.r_offset = (sgot->output_section->vma
 					 + sgot->output_offset
 					 + off);
 		      outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
 		      outrel.r_addend = relocation;
-		      bfd_elf64_swap_reloca_out (output_bfd, &outrel,
-						 (((Elf64_External_Rela *)
-						   srelgot->contents)
-						  + srelgot->reloc_count));
-		      ++srelgot->reloc_count;
+		      loc = s->contents;
+		      loc += s->reloc_count++ * sizeof (Elf64_External_Rela);
+		      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 		    }
 		  else
 		    bfd_put_64 (output_bfd, relocation, sgot->contents + off);
@@ -2647,6 +2645,7 @@ sparc64_elf_finish_dynamic_symbol (outpu
       asection *splt;
       asection *srela;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the PLT.  Set it up.  */
 
@@ -2678,9 +2677,9 @@ sparc64_elf_finish_dynamic_symbol (outpu
 	 Sun forgot to read their own ABI and copied elf32-sparc behaviour,
 	 thus .plt[4] has corresponding .rela.plt[0] and so on.  */
 
-      bfd_elf64_swap_reloca_out (output_bfd, &rela,
-				 ((Elf64_External_Rela *) srela->contents
-				  + (h->plt.offset - 4)));
+      loc = srela->contents;
+      loc += (h->plt.offset - 4) * sizeof (Elf64_External_Rela);
+      bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
 
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
 	{
@@ -2702,6 +2701,7 @@ sparc64_elf_finish_dynamic_symbol (outpu
       asection *sgot;
       asection *srela;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the GOT.  Set it up.  */
 
@@ -2736,16 +2736,16 @@ sparc64_elf_finish_dynamic_symbol (outpu
 
       bfd_put_64 (output_bfd, (bfd_vma) 0,
 		  sgot->contents + (h->got.offset &~ (bfd_vma) 1));
-      bfd_elf64_swap_reloca_out (output_bfd, &rela,
-				 ((Elf64_External_Rela *) srela->contents
-				  + srela->reloc_count));
-      ++srela->reloc_count;
+      loc = srela->contents;
+      loc += srela->reloc_count++ * sizeof (Elf64_External_Rela);
+      bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
     {
       asection *s;
       Elf_Internal_Rela rela;
+      bfd_byte *loc;
 
       /* This symbols needs a copy reloc.  Set it up.  */
 
@@ -2760,10 +2760,8 @@ sparc64_elf_finish_dynamic_symbol (outpu
 		       + h->root.u.def.section->output_offset);
       rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_COPY);
       rela.r_addend = 0;
-      bfd_elf64_swap_reloca_out (output_bfd, &rela,
-				 ((Elf64_External_Rela *) s->contents
-				  + s->reloc_count));
-      ++s->reloc_count;
+      loc = s->contents + s->reloc_count++ * sizeof (Elf64_External_Rela);
+      bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   /* Mark some specially defined symbols as absolute.  */
@@ -2993,7 +2991,7 @@ sparc64_elf_merge_private_bfd_data (ibfd
 static boolean
 sparc64_elf_fake_sections (abfd, hdr, sec)
      bfd *abfd ATTRIBUTE_UNUSED;
-     Elf32_Internal_Shdr *hdr ATTRIBUTE_UNUSED;
+     Elf_Internal_Shdr *hdr ATTRIBUTE_UNUSED;
      asection *sec;
 {
   const char *name;
@@ -3086,10 +3084,10 @@ const struct elf_size_info sparc64_elf_s
   bfd_elf64_slurp_symbol_table,
   bfd_elf64_swap_dyn_in,
   bfd_elf64_swap_dyn_out,
-  NULL,
-  NULL,
-  NULL,
-  NULL
+  bfd_elf64_swap_reloc_in,
+  bfd_elf64_swap_reloc_out,
+  bfd_elf64_swap_reloca_in,
+  bfd_elf64_swap_reloca_out
 };
 
 #define TARGET_BIG_SYM	bfd_elf64_sparc_vec
Index: bfd/elf64-x86-64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v
retrieving revision 1.52
diff -u -p -r1.52 elf64-x86-64.c
--- bfd/elf64-x86-64.c	1 Oct 2002 09:15:34 -0000	1.52
+++ bfd/elf64-x86-64.c	27 Nov 2002 15:52:59 -0000
@@ -153,7 +153,7 @@ static const struct elf_reloc_map x86_64
 static reloc_howto_type *elf64_x86_64_reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
 static void elf64_x86_64_info_to_howto
-  PARAMS ((bfd *, arelent *, Elf64_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static boolean elf64_x86_64_grok_prstatus
   PARAMS ((bfd *, Elf_Internal_Note *));
 static boolean elf64_x86_64_grok_psinfo
@@ -231,7 +231,7 @@ static void
 elf64_x86_64_info_to_howto (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf64_Internal_Rela *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned r_type, i;
 
@@ -2004,14 +2004,14 @@ elf64_x86_64_relocate_section (output_bf
 
 		  if (info->shared)
 		    {
-		      asection *srelgot;
+		      asection *s;
 		      Elf_Internal_Rela outrel;
-		      Elf64_External_Rela *loc;
+		      bfd_byte *loc;
 
 		      /* We need to generate a R_X86_64_RELATIVE reloc
 			 for the dynamic linker.  */
-		      srelgot = htab->srelgot;
-		      if (srelgot == NULL)
+		      s = htab->srelgot;
+		      if (s == NULL)
 			abort ();
 
 		      outrel.r_offset = (htab->sgot->output_section->vma
@@ -2019,8 +2019,8 @@ elf64_x86_64_relocate_section (output_bf
 					 + off);
 		      outrel.r_info = ELF64_R_INFO (0, R_X86_64_RELATIVE);
 		      outrel.r_addend = relocation;
-		      loc = (Elf64_External_Rela *) srelgot->contents;
-		      loc += srelgot->reloc_count++;
+		      loc = s->contents;
+		      loc += s->reloc_count++ * sizeof (Elf64_External_Rela);
 		      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 		    }
 
@@ -2099,9 +2099,9 @@ elf64_x86_64_relocate_section (output_bf
 		      || h->root.type == bfd_link_hash_undefined)))
 	    {
 	      Elf_Internal_Rela outrel;
+	      bfd_byte *loc;
 	      boolean skip, relocate;
 	      asection *sreloc;
-	      Elf64_External_Rela *loc;
 
 	      /* When generating a shared object, these relocations
 		 are copied into the output file to be resolved at run
@@ -2186,8 +2186,8 @@ elf64_x86_64_relocate_section (output_bf
 	      if (sreloc == NULL)
 		abort ();
 
-	      loc = (Elf64_External_Rela *) sreloc->contents;
-	      loc += sreloc->reloc_count++;
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela);
 	      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 
 	      /* If this reloc is against an external symbol, we do
@@ -2333,7 +2333,7 @@ elf64_x86_64_relocate_section (output_bf
           else
 	    {
 	      Elf_Internal_Rela outrel;
-	      Elf64_External_Rela *loc;
+	      bfd_byte *loc;
 	      int dr_type, indx;
 
 	      if (htab->srelgot == NULL)
@@ -2354,8 +2354,8 @@ elf64_x86_64_relocate_section (output_bf
 		outrel.r_addend = relocation - dtpoff_base (info);
 	      outrel.r_info = ELF64_R_INFO (indx, dr_type);
 
-	      loc = (Elf64_External_Rela *) htab->srelgot->contents;
-	      loc += htab->srelgot->reloc_count++;
+	      loc = htab->srelgot->contents;
+	      loc += htab->srelgot->reloc_count++ * sizeof (Elf64_External_Rela);
 	      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 
 	      if (r_type == R_X86_64_TLSGD)
@@ -2375,9 +2375,8 @@ elf64_x86_64_relocate_section (output_bf
 						    R_X86_64_DTPOFF64);
 		      outrel.r_offset += GOT_ENTRY_SIZE;
 		      htab->srelgot->reloc_count++;
-		      loc++;
-		      bfd_elf64_swap_reloca_out (output_bfd, &outrel,
-						 loc);
+		      loc += sizeof (Elf64_External_Rela);
+		      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 		    }
 		}
 
@@ -2473,7 +2472,7 @@ elf64_x86_64_relocate_section (output_bf
 	  else
 	    {
 	      Elf_Internal_Rela outrel;
-	      Elf64_External_Rela *loc;
+	      bfd_byte *loc;
 
 	      if (htab->srelgot == NULL)
 		abort ();
@@ -2487,8 +2486,8 @@ elf64_x86_64_relocate_section (output_bf
 			  htab->sgot->contents + off + GOT_ENTRY_SIZE);
 	      outrel.r_info = ELF64_R_INFO (0, R_X86_64_DTPMOD64);
 	      outrel.r_addend = 0;
-	      loc = (Elf64_External_Rela *) htab->srelgot->contents;
-	      loc += htab->srelgot->reloc_count++;
+	      loc = htab->srelgot->contents;
+	      loc += htab->srelgot->reloc_count++ * sizeof (Elf64_External_Rela);
 	      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 	      htab->tls_ld_got.offset |= 1;
 	    }
@@ -2589,7 +2588,7 @@ elf64_x86_64_finish_dynamic_symbol (outp
       bfd_vma plt_index;
       bfd_vma got_offset;
       Elf_Internal_Rela rela;
-      Elf64_External_Rela *loc;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the procedure linkage table.  Set
 	 it up.	 */
@@ -2649,7 +2648,7 @@ elf64_x86_64_finish_dynamic_symbol (outp
 		       + got_offset);
       rela.r_info = ELF64_R_INFO (h->dynindx, R_X86_64_JUMP_SLOT);
       rela.r_addend = 0;
-      loc = (Elf64_External_Rela *) htab->srelplt->contents + plt_index;
+      loc = htab->srelplt->contents + plt_index * sizeof (Elf64_External_Rela);
       bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
 
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
@@ -2668,7 +2667,7 @@ elf64_x86_64_finish_dynamic_symbol (outp
       && elf64_x86_64_hash_entry (h)->tls_type != GOT_TLS_IE)
     {
       Elf_Internal_Rela rela;
-      Elf64_External_Rela *loc;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
@@ -2706,15 +2705,15 @@ elf64_x86_64_finish_dynamic_symbol (outp
 	  rela.r_addend = 0;
 	}
 
-      loc = (Elf64_External_Rela *) htab->srelgot->contents;
-      loc += htab->srelgot->reloc_count++;
+      loc = htab->srelgot->contents;
+      loc += htab->srelgot->reloc_count++ * sizeof (Elf64_External_Rela);
       bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
     {
       Elf_Internal_Rela rela;
-      Elf64_External_Rela *loc;
+      bfd_byte *loc;
 
       /* This symbol needs a copy reloc.  Set it up.  */
 
@@ -2729,8 +2728,8 @@ elf64_x86_64_finish_dynamic_symbol (outp
 		       + h->root.u.def.section->output_offset);
       rela.r_info = ELF64_R_INFO (h->dynindx, R_X86_64_COPY);
       rela.r_addend = 0;
-      loc = (Elf64_External_Rela *) htab->srelbss->contents;
-      loc += htab->srelbss->reloc_count++;
+      loc = htab->srelbss->contents;
+      loc += htab->srelbss->reloc_count++ * sizeof (Elf64_External_Rela);
       bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
     }
 
Index: bfd/elfarm-nabi.c
===================================================================
RCS file: /cvs/src/src/bfd/elfarm-nabi.c,v
retrieving revision 1.15
diff -u -p -r1.15 elfarm-nabi.c
--- bfd/elfarm-nabi.c	6 Nov 2002 11:38:35 -0000	1.15
+++ bfd/elfarm-nabi.c	27 Nov 2002 15:52:59 -0000
@@ -583,13 +583,13 @@ static reloc_howto_type elf32_arm_thm_pc
 	 true);			/* pcrel_offset */
 
 static void elf32_arm_info_to_howto
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 
 static void
 elf32_arm_info_to_howto (abfd, bfd_reloc, elf_reloc)
      bfd * abfd ATTRIBUTE_UNUSED;
      arelent * bfd_reloc;
-     Elf32_Internal_Rel * elf_reloc;
+     Elf_Internal_Rela * elf_reloc;
 {
   unsigned int r_type;
 
Index: bfd/elfarm-oabi.c
===================================================================
RCS file: /cvs/src/src/bfd/elfarm-oabi.c,v
retrieving revision 1.10
diff -u -p -r1.10 elfarm-oabi.c
--- bfd/elfarm-oabi.c	23 Jul 2002 12:34:35 -0000	1.10
+++ bfd/elfarm-oabi.c	27 Nov 2002 15:52:59 -0000
@@ -49,7 +49,7 @@
 #define ARM_ELF_OS_ABI_VERSION		0
 
 static reloc_howto_type * find_howto                  PARAMS ((unsigned int));
-static void               elf32_arm_info_to_howto     PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+static void               elf32_arm_info_to_howto     PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static reloc_howto_type * elf32_arm_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type));
 
 static reloc_howto_type elf32_arm_howto_table[] =
@@ -369,7 +369,7 @@ static void
 elf32_arm_info_to_howto (abfd, bfd_reloc, elf_reloc)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *bfd_reloc;
-     Elf32_Internal_Rela *elf_reloc;
+     Elf_Internal_Rela *elf_reloc;
 {
   unsigned int r_type;
 
Index: bfd/elfcode.h
===================================================================
RCS file: /cvs/src/src/bfd/elfcode.h,v
retrieving revision 1.38
diff -c -p -r1.38 elfcode.h
*** bfd/elfcode.h	12 Nov 2002 22:49:45 -0000	1.38
--- bfd/elfcode.h	28 Nov 2002 11:27:36 -0000
*************** elf_swap_phdr_out (abfd, src, dst)
*** 421,464 ****
  }
  
  /* Translate an ELF reloc from external format to internal format.  */
! INLINE void
! elf_swap_reloc_in (abfd, src, dst)
       bfd *abfd;
!      const Elf_External_Rel *src;
!      Elf_Internal_Rel *dst;
  {
    dst->r_offset = H_GET_WORD (abfd, src->r_offset);
    dst->r_info = H_GET_WORD (abfd, src->r_info);
  }
  
! INLINE void
! elf_swap_reloca_in (abfd, src, dst)
       bfd *abfd;
!      const Elf_External_Rela *src;
       Elf_Internal_Rela *dst;
  {
    dst->r_offset = H_GET_WORD (abfd, src->r_offset);
    dst->r_info = H_GET_WORD (abfd, src->r_info);
    dst->r_addend = H_GET_SIGNED_WORD (abfd, src->r_addend);
  }
  
  /* Translate an ELF reloc from internal format to external format.  */
! INLINE void
! elf_swap_reloc_out (abfd, src, dst)
       bfd *abfd;
!      const Elf_Internal_Rel *src;
!      Elf_External_Rel *dst;
  {
    H_PUT_WORD (abfd, src->r_offset, dst->r_offset);
    H_PUT_WORD (abfd, src->r_info, dst->r_info);
  }
  
! INLINE void
! elf_swap_reloca_out (abfd, src, dst)
       bfd *abfd;
       const Elf_Internal_Rela *src;
!      Elf_External_Rela *dst;
  {
    H_PUT_WORD (abfd, src->r_offset, dst->r_offset);
    H_PUT_WORD (abfd, src->r_info, dst->r_info);
    H_PUT_SIGNED_WORD (abfd, src->r_addend, dst->r_addend);
--- 421,469 ----
  }
  
  /* Translate an ELF reloc from external format to internal format.  */
! void
! elf_swap_reloc_in (abfd, s, dst)
       bfd *abfd;
!      const bfd_byte *s;
!      Elf_Internal_Rela *dst;
  {
+   const Elf_External_Rel *src = (const Elf_External_Rel *) s;
    dst->r_offset = H_GET_WORD (abfd, src->r_offset);
    dst->r_info = H_GET_WORD (abfd, src->r_info);
+   dst->r_addend = 0;
  }
  
! void
! elf_swap_reloca_in (abfd, s, dst)
       bfd *abfd;
!      const bfd_byte *s;
       Elf_Internal_Rela *dst;
  {
+   const Elf_External_Rela *src = (const Elf_External_Rela *) s;
    dst->r_offset = H_GET_WORD (abfd, src->r_offset);
    dst->r_info = H_GET_WORD (abfd, src->r_info);
    dst->r_addend = H_GET_SIGNED_WORD (abfd, src->r_addend);
  }
  
  /* Translate an ELF reloc from internal format to external format.  */
! void
! elf_swap_reloc_out (abfd, src, d)
       bfd *abfd;
!      const Elf_Internal_Rela *src;
!      bfd_byte *d;
  {
+   Elf_External_Rel *dst = (Elf_External_Rel *) d;
    H_PUT_WORD (abfd, src->r_offset, dst->r_offset);
    H_PUT_WORD (abfd, src->r_info, dst->r_info);
  }
  
! void
! elf_swap_reloca_out (abfd, src, d)
       bfd *abfd;
       const Elf_Internal_Rela *src;
!      bfd_byte *d;
  {
+   Elf_External_Rela *dst = (Elf_External_Rela *) d;
    H_PUT_WORD (abfd, src->r_offset, dst->r_offset);
    H_PUT_WORD (abfd, src->r_info, dst->r_info);
    H_PUT_SIGNED_WORD (abfd, src->r_addend, dst->r_addend);
*************** elf_write_relocs (abfd, sec, data)
*** 858,869 ****
  {
    boolean *failedp = (boolean *) data;
    Elf_Internal_Shdr *rela_hdr;
!   Elf_External_Rela *outbound_relocas;
!   Elf_External_Rel *outbound_relocs;
    unsigned int idx;
!   int use_rela_p;
!   asymbol *last_sym = 0;
!   int last_sym_idx = 0;
  
    /* If we have already failed, don't do anything.  */
    if (*failedp)
--- 863,875 ----
  {
    boolean *failedp = (boolean *) data;
    Elf_Internal_Shdr *rela_hdr;
!   bfd_vma addr_offset;
!   void (*swap_out) PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
!   size_t extsize;
!   bfd_byte *dst_rela;
    unsigned int idx;
!   asymbol *last_sym;
!   int last_sym_idx;
  
    /* If we have already failed, don't do anything.  */
    if (*failedp)
*************** elf_write_relocs (abfd, sec, data)
*** 891,1012 ****
  
    /* Figure out whether the relocations are RELA or REL relocations.  */
    if (rela_hdr->sh_type == SHT_RELA)
!     use_rela_p = true;
    else if (rela_hdr->sh_type == SHT_REL)
!     use_rela_p = false;
    else
      /* Every relocation section should be either an SHT_RELA or an
         SHT_REL section.  */
      abort ();
  
!   /* orelocation has the data, reloc_count has the count...  */
!   if (use_rela_p)
!     {
!       outbound_relocas = (Elf_External_Rela *) rela_hdr->contents;
  
!       for (idx = 0; idx < sec->reloc_count; idx++)
  	{
! 	  Elf_Internal_Rela dst_rela;
! 	  Elf_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.
! 	     The address of a BFD reloc is always section relative.  */
! 	  if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
! 	    dst_rela.r_offset = ptr->address;
! 	  else
! 	    dst_rela.r_offset = ptr->address + sec->vma;
! 
! 	  sym = *ptr->sym_ptr_ptr;
! 	  if (sym == last_sym)
! 	    n = last_sym_idx;
! 	  else if (bfd_is_abs_section (sym->section) && sym->value == 0)
! 	    n = STN_UNDEF;
! 	  else
! 	    {
! 	      last_sym = sym;
! 	      n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
! 	      if (n < 0)
! 		{
! 		  *failedp = true;
! 		  return;
! 		}
! 	      last_sym_idx = n;
! 	    }
! 
! 	  if ((*ptr->sym_ptr_ptr)->the_bfd != NULL
! 	      && (*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
! 	      && ! _bfd_elf_validate_reloc (abfd, ptr))
  	    {
  	      *failedp = true;
  	      return;
  	    }
! 
! 	  dst_rela.r_info = ELF_R_INFO (n, ptr->howto->type);
! 
! 	  dst_rela.r_addend = ptr->addend;
! 	  elf_swap_reloca_out (abfd, &dst_rela, src_rela);
  	}
-     }
-   else
-     /* REL relocations */
-     {
-       outbound_relocs = (Elf_External_Rel *) rela_hdr->contents;
  
!       for (idx = 0; idx < sec->reloc_count; idx++)
  	{
! 	  Elf_Internal_Rel dst_rel;
! 	  Elf_External_Rel *src_rel;
! 	  arelent *ptr;
! 	  int n;
! 	  asymbol *sym;
! 
! 	  ptr = sec->orelocation[idx];
! 	  sym = *ptr->sym_ptr_ptr;
! 	  src_rel = outbound_relocs + idx;
! 
! 	  /* The address of an ELF reloc is section relative for an object
! 	     file, and absolute for an executable file or shared library.
! 	     The address of a BFD reloc is always section relative.  */
! 	  if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
! 	    dst_rel.r_offset = ptr->address;
! 	  else
! 	    dst_rel.r_offset = ptr->address + sec->vma;
! 
! 	  if (sym == last_sym)
! 	    n = last_sym_idx;
! 	  else if (bfd_is_abs_section (sym->section) && sym->value == 0)
! 	    n = STN_UNDEF;
! 	  else
! 	    {
! 	      last_sym = sym;
! 	      n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
! 	      if (n < 0)
! 		{
! 		  *failedp = true;
! 		  return;
! 		}
! 	      last_sym_idx = n;
! 	    }
! 
! 	  if ((*ptr->sym_ptr_ptr)->the_bfd != NULL
! 	      && (*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
! 	      && ! _bfd_elf_validate_reloc (abfd, ptr))
! 	    {
! 	      *failedp = true;
! 	      return;
! 	    }
! 
! 	  dst_rel.r_info = ELF_R_INFO (n, ptr->howto->type);
! 
! 	  elf_swap_reloc_out (abfd, &dst_rel, src_rel);
  	}
      }
  }
  
--- 897,965 ----
  
    /* Figure out whether the relocations are RELA or REL relocations.  */
    if (rela_hdr->sh_type == SHT_RELA)
!     {
!       swap_out = elf_swap_reloca_out;
!       extsize = sizeof (Elf_External_Rela);
!     }
    else if (rela_hdr->sh_type == SHT_REL)
!     {
!       swap_out = elf_swap_reloc_out;
!       extsize = sizeof (Elf_External_Rel);
!     }
    else
      /* Every relocation section should be either an SHT_RELA or an
         SHT_REL section.  */
      abort ();
  
!   /* The address of an ELF reloc is section relative for an object
!      file, and absolute for an executable file or shared library.
!      The address of a BFD reloc is always section relative.  */
!   addr_offset = 0;
!   if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
!     addr_offset = sec->vma;
  
!   /* orelocation has the data, reloc_count has the count...  */
!   last_sym = 0;
!   last_sym_idx = 0;
!   dst_rela = rela_hdr->contents;
! 
!   for (idx = 0; idx < sec->reloc_count; idx++, dst_rela += extsize)
!     {
!       Elf_Internal_Rela src_rela;
!       arelent *ptr;
!       asymbol *sym;
!       int n;
! 
!       ptr = sec->orelocation[idx];
!       sym = *ptr->sym_ptr_ptr;
!       if (sym == last_sym)
! 	n = last_sym_idx;
!       else if (bfd_is_abs_section (sym->section) && sym->value == 0)
! 	n = STN_UNDEF;
!       else
  	{
! 	  last_sym = sym;
! 	  n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
! 	  if (n < 0)
  	    {
  	      *failedp = true;
  	      return;
  	    }
! 	  last_sym_idx = n;
  	}
  
!       if ((*ptr->sym_ptr_ptr)->the_bfd != NULL
! 	  && (*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
! 	  && ! _bfd_elf_validate_reloc (abfd, ptr))
  	{
! 	  *failedp = true;
! 	  return;
  	}
+ 
+       src_rela.r_offset = ptr->address + addr_offset;
+       src_rela.r_info = ELF_R_INFO (n, ptr->howto->type);
+       src_rela.r_addend = ptr->addend;
+       (*swap_out) (abfd, &src_rela, dst_rela);
      }
  }
  
*************** elf_slurp_reloc_table_from_section (abfd
*** 1372,1388 ****
         i++, relent++, native_relocs += entsize)
      {
        Elf_Internal_Rela rela;
-       Elf_Internal_Rel rel;
  
        if (entsize == sizeof (Elf_External_Rela))
! 	elf_swap_reloca_in (abfd, (Elf_External_Rela *) native_relocs, &rela);
        else
! 	{
! 	  elf_swap_reloc_in (abfd, (Elf_External_Rel *) native_relocs, &rel);
! 	  rela.r_offset = rel.r_offset;
! 	  rela.r_info = rel.r_info;
! 	  rela.r_addend = 0;
! 	}
  
        /* The address of an ELF reloc is section relative for an object
  	 file, and absolute for an executable file or shared library.
--- 1325,1335 ----
         i++, relent++, native_relocs += entsize)
      {
        Elf_Internal_Rela rela;
  
        if (entsize == sizeof (Elf_External_Rela))
! 	elf_swap_reloca_in (abfd, native_relocs, &rela);
        else
! 	elf_swap_reloc_in (abfd, native_relocs, &rela);
  
        /* The address of an ELF reloc is section relative for an object
  	 file, and absolute for an executable file or shared library.
*************** elf_slurp_reloc_table_from_section (abfd
*** 1421,1427 ****
        if (entsize == sizeof (Elf_External_Rela))
  	(*ebd->elf_info_to_howto) (abfd, relent, &rela);
        else
! 	(*ebd->elf_info_to_howto_rel) (abfd, relent, &rel);
      }
  
    if (allocated != NULL)
--- 1368,1374 ----
        if (entsize == sizeof (Elf_External_Rela))
  	(*ebd->elf_info_to_howto) (abfd, relent, &rela);
        else
! 	(*ebd->elf_info_to_howto_rel) (abfd, relent, &rela);
      }
  
    if (allocated != NULL)
*************** const struct elf_size_info NAME(_bfd_elf
*** 1649,1656 ****
    elf_slurp_symbol_table,
    elf_swap_dyn_in,
    elf_swap_dyn_out,
!   NULL,
!   NULL,
!   NULL,
!   NULL
  };
--- 1596,1603 ----
    elf_slurp_symbol_table,
    elf_swap_dyn_in,
    elf_swap_dyn_out,
!   elf_swap_reloc_in,
!   elf_swap_reloc_out,
!   elf_swap_reloca_in,
!   elf_swap_reloca_out
  };
Index: bfd/elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.198
diff -c -p -r1.198 elflink.h
*** bfd/elflink.h	26 Nov 2002 11:53:59 -0000	1.198
--- bfd/elflink.h	28 Nov 2002 11:27:40 -0000
*************** elf_link_read_relocs_from_section (abfd,
*** 2484,2490 ****
       Elf_Internal_Rela *internal_relocs;
  {
    struct elf_backend_data *bed;
!   bfd_size_type amt;
  
    /* If there aren't any relocations, that's OK.  */
    if (!shdr)
--- 2484,2493 ----
       Elf_Internal_Rela *internal_relocs;
  {
    struct elf_backend_data *bed;
!   void (*swap_in) PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
!   const bfd_byte *erela;
!   const bfd_byte *erelaend;
!   Elf_Internal_Rela *irela;
  
    /* If there aren't any relocations, that's OK.  */
    if (!shdr)
*************** elf_link_read_relocs_from_section (abfd,
*** 2502,2553 ****
  
    /* Convert the external relocations to the internal format.  */
    if (shdr->sh_entsize == sizeof (Elf_External_Rel))
!     {
!       Elf_External_Rel *erel;
!       Elf_External_Rel *erelend;
!       Elf_Internal_Rela *irela;
!       Elf_Internal_Rel *irel;
! 
!       erel = (Elf_External_Rel *) external_relocs;
!       erelend = erel + NUM_SHDR_ENTRIES (shdr);
!       irela = internal_relocs;
!       amt = bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rel);
!       irel = bfd_alloc (abfd, amt);
!       for (; erel < erelend; erel++, irela += bed->s->int_rels_per_ext_rel)
! 	{
! 	  unsigned int i;
! 
! 	  if (bed->s->swap_reloc_in)
! 	    (*bed->s->swap_reloc_in) (abfd, (bfd_byte *) erel, irel);
! 	  else
! 	    elf_swap_reloc_in (abfd, erel, irel);
! 
! 	  for (i = 0; i < bed->s->int_rels_per_ext_rel; ++i)
! 	    {
! 	      irela[i].r_offset = irel[i].r_offset;
! 	      irela[i].r_info = irel[i].r_info;
! 	      irela[i].r_addend = 0;
! 	    }
! 	}
!     }
    else
      {
!       Elf_External_Rela *erela;
!       Elf_External_Rela *erelaend;
!       Elf_Internal_Rela *irela;
! 
!       BFD_ASSERT (shdr->sh_entsize == sizeof (Elf_External_Rela));
! 
!       erela = (Elf_External_Rela *) external_relocs;
!       erelaend = erela + NUM_SHDR_ENTRIES (shdr);
!       irela = internal_relocs;
!       for (; erela < erelaend; erela++, irela += bed->s->int_rels_per_ext_rel)
! 	{
! 	  if (bed->s->swap_reloca_in)
! 	    (*bed->s->swap_reloca_in) (abfd, (bfd_byte *) erela, irela);
! 	  else
! 	    elf_swap_reloca_in (abfd, erela, irela);
! 	}
      }
  
    return true;
--- 2505,2524 ----
  
    /* Convert the external relocations to the internal format.  */
    if (shdr->sh_entsize == sizeof (Elf_External_Rel))
!     swap_in = bed->s->swap_reloc_in;
!   else if (shdr->sh_entsize == sizeof (Elf_External_Rela))
!     swap_in = bed->s->swap_reloca_in;
    else
+     abort ();
+ 
+   erela = external_relocs;
+   erelaend = erela + NUM_SHDR_ENTRIES (shdr) * shdr->sh_entsize;
+   irela = internal_relocs;
+   while (erela < erelaend)
      {
!       (*swap_in) (abfd, erela, irela);
!       irela += bed->s->int_rels_per_ext_rel;
!       erela += shdr->sh_entsize;
      }
  
    return true;
*************** elf_link_adjust_relocs (abfd, rel_hdr, c
*** 4588,4678 ****
  {
    unsigned int i;
    struct elf_backend_data *bed = get_elf_backend_data (abfd);
!   Elf_Internal_Rel *irel;
!   Elf_Internal_Rela *irela;
!   bfd_size_type amt = sizeof (Elf_Internal_Rel) * bed->s->int_rels_per_ext_rel;
  
!   irel = (Elf_Internal_Rel *) bfd_zmalloc (amt);
!   if (irel == NULL)
      {
!       (*_bfd_error_handler) (_("Error: out of memory"));
!       abort ();
      }
! 
!   amt = sizeof (Elf_Internal_Rela) * bed->s->int_rels_per_ext_rel;
!   irela = (Elf_Internal_Rela *) bfd_zmalloc (amt);
!   if (irela == NULL)
      {
!       (*_bfd_error_handler) (_("Error: out of memory"));
!       abort ();
      }
  
!   for (i = 0; i < count; i++, rel_hash++)
      {
        if (*rel_hash == NULL)
  	continue;
  
        BFD_ASSERT ((*rel_hash)->indx >= 0);
  
!       if (rel_hdr->sh_entsize == sizeof (Elf_External_Rel))
! 	{
! 	  Elf_External_Rel *erel;
! 	  unsigned int j;
! 
! 	  erel = (Elf_External_Rel *) rel_hdr->contents + i;
! 	  if (bed->s->swap_reloc_in)
! 	    (*bed->s->swap_reloc_in) (abfd, (bfd_byte *) erel, irel);
! 	  else
! 	    elf_swap_reloc_in (abfd, erel, irel);
! 
! 	  for (j = 0; j < bed->s->int_rels_per_ext_rel; j++)
! 	    irel[j].r_info = ELF_R_INFO ((*rel_hash)->indx,
! 					 ELF_R_TYPE (irel[j].r_info));
! 
! 	  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
! 	{
! 	  Elf_External_Rela *erela;
! 	  unsigned int j;
! 
! 	  BFD_ASSERT (rel_hdr->sh_entsize
! 		      == sizeof (Elf_External_Rela));
! 
! 	  erela = (Elf_External_Rela *) rel_hdr->contents + i;
! 	  if (bed->s->swap_reloca_in)
! 	    (*bed->s->swap_reloca_in) (abfd, (bfd_byte *) erela, irela);
! 	  else
! 	    elf_swap_reloca_in (abfd, erela, irela);
! 
! 	  for (j = 0; j < bed->s->int_rels_per_ext_rel; j++)
! 	    irela[j].r_info = ELF_R_INFO ((*rel_hash)->indx,
! 					  ELF_R_TYPE (irela[j].r_info));
! 
! 	  if (bed->s->swap_reloca_out)
! 	    (*bed->s->swap_reloca_out) (abfd, irela, (bfd_byte *) erela);
! 	  else
! 	    elf_swap_reloca_out (abfd, irela, erela);
! 	}
      }
- 
-   free (irel);
-   free (irela);
  }
  
  struct elf_link_sort_rela
  {
    bfd_vma offset;
    enum elf_reloc_type_class type;
!   union
!   {
!     /* We use these as arrays of size int_rels_per_ext_rel.  */
!     Elf_Internal_Rel rel[1];
!     Elf_Internal_Rela rela[1];
!   } u;
  };
  
  static int
--- 4559,4609 ----
  {
    unsigned int i;
    struct elf_backend_data *bed = get_elf_backend_data (abfd);
!   bfd_byte *erela;
!   void (*swap_in) PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
!   void (*swap_out) PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
  
!   if (rel_hdr->sh_entsize == sizeof (Elf_External_Rel))
      {
!       swap_in = bed->s->swap_reloc_in;
!       swap_out = bed->s->swap_reloc_out;
      }
!   else if (rel_hdr->sh_entsize == sizeof (Elf_External_Rela))
      {
!       swap_in = bed->s->swap_reloca_in;
!       swap_out = bed->s->swap_reloca_out;
      }
+   else
+     abort ();
+ 
+   if (bed->s->int_rels_per_ext_rel > MAX_INT_RELS_PER_EXT_REL)
+     abort ();
  
!   erela = rel_hdr->contents;
!   for (i = 0; i < count; i++, rel_hash++, erela += rel_hdr->sh_entsize)
      {
+       Elf_Internal_Rela irela[MAX_INT_RELS_PER_EXT_REL];
+       unsigned int j;
+ 
        if (*rel_hash == NULL)
  	continue;
  
        BFD_ASSERT ((*rel_hash)->indx >= 0);
  
!       (*swap_in) (abfd, erela, irela);
!       for (j = 0; j < bed->s->int_rels_per_ext_rel; j++)
! 	irela[j].r_info = ELF_R_INFO ((*rel_hash)->indx,
! 				      ELF_R_TYPE (irela[j].r_info));
!       (*swap_out) (abfd, irela, erela);
      }
  }
  
  struct elf_link_sort_rela
  {
    bfd_vma offset;
    enum elf_reloc_type_class type;
!   /* We use this as an array of size int_rels_per_ext_rel.  */
!   Elf_Internal_Rela rela[1];
  };
  
  static int
*************** elf_link_sort_cmp1 (A, B)
*** 4691,4703 ****
      return 1;
    if (relativea > relativeb)
      return -1;
!   if (ELF_R_SYM (a->u.rel->r_info) < ELF_R_SYM (b->u.rel->r_info))
      return -1;
!   if (ELF_R_SYM (a->u.rel->r_info) > ELF_R_SYM (b->u.rel->r_info))
      return 1;
!   if (a->u.rel->r_offset < b->u.rel->r_offset)
      return -1;
!   if (a->u.rel->r_offset > b->u.rel->r_offset)
      return 1;
    return 0;
  }
--- 4622,4634 ----
      return 1;
    if (relativea > relativeb)
      return -1;
!   if (ELF_R_SYM (a->rela->r_info) < ELF_R_SYM (b->rela->r_info))
      return -1;
!   if (ELF_R_SYM (a->rela->r_info) > ELF_R_SYM (b->rela->r_info))
      return 1;
!   if (a->rela->r_offset < b->rela->r_offset)
      return -1;
!   if (a->rela->r_offset > b->rela->r_offset)
      return 1;
    return 0;
  }
*************** elf_link_sort_cmp2 (A, B)
*** 4721,4729 ****
      return -1;
    if (copya > copyb)
      return 1;
!   if (a->u.rel->r_offset < b->u.rel->r_offset)
      return -1;
!   if (a->u.rel->r_offset > b->u.rel->r_offset)
      return 1;
    return 0;
  }
--- 4652,4660 ----
      return -1;
    if (copya > copyb)
      return 1;
!   if (a->rela->r_offset < b->rela->r_offset)
      return -1;
!   if (a->rela->r_offset > b->rela->r_offset)
      return 1;
    return 0;
  }
*************** elf_link_sort_relocs (abfd, info, psec)
*** 4736,4747 ****
  {
    bfd *dynobj = elf_hash_table (info)->dynobj;
    asection *reldyn, *o;
-   boolean rel = false;
    bfd_size_type count, size;
!   size_t i, j, ret;
!   struct elf_link_sort_rela *rela;
    struct elf_backend_data *bed = get_elf_backend_data (abfd);
    int i2e = bed->s->int_rels_per_ext_rel;
  
    reldyn = bfd_get_section_by_name (abfd, ".rela.dyn");
    if (reldyn == NULL || reldyn->_raw_size == 0)
--- 4667,4680 ----
  {
    bfd *dynobj = elf_hash_table (info)->dynobj;
    asection *reldyn, *o;
    bfd_size_type count, size;
!   size_t i, ret, sort_elt, ext_size;
!   bfd_byte *sort, *s_non_relative, *p;
!   struct elf_link_sort_rela *sq;
    struct elf_backend_data *bed = get_elf_backend_data (abfd);
    int i2e = bed->s->int_rels_per_ext_rel;
+   void (*swap_in) PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
+   void (*swap_out) PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
  
    reldyn = bfd_get_section_by_name (abfd, ".rela.dyn");
    if (reldyn == NULL || reldyn->_raw_size == 0)
*************** elf_link_sort_relocs (abfd, info, psec)
*** 4749,4759 ****
        reldyn = bfd_get_section_by_name (abfd, ".rel.dyn");
        if (reldyn == NULL || reldyn->_raw_size == 0)
  	return 0;
!       rel = true;
!       count = reldyn->_raw_size / sizeof (Elf_External_Rel);
      }
    else
!     count = reldyn->_raw_size / sizeof (Elf_External_Rela);
  
    size = 0;
    for (o = dynobj->sections; o != NULL; o = o->next)
--- 4682,4698 ----
        reldyn = bfd_get_section_by_name (abfd, ".rel.dyn");
        if (reldyn == NULL || reldyn->_raw_size == 0)
  	return 0;
!       ext_size = sizeof (Elf_External_Rel);
!       swap_in = bed->s->swap_reloc_in;
!       swap_out = bed->s->swap_reloc_out;
      }
    else
!     {
!       ext_size = sizeof (Elf_External_Rela);
!       swap_in = bed->s->swap_reloca_in;
!       swap_out = bed->s->swap_reloca_out;
!     }
!   count = reldyn->_raw_size / ext_size;
  
    size = 0;
    for (o = dynobj->sections; o != NULL; o = o->next)
*************** elf_link_sort_relocs (abfd, info, psec)
*** 4765,4788 ****
    if (size != reldyn->_raw_size)
      return 0;
  
!   /* We waste some memory here when N = i2e is greater than 1, since
!      we allocate space for N * sizeof (*rela) where sizeof (*rela) +
!      (N - 1) * sizeof (Elf_Internal_Rel/Rela) would do.  Also, we use
!      rela[k] only when k is a multiple of N, and then we index the
!      array within the union, such that rela[k].u.rel[i], i < N, is the
!      (i+1)th internal relocation corresponding to the (k/N)th external
!      relocation.  This is done such that the relocation swap-in and
!      swap-out functions can gen pointers to arrays of internal
!      relocations that form a single external relocation.
! 
!      If C permitted arrays of structures with dynamic sizes, we could
!      do better, but trying to avoid wasting space at the end of the
!      chunk from rela[k] to rela[k+N-1] would require us to allocate a
!      separate array of pointers and since most ports have N == 1, this
!      would be more wasteful.  */
!   rela = (struct elf_link_sort_rela *) bfd_zmalloc
!     (sizeof (*rela) * count * i2e);
!   if (rela == NULL)
      {
        (*info->callbacks->warning)
  	(info, _("Not enough memory to sort relocations"), 0, abfd, 0,
--- 4704,4713 ----
    if (size != reldyn->_raw_size)
      return 0;
  
!   sort_elt = (sizeof (struct elf_link_sort_rela)
! 	      + (i2e - 1) * sizeof (Elf_Internal_Rela));
!   sort = bfd_zmalloc (sort_elt * count);
!   if (sort == NULL)
      {
        (*info->callbacks->warning)
  	(info, _("Not enough memory to sort relocations"), 0, abfd, 0,
*************** elf_link_sort_relocs (abfd, info, psec)
*** 4795,4897 ****
  	== (SEC_HAS_CONTENTS|SEC_LINKER_CREATED)
  	&& o->output_section == reldyn)
        {
! 	if (rel)
! 	  {
! 	    Elf_External_Rel *erel, *erelend;
! 	    struct elf_link_sort_rela *s;
! 
! 	    erel = (Elf_External_Rel *) o->contents;
! 	    erelend = (Elf_External_Rel *) (o->contents + o->_raw_size);
! 	    s = rela + (o->output_offset / sizeof (Elf_External_Rel) * i2e);
! 	    for (; erel < erelend; erel++, s += i2e)
! 	      {
! 		if (bed->s->swap_reloc_in)
! 		  (*bed->s->swap_reloc_in) (abfd, (bfd_byte *) erel,
! 					    s->u.rel);
! 		else
! 		  elf_swap_reloc_in (abfd, erel, s->u.rel);
  
! 		s->type = (*bed->elf_backend_reloc_type_class) (s->u.rela);
! 	      }
! 	  }
! 	else
  	  {
! 	    Elf_External_Rela *erela, *erelaend;
! 	    struct elf_link_sort_rela *s;
! 
! 	    erela = (Elf_External_Rela *) o->contents;
! 	    erelaend = (Elf_External_Rela *) (o->contents + o->_raw_size);
! 	    s = rela + (o->output_offset / sizeof (Elf_External_Rela) * i2e);
! 	    for (; erela < erelaend; erela++, s += i2e)
! 	      {
! 		if (bed->s->swap_reloca_in)
! 		  (*bed->s->swap_reloca_in) (dynobj, (bfd_byte *) erela,
! 					     s->u.rela);
! 		else
! 		  elf_swap_reloca_in (dynobj, erela, s->u.rela);
! 
! 		s->type = (*bed->elf_backend_reloc_type_class) (s->u.rela);
! 	      }
  	  }
        }
  
!   qsort (rela, (size_t) count, sizeof (*rela) * i2e, elf_link_sort_cmp1);
!   for (ret = 0; ret < count * i2e && rela[ret].type == reloc_class_relative;
!        ret += i2e)
!     ;
!   for (i = ret, j = ret; i < count * i2e; i += i2e)
!     {
!       if (ELF_R_SYM (rela[i].u.rel->r_info)
! 	  != ELF_R_SYM (rela[j].u.rel->r_info))
! 	j = i;
!       rela[i].offset = rela[j].u.rel->r_offset;
!     }
!   ret /= i2e;
!   qsort (rela + ret, (size_t) count - ret,
! 	 sizeof (*rela) * i2e, elf_link_sort_cmp2);
  
    for (o = dynobj->sections; o != NULL; o = o->next)
      if ((o->flags & (SEC_HAS_CONTENTS|SEC_LINKER_CREATED))
  	== (SEC_HAS_CONTENTS|SEC_LINKER_CREATED)
  	&& o->output_section == reldyn)
        {
! 	if (rel)
! 	  {
! 	    Elf_External_Rel *erel, *erelend;
! 	    struct elf_link_sort_rela *s;
  
! 	    erel = (Elf_External_Rel *) o->contents;
! 	    erelend = (Elf_External_Rel *) (o->contents + o->_raw_size);
! 	    s = rela + (o->output_offset / sizeof (Elf_External_Rel) * i2e);
! 	    for (; erel < erelend; erel++, s += i2e)
! 	      {
! 		if (bed->s->swap_reloc_out)
! 		  (*bed->s->swap_reloc_out) (abfd, s->u.rel,
! 					     (bfd_byte *) erel);
! 		else
! 		  elf_swap_reloc_out (abfd, s->u.rel, erel);
! 	      }
! 	  }
! 	else
  	  {
! 	    Elf_External_Rela *erela, *erelaend;
! 	    struct elf_link_sort_rela *s;
! 
! 	    erela = (Elf_External_Rela *) o->contents;
! 	    erelaend = (Elf_External_Rela *) (o->contents + o->_raw_size);
! 	    s = rela + (o->output_offset / sizeof (Elf_External_Rela) * i2e);
! 	    for (; erela < erelaend; erela++, s += i2e)
! 	      {
! 		if (bed->s->swap_reloca_out)
! 		  (*bed->s->swap_reloca_out) (dynobj, s->u.rela,
! 					      (bfd_byte *) erela);
! 		else
! 		  elf_swap_reloca_out (dynobj, s->u.rela, erela);
! 	      }
  	  }
        }
  
-   free (rela);
    *psec = reldyn;
    return ret;
  }
--- 4720,4781 ----
  	== (SEC_HAS_CONTENTS|SEC_LINKER_CREATED)
  	&& o->output_section == reldyn)
        {
! 	bfd_byte *erel, *erelend;
  
! 	erel = o->contents;
! 	erelend = o->contents + o->_raw_size;
! 	p = sort + o->output_offset / ext_size * sort_elt;
! 	while (erel < erelend)
  	  {
! 	    struct elf_link_sort_rela *s = (struct elf_link_sort_rela *) p;
! 	    (*swap_in) (abfd, erel, s->rela);
! 	    s->type = (*bed->elf_backend_reloc_type_class) (s->rela);
! 	    p += sort_elt;
! 	    erel += ext_size;
  	  }
        }
  
!   qsort (sort, (size_t) count, sort_elt, elf_link_sort_cmp1);
! 
!   for (i = 0, p = sort; i < count; i++, p += sort_elt)
!     {
!       struct elf_link_sort_rela *s = (struct elf_link_sort_rela *) p;
!       if (s->type != reloc_class_relative)
! 	break;
!     }
!   ret = i;
!   s_non_relative = p;
! 
!   sq = (struct elf_link_sort_rela *) s_non_relative;
!   for (; i < count; i++, p += sort_elt)
!     {
!       struct elf_link_sort_rela *sp = (struct elf_link_sort_rela *) p;
!       if (ELF_R_SYM (sp->rela->r_info) != ELF_R_SYM (sq->rela->r_info))
! 	sq = sp;
!       sp->offset = sq->rela->r_offset;
!     }
! 
!   qsort (s_non_relative, (size_t) count - ret, sort_elt, elf_link_sort_cmp2);
  
    for (o = dynobj->sections; o != NULL; o = o->next)
      if ((o->flags & (SEC_HAS_CONTENTS|SEC_LINKER_CREATED))
  	== (SEC_HAS_CONTENTS|SEC_LINKER_CREATED)
  	&& o->output_section == reldyn)
        {
! 	bfd_byte *erel, *erelend;
  
! 	erel = o->contents;
! 	erelend = o->contents + o->_raw_size;
! 	p = sort + o->output_offset / ext_size * sort_elt;
! 	while (erel < erelend)
  	  {
! 	    struct elf_link_sort_rela *s = (struct elf_link_sort_rela *) p;
! 	    (*swap_out) (abfd, s->rela, erel);
! 	    p += sort_elt;
! 	    erel += ext_size;
  	  }
        }
  
    *psec = reldyn;
    return ret;
  }
*************** elf_link_output_relocs (output_bfd, inpu
*** 6481,6491 ****
  {
    Elf_Internal_Rela *irela;
    Elf_Internal_Rela *irelaend;
    Elf_Internal_Shdr *output_rel_hdr;
    asection *output_section;
    unsigned int *rel_countp = NULL;
    struct elf_backend_data *bed;
!   bfd_size_type amt;
  
    output_section = input_section->output_section;
    output_rel_hdr = NULL;
--- 6365,6376 ----
  {
    Elf_Internal_Rela *irela;
    Elf_Internal_Rela *irelaend;
+   bfd_byte *erel;
    Elf_Internal_Shdr *output_rel_hdr;
    asection *output_section;
    unsigned int *rel_countp = NULL;
    struct elf_backend_data *bed;
!   void (*swap_out) PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
  
    output_section = input_section->output_section;
    output_rel_hdr = NULL;
*************** elf_link_output_relocs (output_bfd, inpu
*** 6515,6569 ****
      }
  
    bed = get_elf_backend_data (output_bfd);
    irela = internal_relocs;
    irelaend = irela + (NUM_SHDR_ENTRIES (input_rel_hdr)
  		      * bed->s->int_rels_per_ext_rel);
! 
!   if (input_rel_hdr->sh_entsize == sizeof (Elf_External_Rel))
!     {
!       Elf_External_Rel *erel;
!       Elf_Internal_Rel *irel;
! 
!       amt = bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rel);
!       irel = (Elf_Internal_Rel *) bfd_zmalloc (amt);
!       if (irel == NULL)
! 	{
! 	  (*_bfd_error_handler) (_("Error: out of memory"));
! 	  abort ();
! 	}
! 
!       erel = ((Elf_External_Rel *) output_rel_hdr->contents + *rel_countp);
!       for (; irela < irelaend; irela += bed->s->int_rels_per_ext_rel, erel++)
! 	{
! 	  unsigned int i;
! 
! 	  for (i = 0; i < bed->s->int_rels_per_ext_rel; i++)
! 	    {
! 	      irel[i].r_offset = irela[i].r_offset;
! 	      irel[i].r_info = irela[i].r_info;
! 	      BFD_ASSERT (irela[i].r_addend == 0);
! 	    }
! 
! 	  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);
! 	}
! 
!       free (irel);
!     }
!   else
      {
!       Elf_External_Rela *erela;
! 
!       BFD_ASSERT (input_rel_hdr->sh_entsize == sizeof (Elf_External_Rela));
! 
!       erela = ((Elf_External_Rela *) output_rel_hdr->contents + *rel_countp);
!       for (; irela < irelaend; irela += bed->s->int_rels_per_ext_rel, 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
--- 6400,6422 ----
      }
  
    bed = get_elf_backend_data (output_bfd);
+   if (input_rel_hdr->sh_entsize == sizeof (Elf_External_Rel))
+     swap_out = bed->s->swap_reloc_out;
+   else if (input_rel_hdr->sh_entsize == sizeof (Elf_External_Rela))
+     swap_out = bed->s->swap_reloca_out;
+   else
+     abort ();
+ 
+   erel = output_rel_hdr->contents;
+   erel += *rel_countp * input_rel_hdr->sh_entsize;
    irela = internal_relocs;
    irelaend = irela + (NUM_SHDR_ENTRIES (input_rel_hdr)
  		      * bed->s->int_rels_per_ext_rel);
!   while (irela < irelaend)
      {
!       (*swap_out) (output_bfd, irela, erel);
!       irela += bed->s->int_rels_per_ext_rel;
!       erel += input_rel_hdr->sh_entsize;
      }
  
    /* Bump the counter, so that we know where to add the next set of
*************** elf_reloc_link_order (output_bfd, info, 
*** 7221,7226 ****
--- 7074,7082 ----
    struct elf_link_hash_entry **rel_hash_ptr;
    Elf_Internal_Shdr *rel_hdr;
    struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
+   Elf_Internal_Rela irel[MAX_INT_RELS_PER_EXT_REL];
+   bfd_byte *erel;
+   unsigned int i;
  
    howto = bfd_reloc_type_lookup (output_bfd, link_order->u.reloc.p->reloc);
    if (howto == NULL)
*************** elf_reloc_link_order (output_bfd, info, 
*** 7336,7393 ****
    if (! info->relocateable)
      offset += output_section->vma;
  
!   rel_hdr = &elf_section_data (output_section)->rel_hdr;
  
    if (rel_hdr->sh_type == SHT_REL)
      {
!       bfd_size_type size;
!       Elf_Internal_Rel *irel;
!       Elf_External_Rel *erel;
!       unsigned int i;
! 
!       size = bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rel);
!       irel = (Elf_Internal_Rel *) bfd_zmalloc (size);
!       if (irel == NULL)
! 	return false;
! 
!       for (i = 0; i < bed->s->int_rels_per_ext_rel; i++)
! 	irel[i].r_offset = offset;
!       irel[0].r_info = ELF_R_INFO (indx, howto->type);
! 
!       erel = ((Elf_External_Rel *) rel_hdr->contents
! 	      + elf_section_data (output_section)->rel_count);
! 
!       if (bed->s->swap_reloc_out)
! 	(*bed->s->swap_reloc_out) (output_bfd, irel, (bfd_byte *) erel);
!       else
! 	elf_swap_reloc_out (output_bfd, irel, erel);
! 
!       free (irel);
      }
    else
      {
!       bfd_size_type size;
!       Elf_Internal_Rela *irela;
!       Elf_External_Rela *erela;
!       unsigned int i;
! 
!       size = bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rela);
!       irela = (Elf_Internal_Rela *) bfd_zmalloc (size);
!       if (irela == NULL)
! 	return false;
! 
!       for (i = 0; i < bed->s->int_rels_per_ext_rel; i++)
! 	irela[i].r_offset = offset;
!       irela[0].r_info = ELF_R_INFO (indx, howto->type);
!       irela[0].r_addend = addend;
! 
!       erela = ((Elf_External_Rela *) rel_hdr->contents
! 	       + elf_section_data (output_section)->rel_count);
! 
!       if (bed->s->swap_reloca_out)
! 	(*bed->s->swap_reloca_out) (output_bfd, irela, (bfd_byte *) erela);
!       else
! 	elf_swap_reloca_out (output_bfd, irela, erela);
      }
  
    ++elf_section_data (output_section)->rel_count;
--- 7192,7219 ----
    if (! info->relocateable)
      offset += output_section->vma;
  
!   for (i = 0; i < bed->s->int_rels_per_ext_rel; i++)
!     {
!       irel[i].r_offset = offset;
!       irel[i].r_info = 0;
!       irel[i].r_addend = 0;
!     }
!   irel[0].r_info = ELF_R_INFO (indx, howto->type);
  
+   rel_hdr = &elf_section_data (output_section)->rel_hdr;
+   erel = rel_hdr->contents;
    if (rel_hdr->sh_type == SHT_REL)
      {
!       erel += (elf_section_data (output_section)->rel_count
! 	       * sizeof (Elf_External_Rel));
!       (*bed->s->swap_reloc_out) (output_bfd, irel, erel);
      }
    else
      {
!       irel[0].r_addend = addend;
!       erel += (elf_section_data (output_section)->rel_count
! 	       * sizeof (Elf_External_Rela));
!       (*bed->s->swap_reloca_out) (output_bfd, irel, erel);
      }
  
    ++elf_section_data (output_section)->rel_count;
*************** elf_finish_pointer_linker_section (outpu
*** 7604,7622 ****
  	  if (info->shared)
  	    {
  	      asection *srel = lsect->rel_section;
! 	      Elf_Internal_Rela *outrel;
! 	      Elf_External_Rela *erel;
  	      struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
  	      unsigned int i;
- 	      bfd_size_type amt;
- 
- 	      amt = sizeof (Elf_Internal_Rela) * bed->s->int_rels_per_ext_rel;
- 	      outrel = (Elf_Internal_Rela *) bfd_zmalloc (amt);
- 	      if (outrel == NULL)
- 		{
- 		  (*_bfd_error_handler) (_("Error: out of memory"));
- 		  return 0;
- 		}
  
  	      /* We need to generate a relative reloc for the dynamic
  		 linker.  */
--- 7430,7439 ----
  	  if (info->shared)
  	    {
  	      asection *srel = lsect->rel_section;
! 	      Elf_Internal_Rela outrel[MAX_INT_RELS_PER_EXT_REL];
! 	      bfd_byte *erel;
  	      struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
  	      unsigned int i;
  
  	      /* We need to generate a relative reloc for the dynamic
  		 linker.  */
*************** elf_finish_pointer_linker_section (outpu
*** 7630,7646 ****
  	      BFD_ASSERT (srel != NULL);
  
  	      for (i = 0; i < bed->s->int_rels_per_ext_rel; i++)
! 		outrel[i].r_offset = (lsect->section->output_section->vma
! 				      + lsect->section->output_offset
! 				      + linker_section_ptr->offset);
  	      outrel[0].r_info = ELF_R_INFO (0, relative_reloc);
! 	      outrel[0].r_addend = 0;
! 	      erel = (Elf_External_Rela *) lsect->section->contents;
! 	      erel += elf_section_data (lsect->section)->rel_count;
  	      elf_swap_reloca_out (output_bfd, outrel, erel);
- 	      ++elf_section_data (lsect->section)->rel_count;
- 
- 	      free (outrel);
  	    }
  	}
      }
--- 7447,7464 ----
  	      BFD_ASSERT (srel != NULL);
  
  	      for (i = 0; i < bed->s->int_rels_per_ext_rel; i++)
! 		{
! 		  outrel[i].r_offset = (lsect->section->output_section->vma
! 					+ lsect->section->output_offset
! 					+ linker_section_ptr->offset);
! 		  outrel[i].r_info = 0;
! 		  outrel[i].r_addend = 0;
! 		}
  	      outrel[0].r_info = ELF_R_INFO (0, relative_reloc);
! 	      erel = lsect->section->contents;
! 	      erel += (elf_section_data (lsect->section)->rel_count++
! 		       * sizeof (Elf_External_Rela));
  	      elf_swap_reloca_out (output_bfd, outrel, erel);
  	    }
  	}
      }
Index: bfd/elfn32-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfn32-mips.c,v
retrieving revision 1.2
diff -u -p -r1.2 elfn32-mips.c
--- bfd/elfn32-mips.c	18 Sep 2002 01:38:20 -0000	1.2
+++ bfd/elfn32-mips.c	27 Nov 2002 15:53:06 -0000
@@ -77,9 +77,9 @@ static reloc_howto_type *bfd_elf32_bfd_r
 static reloc_howto_type *mips_elf_n32_rtype_to_howto
   PARAMS ((unsigned int, boolean));
 static void mips_info_to_howto_rel
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static void mips_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
 static boolean mips_elf_sym_is_global PARAMS ((bfd *, asymbol *));
 static boolean mips_elf_n32_object_p PARAMS ((bfd *));
 static boolean elf32_mips_grok_prstatus
@@ -1896,7 +1896,7 @@ bfd_elf32_bfd_reloc_type_lookup (abfd, c
     }
 }
 
-/* Given a MIPS Elf32_Internal_Rel, fill in an arelent structure.  */
+/* Given a MIPS Elf_Internal_Rel, fill in an arelent structure.  */
 
 static reloc_howto_type *
 mips_elf_n32_rtype_to_howto (r_type, rela_p)
@@ -1923,13 +1923,13 @@ mips_elf_n32_rtype_to_howto (r_type, rel
     }
 }
 
-/* Given a MIPS Elf32_Internal_Rel, fill in an arelent structure.  */
+/* Given a MIPS Elf_Internal_Rel, fill in an arelent structure.  */
 
 static void
 mips_info_to_howto_rel (abfd, cache_ptr, dst)
      bfd *abfd;
      arelent *cache_ptr;
-     Elf32_Internal_Rel *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
@@ -1946,13 +1946,13 @@ mips_info_to_howto_rel (abfd, cache_ptr,
     cache_ptr->addend = elf_gp (abfd);
 }
 
-/* Given a MIPS Elf32_Internal_Rela, fill in an arelent structure.  */
+/* Given a MIPS Elf_Internal_Rela, fill in an arelent structure.  */
 
 static void
 mips_info_to_howto_rela (abfd, cache_ptr, dst)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
-     Elf32_Internal_Rela *dst;
+     Elf_Internal_Rela *dst;
 {
   unsigned int r_type;
 
Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.60
diff -u -p -r1.60 elfxx-ia64.c
--- bfd/elfxx-ia64.c	12 Nov 2002 06:21:05 -0000	1.60
+++ bfd/elfxx-ia64.c	27 Nov 2002 15:53:08 -0000
@@ -163,18 +163,18 @@ static reloc_howto_type * lookup_howto
 static reloc_howto_type *elfNN_ia64_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type bfd_code));
 static void elfNN_ia64_info_to_howto
-  PARAMS ((bfd *abfd, arelent *bfd_reloc, ElfNN_Internal_Rela *elf_reloc));
+  PARAMS ((bfd *abfd, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc));
 static boolean elfNN_ia64_relax_section
   PARAMS((bfd *abfd, asection *sec, struct bfd_link_info *link_info,
 	  boolean *again));
 static boolean is_unwind_section_name
   PARAMS ((bfd *abfd, const char *));
 static boolean elfNN_ia64_section_from_shdr
-  PARAMS ((bfd *, ElfNN_Internal_Shdr *, const char *));
+  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 static boolean elfNN_ia64_section_flags
-  PARAMS ((flagword *, ElfNN_Internal_Shdr *));
+  PARAMS ((flagword *, Elf_Internal_Shdr *));
 static boolean elfNN_ia64_fake_sections
-  PARAMS ((bfd *abfd, ElfNN_Internal_Shdr *hdr, asection *sec));
+  PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec));
 static void elfNN_ia64_final_write_processing
   PARAMS ((bfd *abfd, boolean linker));
 static boolean elfNN_ia64_add_symbol_hook
@@ -597,7 +597,7 @@ static void
 elfNN_ia64_info_to_howto (abfd, bfd_reloc, elf_reloc)
      bfd *abfd ATTRIBUTE_UNUSED;
      arelent *bfd_reloc;
-     ElfNN_Internal_Rela *elf_reloc;
+     Elf_Internal_Rela *elf_reloc;
 {
   bfd_reloc->howto
     = lookup_howto ((unsigned int) ELFNN_R_TYPE (elf_reloc->r_info));
@@ -1017,7 +1017,7 @@ is_unwind_section_name (abfd, name)
 static boolean
 elfNN_ia64_section_from_shdr (abfd, hdr, name)
      bfd *abfd;
-     ElfNN_Internal_Shdr *hdr;
+     Elf_Internal_Shdr *hdr;
      const char *name;
 {
   asection *newsect;
@@ -1057,7 +1057,7 @@ elfNN_ia64_section_from_shdr (abfd, hdr,
 static boolean
 elfNN_ia64_section_flags (flags, hdr)
      flagword *flags;
-     ElfNN_Internal_Shdr *hdr;
+     Elf_Internal_Shdr *hdr;
 {
   if (hdr->sh_flags & SHF_IA_64_SHORT)
     *flags |= SEC_SMALL_DATA;
@@ -1071,7 +1071,7 @@ elfNN_ia64_section_flags (flags, hdr)
 static boolean
 elfNN_ia64_fake_sections (abfd, hdr, sec)
      bfd *abfd ATTRIBUTE_UNUSED;
-     ElfNN_Internal_Shdr *hdr;
+     Elf_Internal_Shdr *hdr;
      asection *sec;
 {
   register const char *name;
@@ -3203,6 +3203,7 @@ elfNN_ia64_install_dyn_reloc (abfd, info
      bfd_vma addend;
 {
   Elf_Internal_Rela outrel;
+  bfd_byte *loc;
 
   BFD_ASSERT (dynindx != -1);
   outrel.r_info = ELFNN_R_INFO (dynindx, type);
@@ -3219,9 +3220,9 @@ elfNN_ia64_install_dyn_reloc (abfd, info
   else
     outrel.r_offset += sec->output_section->vma + sec->output_offset;
 
-  bfd_elfNN_swap_reloca_out (abfd, &outrel,
-			     ((ElfNN_External_Rela *) srel->contents
-			      + srel->reloc_count++));
+  loc = srel->contents;
+  loc += srel->reloc_count++ * sizeof (ElfNN_External_Rela);
+  bfd_elfNN_swap_reloca_out (abfd, &outrel, loc);
   BFD_ASSERT (sizeof (ElfNN_External_Rela) * srel->reloc_count
 	      <= srel->_cooked_size);
 }
@@ -4350,7 +4351,6 @@ elfNN_ia64_finish_dynamic_symbol (output
       bfd_byte *loc;
       asection *plt_sec;
       bfd_vma plt_addr, pltoff_addr, gp_val, index;
-      ElfNN_External_Rela *rel;
 
       gp_val = _bfd_get_gp_value (output_bfd);
 
@@ -4407,10 +4407,10 @@ elfNN_ia64_finish_dynamic_symbol (output
 	 existing sec->reloc_count to be the base of the array of
 	 PLT relocations.  */
 
-      rel = (ElfNN_External_Rela *)ia64_info->rel_pltoff_sec->contents;
-      rel += ia64_info->rel_pltoff_sec->reloc_count;
-
-      bfd_elfNN_swap_reloca_out (output_bfd, &outrel, rel + index);
+      loc = ia64_info->rel_pltoff_sec->contents;
+      loc += ((ia64_info->rel_pltoff_sec->reloc_count + index)
+	      * sizeof (Elf64_External_Rela));
+      bfd_elfNN_swap_reloca_out (output_bfd, &outrel, loc);
     }
 
   /* Mark some specially defined symbols as absolute.  */
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.31
diff -u -p -r1.31 elfxx-mips.c
--- bfd/elfxx-mips.c	19 Nov 2002 20:52:32 -0000	1.31
+++ bfd/elfxx-mips.c	27 Nov 2002 15:53:13 -0000
@@ -1176,16 +1176,13 @@ sort_dynamic_relocs (arg1, arg2)
      const PTR arg1;
      const PTR arg2;
 {
-  const Elf32_External_Rel *ext_reloc1 = (const Elf32_External_Rel *) arg1;
-  const Elf32_External_Rel *ext_reloc2 = (const Elf32_External_Rel *) arg2;
+  Elf_Internal_Rela int_reloc1;
+  Elf_Internal_Rela int_reloc2;
 
-  Elf_Internal_Rel int_reloc1;
-  Elf_Internal_Rel int_reloc2;
+  bfd_elf32_swap_reloc_in (reldyn_sorting_bfd, arg1, &int_reloc1);
+  bfd_elf32_swap_reloc_in (reldyn_sorting_bfd, arg2, &int_reloc2);
 
-  bfd_elf32_swap_reloc_in (reldyn_sorting_bfd, ext_reloc1, &int_reloc1);
-  bfd_elf32_swap_reloc_in (reldyn_sorting_bfd, ext_reloc2, &int_reloc2);
-
-  return (ELF32_R_SYM (int_reloc1.r_info) - ELF32_R_SYM (int_reloc2.r_info));
+  return ELF32_R_SYM (int_reloc1.r_info) - ELF32_R_SYM (int_reloc2.r_info);
 }
 
 /* This routine is used to write out ECOFF debugging external symbol
@@ -2861,7 +2858,7 @@ mips_elf_create_dynamic_relocation (outp
      bfd_vma *addendp;
      asection *input_section;
 {
-  Elf_Internal_Rel outrel[3];
+  Elf_Internal_Rela outrel[3];
   boolean skip;
   asection *sreloc;
   bfd *dynobj;
@@ -2917,7 +2914,7 @@ mips_elf_create_dynamic_relocation (outp
      record.  Note that R_MIPS_NONE == 0, so that this call to memset
      is a way of setting R_TYPE to R_MIPS_NONE.  */
   if (skip)
-    memset (outrel, 0, sizeof (Elf_Internal_Rel) * 3);
+    memset (outrel, 0, sizeof (Elf_Internal_Rela) * 3);
   else
     {
       long indx;
@@ -3001,10 +2998,9 @@ mips_elf_create_dynamic_relocation (outp
 	  + sreloc->reloc_count * sizeof (Elf64_Mips_External_Rel)));
     }
   else
-    bfd_elf32_swap_reloc_out (output_bfd, &outrel[0],
-			      (((Elf32_External_Rel *)
-				sreloc->contents)
-			       + sreloc->reloc_count));
+    bfd_elf32_swap_reloc_out
+      (output_bfd, &outrel[0],
+       (sreloc->contents + sreloc->reloc_count * sizeof (Elf32_External_Rel)));
 
   /* Record the index of the first relocation referencing H.  This
      information is later emitted in the .msym section.  */
@@ -3577,7 +3573,7 @@ _bfd_mips_elf_section_from_shdr (abfd, h
 boolean
 _bfd_mips_elf_fake_sections (abfd, hdr, sec)
      bfd *abfd;
-     Elf32_Internal_Shdr *hdr;
+     Elf_Internal_Shdr *hdr;
      asection *sec;
 {
   register const char *name;



More information about the Binutils mailing list