This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

[PATCH, needs GWP] Add an ELF rela_plts_and_copies_p parameter


MIPS n32 and n64 traditionally use RELA for ET_REL objects and REL
for dynamic objects.  The former leads to default_rela_p being true,
while the latter means that any future jump slot and copy relocations
should go in .rel.plt and .rel.bss rather than in .rela.plt and .rela.bss.
(See upcoming message about this future.)

This patch adds a new backend field, rela_plts_and_copies_p,
to control the choice of .rel(a).plt and .rel(a).bss.

Tested on mips64-linux-gnu and mips64el-linux-gnu.  OK to install?

Richard


bfd/
	* elf-bfd.h (elf_backend_data): Add a "rela_plts_and_copies_p" field.
	* elfxx-target.h (elf_backend_rela_plts_and_copies_p): New macro.
	(elfNN_bed): Use it.
	* elf.c (_bfd_elf_get_synthetic_symtab): Use rela_plts_and_copies_p
	instead of default_use_rela_p to choose between ".rel.plt" and
	".rela.plt".
	* elflink.c (_bfd_elf_create_dynamic_sections): Use
	rela_plts_and_copies_p instead of default_use_rela_p to choose
	between ".rel.plt" and ".rela.plt", and between ".rel.bss" and
	".rela.bss".

Index: bfd/elf-bfd.h
===================================================================
--- bfd/elf-bfd.h	2008-06-28 17:14:53.000000000 +0100
+++ bfd/elf-bfd.h	2008-06-28 17:14:56.000000000 +0100
@@ -1189,6 +1189,9 @@ struct elf_backend_data
      section.  */
   unsigned default_use_rela_p : 1;
 
+  /* True if PLT and copy relocations should be RELA by default.  */
+  unsigned rela_plts_and_copies_p : 1;
+
   /* Set if RELA relocations for a relocatable link can be handled by
      generic code.  Backends that set this flag need do nothing in the
      backend relocate_section routine for relocatable linking.  */
Index: bfd/elfxx-target.h
===================================================================
--- bfd/elfxx-target.h	2008-06-28 17:08:55.000000000 +0100
+++ bfd/elfxx-target.h	2008-06-28 17:14:56.000000000 +0100
@@ -555,6 +555,9 @@ #define elf_backend_may_use_rela_p !USE_
 #ifndef elf_backend_default_use_rela_p
 #define elf_backend_default_use_rela_p !USE_REL
 #endif
+#ifndef elf_backend_rela_plts_and_copies_p
+#define elf_backend_rela_plts_and_copies_p elf_backend_default_use_rela_p
+#endif
 
 #ifndef elf_backend_rela_normal
 #define elf_backend_rela_normal 0
@@ -718,6 +721,7 @@ static struct elf_backend_data elfNN_bed
   elf_backend_may_use_rel_p,
   elf_backend_may_use_rela_p,
   elf_backend_default_use_rela_p,
+  elf_backend_rela_plts_and_copies_p,
   elf_backend_rela_normal,
   elf_backend_sign_extend_vma,
   elf_backend_want_got_plt,
Index: bfd/elf.c
===================================================================
--- bfd/elf.c	2008-06-28 17:14:51.000000000 +0100
+++ bfd/elf.c	2008-06-28 17:14:56.000000000 +0100
@@ -8741,7 +8741,7 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd
 
   relplt_name = bed->relplt_name;
   if (relplt_name == NULL)
-    relplt_name = bed->default_use_rela_p ? ".rela.plt" : ".rel.plt";
+    relplt_name = bed->rela_plts_and_copies_p ? ".rela.plt" : ".rel.plt";
   relplt = bfd_get_section_by_name (abfd, relplt_name);
   if (relplt == NULL)
     return 0;
Index: bfd/elflink.c
===================================================================
--- bfd/elflink.c	2008-06-28 17:08:55.000000000 +0100
+++ bfd/elflink.c	2008-06-28 17:14:57.000000000 +0100
@@ -309,7 +309,7 @@ _bfd_elf_create_dynamic_sections (bfd *a
     }
 
   s = bfd_make_section_with_flags (abfd,
-				   (bed->default_use_rela_p
+				   (bed->rela_plts_and_copies_p
 				    ? ".rela.plt" : ".rel.plt"),
 				   flags | SEC_READONLY);
   if (s == NULL
@@ -347,7 +347,7 @@ _bfd_elf_create_dynamic_sections (bfd *a
       if (! info->shared)
 	{
 	  s = bfd_make_section_with_flags (abfd,
-					   (bed->default_use_rela_p
+					   (bed->rela_plts_and_copies_p
 					    ? ".rela.bss" : ".rel.bss"),
 					   flags | SEC_READONLY);
 	  if (s == NULL


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