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 <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. * 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.
This commit is contained in:
parent
aab82f4c20
commit
2318686590
27 changed files with 124 additions and 10 deletions
|
@ -1,3 +1,36 @@
|
|||
2017-05-10 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.
|
||||
* 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 <hongjiu.lu@intel.com>
|
||||
|
||||
PR ld/21481
|
||||
|
|
|
@ -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 =
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
12
bfd/bfd.c
12
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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 =
|
||||
{
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 =
|
||||
{
|
||||
|
|
26
bfd/reloc.c
26
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;
|
||||
}
|
||||
|
|
|
@ -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 =
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 =
|
||||
{
|
||||
|
|
|
@ -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. */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue