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 patch for m68k


Here is the combreloc patch for m68k.  No regressions on m68k-linux.

Andreas.

2001-08-24  Andreas Schwab  <schwab@suse.de>

	* elf32-m68k.c (elf32_m68k_check_relocs): Set DF_TEXTREL if the
	reloc is against read-only section.
	(elf32_m68k_size_dynamic_sections): Use DF_TEXTREL flag instead of
	looking up section names for DT_TEXTREL.
	(elf32_m68k_reloc_type_class): New function.
	(elf_backend_reloc_type_class): Define.

Index: elf32-m68k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68k.c,v
retrieving revision 1.23
diff -u -a -u -r1.23 elf32-m68k.c
--- elf32-m68k.c	2001/03/20 10:11:07	1.23
+++ elf32-m68k.c	2001/08/24 21:51:53
@@ -63,6 +63,8 @@
   PARAMS ((bfd *, bfd *));
 static boolean elf32_m68k_print_private_bfd_data
   PARAMS ((bfd *, PTR));
+static enum elf_reloc_type_class elf32_m68k_reloc_type_class
+  PARAMS ((int));
 
 static reloc_howto_type howto_table[] = {
   HOWTO(R_68K_NONE,       0, 0, 0, false,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_NONE",      false, 0, 0x00000000,false),
@@ -718,6 +720,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);
@@ -1130,14 +1134,13 @@
 
 static boolean
 elf_m68k_size_dynamic_sections (output_bfd, info)
-     bfd *output_bfd;
+     bfd *output_bfd ATTRIBUTE_UNUSED;
      struct bfd_link_info *info;
 {
   bfd *dynobj;
   asection *s;
   boolean plt;
   boolean relocs;
-  boolean reltext;
 
   dynobj = elf_hash_table (info)->dynobj;
   BFD_ASSERT (dynobj != NULL);
@@ -1179,7 +1182,6 @@
      memory for them.  */
   plt = false;
   relocs = false;
-  reltext = false;
   for (s = dynobj->sections; s != NULL; s = s->next)
     {
       const char *name;
@@ -1225,29 +1227,8 @@
 	    }
 	  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.  .rela.plt is actually associated with
-		     .got.plt, which is never 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;
@@ -1307,11 +1288,10 @@
 	    return false;
 	}
 
-      if (reltext)
+      if ((info->flags & DF_TEXTREL) != 0)
 	{
 	  if (!bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
 	    return false;
-	  info->flags |= DF_TEXTREL;
 	}
     }
 
@@ -2322,6 +2302,23 @@
   return false;
 }
 
+static enum elf_reloc_type_class
+elf32_m68k_reloc_type_class (type)
+     int type;
+{
+  switch (type)
+    {
+    case R_68K_RELATIVE:
+      return reloc_class_relative;
+    case R_68K_JMP_SLOT:
+      return reloc_class_plt;
+    case R_68K_COPY:
+      return reloc_class_copy;
+    default:
+      return reloc_class_normal;
+    }
+}
+
 #define TARGET_BIG_SYM			bfd_elf32_m68k_vec
 #define TARGET_BIG_NAME			"elf32-m68k"
 #define ELF_MACHINE_CODE		EM_68K
@@ -2352,6 +2349,7 @@
                                         elf32_m68k_set_private_flags
 #define bfd_elf32_bfd_print_private_bfd_data \
                                         elf32_m68k_print_private_bfd_data
+#define elf_backend_reloc_type_class	elf32_m68k_reloc_type_class
 
 #define elf_backend_can_gc_sections 1
 #define elf_backend_want_got_plt 1

-- 
Andreas Schwab                                  "And now for something
SuSE Labs                                        completely different."
Andreas.Schwab@suse.de
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5


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