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 patches for s390, s390x, ppc



Here's a patch to change the textrel sections and add reloc_type_class
for three more architectures.

Note I'm not convinced that my patches for reloc_type_class are
correct.  Jakub, can you document a bit for which relocations
reloc_class_relative has to be returned?  I think it would be helpfull
if you could document the enum elf_reloc_type_class.

I currently test the s390 and ppc changes but won't see the results
before tomorrow and therefore decided to mail this already.

Ok to commit if make check passes with combreloc set to true?

Thanks,
Andreas

2001-08-24  Andreas Jaeger  <aj@suse.de>

	* elf64-s390.c (elf_s390_check_relocs): Set DF_TEXTREL if the
	reloc is against read-only section.
	(elf_s390_size_dynamic_sections): Use DF_TEXTREL flag instead of
	looking up section names for DT_TEXTREL.
	(elf_s390_reloc_type_class): New.
	(elf_backend_reloc_type_class): Define.

	* elf32-s390.c (elf_s390_check_relocs): Set DF_TEXTREL if the
	reloc is against read-only section.
	(elf_s390_size_dynamic_sections): Use DF_TEXTREL flag instead of
	looking up section names for DT_TEXTREL.
	(elf_s390_reloc_type_class): New.
	(elf_backend_reloc_type_class): Define.

	* elf32-ppc.c (ppc_elf_check_relocs): Set DF_TEXTREL if the reloc
	is against read-only section.
	(ppc_elf_size_dynamic_sections): Use DF_TEXTREL flag instead of
	looking up section names for DT_TEXTREL.
	(ppc_elf_reloc_type_class): New.
	(elf_backend_reloc_type_class): Define.


============================================================
Index: bfd/elf32-ppc.c
--- bfd/elf32-ppc.c	2001/08/17 15:56:58	1.24
+++ bfd/elf32-ppc.c	2001/08/24 18:07:36
@@ -108,6 +108,7 @@
 						      Elf_Internal_Sym *));
 
 static boolean ppc_elf_finish_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *));
+static enum elf_reloc_type_class ppc_elf_reloc_type_class PARAMS ((int));
 
 #define BRANCH_PREDICT_BIT 0x200000		/* branch prediction bit for branch taken relocs */
 #define RA_REGISTER_MASK 0x001f0000		/* mask to set RA in memory instructions */
@@ -1885,7 +1886,6 @@
   asection *s;
   boolean plt;
   boolean relocs;
-  boolean reltext;
 
 #ifdef DEBUG
   fprintf (stderr, "ppc_elf_size_dynamic_sections called\n");
@@ -1930,7 +1930,6 @@
      memory for them.  */
   plt = false;
   relocs = false;
-  reltext = false;
   for (s = dynobj->sections; s != NULL; s = s->next)
     {
       const char *name;
@@ -1976,22 +1975,9 @@
 	    }
 	  else
 	    {
-	      asection *target;
-	      const char *outname;
-
 	      /* Remember whether there are any relocation sections.  */
 	      relocs = true;
 
-	      /* If this relocation section applies to a read only
-		 section, then we probably need a DT_TEXTREL entry.  */
-	      outname = bfd_get_section_name (output_bfd,
-					      s->output_section);
-	      target = bfd_get_section_by_name (output_bfd, outname + 5);
-	      if (target != NULL
-		  && (target->flags & SEC_READONLY) != 0
-		  && (target->flags & SEC_ALLOC) != 0)
-		reltext = true;
-
 	      /* We use the reloc_count field as a counter if we need
 		 to copy relocs into the output file.  */
 	      s->reloc_count = 0;
@@ -2048,7 +2034,7 @@
 	    return false;
 	}
 
-      if (reltext)
+      if ((info->flags & DF_TEXTREL) != 0)
 	{
 	  if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
 	    return false;
@@ -2433,6 +2419,8 @@
 			  || ! bfd_set_section_alignment (dynobj, sreloc, 2))
 			return false;
 		    }
+		  if (sec->flags & SEC_READONLY)
+		    info->flags |= DF_TEXTREL;
 		}
 
 	      sreloc->_raw_size += sizeof (Elf32_External_Rela);
@@ -3712,6 +3700,28 @@
 
   return ret;
 }
+
+static enum elf_reloc_type_class
+ppc_elf_reloc_type_class (type)
+     int type;
+{
+  switch (type)
+    {
+    case R_PPC_REL24:
+    case R_PPC_REL14:
+    case R_PPC_REL14_BRTAKEN:
+    case R_PPC_REL14_BRNTAKEN:
+    case R_PPC_REL32:
+    case R_PPC_RELATIVE:
+      return reloc_class_relative;
+    case R_PPC_JMP_SLOT:
+      return reloc_class_plt;
+    case R_PPC_COPY:
+      return reloc_class_copy;
+    default:
+      return reloc_class_normal;
+    }
+}
 
 #define TARGET_LITTLE_SYM	bfd_elf32_powerpcle_vec
 #define TARGET_LITTLE_NAME	"elf32-powerpcle"
@@ -3757,5 +3767,6 @@
 #define elf_backend_fake_sections		ppc_elf_fake_sections
 #define elf_backend_additional_program_headers	ppc_elf_additional_program_headers
 #define elf_backend_modify_segment_map		ppc_elf_modify_segment_map
+#define elf_backend_reloc_type_class		ppc_elf_reloc_type_class
 
 #include "elf32-target.h"
============================================================
Index: bfd/elf32-s390.c
--- bfd/elf32-s390.c	2001/08/21 08:40:23	1.3
+++ bfd/elf32-s390.c	2001/08/24 18:07:38
@@ -56,6 +56,7 @@
 static boolean elf_s390_finish_dynamic_sections
   PARAMS ((bfd *, struct bfd_link_info *));
 static boolean elf_s390_object_p PARAMS ((bfd *));
+static enum elf_reloc_type_class elf_s390_reloc_type_class PARAMS ((int));
 
 #define USE_RELA 1		/* We want RELA relocations, not REL.  */
 
@@ -712,6 +713,8 @@
 			  || ! bfd_set_section_alignment (dynobj, sreloc, 2))
 			return false;
 		    }
+		  if (sec->flags & SEC_READONLY)
+		    info->flags |= DF_TEXTREL;
 		}
 
 	      sreloc->_raw_size += sizeof (Elf32_External_Rela);
@@ -1094,7 +1097,6 @@
 {
   bfd *dynobj;
   asection *s;
-  boolean reltext;
   boolean relocs;
   boolean plt;
 
@@ -1137,7 +1139,6 @@
      determined the sizes of the various dynamic sections.  Allocate
      memory for them.  */
   plt = false;
-  reltext = false;
   relocs = false;
   for (s = dynobj->sections; s != NULL; s = s->next)
     {
@@ -1184,30 +1185,11 @@
 	    }
 	  else
 	    {
-	      asection *target;
-
 	      /* Remember whether there are any reloc sections other
                  than .rela.plt.  */
 	      if (strcmp (name, ".rela.plt") != 0)
-		{
-		  const char *outname;
-
-		  relocs = true;
+		relocs = true;
 
-		  /* If this relocation section applies to a read only
-		     section, then we probably need a DT_TEXTREL
-		     entry.  The entries in the .rela.plt section
-		     really apply to the .got section, which we
-		     created ourselves and so know is not readonly.  */
-		  outname = bfd_get_section_name (output_bfd,
-						  s->output_section);
-		  target = bfd_get_section_by_name (output_bfd, outname + 5);
-		  if (target != NULL
-		      && (target->flags & SEC_READONLY) != 0
-		      && (target->flags & SEC_ALLOC) != 0)
-		    reltext = true;
-		}
-
 	      /* We use the reloc_count field as a counter if we need
 		 to copy relocs into the output file.  */
 	      s->reloc_count = 0;
@@ -1262,7 +1244,7 @@
 	    return false;
          }
 
-      if (reltext)
+      if ((info->flags & DF_TEXTREL) != 0)
 	{
 	  if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
 	    return false;
@@ -2150,6 +2132,26 @@
   return bfd_default_set_arch_mach (abfd, bfd_arch_s390, bfd_mach_s390_esa);
 }
 
+static enum elf_reloc_type_class
+elf_s390_reloc_type_class (type)
+     int type;
+{
+  switch (type)
+    {
+    case R_390_PC16:
+    case R_390_PC16DBL:
+    case R_390_PC32:
+    case R_390_RELATIVE:
+      return reloc_class_relative;
+    case R_390_JMP_SLOT:
+      return reloc_class_plt;
+    case R_390_COPY:
+      return reloc_class_copy;
+    default:
+      return reloc_class_normal;
+    }
+}
+
 #define TARGET_BIG_SYM	bfd_elf32_s390_vec
 #define TARGET_BIG_NAME	"elf32-s390"
 #define ELF_ARCH	bfd_arch_s390
@@ -2180,6 +2182,7 @@
 #define elf_backend_gc_sweep_hook             elf_s390_gc_sweep_hook
 #define elf_backend_relocate_section          elf_s390_relocate_section
 #define elf_backend_size_dynamic_sections     elf_s390_size_dynamic_sections
+#define elf_backend_reloc_type_class	      elf_s390_reloc_type_class
 
 #define elf_backend_object_p            elf_s390_object_p
 
============================================================
Index: bfd/elf64-s390.c
--- bfd/elf64-s390.c	2001/08/11 07:59:54	1.3
+++ bfd/elf64-s390.c	2001/08/24 18:07:40
@@ -684,6 +684,8 @@
 			  || ! bfd_set_section_alignment (dynobj, sreloc, 2))
 			return false;
 		    }
+		  if (sec->flags & SEC_READONLY)
+		    info->flags |= DF_TEXTREL;
 		}
 
 	      sreloc->_raw_size += sizeof (Elf64_External_Rela);
@@ -1074,7 +1076,6 @@
 {
   bfd *dynobj;
   asection *s;
-  boolean reltext;
   boolean relocs;
   boolean plt;
 
@@ -1117,7 +1118,6 @@
      determined the sizes of the various dynamic sections.  Allocate
      memory for them.  */
   plt = false;
-  reltext = false;
   relocs = false;
   for (s = dynobj->sections; s != NULL; s = s->next)
     {
@@ -1164,30 +1164,11 @@
 	    }
 	  else
 	    {
-	      asection *target;
-
 	      /* Remember whether there are any reloc sections other
                  than .rela.plt.  */
 	      if (strcmp (name, ".rela.plt") != 0)
-		{
-		  const char *outname;
-
-		  relocs = true;
+		relocs = true;
 
-		  /* If this relocation section applies to a read only
-		     section, then we probably need a DT_TEXTREL
-		     entry.  The entries in the .rela.plt section
-		     really apply to the .got section, which we
-		     created ourselves and so know is not readonly.  */
-		  outname = bfd_get_section_name (output_bfd,
-						  s->output_section);
-		  target = bfd_get_section_by_name (output_bfd, outname + 5);
-		  if (target != NULL
-		      && (target->flags & SEC_READONLY) != 0
-		      && (target->flags & SEC_ALLOC) != 0)
-		    reltext = true;
-		}
-
 	      /* We use the reloc_count field as a counter if we need
 		 to copy relocs into the output file.  */
 	      s->reloc_count = 0;
@@ -1242,7 +1223,7 @@
 	    return false;
          }
 
-      if (reltext)
+      if ((info->flags & DF_TEXTREL) != 0)
 	{
 	  if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
 	    return false;
@@ -2112,6 +2093,29 @@
   return bfd_default_set_arch_mach (abfd, bfd_arch_s390, bfd_mach_s390_esame);
 }
 
+
+static enum elf_reloc_type_class
+elf_s390_reloc_type_class (type)
+     int type;
+{
+  switch (type)
+    {
+    case R_390_PC16:
+    case R_390_PC16DBL:
+    case R_390_PC32:
+    case R_390_PC32DBL:
+    case R_390_PC64:
+    case R_390_RELATIVE:
+      return reloc_class_relative;
+    case R_390_JMP_SLOT:
+      return reloc_class_plt;
+    case R_390_COPY:
+      return reloc_class_copy;
+    default:
+      return reloc_class_normal;
+    }
+}
+
 /*
  * Why was the hash table entry size definition changed from
  * ARCH_SIZE/8 to 4? This breaks the 64 bit dynamic linker and
@@ -2179,6 +2183,7 @@
 #define elf_backend_gc_sweep_hook	      elf_s390_gc_sweep_hook
 #define elf_backend_relocate_section	      elf_s390_relocate_section
 #define elf_backend_size_dynamic_sections     elf_s390_size_dynamic_sections
+#define elf_backend_reloc_type_class	      elf_s390_reloc_type_class
 
 #define elf_backend_object_p                  elf_s390_object_p
 

-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj


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