diff options
author | Nick Clifton <nickc@redhat.com> | 2016-04-21 15:43:00 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2016-04-21 15:43:00 +0100 |
commit | 4f3b23b390640efdc36c575dbda2175e61154bc9 (patch) | |
tree | b6b86755f91753a236e53eb4719a6dae7ac4a6ee | |
parent | 71829b1a3f9b4825150747b138b5cfadf0c5fcba (diff) | |
download | gdb-4f3b23b390640efdc36c575dbda2175e61154bc9.zip gdb-4f3b23b390640efdc36c575dbda2175e61154bc9.tar.gz gdb-4f3b23b390640efdc36c575dbda2175e61154bc9.tar.bz2 |
Add support for non-ELF targets to check their relocs.
bfd * aout-adobe.c: Use _bfd_generic_link_check_relocs.
* aout-target.h: Likewise.
* aout-tic30.c: Likewise.
* binary.c: Likewise.
* bout.c: Likewise.
* coff-alpha.c: Likewise.
* coff-rs6000.c: Likewise.
* coff64-rs6000.c: Likewise.
* coffcode.h: Likewise.
* i386msdos.c: Likewise.
* i386os9k.c: Likewise.
* ieee.c: Likewise.
* ihex.c: Likewise.
* libbfd-in.h: Likewise.
* libecoff.h: Likewise.
* mach-o-target.c: Likewise.
* mmo.c: Likewise.
* nlm-target.h: Likewise.
* oasys.c: Likewise.
* pef.c: Likewise.
* plugin.c: Likewise.
* ppcboot.c: Likewise.
* som.c: Likewise.
* srec.c: Likewise.
* tekhex.c: Likewise.
* versados.c: Likewise.
* vms-alpha.c: Likewise.
* xsym.c: Likewise.
* elfxx-target.h: Use _bfd_elf_link_check_relocs.
* linker.c (bfd_link_check_relocs): New function.
(_bfd_generic_link_check_relocs): New function.
* targets.c (BFD_JUMP_TABLE_LINK): Add initialization of
_bfd_link_check_relocs field.
(struct bfd_target)L Add _bfd_link_check_relocs field.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
ld * ldlang.c (lang_check_relocs): Use bfd_link_check_relocs in
prefernce to _bfd_elf_link_check_relocs. Drop test for ELF
targets. Do not stop the checks when problems are encountered.
include * bfdlink.h: Add prototype for bfd_link_check_relocs.
-rw-r--r-- | bfd/ChangeLog | 39 | ||||
-rw-r--r-- | bfd/aout-adobe.c | 1 | ||||
-rw-r--r-- | bfd/aout-target.h | 4 | ||||
-rw-r--r-- | bfd/aout-tic30.c | 4 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 10 | ||||
-rw-r--r-- | bfd/binary.c | 4 | ||||
-rw-r--r-- | bfd/bout.c | 1 | ||||
-rw-r--r-- | bfd/coff-alpha.c | 1 | ||||
-rw-r--r-- | bfd/coff-rs6000.c | 1 | ||||
-rw-r--r-- | bfd/coff64-rs6000.c | 2 | ||||
-rw-r--r-- | bfd/coffcode.h | 2 | ||||
-rw-r--r-- | bfd/elfxx-target.h | 4 | ||||
-rw-r--r-- | bfd/i386msdos.c | 1 | ||||
-rw-r--r-- | bfd/i386os9k.c | 1 | ||||
-rw-r--r-- | bfd/ieee.c | 1 | ||||
-rw-r--r-- | bfd/ihex.c | 4 | ||||
-rw-r--r-- | bfd/libbfd-in.h | 2 | ||||
-rw-r--r-- | bfd/libbfd.h | 2 | ||||
-rw-r--r-- | bfd/libecoff.h | 1 | ||||
-rw-r--r-- | bfd/linker.c | 43 | ||||
-rw-r--r-- | bfd/mach-o-target.c | 1 | ||||
-rw-r--r-- | bfd/mmo.c | 1 | ||||
-rw-r--r-- | bfd/nlm-target.h | 1 | ||||
-rw-r--r-- | bfd/oasys.c | 1 | ||||
-rw-r--r-- | bfd/pef.c | 1 | ||||
-rw-r--r-- | bfd/plugin.c | 1 | ||||
-rw-r--r-- | bfd/ppcboot.c | 1 | ||||
-rw-r--r-- | bfd/som.c | 1 | ||||
-rw-r--r-- | bfd/srec.c | 4 | ||||
-rw-r--r-- | bfd/targets.c | 4 | ||||
-rw-r--r-- | bfd/tekhex.c | 4 | ||||
-rw-r--r-- | bfd/versados.c | 1 | ||||
-rw-r--r-- | bfd/vms-alpha.c | 1 | ||||
-rw-r--r-- | bfd/xsym.c | 1 | ||||
-rw-r--r-- | include/ChangeLog | 4 | ||||
-rw-r--r-- | include/bfdlink.h | 5 | ||||
-rw-r--r-- | ld/ChangeLog | 6 | ||||
-rw-r--r-- | ld/ldlang.c | 11 |
38 files changed, 164 insertions, 13 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 201b163..9793225 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,42 @@ +2016-04-21 Nick Clifton <nickc@redhat.com> + + * aout-adobe.c: Use _bfd_generic_link_check_relocs. + * aout-target.h: Likewise. + * aout-tic30.c: Likewise. + * binary.c: Likewise. + * bout.c: Likewise. + * coff-alpha.c: Likewise. + * coff-rs6000.c: Likewise. + * coff64-rs6000.c: Likewise. + * coffcode.h: Likewise. + * i386msdos.c: Likewise. + * i386os9k.c: Likewise. + * ieee.c: Likewise. + * ihex.c: Likewise. + * libbfd-in.h: Likewise. + * libecoff.h: Likewise. + * mach-o-target.c: Likewise. + * mmo.c: Likewise. + * nlm-target.h: Likewise. + * oasys.c: Likewise. + * pef.c: Likewise. + * plugin.c: Likewise. + * ppcboot.c: Likewise. + * som.c: Likewise. + * srec.c: Likewise. + * tekhex.c: Likewise. + * versados.c: Likewise. + * vms-alpha.c: Likewise. + * xsym.c: Likewise. + * elfxx-target.h: Use _bfd_elf_link_check_relocs. + * linker.c (bfd_link_check_relocs): New function. + (_bfd_generic_link_check_relocs): New function. + * targets.c (BFD_JUMP_TABLE_LINK): Add initialization of + _bfd_link_check_relocs field. + (struct bfd_target)L Add _bfd_link_check_relocs field. + * bfd-in2.h: Regenerate. + * libbfd.h: Regenerate. + 2016-04-20 H.J. Lu <hongjiu.lu@intel.com> * elf32-i386.c (elf_i386_gc_sweep_hook): Removed. diff --git a/bfd/aout-adobe.c b/bfd/aout-adobe.c index 9556c89..57fdce7 100644 --- a/bfd/aout-adobe.c +++ b/bfd/aout-adobe.c @@ -472,6 +472,7 @@ aout_adobe_sizeof_headers (bfd *ignore_abfd ATTRIBUTE_UNUSED, _bfd_generic_copy_link_hash_symbol_type #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 const bfd_target aout_adobe_vec = { diff --git a/bfd/aout-target.h b/bfd/aout-target.h index 7d96260..c7f5b1b 100644 --- a/bfd/aout-target.h +++ b/bfd/aout-target.h @@ -542,6 +542,10 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info) #define MY_bfd_link_split_section _bfd_generic_link_split_section #endif +#ifndef MY_bfd_link_check_relocs +#define MY_bfd_link_check_relocs _bfd_generic_link_check_relocs +#endif + #ifndef MY_bfd_copy_private_bfd_data #define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data #endif diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c index f73b7e4..468944c 100644 --- a/bfd/aout-tic30.c +++ b/bfd/aout-tic30.c @@ -997,6 +997,10 @@ tic30_aout_set_arch_mach (bfd *abfd, #define MY_bfd_link_split_section _bfd_generic_link_split_section #endif +#ifndef MY_bfd_link_check_relocs +#define MY_bfd_link_check_relocs _bfd_generic_link_check_relocs +#endif + #ifndef MY_bfd_copy_private_bfd_data #define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data #endif diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 6532f6e..a19a651 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -7413,6 +7413,7 @@ typedef struct bfd_target NAME##_bfd_copy_link_hash_symbol_type, \ NAME##_bfd_final_link, \ NAME##_bfd_link_split_section, \ + NAME##_bfd_link_check_relocs, \ NAME##_bfd_gc_sections, \ NAME##_bfd_lookup_section_flags, \ NAME##_bfd_merge_sections, \ @@ -7454,6 +7455,9 @@ typedef struct bfd_target /* Should this section be split up into smaller pieces during linking. */ bfd_boolean (*_bfd_link_split_section) (bfd *, struct bfd_section *); + /* Check the relocations in the bfd for validity. */ + bfd_boolean (* _bfd_link_check_relocs)(bfd *, struct bfd_link_info *); + /* Remove sections that are not referenced from the output. */ bfd_boolean (*_bfd_gc_sections) (bfd *, struct bfd_link_info *); @@ -7566,6 +7570,12 @@ struct bfd_elf_version_tree * bfd_find_version_for_sym bfd_boolean bfd_hide_sym_by_version (struct bfd_elf_version_tree *verdefs, const char *sym_name); +bfd_boolean bfd_link_check_relocs + (bfd *abfd, struct bfd_link_info *info); + +bfd_boolean _bfd_generic_link_check_relocs + (bfd *abfd, struct bfd_link_info *info); + /* Extracted from simple.c. */ bfd_byte *bfd_simple_get_relocated_section_contents (bfd *abfd, asection *sec, bfd_byte *outbuf, asymbol **symbol_table); diff --git a/bfd/binary.c b/bfd/binary.c index ce94af2..2223b5d 100644 --- a/bfd/binary.c +++ b/bfd/binary.c @@ -309,12 +309,12 @@ binary_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, #define binary_bfd_define_common_symbol bfd_generic_define_common_symbol #define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define binary_bfd_link_just_syms _bfd_generic_link_just_syms -#define binary_bfd_copy_link_hash_symbol_type \ - _bfd_generic_copy_link_hash_symbol_type +#define binary_bfd_copy_link_hash_symbol_type _bfd_generic_copy_link_hash_symbol_type #define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols #define binary_bfd_final_link _bfd_generic_final_link #define binary_bfd_link_split_section _bfd_generic_link_split_section #define binary_get_section_contents_in_window _bfd_generic_get_section_contents_in_window +#define binary_bfd_link_check_relocs _bfd_generic_link_check_relocs const bfd_target binary_vec = { @@ -1393,6 +1393,7 @@ b_out_bfd_get_relocated_section_contents (bfd *output_bfd, #define b_out_section_already_linked _bfd_generic_section_already_linked #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 extern const bfd_target bout_le_vec; diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c index 70388f7..55fd350 100644 --- a/bfd/coff-alpha.c +++ b/bfd/coff-alpha.c @@ -2351,6 +2351,7 @@ static const struct ecoff_backend_data alpha_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_bfd_link_check_relocs _bfd_generic_link_check_relocs const bfd_target alpha_ecoff_le_vec = { diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index e7a215b..ffef1ba 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -4014,6 +4014,7 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = { #define _bfd_xcoff_bfd_discard_group bfd_generic_discard_group #define _bfd_xcoff_section_already_linked _bfd_generic_section_already_linked #define _bfd_xcoff_bfd_define_common_symbol _bfd_xcoff_define_common_symbol +#define _bfd_xcoff_bfd_link_check_relocs _bfd_generic_link_check_relocs /* For dynamic symbols and relocs entry points. */ #define _bfd_xcoff_get_synthetic_symtab _bfd_nodynamic_get_synthetic_symtab diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c index a0bc160..7b5bb24 100644 --- a/bfd/coff64-rs6000.c +++ b/bfd/coff64-rs6000.c @@ -2741,6 +2741,7 @@ const bfd_target rs6000_xcoff64_vec = _bfd_generic_copy_link_hash_symbol_type, _bfd_xcoff_bfd_final_link, _bfd_generic_link_split_section, + _bfd_generic_link_check_relocs, bfd_generic_gc_sections, bfd_generic_lookup_section_flags, bfd_generic_merge_sections, @@ -2999,6 +3000,7 @@ const bfd_target rs6000_xcoff64_aix_vec = _bfd_generic_copy_link_hash_symbol_type, _bfd_xcoff_bfd_final_link, _bfd_generic_link_split_section, + _bfd_generic_link_check_relocs, bfd_generic_gc_sections, bfd_generic_lookup_section_flags, bfd_generic_merge_sections, diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 798f7f7..eef3fa8 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -5480,6 +5480,8 @@ dummy_reloc16_extra_cases (bfd *abfd ATTRIBUTE_UNUSED, _bfd_generic_copy_link_hash_symbol_type #define coff_bfd_link_split_section _bfd_generic_link_split_section +#define coff_bfd_link_check_relocs _bfd_generic_link_check_relocs + #ifndef coff_start_final_link #define coff_start_final_link NULL #endif diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index c179721..fde34b7 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -287,6 +287,10 @@ #define bfd_elfNN_bfd_link_split_section _bfd_generic_link_split_section #endif +#ifndef bfd_elfNN_bfd_link_check_relocs +#define bfd_elfNN_bfd_link_check_relocs _bfd_elf_link_check_relocs +#endif + #ifndef bfd_elfNN_archive_p #define bfd_elfNN_archive_p bfd_generic_archive_p #endif diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c index fd24e8b..7be9544 100644 --- a/bfd/i386msdos.c +++ b/bfd/i386msdos.c @@ -157,6 +157,7 @@ msdos_set_section_contents (bfd *abfd, #define msdos_bfd_final_link _bfd_generic_final_link #define msdos_bfd_link_split_section _bfd_generic_link_split_section #define msdos_set_arch_mach _bfd_generic_set_arch_mach +#define msdos_bfd_link_check_relocs _bfd_generic_link_check_relocs #define msdos_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound #define msdos_canonicalize_symtab _bfd_nosymbols_canonicalize_symtab diff --git a/bfd/i386os9k.c b/bfd/i386os9k.c index 6bfe218..dc5624a 100644 --- a/bfd/i386os9k.c +++ b/bfd/i386os9k.c @@ -183,6 +183,7 @@ os9k_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, _bfd_generic_copy_link_hash_symbol_type #define os9k_bfd_final_link _bfd_generic_final_link #define os9k_bfd_link_split_section _bfd_generic_link_split_section +#define os9k_bfd_link_check_relocs _bfd_generic_link_check_relocs const bfd_target i386_aout_os9k_vec = { @@ -3863,6 +3863,7 @@ ieee_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, _bfd_generic_copy_link_hash_symbol_type #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 const bfd_target ieee_vec = { @@ -940,10 +940,10 @@ ihex_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, #define ihex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define ihex_bfd_link_add_symbols _bfd_generic_link_add_symbols #define ihex_bfd_link_just_syms _bfd_generic_link_just_syms -#define ihex_bfd_copy_link_hash_symbol_type \ - _bfd_generic_copy_link_hash_symbol_type +#define ihex_bfd_copy_link_hash_symbol_type _bfd_generic_copy_link_hash_symbol_type #define ihex_bfd_final_link _bfd_generic_final_link #define ihex_bfd_link_split_section _bfd_generic_link_split_section +#define ihex_bfd_link_check_relocs _bfd_generic_link_check_relocs /* The Intel Hex target vector. */ diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index 89d215b..5f28863 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -499,6 +499,8 @@ extern bfd_boolean _bfd_generic_set_section_contents #define _bfd_nolink_bfd_define_common_symbol \ ((bfd_boolean (*) (bfd *, struct bfd_link_info *, \ struct bfd_link_hash_entry *)) bfd_false) +#define _bfd_nolink_bfd_link_check_relocs \ + _bfd_generic_link_check_relocs /* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 16c0aee..5fe45ec 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -504,6 +504,8 @@ extern bfd_boolean _bfd_generic_set_section_contents #define _bfd_nolink_bfd_define_common_symbol \ ((bfd_boolean (*) (bfd *, struct bfd_link_info *, \ struct bfd_link_hash_entry *)) bfd_false) +#define _bfd_nolink_bfd_link_check_relocs \ + _bfd_generic_link_check_relocs /* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC diff --git a/bfd/libecoff.h b/bfd/libecoff.h index 0d97c46..e0991ee 100644 --- a/bfd/libecoff.h +++ b/bfd/libecoff.h @@ -242,6 +242,7 @@ extern bfd_boolean _bfd_ecoff_get_section_contents (bfd *, asection *, void * location, file_ptr, bfd_size_type); #define _bfd_ecoff_bfd_link_split_section _bfd_generic_link_split_section +#define _bfd_ecoff_bfd_link_check_relocs _bfd_generic_link_check_relocs extern bfd_boolean _bfd_ecoff_bfd_copy_private_bfd_data (bfd *, bfd *); diff --git a/bfd/linker.c b/bfd/linker.c index 97b5d18..082eea0 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -3304,3 +3304,46 @@ bfd_hide_sym_by_version (struct bfd_elf_version_tree *verdefs, bfd_find_version_for_sym (verdefs, sym_name, &hidden); return hidden; } + +/* +FUNCTION + bfd_link_check_relocs + +SYNOPSIS + bfd_boolean bfd_link_check_relocs + (bfd *abfd, struct bfd_link_info *info); + +DESCRIPTION + Checks the relocs in ABFD for validity. + Does not execute the relocs. + Return TRUE if everything is OK, FALSE otherwise. + This is the external entry point to this code. +*/ + +bfd_boolean +bfd_link_check_relocs (bfd *abfd, struct bfd_link_info *info) +{ + return BFD_SEND (abfd, _bfd_link_check_relocs, (abfd, info)); +} + +/* +FUNCTION + _bfd_generic_link_check_relocs + +SYNOPSIS + bfd_boolean _bfd_generic_link_check_relocs + (bfd *abfd, struct bfd_link_info *info); + +DESCRIPTION + Stub function for targets that do not implement reloc checking. + Return TRUE. + This is an internal function. It should not be called from + outside the BFD library. +*/ + +bfd_boolean +_bfd_generic_link_check_relocs (bfd *abfd ATTRIBUTE_UNUSED, + struct bfd_link_info *info ATTRIBUTE_UNUSED) +{ + return TRUE; +} diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c index bf956fd..6b615ed 100644 --- a/bfd/mach-o-target.c +++ b/bfd/mach-o-target.c @@ -44,6 +44,7 @@ _bfd_generic_copy_link_hash_symbol_type #define bfd_mach_o_bfd_final_link _bfd_generic_final_link #define bfd_mach_o_bfd_link_split_section _bfd_generic_link_split_section +#define bfd_mach_o_bfd_link_check_relocs _bfd_generic_link_check_relocs #define bfd_mach_o_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data #define bfd_mach_o_bfd_set_private_flags bfd_mach_o_bfd_set_private_flags #define bfd_mach_o_get_section_contents _bfd_generic_get_section_contents @@ -3278,6 +3278,7 @@ mmo_write_object_contents (bfd *abfd) _bfd_generic_copy_link_hash_symbol_type #define mmo_bfd_final_link _bfd_generic_final_link #define mmo_bfd_link_split_section _bfd_generic_link_split_section +#define mmo_bfd_link_check_relocs _bfd_generic_link_check_relocs /* Strictly speaking, only MMIX uses this restricted format, but let's not stop anybody from shooting themselves in the foot. */ diff --git a/bfd/nlm-target.h b/bfd/nlm-target.h index 082e856..6ed0b5c 100644 --- a/bfd/nlm-target.h +++ b/bfd/nlm-target.h @@ -59,6 +59,7 @@ _bfd_generic_copy_link_hash_symbol_type #define nlm_bfd_final_link _bfd_generic_final_link #define nlm_bfd_link_split_section _bfd_generic_link_split_section +#define nlm_bfd_link_check_relocs _bfd_generic_link_check_relocs /* This structure contains everything that BFD knows about a target. It includes things like its byte order, name, what routines to call diff --git a/bfd/oasys.c b/bfd/oasys.c index f7791d2..31555e0 100644 --- a/bfd/oasys.c +++ b/bfd/oasys.c @@ -1192,6 +1192,7 @@ oasys_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, _bfd_generic_copy_link_hash_symbol_type #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 const bfd_target oasys_vec = { @@ -67,6 +67,7 @@ #define bfd_pef_bfd_final_link _bfd_generic_final_link #define bfd_pef_bfd_link_split_section _bfd_generic_link_split_section #define bfd_pef_get_section_contents_in_window _bfd_generic_get_section_contents_in_window +#define bfd_pef_bfd_link_check_relocs _bfd_generic_link_check_relocs static int bfd_pef_parse_traceback_table (bfd *abfd, diff --git a/bfd/plugin.c b/bfd/plugin.c index f57833c..fd7bac0 100644 --- a/bfd/plugin.c +++ b/bfd/plugin.c @@ -106,6 +106,7 @@ dlerror (void) #define bfd_plugin_section_already_linked _bfd_generic_section_already_linked #define bfd_plugin_bfd_define_common_symbol bfd_generic_define_common_symbol #define bfd_plugin_bfd_copy_link_hash_symbol_type _bfd_generic_copy_link_hash_symbol_type +#define bfd_plugin_bfd_link_check_relocs _bfd_generic_link_check_relocs static enum ld_plugin_status message (int level ATTRIBUTE_UNUSED, diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c index ea54d62..afb6ce0 100644 --- a/bfd/ppcboot.c +++ b/bfd/ppcboot.c @@ -465,6 +465,7 @@ ppcboot_bfd_print_private_bfd_data (bfd *abfd, void * farg) #define ppcboot_bfd_link_split_section _bfd_generic_link_split_section #define ppcboot_get_section_contents_in_window \ _bfd_generic_get_section_contents_in_window +#define ppcboot_bfd_link_check_relocs _bfd_generic_link_check_relocs #define ppcboot_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data #define ppcboot_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data @@ -6758,6 +6758,7 @@ som_bfd_link_split_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) #define som_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data #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 const bfd_target hppa_som_vec = { @@ -1275,10 +1275,10 @@ srec_print_symbol (bfd *abfd, #define srec_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols #define srec_bfd_link_just_syms _bfd_generic_link_just_syms -#define srec_bfd_copy_link_hash_symbol_type \ - _bfd_generic_copy_link_hash_symbol_type +#define srec_bfd_copy_link_hash_symbol_type _bfd_generic_copy_link_hash_symbol_type #define srec_bfd_final_link _bfd_generic_final_link #define srec_bfd_link_split_section _bfd_generic_link_split_section +#define srec_bfd_link_check_relocs _bfd_generic_link_check_relocs const bfd_target srec_vec = { diff --git a/bfd/targets.c b/bfd/targets.c index 50f3712..a9edd4c 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -452,6 +452,7 @@ BFD_JUMP_TABLE macros. . NAME##_bfd_copy_link_hash_symbol_type, \ . NAME##_bfd_final_link, \ . NAME##_bfd_link_split_section, \ +. NAME##_bfd_link_check_relocs, \ . NAME##_bfd_gc_sections, \ . NAME##_bfd_lookup_section_flags, \ . NAME##_bfd_merge_sections, \ @@ -493,6 +494,9 @@ BFD_JUMP_TABLE macros. . {* Should this section be split up into smaller pieces during linking. *} . bfd_boolean (*_bfd_link_split_section) (bfd *, struct bfd_section *); . +. {* Check the relocations in the bfd for validity. *} +. bfd_boolean (* _bfd_link_check_relocs)(bfd *, struct bfd_link_info *); +. . {* Remove sections that are not referenced from the output. *} . bfd_boolean (*_bfd_gc_sections) (bfd *, struct bfd_link_info *); . diff --git a/bfd/tekhex.c b/bfd/tekhex.c index 7de2f24..b94f843 100644 --- a/bfd/tekhex.c +++ b/bfd/tekhex.c @@ -980,11 +980,11 @@ tekhex_print_symbol (bfd *abfd, #define tekhex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define tekhex_bfd_link_add_symbols _bfd_generic_link_add_symbols #define tekhex_bfd_link_just_syms _bfd_generic_link_just_syms -#define tekhex_bfd_copy_link_hash_symbol_type \ - _bfd_generic_copy_link_hash_symbol_type +#define tekhex_bfd_copy_link_hash_symbol_type _bfd_generic_copy_link_hash_symbol_type #define tekhex_bfd_final_link _bfd_generic_final_link #define tekhex_bfd_link_split_section _bfd_generic_link_split_section #define tekhex_get_section_contents_in_window _bfd_generic_get_section_contents_in_window +#define tekhex_bfd_link_check_relocs _bfd_generic_link_check_relocs const bfd_target tekhex_vec = { diff --git a/bfd/versados.c b/bfd/versados.c index c8b3c48..ed46e3b 100644 --- a/bfd/versados.c +++ b/bfd/versados.c @@ -873,6 +873,7 @@ versados_canonicalize_reloc (bfd *abfd, _bfd_generic_copy_link_hash_symbol_type #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 const bfd_target m68k_versados_vec = { diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index d55780e..e6cfc1f 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -9260,6 +9260,7 @@ bfd_vms_get_data (bfd *abfd) _bfd_nodynamic_get_dynamic_reloc_upper_bound #define alpha_vms_canonicalize_dynamic_reloc \ _bfd_nodynamic_canonicalize_dynamic_reloc +#define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs const bfd_target alpha_vms_vec = { @@ -59,6 +59,7 @@ #define bfd_sym_bfd_final_link _bfd_generic_final_link #define bfd_sym_bfd_link_split_section _bfd_generic_link_split_section #define bfd_sym_get_section_contents_in_window _bfd_generic_get_section_contents_in_window +#define bfd_sym_bfd_link_check_relocs _bfd_generic_link_check_relocs extern const bfd_target sym_vec; diff --git a/include/ChangeLog b/include/ChangeLog index a419ef2..c73bdf4 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2016-04-21 Nick Clifton <nickc@redhat.com> + + * bfdlink.h: Add prototype for bfd_link_check_relocs. + 2016-04-20 H.J. Lu <hongjiu.lu@intel.com> * bfdlink.h (bfd_link_info): Add check_relocs_after_open_input. diff --git a/include/bfdlink.h b/include/bfdlink.h index 90467b5..728fbe7 100644 --- a/include/bfdlink.h +++ b/include/bfdlink.h @@ -226,6 +226,11 @@ extern void bfd_link_repair_undef_list /* Read symbols and cache symbol pointer array in outsymbols. */ extern bfd_boolean bfd_generic_link_read_symbols (bfd *); +/* Check the relocs in the BFD. Called after all the input + files have been loaded, and garbage collection has tagged + any unneeded sections. */ +extern bfd_boolean bfd_link_check_relocs (bfd *,struct bfd_link_info *); + struct bfd_sym_chain { struct bfd_sym_chain *next; diff --git a/ld/ChangeLog b/ld/ChangeLog index 0721142..8bb2be1 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2016-04-21 Nick Clifton <nickc@redhat.com> + + * ldlang.c (lang_check_relocs): Use bfd_link_check_relocs in + prefernce to _bfd_elf_link_check_relocs. Drop test for ELF + targets. Do not stop the checks when problems are encountered. + 2016-04-21 Alan Modra <amodra@gmail.com> * testsuite/ld-scripts/cross3.t: Add commonly used data diff --git a/ld/ldlang.c b/ld/ldlang.c index 2ae3640..96947da 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -6783,18 +6783,19 @@ lang_add_gc_name (const char * name) static void lang_check_relocs (void) { - if (link_info.check_relocs_after_open_input - && bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour) + if (link_info.check_relocs_after_open_input) { bfd *abfd; for (abfd = link_info.input_bfds; abfd != (bfd *) NULL; abfd = abfd->link.next) - if (!_bfd_elf_link_check_relocs (abfd, &link_info)) + if (!bfd_link_check_relocs (abfd, &link_info)) { - /* no object output, fail return */ + /* No object output, fail return. */ config.make_executable = FALSE; - break; + /* Note: we do not abort the loop, but rather + continue the scan in case there are other + bad relocations to report. */ } } } |