This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


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

combreloc


Hi Jakub,
  I've been looking at what needs to be done to make elf32-hppa support
"combreloc".  elf32-hppa doesn't use a *_RELATIVE reloc for relocations
that are relative to the base of the shared library;  Instead, we use
normal relocs with a symbol index of zero.  That presents a problem
with the elf_backend_reloc_type_class interface as I need to look at
more than just the reloc type.  Easily fixed with the attached patch.

Now I have a small problem with reloc_class_plt, as some of these relocs
can belong to reloc_class_relative as well (.plt entries for local
functions), but can't see any code in binutils that makes use of
reloc_class_plt.  Did this class leak in from your dynamic linker work,
or do you have some future use in mind?

-- 
Alan Modra

bfd/ChangeLog
	* elf-bfd.h (elf_backend_reloc_type_class): Pass in the entire
	reloc rather than just the type.
	(_bfd_elf_reloc_type_class): Likewise.
	* elf.c (_bfd_elf_reloc_type_class): Likewise.
	* elf32-arm.h (elf32_arm_reloc_type_class): Likewise.
	* elf32-cris.c (elf_cris_reloc_type_class): Likewise.
	* elf32-i386.c (elf_i386_reloc_type_class): Likewise.
	* elf32-m68k.c (elf32_m68k_reloc_type_class): Likewise.
	* elf32-ppc.c (ppc_elf_reloc_type_class): Likewise.
	* elf32-s390.c (elf_s390_reloc_type_class): Likewise.
	* elf32-sh.c (sh_elf_reloc_type_class): Likewise.
	* elf32-sparc.c (elf32_sparc_reloc_type_class): Likewise.
	* elf64-alpha.c (elf64_alpha_reloc_type_class): Likewise.
	* elf64-s390.c (elf_s390_reloc_type_class): Likewise.
	* elf64-sparc.c (sparc64_elf_reloc_type_class): Likewise.
	* elf64-x86-64.c (elf64_x86_64_reloc_type_class): Likewise.
	* elfxx-ia64.c (elfNN_ia64_reloc_type_class): Likewise.
	* elflink.h: Formatting fixes.
	(elf_link_sort_relocs): Make "count" and "size" bfd_size_type.
	Call bfd_zmalloc rather than calloc.  Remove unnecessary cast of
	o->contents to PTR.  Update call to elf_backend_reloc_type_class.

Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.44
diff -u -p -r1.44 elf-bfd.h
--- elf-bfd.h	2001/09/18 09:57:23	1.44
+++ elf-bfd.h	2001/09/23 13:08:19
@@ -665,8 +665,8 @@ struct elf_backend_data
     PARAMS ((bfd *, PTR, bfd_vma));
 
   /* This function returns class of a reloc type.  */
-  enum elf_reloc_type_class (* elf_backend_reloc_type_class)
-    PARAMS ((int));
+  enum elf_reloc_type_class (*elf_backend_reloc_type_class)
+    PARAMS ((const Elf_Internal_Rela *));
 
   /* The swapping table to use when dealing with ECOFF information.
      Used for the MIPS ELF .mdebug section.  */
@@ -1044,7 +1044,7 @@ extern void _bfd_elf_fprintf_vma
   PARAMS ((bfd *, PTR, bfd_vma));
 
 extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
-  PARAMS ((int));
+  PARAMS ((const Elf_Internal_Rela *));
 
 extern unsigned long bfd_elf_hash
   PARAMS ((const char *));
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.93
diff -u -p -r1.93 elf.c
--- elf.c	2001/09/20 23:30:35	1.93
+++ elf.c	2001/09/23 13:08:24
@@ -5982,8 +5982,8 @@ _bfd_elf_fprintf_vma (abfd, stream, valu
 }
 
 enum elf_reloc_type_class
-_bfd_elf_reloc_type_class (type)
-     int type ATTRIBUTE_UNUSED;
+_bfd_elf_reloc_type_class (rela)
+     const Elf_Internal_Rela *rela ATTRIBUTE_UNUSED;
 {
   return reloc_class_normal;
 }
Index: bfd/elf32-arm.h
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.h,v
retrieving revision 1.58
diff -u -p -r1.58 elf32-arm.h
--- elf32-arm.h	2001/09/20 23:30:35	1.58
+++ elf32-arm.h	2001/09/23 13:08:27
@@ -92,7 +92,7 @@ boolean bfd_elf32_arm_get_bfd_for_interw
 boolean bfd_elf32_arm_process_before_allocation
   PARAMS ((bfd *, struct bfd_link_info *, int));
 static enum elf_reloc_type_class elf32_arm_reloc_type_class
-  PARAMS ((int));
+  PARAMS ((const Elf_Internal_Rela *));
 
 #define INTERWORK_FLAG(abfd)   (elf_elfheader (abfd)->e_flags & EF_ARM_INTERWORK)
 
@@ -3459,10 +3459,10 @@ elf32_arm_post_process_headers (abfd, li
 }
 
 static enum elf_reloc_type_class
-elf32_arm_reloc_type_class (type)
-     int type;
+elf32_arm_reloc_type_class (rela)
+     const Elf_Internal_Rela *rela;
 {
-  switch (type)
+  switch ((int) ELF32_R_TYPE (rela->r_info))
     {
     case R_ARM_RELATIVE:
       return reloc_class_relative;
Index: bfd/elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.107
diff -u -p -r1.107 elflink.h
--- elflink.h	2001/09/20 23:30:36	1.107
+++ elflink.h	2001/09/23 13:09:09
@@ -4338,8 +4338,8 @@ elf_link_sort_cmp1 (A, B)
      const PTR A;
      const PTR B;
 {
-  struct elf_link_sort_rela *a = (struct elf_link_sort_rela *)A;
-  struct elf_link_sort_rela *b = (struct elf_link_sort_rela *)B;
+  struct elf_link_sort_rela *a = (struct elf_link_sort_rela *) A;
+  struct elf_link_sort_rela *b = (struct elf_link_sort_rela *) B;
   int relativea, relativeb;
 
   relativea = a->type == reloc_class_relative;
@@ -4365,8 +4365,8 @@ elf_link_sort_cmp2 (A, B)
      const PTR A;
      const PTR B;
 {
-  struct elf_link_sort_rela *a = (struct elf_link_sort_rela *)A;
-  struct elf_link_sort_rela *b = (struct elf_link_sort_rela *)B;
+  struct elf_link_sort_rela *a = (struct elf_link_sort_rela *) A;
+  struct elf_link_sort_rela *b = (struct elf_link_sort_rela *) B;
   int copya, copyb;
 
   if (a->offset < b->offset)
@@ -4395,7 +4395,8 @@ elf_link_sort_relocs (abfd, info, psec)
   bfd *dynobj = elf_hash_table (info)->dynobj;
   asection *reldyn, *o;
   boolean rel = false;
-  size_t count, size, i, j, ret;
+  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);
 
@@ -4421,7 +4422,7 @@ elf_link_sort_relocs (abfd, info, psec)
   if (size != reldyn->_raw_size)
     return 0;
 
-  rela = (struct elf_link_sort_rela *) calloc (sizeof (*rela), count);
+  rela = (struct elf_link_sort_rela *) bfd_zmalloc (sizeof (*rela) * count);
   if (rela == NULL)
     {
       (*info->callbacks->warning)
@@ -4441,7 +4442,7 @@ elf_link_sort_relocs (abfd, info, psec)
 	    struct elf_link_sort_rela *s;
 
 	    erel = (Elf_External_Rel *) o->contents;
-	    erelend = (Elf_External_Rel *) ((PTR) o->contents + o->_raw_size);
+	    erelend = (Elf_External_Rel *) (o->contents + o->_raw_size);
 	    s = rela + o->output_offset / sizeof (Elf_External_Rel);
 	    for (; erel < erelend; erel++, s++)
 	      {
@@ -4450,8 +4451,7 @@ elf_link_sort_relocs (abfd, info, psec)
 		else
 		  elf_swap_reloc_in (abfd, erel, &s->u.rel);
 
-		s->type = ((*bed->elf_backend_reloc_type_class)
-			   ((int) ELF_R_TYPE (s->u.rel.r_info)));
+		s->type = (*bed->elf_backend_reloc_type_class) (&s->u.rela);
 	      }
 	  }
 	else
@@ -4460,7 +4460,7 @@ elf_link_sort_relocs (abfd, info, psec)
 	    struct elf_link_sort_rela *s;
 
 	    erela = (Elf_External_Rela *) o->contents;
-	    erelaend = (Elf_External_Rela *) ((PTR) o->contents + o->_raw_size);
+	    erelaend = (Elf_External_Rela *) (o->contents + o->_raw_size);
 	    s = rela + o->output_offset / sizeof (Elf_External_Rela);
 	    for (; erela < erelaend; erela++, s++)
 	      {
@@ -4470,8 +4470,7 @@ elf_link_sort_relocs (abfd, info, psec)
 		else
 		  elf_swap_reloca_in (dynobj, erela, &s->u.rela);
 
-		s->type = ((*bed->elf_backend_reloc_type_class)
-			   ((int) ELF_R_TYPE (s->u.rel.r_info)));
+		s->type = (*bed->elf_backend_reloc_type_class) (&s->u.rela);
 	      }
 	  }
       }

Rest of boring similar backed patches trimmed.


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