From: Jose E. Marchesi Date: Wed, 10 May 2017 16:40:04 +0000 (+0200) Subject: bfd: new BFD target entry point _bfd_set_reloc. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2318686590bd252a47f494554dfc11bc18a3e58b;p=binutils-gdb.git 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. bfd/ChangeLog: 2017-05-10 Jose E. Marchesi * 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. * coff-alpha.c (_bfd_ecoff_set_reloc): Likewise. * mach-o-target.c (bfd_mach_o_set_reloc): Likewise. * vms-alpha.c (alpha_vms_set_reloc): Likewise. * aout-adobe.c (aout_32_set_reloc): Likewise. * bout.c (b_out_set_reloc): Likewise. * coff-mips.c (_bfd_ecoff_set_reloc): Likewise. * i386os9k.c (aout_32_set_reloc): Likewise. * ieee.c (ieee_set_reloc): Likewise. * oasys.c (oasys_set_reloc): Likewise. * som.c (som_set_reloc): Likewise. * versados.c (versados_set_reloc): Likewise. * coff64-rs6000.c (rs6000_xcoff64_vec): Add _bfd_generic_set_reloc. (rs6000_xcoff64_aix_vec): 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. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index b307ecb1111..e9095b1866b 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,36 @@ +2017-05-10 Jose E. Marchesi + + * 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. + * coff-alpha.c (_bfd_ecoff_set_reloc): Likewise. + * mach-o-target.c (bfd_mach_o_set_reloc): Likewise. + * vms-alpha.c (alpha_vms_set_reloc): Likewise. + * aout-adobe.c (aout_32_set_reloc): Likewise. + * bout.c (b_out_set_reloc): Likewise. + * coff-mips.c (_bfd_ecoff_set_reloc): Likewise. + * i386os9k.c (aout_32_set_reloc): Likewise. + * ieee.c (ieee_set_reloc): Likewise. + * oasys.c (oasys_set_reloc): Likewise. + * som.c (som_set_reloc): Likewise. + * versados.c (versados_set_reloc): Likewise. + * coff64-rs6000.c (rs6000_xcoff64_vec): Add + _bfd_generic_set_reloc. + (rs6000_xcoff64_aix_vec): 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-10 H.J. Lu PR ld/21481 diff --git a/bfd/aout-adobe.c b/bfd/aout-adobe.c index d47dd20889a..a2c927da23a 100644 --- a/bfd/aout-adobe.c +++ b/bfd/aout-adobe.c @@ -474,6 +474,7 @@ aout_adobe_sizeof_headers (bfd *ignore_abfd ATTRIBUTE_UNUSED, #define aout_32_bfd_final_link _bfd_generic_final_link #define aout_32_bfd_link_split_section _bfd_generic_link_split_section #define aout_32_bfd_link_check_relocs _bfd_generic_link_check_relocs +#define aout_32_set_reloc _bfd_generic_set_reloc const bfd_target aout_adobe_vec = { diff --git a/bfd/aout-target.h b/bfd/aout-target.h index 9f77c95cd88..2e98c4d0f9d 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 29dad9ff932..5db3da7c34a 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 17a35c09edf..8617881cdbf 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -7075,6 +7075,8 @@ long bfd_canonicalize_reloc void bfd_set_reloc (bfd *abfd, asection *sec, arelent **rel, unsigned int count); +#define bfd_set_reloc(abfd, asect, location, count) \ + BFD_SEND (abfd, _bfd_set_reloc, (abfd, asect, location, count)) bfd_boolean bfd_set_file_flags (bfd *abfd, flagword flags); int bfd_get_arch_size (bfd *abfd); @@ -7542,12 +7544,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 23a435043a0..c6fce45abf1 100644 --- a/bfd/bfd.c +++ b/bfd/bfd.c @@ -1064,18 +1064,10 @@ DESCRIPTION section @var{sec} to the values @var{rel} and @var{count}. The argument @var{abfd} is ignored. +.#define bfd_set_reloc(abfd, asect, location, count) \ +. BFD_SEND (abfd, _bfd_set_reloc, (abfd, asect, location, count)) */ -void -bfd_set_reloc (bfd *ignore_abfd ATTRIBUTE_UNUSED, - sec_ptr asect, - arelent **location, - unsigned int count) -{ - asect->orelocation = location; - asect->reloc_count = count; -} - /* FUNCTION bfd_set_file_flags diff --git a/bfd/bout.c b/bfd/bout.c index 1d3bf6612d6..0a6f8db0fbe 100644 --- a/bfd/bout.c +++ b/bfd/bout.c @@ -1392,6 +1392,7 @@ b_out_bfd_get_relocated_section_contents (bfd *output_bfd, #define b_out_bfd_define_common_symbol bfd_generic_define_common_symbol #define aout_32_get_section_contents_in_window _bfd_generic_get_section_contents_in_window #define b_out_bfd_link_check_relocs _bfd_generic_link_check_relocs +#define b_out_set_reloc _bfd_generic_set_reloc extern const bfd_target bout_le_vec; diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c index 9ce1975dac6..8ecba2f0d8f 100644 --- a/bfd/coff-alpha.c +++ b/bfd/coff-alpha.c @@ -2342,6 +2342,9 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data = #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol #define _bfd_ecoff_bfd_link_check_relocs _bfd_generic_link_check_relocs +/* Installing internal relocations in a section is also generic. */ +#define _bfd_ecoff_set_reloc _bfd_generic_set_reloc + const bfd_target alpha_ecoff_le_vec = { "ecoff-littlealpha", /* name */ diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c index f872ebecb5d..45c65f8f8e7 100644 --- a/bfd/coff-mips.c +++ b/bfd/coff-mips.c @@ -1356,6 +1356,7 @@ static const struct ecoff_backend_data mips_ecoff_backend_data = #define _bfd_ecoff_section_already_linked \ _bfd_coff_section_already_linked #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol +#define _bfd_ecoff_set_reloc _bfd_generic_set_reloc extern const bfd_target mips_ecoff_be_vec; diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index e2b149bddeb..b49e393e48f 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/coff64-rs6000.c b/bfd/coff64-rs6000.c index e919dcb05b4..56458e0f0af 100644 --- a/bfd/coff64-rs6000.c +++ b/bfd/coff64-rs6000.c @@ -2720,6 +2720,7 @@ const bfd_target rs6000_xcoff64_vec = /* Reloc */ coff_get_reloc_upper_bound, coff_canonicalize_reloc, + _bfd_generic_set_reloc, xcoff64_reloc_type_lookup, xcoff64_reloc_name_lookup, @@ -2979,6 +2980,7 @@ const bfd_target rs6000_xcoff64_aix_vec = /* Reloc */ coff_get_reloc_upper_bound, coff_canonicalize_reloc, + _bfd_generic_set_reloc, xcoff64_reloc_type_lookup, xcoff64_reloc_name_lookup, diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 96a7886bc81..f9d3978b2d5 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 2e24e119459..072efaa93d7 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 d37d0007e95..5062506c53d 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/i386os9k.c b/bfd/i386os9k.c index fbec96c4feb..7f79b2357f4 100644 --- a/bfd/i386os9k.c +++ b/bfd/i386os9k.c @@ -165,6 +165,8 @@ os9k_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, #define aout_32_get_section_contents_in_window \ _bfd_generic_get_section_contents_in_window +#define aout_32_set_reloc _bfd_generic_set_reloc + #define os9k_bfd_get_relocated_section_contents \ bfd_generic_get_relocated_section_contents #define os9k_bfd_relax_section bfd_generic_relax_section diff --git a/bfd/ieee.c b/bfd/ieee.c index a2d38352db4..763c2b81822 100644 --- a/bfd/ieee.c +++ b/bfd/ieee.c @@ -3880,6 +3880,7 @@ ieee_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, #define ieee_bfd_final_link _bfd_generic_final_link #define ieee_bfd_link_split_section _bfd_generic_link_split_section #define ieee_bfd_link_check_relocs _bfd_generic_link_check_relocs +#define ieee_set_reloc _bfd_generic_set_reloc const bfd_target ieee_vec = { diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index ad362dce015..2d1bf27f71d 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 46bb2329273..554234fbcfd 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 8bac6501f3f..7e58598b908 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/mach-o-target.c b/bfd/mach-o-target.c index 3a4e72f9a9b..c25a74365d8 100644 --- a/bfd/mach-o-target.c +++ b/bfd/mach-o-target.c @@ -58,6 +58,7 @@ #define bfd_mach_o_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data #define bfd_mach_o_core_file_matches_executable_p generic_core_file_matches_executable_p #define bfd_mach_o_core_file_pid _bfd_nocore_core_file_pid +#define bfd_mach_o_set_reloc _bfd_generic_set_reloc #define bfd_mach_o_get_dynamic_symtab_upper_bound bfd_mach_o_get_symtab_upper_bound #define bfd_mach_o_canonicalize_dynamic_symtab bfd_mach_o_canonicalize_symtab diff --git a/bfd/nlm-target.h b/bfd/nlm-target.h index 4f9e50f3d3f..872ee320ca2 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/oasys.c b/bfd/oasys.c index 06491aaeb77..defb25abfd8 100644 --- a/bfd/oasys.c +++ b/bfd/oasys.c @@ -1194,6 +1194,7 @@ oasys_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, #define oasys_bfd_final_link _bfd_generic_final_link #define oasys_bfd_link_split_section _bfd_generic_link_split_section #define oasys_bfd_link_check_relocs _bfd_generic_link_check_relocs +#define oasys_set_reloc _bfd_generic_set_reloc const bfd_target oasys_vec = { diff --git a/bfd/reloc.c b/bfd/reloc.c index 12520d15542..8dedfe82bf0 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/som.c b/bfd/som.c index f78b651d1a0..496040c3f0f 100644 --- a/bfd/som.c +++ b/bfd/som.c @@ -6759,6 +6759,7 @@ som_bfd_link_split_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) #define som_bfd_set_private_flags _bfd_generic_bfd_set_private_flags #define som_find_inliner_info _bfd_nosymbols_find_inliner_info #define som_bfd_link_check_relocs _bfd_generic_link_check_relocs +#define som_set_reloc _bfd_generic_set_reloc const bfd_target hppa_som_vec = { diff --git a/bfd/targets.c b/bfd/targets.c index 5841e8d6e50..2f3ea1346e2 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); diff --git a/bfd/versados.c b/bfd/versados.c index f5755229d55..2efbcff5e94 100644 --- a/bfd/versados.c +++ b/bfd/versados.c @@ -875,6 +875,7 @@ versados_canonicalize_reloc (bfd *abfd, #define versados_bfd_final_link _bfd_generic_final_link #define versados_bfd_link_split_section _bfd_generic_link_split_section #define versados_bfd_link_check_relocs _bfd_generic_link_check_relocs +#define versados_set_reloc _bfd_generic_set_reloc const bfd_target m68k_versados_vec = { diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index 4a9881be552..ef52120ad62 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -5118,6 +5118,11 @@ alpha_vms_canonicalize_reloc (bfd *abfd, asection *section, arelent **relptr, *relptr = (arelent *) NULL; return section->reloc_count; } + +/* Install a new set of internal relocs. */ + +#define alpha_vms_set_reloc _bfd_generic_set_reloc + /* This is just copied from ecoff-alpha, needs to be fixed probably. */