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 1/3] bfd: new BFD target entry point _bfd_set_reloc.


This patch adds a new entry point to the BFD_JUMP_TABLE_RELOCS.  The
previous common implementation `bfd_set_reloc', in bfd/bfd.c, has been
moved to bfd/reloc.c with the name `_bfd_generic_set_reloc', and all
BFD targets has been adapted to use it.

This patch doesn't introduce any change on functionality, but prepares
the ground for further work.

Tested in x86_64-linux-gnu and sparc64-linux-gnu.
No regressions found.

bfd/ChangeLog:

2017-05-04  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* targets.c (BFD_JUMP_TABLE_RELOCS): Add NAME##_set_reloc.
	(struct bfd_target): New field _bfd_set_reloc.
	* bfd.c (bfd_set_reloc): Call backend _set_bfd.
	* reloc.c (_bfd_generic_set_reloc): New function.
	* coffcode.h (coff_set_reloc): Define to _bfd_generic_set_reloc.
	* nlm-target.h (nlm_set_reloc): Likewise.
	* coff-rs6000.c (_bfd_xcoff_set_reloc): Likewise.
	* aout-tic30.c (MY_set_reloc): Likewise.
	* aout-target.h (MY_set_reloc): Likewise.
	* elfxx-target.h (bfd_elfNN_set_reloc): Likewise.
	* libbfd.c (_bfd_norelocs_set_reloc): New function.
	* libbfd-in.h: Prototype for _bfd_norelocs_set_reloc.
	* i386msdos.c (msdos_set_reloc): Define to
	_bfd_norelocs_set_reloc.
	* elfcode.h (elf_set_reloc): Define.
	* bfd-in2.h: Regenerated.
---
 bfd/ChangeLog      | 19 +++++++++++++++++++
 bfd/aout-target.h  |  3 +++
 bfd/aout-tic30.c   |  3 +++
 bfd/bfd-in2.h      |  3 +++
 bfd/bfd.c          |  5 ++---
 bfd/coff-rs6000.c  |  1 +
 bfd/coffcode.h     |  4 ++++
 bfd/elfxx-target.h |  3 +++
 bfd/i386msdos.c    |  1 +
 bfd/libbfd-in.h    |  2 ++
 bfd/libbfd.c       |  9 +++++++++
 bfd/libbfd.h       |  8 ++++++++
 bfd/nlm-target.h   |  1 +
 bfd/reloc.c        | 26 ++++++++++++++++++++++++++
 bfd/targets.c      |  3 +++
 15 files changed, 88 insertions(+), 3 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 27ac8c3..0547f8b 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,22 @@
+2017-05-04  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+	* targets.c (BFD_JUMP_TABLE_RELOCS): Add NAME##_set_reloc.
+	(struct bfd_target): New field _bfd_set_reloc.
+	* bfd.c (bfd_set_reloc): Call backend _set_bfd.
+	* reloc.c (_bfd_generic_set_reloc): New function.
+	* coffcode.h (coff_set_reloc): Define to _bfd_generic_set_reloc.
+	* nlm-target.h (nlm_set_reloc): Likewise.
+	* coff-rs6000.c (_bfd_xcoff_set_reloc): Likewise.
+	* aout-tic30.c (MY_set_reloc): Likewise.
+	* aout-target.h (MY_set_reloc): Likewise.
+	* elfxx-target.h (bfd_elfNN_set_reloc): Likewise.
+	* libbfd.c (_bfd_norelocs_set_reloc): New function.
+	* libbfd-in.h: Prototype for _bfd_norelocs_set_reloc.
+	* i386msdos.c (msdos_set_reloc): Define to
+	_bfd_norelocs_set_reloc.
+	* elfcode.h (elf_set_reloc): Define.
+	* bfd-in2.h: Regenerated.
+
 2017-05-01  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
 
 	PR ld/21404
diff --git a/bfd/aout-target.h b/bfd/aout-target.h
index 9f77c95..2e98c4d 100644
--- a/bfd/aout-target.h
+++ b/bfd/aout-target.h
@@ -450,6 +450,9 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
 #ifndef MY_canonicalize_reloc
 #define MY_canonicalize_reloc NAME (aout, canonicalize_reloc)
 #endif
+#ifndef MY_set_reloc
+#define MY_set_reloc _bfd_generic_set_reloc
+#endif
 #ifndef MY_make_empty_symbol
 #define MY_make_empty_symbol NAME (aout, make_empty_symbol)
 #endif
diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c
index 29dad9f..5db3da7 100644
--- a/bfd/aout-tic30.c
+++ b/bfd/aout-tic30.c
@@ -905,6 +905,9 @@ tic30_aout_set_arch_mach (bfd *abfd,
 #ifndef MY_canonicalize_reloc
 #define MY_canonicalize_reloc NAME (aout, canonicalize_reloc)
 #endif
+#ifndef MY_set_reloc
+#define MY_set_reloc _bfd_generic_set_reloc
+#endif
 #ifndef MY_make_empty_symbol
 #define MY_make_empty_symbol NAME (aout, make_empty_symbol)
 #endif
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 17a35c0..d63d706 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -7542,12 +7542,15 @@ typedef struct bfd_target
 #define BFD_JUMP_TABLE_RELOCS(NAME) \
   NAME##_get_reloc_upper_bound, \
   NAME##_canonicalize_reloc, \
+  NAME##_set_reloc, \
   NAME##_bfd_reloc_type_lookup, \
   NAME##_bfd_reloc_name_lookup
 
   long        (*_get_reloc_upper_bound) (bfd *, sec_ptr);
   long        (*_bfd_canonicalize_reloc)
     (bfd *, sec_ptr, arelent **, struct bfd_symbol **);
+  void        (*_bfd_set_reloc)
+    (bfd *, sec_ptr, arelent **, unsigned int);
   /* See documentation on reloc types.  */
   reloc_howto_type *
               (*reloc_type_lookup) (bfd *, bfd_reloc_code_real_type);
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 23a4350..0547238 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1067,13 +1067,12 @@ DESCRIPTION
 */
 
 void
-bfd_set_reloc (bfd *ignore_abfd ATTRIBUTE_UNUSED,
+bfd_set_reloc (bfd *abfd,
 	       sec_ptr asect,
 	       arelent **location,
 	       unsigned int count)
 {
-  asect->orelocation = location;
-  asect->reloc_count = count;
+  BFD_SEND (abfd, _bfd_set_reloc, (abfd, asect, location, count));
 }
 
 /*
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index e2b149b..b49e393 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -3993,6 +3993,7 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = {
 /* For reloc entry points.  */
 #define _bfd_xcoff_get_reloc_upper_bound coff_get_reloc_upper_bound
 #define _bfd_xcoff_canonicalize_reloc coff_canonicalize_reloc
+#define _bfd_xcoff_set_reloc _bfd_generic_set_reloc
 #define _bfd_xcoff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup
 #define _bfd_xcoff_bfd_reloc_name_lookup _bfd_xcoff_reloc_name_lookup
 
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 96a7886..f9d3978 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -5439,6 +5439,10 @@ coff_canonicalize_reloc (bfd * abfd,
   return section->reloc_count;
 }
 
+#ifndef coff_set_reloc
+#define coff_set_reloc _bfd_generic_set_reloc
+#endif
+
 #ifndef coff_reloc16_estimate
 #define coff_reloc16_estimate dummy_reloc16_estimate
 
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index 2e24e11..072efaa 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -46,6 +46,9 @@
 #ifndef bfd_elfNN_canonicalize_reloc
 #define bfd_elfNN_canonicalize_reloc	_bfd_elf_canonicalize_reloc
 #endif
+#ifndef bfd_elfNN_set_reloc
+#define bfd_elfNN_set_reloc		_bfd_generic_set_reloc
+#endif
 #ifndef bfd_elfNN_find_nearest_line
 #define bfd_elfNN_find_nearest_line	_bfd_elf_find_nearest_line
 #endif
diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c
index d37d000..5062506 100644
--- a/bfd/i386msdos.c
+++ b/bfd/i386msdos.c
@@ -176,6 +176,7 @@ msdos_set_section_contents (bfd *abfd,
 #define msdos_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
 
 #define msdos_canonicalize_reloc _bfd_norelocs_canonicalize_reloc
+#define msdos_set_reloc _bfd_norelocs_set_reloc
 #define msdos_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound
 #define msdos_32_bfd_link_split_section  _bfd_generic_link_split_section
 
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index ad362dc..2d1bf27 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -444,6 +444,8 @@ extern bfd_boolean _bfd_vms_lib_ia64_mkarchive (bfd *abfd);
 extern long _bfd_norelocs_get_reloc_upper_bound (bfd *, asection *);
 extern long _bfd_norelocs_canonicalize_reloc (bfd *, asection *,
 					      arelent **, asymbol **);
+extern void _bfd_norelocs_set_reloc (bfd *, asection *,
+                                     arelent **, unsigned int);
 #define _bfd_norelocs_bfd_reloc_type_lookup \
   ((reloc_howto_type *(*) (bfd *, bfd_reloc_code_real_type)) bfd_nullvoidptr)
 #define _bfd_norelocs_bfd_reloc_name_lookup \
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 46bb232..554234f 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -119,6 +119,15 @@ _bfd_norelocs_canonicalize_reloc (bfd *abfd ATTRIBUTE_UNUSED,
   return 0;
 }
 
+void
+_bfd_norelocs_set_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+                         asection *sec ATTRIBUTE_UNUSED,
+                         arelent **relptr ATTRIBUTE_UNUSED,
+                         unsigned int count ATTRIBUTE_UNUSED)
+{
+  /* Do nothing.  */
+}
+
 bfd_boolean
 _bfd_nocore_core_file_matches_executable_p
   (bfd *ignore_core_bfd ATTRIBUTE_UNUSED,
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 8bac650..7e58598 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -449,6 +449,8 @@ extern bfd_boolean _bfd_vms_lib_ia64_mkarchive (bfd *abfd);
 extern long _bfd_norelocs_get_reloc_upper_bound (bfd *, asection *);
 extern long _bfd_norelocs_canonicalize_reloc (bfd *, asection *,
 					      arelent **, asymbol **);
+extern void _bfd_norelocs_set_reloc (bfd *, asection *,
+                                     arelent **, unsigned int);
 #define _bfd_norelocs_bfd_reloc_type_lookup \
   ((reloc_howto_type *(*) (bfd *, bfd_reloc_code_real_type)) bfd_nullvoidptr)
 #define _bfd_norelocs_bfd_reloc_name_lookup \
@@ -3206,6 +3208,12 @@ bfd_byte *bfd_generic_get_relocated_section_contents
     bfd_boolean relocatable,
     asymbol **symbols);
 
+void _bfd_generic_set_reloc
+   (bfd *abfd,
+    sec_ptr section,
+    arelent **relptr,
+    unsigned int count);
+
 /* Extracted from archures.c.  */
 extern const bfd_arch_info_type bfd_default_arch_struct;
 const bfd_arch_info_type *bfd_default_compatible
diff --git a/bfd/nlm-target.h b/bfd/nlm-target.h
index 4f9e50f..872ee32 100644
--- a/bfd/nlm-target.h
+++ b/bfd/nlm-target.h
@@ -38,6 +38,7 @@
 
 #define nlm_get_reloc_upper_bound               nlmNAME (get_reloc_upper_bound)
 #define nlm_canonicalize_reloc                  nlmNAME (canonicalize_reloc)
+#define nlm_set_reloc				_bfd_generic_set_reloc
 #define nlm_bfd_reloc_type_lookup               bfd_default_reloc_type_lookup
 #define nlm_bfd_reloc_name_lookup         _bfd_norelocs_bfd_reloc_name_lookup
 #define nlm_set_section_contents                nlmNAME (set_section_contents)
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 12520d1..8dedfe8 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -8258,3 +8258,29 @@ error_return:
   free (reloc_vector);
   return NULL;
 }
+
+/*
+INTERNAL_FUNCTION
+	_bfd_generic_set_reloc
+
+SYNOPSIS
+	void _bfd_generic_set_reloc
+	  (bfd *abfd,
+	   sec_ptr section,
+	   arelent **relptr,
+	   unsigned int count);
+
+DESCRIPTION
+	Installs a new set of internal relocations in SECTION.
+*/
+
+
+void _bfd_generic_set_reloc
+  (bfd *abfd ATTRIBUTE_UNUSED,
+   sec_ptr section,
+   arelent **relptr,
+   unsigned int count)
+{
+  section->orelocation = relptr;
+  section->reloc_count = count;
+}
diff --git a/bfd/targets.c b/bfd/targets.c
index 5841e8d..2f3ea13 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -418,12 +418,15 @@ BFD_JUMP_TABLE macros.
 .#define BFD_JUMP_TABLE_RELOCS(NAME) \
 .  NAME##_get_reloc_upper_bound, \
 .  NAME##_canonicalize_reloc, \
+.  NAME##_set_reloc, \
 .  NAME##_bfd_reloc_type_lookup, \
 .  NAME##_bfd_reloc_name_lookup
 .
 .  long        (*_get_reloc_upper_bound) (bfd *, sec_ptr);
 .  long        (*_bfd_canonicalize_reloc)
 .    (bfd *, sec_ptr, arelent **, struct bfd_symbol **);
+.  void	       (*_bfd_set_reloc)
+.    (bfd *, sec_ptr, arelent **, unsigned int);
 .  {* See documentation on reloc types.  *}
 .  reloc_howto_type *
 .              (*reloc_type_lookup) (bfd *, bfd_reloc_code_real_type);
-- 
2.3.4


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