* [rfc] new bfd hook: additional link map text @ 2014-04-11 2:14 DJ Delorie 2014-04-11 7:10 ` Tristan Gingold 0 siblings, 1 reply; 19+ messages in thread From: DJ Delorie @ 2014-04-11 2:14 UTC (permalink / raw) To: binutils This is an RFC for a new bfd target hook "additional_link_map_text" that's used to give targets a way to add target-specific text to the end of the linker's map file (-Map). This extra text is added at the end of the map file, in case there are programs which parse map files (where the extra text might confuse the parser, if encountered early). Tested with --enable-targets=all although I had to manually fix today's AVR reloc patch bug. I have a follow-up patch that adds a new feature to the rx target which includes link map text, too... Comments? [bfd] * aout-adobe.c: Add additional_link_map_text hook. * aout-target.h: Likewise. * aout-tic30.c: Likewise. * bfd-in2.h: Likewise. * binary.c: Likewise. * bout.c: Likewise. * coff-alpha.c: Likewise. * coff-mips.c: Likewise. * coff-rs6000.c: Likewise. * coff64-rs6000.c: Likewise. * coffcode.h: Likewise. * elf32-rx.c: Likewise. * elfxx-target.h: Likewise. * i386msdos.c: Likewise. * i386os9k.c: Likewise. * ieee.c: Likewise. * ihex.c: Likewise. * libbfd-in.h: Likewise. * mach-o-target.c: Likewise. * mmo.c: Likewise. * nlm-target.h: Likewise. * oasys.c: Likewise. * pef.c: Likewise. * ppcboot.c: Likewise. * som.c: Likewise. * srec.c: Likewise. * targets.c: Likewise. * tekhex.c: Likewise. * versados.c: Likewise. * vms-alpha.c: Likewise. * xsym.c: Likewise. * linker.c (bfd_generic_additional_link_map_text, bfd_additional_link_map_text): New. * libbfd.h: Regenerate. [ld] * ldlang.c (lang_map): Call bfd_additional_link_map_text(). diff --git a/bfd/aout-adobe.c b/bfd/aout-adobe.c index 2516a8d..f5d0515 100644 --- a/bfd/aout-adobe.c +++ b/bfd/aout-adobe.c @@ -463,6 +463,7 @@ aout_adobe_sizeof_headers (bfd *ignore_abfd ATTRIBUTE_UNUSED, #define aout_32_bfd_discard_group bfd_generic_discard_group #define aout_32_section_already_linked _bfd_generic_section_already_linked #define aout_32_bfd_define_common_symbol bfd_generic_define_common_symbol +#define aout_32_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define aout_32_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define aout_32_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define aout_32_bfd_link_add_symbols _bfd_generic_link_add_symbols diff --git a/bfd/aout-target.h b/bfd/aout-target.h index 9786f42..521181d 100644 --- a/bfd/aout-target.h +++ b/bfd/aout-target.h @@ -503,6 +503,9 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info) #ifndef MY_bfd_define_common_symbol #define MY_bfd_define_common_symbol bfd_generic_define_common_symbol #endif +#ifndef MY_bfd_additional_link_map_text +#define MY_bfd_additional_link_map_text bfd_generic_additional_link_map_text +#endif #ifndef MY_bfd_reloc_type_lookup #define MY_bfd_reloc_type_lookup NAME (aout, reloc_type_lookup) #endif diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c index 680ef61..ec3b3c9 100644 --- a/bfd/aout-tic30.c +++ b/bfd/aout-tic30.c @@ -961,6 +961,9 @@ tic30_aout_set_arch_mach (bfd *abfd, #ifndef MY_bfd_define_common_symbol #define MY_bfd_define_common_symbol bfd_generic_define_common_symbol #endif +#ifndef MY_bfd_additional_link_map_text +#define MY_bfd_additional_link_map_text bfd_generic_additional_link_map_text +#endif #ifndef MY_bfd_reloc_type_lookup #define MY_bfd_reloc_type_lookup tic30_aout_reloc_type_lookup #endif diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index cd45d71..bc75552 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -7016,7 +7026,8 @@ typedef struct bfd_target NAME##_bfd_is_group_section, \ NAME##_bfd_discard_group, \ NAME##_section_already_linked, \ - NAME##_bfd_define_common_symbol + NAME##_bfd_define_common_symbol, \ + NAME##_bfd_additional_link_map_text int (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *); bfd_byte * (*_bfd_get_relocated_section_contents) @@ -7079,6 +7090,11 @@ typedef struct bfd_target bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *); + /* Let the backend print additional information about the output + BFD to the map file. */ + void (*_bfd_additional_link_map_text) + (bfd *, struct bfd_link_info *, FILE *); + /* Routines to handle dynamic symbols and relocs. */ #define BFD_JUMP_TABLE_DYNAMIC(NAME) \ NAME##_get_dynamic_symtab_upper_bound, \ @@ -7156,6 +7172,12 @@ bfd_boolean bfd_generic_define_common_symbol #define bfd_define_common_symbol(output_bfd, info, h) \ BFD_SEND (output_bfd, _bfd_define_common_symbol, (output_bfd, info, h)) +void bfd_generic_additional_link_map_text + (bfd *output_bfd, struct bfd_link_info *info, FILE *mapfile); + +#define bfd_additional_link_map_text(output_bfd, info, mapfile) \ + BFD_SEND (output_bfd, _bfd_additional_link_map_text, (output_bfd, info, mapfile)) + struct bfd_elf_version_tree * bfd_find_version_for_sym (struct bfd_elf_version_tree *verdefs, const char *sym_name, bfd_boolean *hide); diff --git a/bfd/binary.c b/bfd/binary.c index 13825d2..a699dca 100644 --- a/bfd/binary.c +++ b/bfd/binary.c @@ -304,6 +304,7 @@ binary_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, #define binary_bfd_discard_group bfd_generic_discard_group #define binary_section_already_linked _bfd_generic_section_already_linked #define binary_bfd_define_common_symbol bfd_generic_define_common_symbol +#define binary_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define binary_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define binary_bfd_link_just_syms _bfd_generic_link_just_syms diff --git a/bfd/bout.c b/bfd/bout.c index 2c19ecc..fb977e5 100644 --- a/bfd/bout.c +++ b/bfd/bout.c @@ -1391,6 +1391,7 @@ b_out_bfd_get_relocated_section_contents (bfd *output_bfd, #define b_out_bfd_discard_group bfd_generic_discard_group #define b_out_section_already_linked _bfd_generic_section_already_linked #define b_out_bfd_define_common_symbol bfd_generic_define_common_symbol +#define b_out_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define aout_32_get_section_contents_in_window _bfd_generic_get_section_contents_in_window extern const bfd_target b_out_vec_little_host; diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c index 8c68b56..b28aa5e 100644 --- a/bfd/coff-alpha.c +++ b/bfd/coff-alpha.c @@ -2345,6 +2345,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_additional_link_map_text bfd_generic_additional_link_map_text const bfd_target ecoffalpha_little_vec = { diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c index 3a30d83..d5704d0 100644 --- a/bfd/coff-mips.c +++ b/bfd/coff-mips.c @@ -1362,6 +1362,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_bfd_additional_link_map_text bfd_generic_additional_link_map_text extern const bfd_target ecoff_big_vec; diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index d0b8eaf..1d59f8d 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -4075,6 +4075,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_additional_link_map_text bfd_generic_additional_link_map_text /* 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 d660e3a..64d5c29 100644 --- a/bfd/coff64-rs6000.c +++ b/bfd/coff64-rs6000.c @@ -2751,6 +2751,7 @@ const bfd_target rs6000coff64_vec = bfd_generic_discard_group, _bfd_generic_section_already_linked, _bfd_xcoff_define_common_symbol, + bfd_generic_additional_link_map_text, /* Dynamic */ _bfd_xcoff_get_dynamic_symtab_upper_bound, @@ -3010,6 +3011,7 @@ const bfd_target aix5coff64_vec = bfd_generic_discard_group, _bfd_generic_section_already_linked, _bfd_xcoff_define_common_symbol, + bfd_generic_additional_link_map_text, /* Dynamic */ _bfd_xcoff_get_dynamic_symtab_upper_bound, diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 4994fb3..013a9cd 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -5959,6 +5959,10 @@ static bfd_coff_backend_data bigobj_swap_table = #define coff_bfd_define_common_symbol bfd_generic_define_common_symbol #endif +#ifndef coff_bfd_additional_link_map_text +#define coff_bfd_additional_link_map_text bfd_generic_additional_link_map_text +#endif + #define CREATE_BIG_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE) \ const bfd_target VAR = \ { \ diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index 1460d6a..22a575b 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -178,6 +178,10 @@ #define bfd_elfNN_bfd_define_common_symbol bfd_generic_define_common_symbol #endif +#ifndef bfd_elfNN_bfd_additional_link_map_text +#define bfd_elfNN_bfd_additional_link_map_text bfd_generic_additional_link_map_text +#endif + #ifndef bfd_elfNN_bfd_lookup_section_flags #define bfd_elfNN_bfd_lookup_section_flags bfd_elf_lookup_section_flags #endif diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c index fdba24d..778bd7b 100644 --- a/bfd/i386msdos.c +++ b/bfd/i386msdos.c @@ -149,6 +149,7 @@ msdos_set_section_contents (bfd *abfd, #define msdos_section_already_linked \ _bfd_generic_section_already_linked #define msdos_bfd_define_common_symbol bfd_generic_define_common_symbol +#define msdos_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define msdos_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define msdos_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define msdos_bfd_link_add_symbols _bfd_generic_link_add_symbols diff --git a/bfd/i386os9k.c b/bfd/i386os9k.c index 7df7b00..3856a59 100644 --- a/bfd/i386os9k.c +++ b/bfd/i386os9k.c @@ -173,6 +173,7 @@ os9k_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, #define os9k_section_already_linked \ _bfd_generic_section_already_linked #define os9k_bfd_define_common_symbol bfd_generic_define_common_symbol +#define os9k_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define os9k_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define os9k_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define os9k_bfd_link_add_symbols _bfd_generic_link_add_symbols diff --git a/bfd/ieee.c b/bfd/ieee.c index 7eb4dde..fc99e43 100644 --- a/bfd/ieee.c +++ b/bfd/ieee.c @@ -3778,6 +3778,7 @@ ieee_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, #define ieee_section_already_linked \ _bfd_generic_section_already_linked #define ieee_bfd_define_common_symbol bfd_generic_define_common_symbol +#define ieee_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define ieee_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols diff --git a/bfd/ihex.c b/bfd/ihex.c index f767cb0..2867f14 100644 --- a/bfd/ihex.c +++ b/bfd/ihex.c @@ -935,6 +935,7 @@ ihex_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, #define ihex_bfd_discard_group bfd_generic_discard_group #define ihex_section_already_linked _bfd_generic_section_already_linked #define ihex_bfd_define_common_symbol bfd_generic_define_common_symbol +#define ihex_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define ihex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define ihex_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define ihex_bfd_link_add_symbols _bfd_generic_link_add_symbols diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index 62804af..d60716e 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -490,6 +490,9 @@ 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_additional_link_map_text \ + ((void (*) (bfd *, struct bfd_link_info *, \ + FILE *)) bfd_void) /* 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 f836f3f..f969cd4 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -495,6 +495,9 @@ 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_additional_link_map_text \ + ((void (*) (bfd *, struct bfd_link_info *, \ + FILE *)) bfd_void) /* 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/linker.c b/bfd/linker.c index a20a276..55356bc 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -3298,6 +3298,31 @@ bfd_generic_define_common_symbol (bfd *output_bfd, return TRUE; } + +/* +FUNCTION + bfd_generic_additional_link_map_text + +SYNOPSIS + void bfd_generic_additional_link_map_text + (bfd *output_bfd, struct bfd_link_info *info, FILE *mapfile); + +DESCRIPTION + Hook to allow backends to emit backend-specific or + target-specific text to the linker map.. + +.#define bfd_additional_link_map_text(output_bfd, info, mapfile) \ +. BFD_SEND (output_bfd, _bfd_additional_link_map_text, (output_bfd, info, mapfile)) +. +*/ + +void +bfd_generic_additional_link_map_text (bfd *output_bfd ATTRIBUTE_UNUSED, + struct bfd_link_info *info ATTRIBUTE_UNUSED, + FILE *mapfile ATTRIBUTE_UNUSED) +{ +} + /* FUNCTION bfd_find_version_for_sym diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c index 65d5118..1e222c7 100644 --- a/bfd/mach-o-target.c +++ b/bfd/mach-o-target.c @@ -54,6 +54,7 @@ #define bfd_mach_o_bfd_discard_group bfd_generic_discard_group #define bfd_mach_o_section_already_linked _bfd_generic_section_already_linked #define bfd_mach_o_bfd_define_common_symbol bfd_generic_define_common_symbol +#define bfd_mach_o_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define bfd_mach_o_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_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 diff --git a/bfd/mmo.c b/bfd/mmo.c index e8ce288..a15613a 100644 --- a/bfd/mmo.c +++ b/bfd/mmo.c @@ -3213,6 +3213,7 @@ mmo_write_object_contents (bfd *abfd) #define mmo_section_already_linked \ _bfd_generic_section_already_linked #define mmo_bfd_define_common_symbol bfd_generic_define_common_symbol +#define mmo_bfd_additional_link_map_text bfd_generic_additional_link_map_text /* We want to copy time of creation, otherwise we'd use BFD_JUMP_TABLE_COPY (_bfd_generic). */ diff --git a/bfd/nlm-target.h b/bfd/nlm-target.h index e55ddb6..772e8ca 100644 --- a/bfd/nlm-target.h +++ b/bfd/nlm-target.h @@ -50,6 +50,7 @@ #define nlm_bfd_discard_group bfd_generic_discard_group #define nlm_section_already_linked _bfd_generic_section_already_linked #define nlm_bfd_define_common_symbol bfd_generic_define_common_symbol +#define nlm_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define nlm_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define nlm_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define nlm_bfd_link_add_symbols _bfd_generic_link_add_symbols diff --git a/bfd/oasys.c b/bfd/oasys.c index 74305d7..51dfc4a 100644 --- a/bfd/oasys.c +++ b/bfd/oasys.c @@ -1203,6 +1203,7 @@ oasys_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, #define oasys_bfd_discard_group bfd_generic_discard_group #define oasys_section_already_linked _bfd_generic_section_already_linked #define oasys_bfd_define_common_symbol bfd_generic_define_common_symbol +#define oasys_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define oasys_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define oasys_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define oasys_bfd_link_add_symbols _bfd_generic_link_add_symbols diff --git a/bfd/pef.c b/bfd/pef.c index f0b3233..95d07ed 100644 --- a/bfd/pef.c +++ b/bfd/pef.c @@ -57,6 +57,7 @@ #define bfd_pef_bfd_discard_group bfd_generic_discard_group #define bfd_pef_section_already_linked _bfd_generic_section_already_linked #define bfd_pef_bfd_define_common_symbol bfd_generic_define_common_symbol +#define bfd_pef_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define bfd_pef_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define bfd_pef_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define bfd_pef_bfd_link_add_symbols _bfd_generic_link_add_symbols diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c index a05c368..05fa684 100644 --- a/bfd/ppcboot.c +++ b/bfd/ppcboot.c @@ -453,6 +453,7 @@ ppcboot_bfd_print_private_bfd_data (bfd *abfd, void * farg) #define ppcboot_section_already_linked \ _bfd_generic_section_already_linked #define ppcboot_bfd_define_common_symbol bfd_generic_define_common_symbol +#define ppcboot_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define ppcboot_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define ppcboot_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define ppcboot_bfd_link_add_symbols _bfd_generic_link_add_symbols diff --git a/bfd/som.c b/bfd/som.c index 4fddf32..30b847a 100644 --- a/bfd/som.c +++ b/bfd/som.c @@ -6745,6 +6745,7 @@ som_bfd_link_split_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) #define som_bfd_discard_group bfd_generic_discard_group #define som_section_already_linked _bfd_generic_section_already_linked #define som_bfd_define_common_symbol bfd_generic_define_common_symbol +#define som_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define som_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data #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 diff --git a/bfd/srec.c b/bfd/srec.c index 1045d99..4fea7b7 100644 --- a/bfd/srec.c +++ b/bfd/srec.c @@ -1257,6 +1257,7 @@ srec_print_symbol (bfd *abfd, #define srec_bfd_discard_group bfd_generic_discard_group #define srec_section_already_linked _bfd_generic_section_already_linked #define srec_bfd_define_common_symbol bfd_generic_define_common_symbol +#define srec_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define srec_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define srec_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols diff --git a/bfd/targets.c b/bfd/targets.c index 058ab77..7966241 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -458,7 +458,8 @@ BFD_JUMP_TABLE macros. . NAME##_bfd_is_group_section, \ . NAME##_bfd_discard_group, \ . NAME##_section_already_linked, \ -. NAME##_bfd_define_common_symbol +. NAME##_bfd_define_common_symbol, \ +. NAME##_bfd_additional_link_map_text . . int (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *); . bfd_byte * (*_bfd_get_relocated_section_contents) @@ -521,6 +522,11 @@ BFD_JUMP_TABLE macros. . bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *, . struct bfd_link_hash_entry *); . +. {* Let the backend print additional information about the output +. BFD to the map file. *} +. void (*_bfd_additional_link_map_text) +. (bfd *, struct bfd_link_info *, FILE *); +. . {* Routines to handle dynamic symbols and relocs. *} .#define BFD_JUMP_TABLE_DYNAMIC(NAME) \ . NAME##_get_dynamic_symtab_upper_bound, \ diff --git a/bfd/tekhex.c b/bfd/tekhex.c index 7fcab93..1d0ef8d 100644 --- a/bfd/tekhex.c +++ b/bfd/tekhex.c @@ -948,6 +948,7 @@ tekhex_print_symbol (bfd *abfd, #define tekhex_bfd_discard_group bfd_generic_discard_group #define tekhex_section_already_linked _bfd_generic_section_already_linked #define tekhex_bfd_define_common_symbol bfd_generic_define_common_symbol +#define tekhex_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define tekhex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define tekhex_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define tekhex_bfd_link_add_symbols _bfd_generic_link_add_symbols diff --git a/bfd/versados.c b/bfd/versados.c index a2dbdf5..33ba625 100644 --- a/bfd/versados.c +++ b/bfd/versados.c @@ -811,6 +811,7 @@ versados_canonicalize_reloc (bfd *abfd, #define versados_bfd_discard_group bfd_generic_discard_group #define versados_section_already_linked _bfd_generic_section_already_linked #define versados_bfd_define_common_symbol bfd_generic_define_common_symbol +#define versados_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define versados_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define versados_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define versados_bfd_link_add_symbols _bfd_generic_link_add_symbols diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index e038f1a..63fb3c2 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -9194,6 +9194,7 @@ bfd_vms_get_data (bfd *abfd) #define vms_bfd_discard_group bfd_generic_discard_group #define vms_section_already_linked _bfd_generic_section_already_linked #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol +#define vms_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data @@ -9239,6 +9240,7 @@ bfd_vms_get_data (bfd *abfd) _bfd_generic_section_already_linked #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol +#define alpha_vms_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define alpha_vms_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms #define alpha_vms_bfd_copy_link_hash_symbol_type \ diff --git a/bfd/xsym.c b/bfd/xsym.c index 1945113..2310227 100644 --- a/bfd/xsym.c +++ b/bfd/xsym.c @@ -49,6 +49,7 @@ #define bfd_sym_bfd_discard_group bfd_generic_discard_group #define bfd_sym_section_already_linked _bfd_generic_section_already_linked #define bfd_sym_bfd_define_common_symbol bfd_generic_define_common_symbol +#define bfd_sym_bfd_additional_link_map_text bfd_generic_additional_link_map_text #define bfd_sym_bfd_link_hash_table_create _bfd_generic_link_hash_table_create #define bfd_sym_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define bfd_sym_bfd_link_add_symbols _bfd_generic_link_add_symbols diff --git a/ld/ldlang.c b/ld/ldlang.c index d147ee0..3861846 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -2123,6 +2123,8 @@ lang_map (void) } lang_statement_iteration++; print_statements (); + + bfd_additional_link_map_text (link_info.output_bfd, &link_info, config.map_file); } static bfd_boolean ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-04-11 2:14 [rfc] new bfd hook: additional link map text DJ Delorie @ 2014-04-11 7:10 ` Tristan Gingold 2014-04-22 20:55 ` DJ Delorie 0 siblings, 1 reply; 19+ messages in thread From: Tristan Gingold @ 2014-04-11 7:10 UTC (permalink / raw) To: DJ Delorie; +Cc: binutils On 11 Apr 2014, at 04:14, DJ Delorie <dj@redhat.com> wrote: > > This is an RFC for a new bfd target hook "additional_link_map_text" > that's used to give targets a way to add target-specific text to the > end of the linker's map file (-Map). This extra text is added at the > end of the map file, in case there are programs which parse map files > (where the extra text might confuse the parser, if encountered early). > > Tested with --enable-targets=all although I had to manually fix > today's AVR reloc patch bug. > > I have a follow-up patch that adds a new feature to the rx target > which includes link map text, too... > > Comments? Why not adding a new field in ld_emulation_xfer_struct ? Looks lighter. Tristan. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-04-11 7:10 ` Tristan Gingold @ 2014-04-22 20:55 ` DJ Delorie 2014-05-06 15:15 ` DJ Delorie 0 siblings, 1 reply; 19+ messages in thread From: DJ Delorie @ 2014-04-22 20:55 UTC (permalink / raw) To: Tristan Gingold; +Cc: binutils > > This is an RFC for a new bfd target hook "additional_link_map_text" > > that's used to give targets a way to add target-specific text to the > > end of the linker's map file (-Map). This extra text is added at the > > end of the map file, in case there are programs which parse map files > > (where the extra text might confuse the parser, if encountered early). > > > > Tested with --enable-targets=all although I had to manually fix > > today's AVR reloc patch bug. > > > > I have a follow-up patch that adds a new feature to the rx target > > which includes link map text, too... > > > > Comments? > > Why not adding a new field in ld_emulation_xfer_struct ? Looks lighter. Attached, mostly. Git is giving me a diff relative to the previous patch. The one catch is that there isn't a good place to put the function prototype if the function happens to need to be defined inside bfd, which in my case it does since I need to hook a few other points in the process to set up the data I'm printing. With the bfd hook, everything's in one file, so prototypes aren't a problem and all the functions can be static. diff --git a/ld/emultempl/aix.em b/ld/emultempl/aix.em index caa74a9..56985cf 100644 --- a/ld/emultempl/aix.em +++ b/ld/emultempl/aix.em @@ -1553,6 +1553,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = { NULL, /* list_options */ NULL, /* recognized_file */ NULL, /* find potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/armcoff.em b/ld/emultempl/armcoff.em index 8e9befc..de10a6c 100644 --- a/ld/emultempl/armcoff.em +++ b/ld/emultempl/armcoff.em @@ -279,6 +279,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = gld${EMULATION_NAME}_list_options, NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/beos.em b/ld/emultempl/beos.em index 2196510..732abfd 100644 --- a/ld/emultempl/beos.em +++ b/ld/emultempl/beos.em @@ -777,6 +777,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 31761ca..3ebf3b5 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -2498,6 +2498,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = ${LDEMUL_LIST_OPTIONS-gld${EMULATION_NAME}_list_options}, ${LDEMUL_RECOGNIZED_FILE-gld${EMULATION_NAME}_load_symbols}, ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL}, - ${LDEMUL_NEW_VERS_PATTERN-NULL} + ${LDEMUL_NEW_VERS_PATTERN-NULL}, + ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL} }; EOF diff --git a/ld/emultempl/generic.em b/ld/emultempl/generic.em index b22e2a6..aac4b93 100644 --- a/ld/emultempl/generic.em +++ b/ld/emultempl/generic.em @@ -156,5 +156,6 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = ${LDEMUL_RECOGNIZED_FILE-NULL}, ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL}, ${LDEMUL_NEW_VERS_PATTERN-NULL} + ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL} }; EOF diff --git a/ld/emultempl/gld960.em b/ld/emultempl/gld960.em index 0df99e3..5632f31 100644 --- a/ld/emultempl/gld960.em +++ b/ld/emultempl/gld960.em @@ -148,6 +148,7 @@ struct ld_emulation_xfer_struct ld_gld960_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/gld960c.em b/ld/emultempl/gld960c.em index 805e69b..dd69c79 100644 --- a/ld/emultempl/gld960c.em +++ b/ld/emultempl/gld960c.em @@ -161,6 +161,7 @@ struct ld_emulation_xfer_struct ld_gld960coff_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/linux.em b/ld/emultempl/linux.em index b30e872..bbc5946 100644 --- a/ld/emultempl/linux.em +++ b/ld/emultempl/linux.em @@ -205,6 +205,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/lnk960.em b/ld/emultempl/lnk960.em index 9c6ff38..6364f6d 100644 --- a/ld/emultempl/lnk960.em +++ b/ld/emultempl/lnk960.em @@ -342,6 +342,7 @@ struct ld_emulation_xfer_struct ld_lnk960_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/m68kcoff.em b/ld/emultempl/m68kcoff.em index 1ea900a..e46889a 100644 --- a/ld/emultempl/m68kcoff.em +++ b/ld/emultempl/m68kcoff.em @@ -239,6 +239,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index ba51cc0..3a37508 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -2449,6 +2449,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = gld_${EMULATION_NAME}_list_options, gld_${EMULATION_NAME}_recognized_file, gld_${EMULATION_NAME}_find_potential_libraries, - NULL /* new_vers_pattern. */ + NULL, /* new_vers_pattern. */ + NULL /* extra_map_file_text. */ }; EOF diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index d1575e2..1f78655 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -2213,6 +2213,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = gld_${EMULATION_NAME}_list_options, gld_${EMULATION_NAME}_recognized_file, gld_${EMULATION_NAME}_find_potential_libraries, - NULL /* new_vers_pattern. */ + NULL, /* new_vers_pattern. */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/rxelf.em b/ld/emultempl/rxelf.em index 5998790..b0e4ead 100644 --- a/ld/emultempl/rxelf.em +++ b/ld/emultempl/rxelf.em @@ -25,6 +25,8 @@ test -z "$TARGET2_TYPE" && TARGET2_TYPE="rel" fragment <<EOF +extern void rx_additional_link_map_text (bfd *obfd, struct bfd_link_info *info, FILE *mapfile); + static bfd_boolean no_flag_mismatch_warnings = TRUE; static bfd_boolean ignore_lma = TRUE; @@ -86,3 +88,5 @@ PARSE_AND_LIST_ARGS_CASES=' ' LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=rx_elf_create_output_section_statements + +LDEMUL_EXTRA_MAP_FILE_TEXT=rx_additional_link_map_text diff --git a/ld/emultempl/sunos.em b/ld/emultempl/sunos.em index b527bba..e57e1f0 100644 --- a/ld/emultempl/sunos.em +++ b/ld/emultempl/sunos.em @@ -1033,6 +1033,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/ticoff.em b/ld/emultempl/ticoff.em index a94f937..c403d56 100644 --- a/ld/emultempl/ticoff.em +++ b/ld/emultempl/ticoff.em @@ -180,6 +180,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = gld_${EMULATION_NAME}_list_options, NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/vanilla.em b/ld/emultempl/vanilla.em index f53a4e3..f8ade99 100644 --- a/ld/emultempl/vanilla.em +++ b/ld/emultempl/vanilla.em @@ -81,6 +81,7 @@ struct ld_emulation_xfer_struct ld_vanilla_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/ldemul.c b/ld/ldemul.c index edbc9ee..6809ff9 100644 --- a/ld/ldemul.c +++ b/ld/ldemul.c @@ -348,3 +348,15 @@ ldemul_new_vers_pattern (struct bfd_elf_version_expr *entry) entry = (*ld_emulation->new_vers_pattern) (entry); return entry; } + +void +ldemul_extra_map_file_text(bfd *abfd, struct bfd_link_info *info, FILE *mapf) +{ + if (ld_emulation->extra_map_file_text) + { + fprintf(stderr, "CALLING IT!\n"); + ld_emulation->extra_map_file_text (abfd, info, mapf); + } + else + fprintf(stderr, "SKIP!\n"); +} diff --git a/ld/ldemul.h b/ld/ldemul.h index a9ea2f6..27b13ad 100644 --- a/ld/ldemul.h +++ b/ld/ldemul.h @@ -94,6 +94,8 @@ extern int ldemul_find_potential_libraries (char *, struct lang_input_statement_struct *); extern struct bfd_elf_version_expr *ldemul_new_vers_pattern (struct bfd_elf_version_expr *); +extern void ldemul_extra_map_file_text + (bfd *, struct bfd_link_info *, FILE *); typedef struct ld_emulation_xfer_struct { /* Run before parsing the command line and script file. @@ -194,6 +196,11 @@ typedef struct ld_emulation_xfer_struct { struct bfd_elf_version_expr * (*new_vers_pattern) (struct bfd_elf_version_expr *); + /* Called when printing the map file, in case there are + emulation-specific sections for it. */ + void (*extra_map_file_text) + (bfd *, struct bfd_link_info *, FILE *); + } ld_emulation_xfer_type; typedef enum { diff --git a/ld/ldlang.c b/ld/ldlang.c index 3861846..596aecc 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -2124,7 +2124,7 @@ lang_map (void) lang_statement_iteration++; print_statements (); - bfd_additional_link_map_text (link_info.output_bfd, &link_info, config.map_file); + ldemul_extra_map_file_text (link_info.output_bfd, &link_info, config.map_file); } static bfd_boolean ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-04-22 20:55 ` DJ Delorie @ 2014-05-06 15:15 ` DJ Delorie 2014-05-07 3:02 ` Alan Modra 0 siblings, 1 reply; 19+ messages in thread From: DJ Delorie @ 2014-05-06 15:15 UTC (permalink / raw) To: gingold, binutils > > Why not adding a new field in ld_emulation_xfer_struct ? Looks lighter. > > Attached, mostly. Git is giving me a diff relative to the previous patch. Ping? https://sourceware.org/ml/binutils/2014-04/msg00223.html ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-05-06 15:15 ` DJ Delorie @ 2014-05-07 3:02 ` Alan Modra 2014-05-07 3:13 ` DJ Delorie 2014-05-10 2:33 ` DJ Delorie 0 siblings, 2 replies; 19+ messages in thread From: Alan Modra @ 2014-05-07 3:02 UTC (permalink / raw) To: DJ Delorie; +Cc: gingold, binutils On Tue, May 06, 2014 at 11:15:49AM -0400, DJ Delorie wrote: > > > > Why not adding a new field in ld_emulation_xfer_struct ? Looks lighter. > > > > Attached, mostly. Git is giving me a diff relative to the previous patch. I think the idea is good. I'm assuming the previous patch won't be going in, nor the debug printfs. :) The place to declare rx_additional_link_map_text is in a new bfd/elf32-rx.h file, included by both ld/emultempl/rxelf.em and bfd/elf32-rx.c, assuming the latter is where you'll define the function. -- Alan Modra Australia Development Lab, IBM ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-05-07 3:02 ` Alan Modra @ 2014-05-07 3:13 ` DJ Delorie 2014-05-10 2:33 ` DJ Delorie 1 sibling, 0 replies; 19+ messages in thread From: DJ Delorie @ 2014-05-07 3:13 UTC (permalink / raw) To: Alan Modra; +Cc: gingold, binutils > I think the idea is good. I'm assuming the previous patch won't be > going in, nor the debug printfs. :) The place to declare Nope :-) > rx_additional_link_map_text is in a new bfd/elf32-rx.h file, included > by both ld/emultempl/rxelf.em and bfd/elf32-rx.c, assuming the latter > is where you'll define the function. Makes sense. I don't see any clear rule about what goes in include/*.h vs bfd/*.h though - and there are some files in include/ which #include headers in bfd/ too :-P ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-05-07 3:02 ` Alan Modra 2014-05-07 3:13 ` DJ Delorie @ 2014-05-10 2:33 ` DJ Delorie 2014-05-27 15:53 ` DJ Delorie ` (2 more replies) 1 sibling, 3 replies; 19+ messages in thread From: DJ Delorie @ 2014-05-10 2:33 UTC (permalink / raw) To: Alan Modra; +Cc: gingold, binutils Here's the current patch, without the debugs, with elf32-rx.h, and without the old bfd hook. In case you're wondering, the purpose for all this is to have better support for auto-generated interrupt vector tables. The compiler sets up all the hooks, the bfd pass stitches the tables together, and this new linker map hook dumps the generated table info to the map file. * bfd/elf32-rx.c (get_symbol_value_maybe): New. (rx_elf_relocate_section): If we find a reloc against $tableentry$default$<name>, redirect it to the appropriate $tableentry$<n>$. (RX_Table_Info): New. (rx_table_find): New. Check all tables and SEC_KEEP all sections with table parts in them. (rx_check_directives): New. (rx_table_map_2): New. (rx_table_map): New. (rx_additional_link_map_text): New. Called to dump tables to the map file. * bfd/elf32-rx.h: New. * ld/ldemul.h (extra_map_file_text): New field. (ldemul_extra_map_file_text): Declare. * ld/ldemul.c (ldemul_extra_map_file_text): Define. * ld/ldlang.c (lang_map): Call it. * ld/emultempl/rxelf.em: Add extra_map_file_text hook. * ld/emultempl/aix.em: Add NULL extra_map_file_text hook. * ld/emultempl/armcoff.em: Likewise. * ld/emultempl/beos.em: Likewise. * ld/emultempl/elf32.em: Likewise. * ld/emultempl/generic.em: Likewise. * ld/emultempl/gld960.em: Likewise. * ld/emultempl/gld960c.em: Likewise. * ld/emultempl/linux.em: Likewise. * ld/emultempl/lnk960.em: Likewise. * ld/emultempl/m68kcoff.em: Likewise. * ld/emultempl/pe.em: Likewise. * ld/emultempl/pep.em: Likewise. * ld/emultempl/sunos.em: Likewise. * ld/emultempl/ticoff.em: Likewise. * ld/emultempl/vanilla.em: Likewise. diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c index 2045cb7..e1856a9 100644 --- a/bfd/elf32-rx.c +++ b/bfd/elf32-rx.c @@ -24,6 +24,7 @@ #include "elf-bfd.h" #include "elf/rx.h" #include "libiberty.h" +#include "elf32-rx.h" #define RX_OPCODE_BIG_ENDIAN 0 @@ -335,6 +336,26 @@ get_symbol_value (const char * name, return value; } +static bfd_vma +get_symbol_value_maybe (const char * name, + struct bfd_link_info * info) +{ + bfd_vma value = 0; + struct bfd_link_hash_entry * h; + + h = bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, TRUE); + + if (h == NULL + || (h->type != bfd_link_hash_defined + && h->type != bfd_link_hash_defweak)) + return 0; + else + value = (h->u.def.value + + h->u.def.section->output_section->vma + + h->u.def.section->output_offset); + + return value; +} static bfd_vma get_gp (bfd_reloc_status_type * status, @@ -464,6 +485,9 @@ rx_elf_relocate_section Elf_Internal_Rela * relend; bfd_boolean pid_mode; bfd_boolean saw_subtract = FALSE; + const char * table_default_cache = NULL; + bfd_vma table_start_cache = 0; + bfd_vma table_end_cache = 0; if (elf_elfheader (output_bfd)->e_flags & E_FLAG_RX_PID) pid_mode = TRUE; @@ -520,6 +544,86 @@ rx_elf_relocate_section name = h->root.root.string; } + if (strncmp (name, "$tableentry$default$", 20) == 0) + { + bfd_vma entry_vma; + int idx; + char *buf; + bfd_reloc_status_type tstat = 0; + + if (table_default_cache != name) + { + + /* All relocs for a given table should be to the same + (weak) default symbol) so we can use it to detect a + cache miss. We use the offset into the table to find + the "real" symbol. Calculate and store the table's + offset here. */ + + table_default_cache = name; + + /* We have already done error checking in rx_table_find(). */ + + buf = (char *) malloc (13 + strlen (name + 20)); + + sprintf (buf, "$tablestart$%s", name + 20); + tstat = 0; + table_start_cache = get_symbol_value (buf, + &tstat, + info, + input_bfd, + input_section, + rel->r_offset); + + sprintf (buf, "$tableend$%s", name + 20); + tstat = 0; + table_end_cache = get_symbol_value (buf, + &tstat, + info, + input_bfd, + input_section, + rel->r_offset); + + free (buf); + } + + entry_vma = (input_section->output_section->vma + + input_section->output_offset + + rel->r_offset); + + if (table_end_cache <= entry_vma || entry_vma < table_start_cache) + { + _bfd_error_handler (_("%B:%A: table entry %s outside table"), + input_bfd, input_section, + name); + } + else if ((int) (entry_vma - table_start_cache) % 4) + { + _bfd_error_handler (_("%B:%A: table entry %s not word-aligned within table"), + input_bfd, input_section, + name); + } + else + { + idx = (int) (entry_vma - table_start_cache) / 4; + + /* This will look like $tableentry$<N>$<name> */ + buf = (char *) malloc (12 + 20 + strlen (name + 20)); + sprintf (buf, "$tableentry$%d$%s", idx, name + 20); + + h = (struct elf_link_hash_entry *) bfd_link_hash_lookup (info->hash, buf, FALSE, FALSE, TRUE); + + if (h) + { + relocation = (h->root.u.def.value + + h->root.u.def.section->output_section->vma + + h->root.u.def.section->output_offset);; + } + + free (buf); + } + } + if (sec != NULL && discarded_section (sec)) RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, rel, 1, relend, howto, 0, contents); @@ -3544,6 +3648,298 @@ static const struct bfd_elf_special_section elf32_rx_special_sections[] = { NULL, 0, 0, 0, 0 } }; \f +typedef struct { + bfd *abfd; + struct bfd_link_info *info; + bfd_vma table_start; + int table_size; + bfd_vma *table_handlers; + bfd_vma table_default_handler; + struct bfd_link_hash_entry **table_entries; + struct bfd_link_hash_entry *table_default_entry; + FILE *mapfile; +} RX_Table_Info; + +static bfd_boolean +rx_table_find (struct bfd_hash_entry *vent, void *vinfo) +{ + RX_Table_Info *info = (RX_Table_Info *)vinfo; + struct bfd_link_hash_entry *ent = (struct bfd_link_hash_entry *)vent; + const char *name; /* of the symbol we've found */ + asection *sec; + struct bfd *abfd; + int idx; + const char *tname; /* name of the table */ + bfd_vma start_addr, end_addr; + char *buf; + struct bfd_link_hash_entry * h; + + /* We're looking for globally defined symbols of the form + $tablestart$<NAME>. */ + if (ent->type != bfd_link_hash_defined + && ent->type != bfd_link_hash_defweak) + return TRUE; + + name = ent->root.string; + sec = ent->u.def.section; + abfd = sec->owner; + + if (strncmp (name, "$tablestart$", 12)) + return TRUE; + + sec->flags |= SEC_KEEP; + + tname = name + 12; + + start_addr = ent->u.def.value; + + /* At this point, we can't build the table but we can (and must) + find all the related symbols and mark their sections as SEC_KEEP + so we don't garbage collect them. */ + + buf = (char *) malloc (12 + 10 + strlen (tname)); + + sprintf (buf, "$tableend$%s", tname); + h = bfd_link_hash_lookup (info->info->hash, buf, FALSE, FALSE, TRUE); + if (!h || (h->type != bfd_link_hash_defined + && h->type != bfd_link_hash_defweak)) + { + _bfd_error_handler (_("%B:%A: table %s missing corresponding %s"), + abfd, sec, name, buf); + return TRUE; + } + + if (h->u.def.section != ent->u.def.section) + { + _bfd_error_handler (_("%B:%A: %s and %s must be in the same input section"), + h->u.def.section->owner, h->u.def.section, + name, buf); + return TRUE; + } + + end_addr = h->u.def.value; + + sprintf (buf, "$tableentry$default$%s", tname); + h = bfd_link_hash_lookup (info->info->hash, buf, FALSE, FALSE, TRUE); + if (h && (h->type == bfd_link_hash_defined + || h->type == bfd_link_hash_defweak)) + { + h->u.def.section->flags |= SEC_KEEP; + } + + for (idx = 0; idx < (int) (end_addr - start_addr) / 4; idx ++) + { + sprintf (buf, "$tableentry$%d$%s", idx, tname); + h = bfd_link_hash_lookup (info->info->hash, buf, FALSE, FALSE, TRUE); + if (h && (h->type == bfd_link_hash_defined + || h->type == bfd_link_hash_defweak)) + { + h->u.def.section->flags |= SEC_KEEP; + } + } + + /* Return TRUE to keep scanning, FALSE to end the traversal. */ + return TRUE; +} + +/* We need to check for table entry symbols and build the tables, and + we need to do it before the linker does garbage collection. This function is + called once per input object file. */ +static bfd_boolean +rx_check_directives + (bfd * abfd ATTRIBUTE_UNUSED, + struct bfd_link_info * info ATTRIBUTE_UNUSED) +{ + RX_Table_Info stuff; + + stuff.abfd = abfd; + stuff.info = info; + bfd_hash_traverse (&(info->hash->table), rx_table_find, &stuff); + + return TRUE; +} + +\f +static bfd_boolean +rx_table_map_2 (struct bfd_hash_entry *vent, void *vinfo) +{ + RX_Table_Info *info = (RX_Table_Info *)vinfo; + struct bfd_link_hash_entry *ent = (struct bfd_link_hash_entry *)vent; + int idx; + const char *name; + bfd_vma addr; + + /* See if the symbol ENT has an address listed in the table, and + isn't a debug/special symbol. If so, put it in the table. */ + + if (ent->type != bfd_link_hash_defined + && ent->type != bfd_link_hash_defweak) + return TRUE; + + name = ent->root.string; + + if (name[0] == '$' || name[0] == '.' || name[0] < ' ') + return TRUE; + + addr = (ent->u.def.value + + ent->u.def.section->output_section->vma + + ent->u.def.section->output_offset); + + for (idx = 0; idx < info->table_size; idx ++) + if (addr == info->table_handlers[idx]) + info->table_entries[idx] = ent; + + if (addr == info->table_default_handler) + info->table_default_entry = ent; + + return TRUE; +} + +static bfd_boolean +rx_table_map (struct bfd_hash_entry *vent, void *vinfo) +{ + RX_Table_Info *info = (RX_Table_Info *)vinfo; + struct bfd_link_hash_entry *ent = (struct bfd_link_hash_entry *)vent; + const char *name; /* of the symbol we've found */ + asection *sec; + struct bfd *abfd; + int idx; + const char *tname; /* name of the table */ + bfd_vma start_addr, end_addr; + char *buf; + struct bfd_link_hash_entry * h; + int need_elipses; + + /* We're looking for globally defined symbols of the form + $tablestart$<NAME>. */ + if (ent->type != bfd_link_hash_defined + && ent->type != bfd_link_hash_defweak) + return TRUE; + + name = ent->root.string; + sec = ent->u.def.section; + abfd = sec->owner; + + if (strncmp (name, "$tablestart$", 12)) + return TRUE; + + tname = name + 12; + start_addr = (ent->u.def.value + + ent->u.def.section->output_section->vma + + ent->u.def.section->output_offset); + + buf = (char *) malloc (12 + 10 + strlen (tname)); + + sprintf (buf, "$tableend$%s", tname); + end_addr = get_symbol_value_maybe (buf, info->info); + + sprintf (buf, "$tableentry$default$%s", tname); + h = bfd_link_hash_lookup (info->info->hash, buf, FALSE, FALSE, TRUE); + if (h) + { + info->table_default_handler = (h->u.def.value + + h->u.def.section->output_section->vma + + h->u.def.section->output_offset); + } + else + /* Zero is a valid handler address! */ + info->table_default_handler = (bfd_vma) (-1); + info->table_default_entry = NULL; + + info->table_start = start_addr; + info->table_size = (int) (end_addr - start_addr) / 4; + info->table_handlers = (bfd_vma *) malloc (info->table_size * sizeof (bfd_vma)); + info->table_entries = (struct bfd_link_hash_entry **) malloc (info->table_size * sizeof (struct bfd_link_hash_entry)); + + for (idx = 0; idx < (int) (end_addr - start_addr) / 4; idx ++) + { + sprintf (buf, "$tableentry$%d$%s", idx, tname); + h = bfd_link_hash_lookup (info->info->hash, buf, FALSE, FALSE, TRUE); + if (h && (h->type == bfd_link_hash_defined + || h->type == bfd_link_hash_defweak)) + { + info->table_handlers[idx] = (h->u.def.value + + h->u.def.section->output_section->vma + + h->u.def.section->output_offset); + } + else + info->table_handlers[idx] = info->table_default_handler; + info->table_entries[idx] = NULL; + } + + free (buf); + + bfd_hash_traverse (&(info->info->hash->table), rx_table_map_2, info); + + fprintf (info->mapfile, "\nRX Vector Table: %s has %d entries at 0x%08lx\n\n", + tname, info->table_size, start_addr); + + if (info->table_default_entry) + fprintf (info->mapfile, " default handler is: %s at 0x%08lx\n", + info->table_default_entry->root.string, + info->table_default_handler); + else if (info->table_default_handler != (bfd_vma)(-1)) + fprintf (info->mapfile, " default handler is at 0x%08lx\n", + info->table_default_handler); + else + fprintf (info->mapfile, " no default handler\n"); + + need_elipses = 1; + for (idx = 0; idx < info->table_size; idx ++) + { + if (info->table_handlers[idx] == info->table_default_handler) + { + if (need_elipses) + fprintf (info->mapfile, " . . .\n"); + need_elipses = 0; + continue; + } + need_elipses = 1; + + fprintf (info->mapfile, " 0x%08lx [%3d] ", start_addr + 4 * idx, idx); + + if (info->table_handlers[idx] == (bfd_vma) (-1)) + fprintf (info->mapfile, "(no handler found)\n"); + + else if (info->table_handlers[idx] == info->table_default_handler) + { + if (info->table_default_entry) + fprintf (info->mapfile, "(default)\n"); + else + fprintf (info->mapfile, "(default)\n"); + } + + else if (info->table_entries[idx]) + { + fprintf (info->mapfile, "0x%08lx %s\n", info->table_handlers[idx], info->table_entries[idx]->root.string); + } + + else + { + fprintf (info->mapfile, "0x%08lx ???\n", info->table_handlers[idx]); + } + } + if (need_elipses) + fprintf (info->mapfile, " . . .\n"); + + return TRUE; +} + +void +rx_additional_link_map_text (bfd *obfd, struct bfd_link_info *info, FILE *mapfile) +{ + /* We scan the symbol table looking for $tableentry$'s, and for + each, try to deduce which handlers go with which entries. */ + + RX_Table_Info stuff; + + stuff.abfd = obfd; + stuff.info = info; + stuff.mapfile = mapfile; + bfd_hash_traverse (&(info->hash->table), rx_table_map, &stuff); +} + +\f #define ELF_ARCH bfd_arch_rx #define ELF_MACHINE_CODE EM_RX #define ELF_MAXPAGESIZE 0x1000 @@ -3572,6 +3968,7 @@ static const struct bfd_elf_special_section elf32_rx_special_sections[] = #define bfd_elf32_bfd_final_link rx_final_link #define bfd_elf32_bfd_relax_section elf32_rx_relax_section_wrapper #define elf_backend_special_sections elf32_rx_special_sections +#define elf_backend_check_directives rx_check_directives #include "elf32-target.h" diff --git a/bfd/elf32-rx.h b/bfd/elf32-rx.h new file mode 100644 index 0000000..3779388 --- /dev/null +++ b/bfd/elf32-rx.h @@ -0,0 +1,21 @@ +/* Renesas RX specific support for 32-bit ELF. + Copyright (C) 2014 Free Software Foundation, Inc. + + This file is part of BFD, the Binary File Descriptor library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + + +void rx_additional_link_map_text (bfd *obfd, struct bfd_link_info *info, FILE *mapfile); diff --git a/ld/emultempl/aix.em b/ld/emultempl/aix.em index caa74a9..56985cf 100644 --- a/ld/emultempl/aix.em +++ b/ld/emultempl/aix.em @@ -1553,6 +1553,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = { NULL, /* list_options */ NULL, /* recognized_file */ NULL, /* find potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/armcoff.em b/ld/emultempl/armcoff.em index 8e9befc..de10a6c 100644 --- a/ld/emultempl/armcoff.em +++ b/ld/emultempl/armcoff.em @@ -279,6 +279,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = gld${EMULATION_NAME}_list_options, NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/beos.em b/ld/emultempl/beos.em index 2196510..732abfd 100644 --- a/ld/emultempl/beos.em +++ b/ld/emultempl/beos.em @@ -777,6 +777,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 31761ca..3ebf3b5 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -2498,6 +2498,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = ${LDEMUL_LIST_OPTIONS-gld${EMULATION_NAME}_list_options}, ${LDEMUL_RECOGNIZED_FILE-gld${EMULATION_NAME}_load_symbols}, ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL}, - ${LDEMUL_NEW_VERS_PATTERN-NULL} + ${LDEMUL_NEW_VERS_PATTERN-NULL}, + ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL} }; EOF diff --git a/ld/emultempl/generic.em b/ld/emultempl/generic.em index b22e2a6..aac4b93 100644 --- a/ld/emultempl/generic.em +++ b/ld/emultempl/generic.em @@ -156,5 +156,6 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = ${LDEMUL_RECOGNIZED_FILE-NULL}, ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL}, ${LDEMUL_NEW_VERS_PATTERN-NULL} + ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL} }; EOF diff --git a/ld/emultempl/gld960.em b/ld/emultempl/gld960.em index 0df99e3..5632f31 100644 --- a/ld/emultempl/gld960.em +++ b/ld/emultempl/gld960.em @@ -148,6 +148,7 @@ struct ld_emulation_xfer_struct ld_gld960_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/gld960c.em b/ld/emultempl/gld960c.em index 805e69b..dd69c79 100644 --- a/ld/emultempl/gld960c.em +++ b/ld/emultempl/gld960c.em @@ -161,6 +161,7 @@ struct ld_emulation_xfer_struct ld_gld960coff_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/linux.em b/ld/emultempl/linux.em index b30e872..bbc5946 100644 --- a/ld/emultempl/linux.em +++ b/ld/emultempl/linux.em @@ -205,6 +205,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/lnk960.em b/ld/emultempl/lnk960.em index 9c6ff38..6364f6d 100644 --- a/ld/emultempl/lnk960.em +++ b/ld/emultempl/lnk960.em @@ -342,6 +342,7 @@ struct ld_emulation_xfer_struct ld_lnk960_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/m68kcoff.em b/ld/emultempl/m68kcoff.em index 1ea900a..e46889a 100644 --- a/ld/emultempl/m68kcoff.em +++ b/ld/emultempl/m68kcoff.em @@ -239,6 +239,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index ba51cc0..3a37508 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -2449,6 +2449,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = gld_${EMULATION_NAME}_list_options, gld_${EMULATION_NAME}_recognized_file, gld_${EMULATION_NAME}_find_potential_libraries, - NULL /* new_vers_pattern. */ + NULL, /* new_vers_pattern. */ + NULL /* extra_map_file_text. */ }; EOF diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index d1575e2..1f78655 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -2213,6 +2213,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = gld_${EMULATION_NAME}_list_options, gld_${EMULATION_NAME}_recognized_file, gld_${EMULATION_NAME}_find_potential_libraries, - NULL /* new_vers_pattern. */ + NULL, /* new_vers_pattern. */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/rxelf.em b/ld/emultempl/rxelf.em index 5998790..6386abd 100644 --- a/ld/emultempl/rxelf.em +++ b/ld/emultempl/rxelf.em @@ -25,6 +25,8 @@ test -z "$TARGET2_TYPE" && TARGET2_TYPE="rel" fragment <<EOF +#include "elf32-rx.h" + static bfd_boolean no_flag_mismatch_warnings = TRUE; static bfd_boolean ignore_lma = TRUE; @@ -86,3 +88,5 @@ PARSE_AND_LIST_ARGS_CASES=' ' LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=rx_elf_create_output_section_statements + +LDEMUL_EXTRA_MAP_FILE_TEXT=rx_additional_link_map_text diff --git a/ld/emultempl/sunos.em b/ld/emultempl/sunos.em index b527bba..e57e1f0 100644 --- a/ld/emultempl/sunos.em +++ b/ld/emultempl/sunos.em @@ -1033,6 +1033,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/ticoff.em b/ld/emultempl/ticoff.em index a94f937..c403d56 100644 --- a/ld/emultempl/ticoff.em +++ b/ld/emultempl/ticoff.em @@ -180,6 +180,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = gld_${EMULATION_NAME}_list_options, NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/emultempl/vanilla.em b/ld/emultempl/vanilla.em index f53a4e3..f8ade99 100644 --- a/ld/emultempl/vanilla.em +++ b/ld/emultempl/vanilla.em @@ -81,6 +81,7 @@ struct ld_emulation_xfer_struct ld_vanilla_emulation = NULL, /* list options */ NULL, /* recognized file */ NULL, /* find_potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF diff --git a/ld/ldemul.c b/ld/ldemul.c index edbc9ee..7409046 100644 --- a/ld/ldemul.c +++ b/ld/ldemul.c @@ -348,3 +348,10 @@ ldemul_new_vers_pattern (struct bfd_elf_version_expr *entry) entry = (*ld_emulation->new_vers_pattern) (entry); return entry; } + +void +ldemul_extra_map_file_text (bfd *abfd, struct bfd_link_info *info, FILE *mapf) +{ + if (ld_emulation->extra_map_file_text) + ld_emulation->extra_map_file_text (abfd, info, mapf); +} diff --git a/ld/ldemul.h b/ld/ldemul.h index a9ea2f6..27b13ad 100644 --- a/ld/ldemul.h +++ b/ld/ldemul.h @@ -94,6 +94,8 @@ extern int ldemul_find_potential_libraries (char *, struct lang_input_statement_struct *); extern struct bfd_elf_version_expr *ldemul_new_vers_pattern (struct bfd_elf_version_expr *); +extern void ldemul_extra_map_file_text + (bfd *, struct bfd_link_info *, FILE *); typedef struct ld_emulation_xfer_struct { /* Run before parsing the command line and script file. @@ -194,6 +196,11 @@ typedef struct ld_emulation_xfer_struct { struct bfd_elf_version_expr * (*new_vers_pattern) (struct bfd_elf_version_expr *); + /* Called when printing the map file, in case there are + emulation-specific sections for it. */ + void (*extra_map_file_text) + (bfd *, struct bfd_link_info *, FILE *); + } ld_emulation_xfer_type; typedef enum { diff --git a/ld/ldlang.c b/ld/ldlang.c index d147ee0..596aecc 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -2123,6 +2123,8 @@ lang_map (void) } lang_statement_iteration++; print_statements (); + + ldemul_extra_map_file_text (link_info.output_bfd, &link_info, config.map_file); } static bfd_boolean ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-05-10 2:33 ` DJ Delorie @ 2014-05-27 15:53 ` DJ Delorie 2014-05-27 16:20 ` Nicholas Clifton 2014-05-27 22:04 ` Breakage with "[rfc] new bfd hook: additional link map text" Hans-Peter Nilsson 2014-06-03 15:43 ` [rfc] new bfd hook: additional link map text Maciej W. Rozycki 2 siblings, 1 reply; 19+ messages in thread From: DJ Delorie @ 2014-05-27 15:53 UTC (permalink / raw) To: amodra, gingold, binutils > Here's the current patch, without the debugs, with elf32-rx.h, and > without the old bfd hook. Ping? https://sourceware.org/ml/binutils/2014-05/msg00093.html ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-05-27 15:53 ` DJ Delorie @ 2014-05-27 16:20 ` Nicholas Clifton 2014-05-27 21:16 ` DJ Delorie 0 siblings, 1 reply; 19+ messages in thread From: Nicholas Clifton @ 2014-05-27 16:20 UTC (permalink / raw) To: DJ Delorie, amodra, gingold, binutils Hi DJ, >> Here's the current patch, without the debugs, with elf32-rx.h, and >> without the old bfd hook. > > Ping? > > https://sourceware.org/ml/binutils/2014-05/msg00093.html Well nobody else has said anything, so I will go ahead and approve this patch. DJ - please apply. Cheers Nick ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-05-27 16:20 ` Nicholas Clifton @ 2014-05-27 21:16 ` DJ Delorie 2014-05-28 13:13 ` Alan Modra 0 siblings, 1 reply; 19+ messages in thread From: DJ Delorie @ 2014-05-27 21:16 UTC (permalink / raw) To: Nicholas Clifton; +Cc: amodra, gingold, binutils > Well nobody else has said anything, so I will go ahead and approve this > patch. DJ - please apply. Thanks! Pushed. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-05-27 21:16 ` DJ Delorie @ 2014-05-28 13:13 ` Alan Modra 0 siblings, 0 replies; 19+ messages in thread From: Alan Modra @ 2014-05-28 13:13 UTC (permalink / raw) To: DJ Delorie; +Cc: Nicholas Clifton, gingold, binutils Applied. * elf32-rx.c (rx_table_map): Delete set but not used variables. diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c index e1856a9..469ba48 100644 --- a/bfd/elf32-rx.c +++ b/bfd/elf32-rx.c @@ -3801,8 +3801,6 @@ rx_table_map (struct bfd_hash_entry *vent, void *vinfo) RX_Table_Info *info = (RX_Table_Info *)vinfo; struct bfd_link_hash_entry *ent = (struct bfd_link_hash_entry *)vent; const char *name; /* of the symbol we've found */ - asection *sec; - struct bfd *abfd; int idx; const char *tname; /* name of the table */ bfd_vma start_addr, end_addr; @@ -3817,8 +3815,6 @@ rx_table_map (struct bfd_hash_entry *vent, void *vinfo) return TRUE; name = ent->root.string; - sec = ent->u.def.section; - abfd = sec->owner; if (strncmp (name, "$tablestart$", 12)) return TRUE; -- Alan Modra Australia Development Lab, IBM ^ permalink raw reply [flat|nested] 19+ messages in thread
* Breakage with "[rfc] new bfd hook: additional link map text" 2014-05-10 2:33 ` DJ Delorie 2014-05-27 15:53 ` DJ Delorie @ 2014-05-27 22:04 ` Hans-Peter Nilsson 2014-05-27 23:06 ` DJ Delorie 2014-06-03 15:43 ` [rfc] new bfd hook: additional link map text Maciej W. Rozycki 2 siblings, 1 reply; 19+ messages in thread From: Hans-Peter Nilsson @ 2014-05-27 22:04 UTC (permalink / raw) To: dj; +Cc: binutils > From: DJ Delorie <dj@redhat.com> > Date: Sat, 10 May 2014 04:33:12 +0200 > * bfd/elf32-rx.c (get_symbol_value_maybe): New. > (rx_elf_relocate_section): If we find a reloc against > $tableentry$default$<name>, redirect it to the appropriate > $tableentry$<n>$. > (RX_Table_Info): New. > (rx_table_find): New. Check all tables and SEC_KEEP all sections > with table parts in them. > (rx_check_directives): New. > (rx_table_map_2): New. > (rx_table_map): New. > (rx_additional_link_map_text): New. Called to dump tables to the > map file. > * bfd/elf32-rx.h: New. > > * ld/ldemul.h (extra_map_file_text): New field. > (ldemul_extra_map_file_text): Declare. > * ld/ldemul.c (ldemul_extra_map_file_text): Define. > * ld/ldlang.c (lang_map): Call it. > > * ld/emultempl/rxelf.em: Add extra_map_file_text hook. > * ld/emultempl/aix.em: Add NULL extra_map_file_text hook. > * ld/emultempl/armcoff.em: Likewise. > * ld/emultempl/beos.em: Likewise. > * ld/emultempl/elf32.em: Likewise. > * ld/emultempl/generic.em: Likewise. > * ld/emultempl/gld960.em: Likewise. > * ld/emultempl/gld960c.em: Likewise. > * ld/emultempl/linux.em: Likewise. > * ld/emultempl/lnk960.em: Likewise. > * ld/emultempl/m68kcoff.em: Likewise. > * ld/emultempl/pe.em: Likewise. > * ld/emultempl/pep.em: Likewise. > * ld/emultempl/sunos.em: Likewise. > * ld/emultempl/ticoff.em: Likewise. > * ld/emultempl/vanilla.em: Likewise. This broke cris-elf (building the aout emulation) and mmix-knuth-mmixware, probably various other some-odd-emulation-included targets too as follows: ... LIB_PATH='' /bin/bash /tmp/hpautotest-binutils/bsrc/src/ld/genscripts.sh "/tmp/hpautotest-binutils/bsrc/src/ld" "/usr/local/lib" "/usr/local" "/usr/local" x86_64-unknown-linux-gnu cris-axis-elf cris-axis-elf "criself crisaout crislinux" "/usr/local/lib /lib /usr/lib" no no crisaout "" gcc -O2 -m32 -DHAVE_CONFIG_H -I. -I/tmp/hpautotest-binutils/bsrc/src/ld -I. -I/tmp/hpautotest-binutils/bsrc/src/ld -I../bfd -I/tmp/hpautotest-binutils/bsrc/src/ld/../bfd -I/tmp/hpautotest-binutils/bsrc/src/ld/../include -g -O2 -DENABLE_PLUGINS -DLOCALEDIR="\"/usr/local/share/locale\"" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT ecrisaout.o -MD -MP -MF .deps/ecrisaout.Tpo -c -o ecrisaout.o ecrisaout.c ecrisaout.c:586:3: error: called object '0u' is not a function ecrisaout.c:587:1: error: missing initializer [-Werror=missing-field-initializers] ecrisaout.c:587:1: error: (near initialization for 'ld_crisaout_emulation.new_vers_pattern') [-Werror=missing-field-initializers] cc1: all warnings being treated as errors make[4]: *** [ecrisaout.o] Error 1 make[4]: Leaving directory `/tmp/hpautotest-binutils/cris-axis-elf/ld' ... cp /tmp/hpautotest-binutils/bsrc/src/ld/emultempl/astring.sed stringify.sed LIB_PATH='' /bin/bash /tmp/hpautotest-binutils/bsrc/src/ld/genscripts.sh "/tmp/hpautotest-binutils/bsrc/src/ld" "/usr/local/lib" "/usr/local" "/usr/local" x86_64-unknown-linux-gnu mmix-knuth-mmixware mmix-knuth-mmixware "mmo" "/usr/local/lib /lib /usr/lib" no no mmo "mmix-knuth-mmixware" gcc -O2 -m32 -DHAVE_CONFIG_H -I. -I/tmp/hpautotest-binutils/bsrc/src/ld -I. -I/tmp/hpautotest-binutils/bsrc/src/ld -I../bfd -I/tmp/hpautotest-binutils/bsrc/src/ld/../bfd -I/tmp/hpautotest-binutils/bsrc/src/ld/../include -g -O2 -DENABLE_PLUGINS -DLOCALEDIR="\"/usr/local/share/locale\"" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT emmo.o -MD -MP -MF .deps/emmo.Tpo -c -o emmo.o emmo.c emmo.c:1004:3: error: called object '0u' is not a function emmo.c:1005:1: error: missing initializer [-Werror=missing-field-initializers] emmo.c:1005:1: error: (near initialization for 'ld_mmo_emulation.new_vers_pattern') [-Werror=missing-field-initializers] cc1: all warnings being treated as errors make[4]: *** [emmo.o] Error 1 make[4]: Leaving directory `/tmp/hpautotest-binutils/mmix-knuth-mmixware/ld' brgds, H-P ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Breakage with "[rfc] new bfd hook: additional link map text" 2014-05-27 22:04 ` Breakage with "[rfc] new bfd hook: additional link map text" Hans-Peter Nilsson @ 2014-05-27 23:06 ` DJ Delorie 0 siblings, 0 replies; 19+ messages in thread From: DJ Delorie @ 2014-05-27 23:06 UTC (permalink / raw) To: Hans-Peter Nilsson; +Cc: binutils Stupid comma. Fixed. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-05-10 2:33 ` DJ Delorie 2014-05-27 15:53 ` DJ Delorie 2014-05-27 22:04 ` Breakage with "[rfc] new bfd hook: additional link map text" Hans-Peter Nilsson @ 2014-06-03 15:43 ` Maciej W. Rozycki 2014-06-03 15:58 ` DJ Delorie 2014-06-03 20:25 ` DJ Delorie 2 siblings, 2 replies; 19+ messages in thread From: Maciej W. Rozycki @ 2014-06-03 15:43 UTC (permalink / raw) To: DJ Delorie; +Cc: Alan Modra, Tristan Gingold, binutils On Sat, 10 May 2014, DJ Delorie wrote: > Here's the current patch, without the debugs, with elf32-rx.h, and > without the old bfd hook. > > In case you're wondering, the purpose for all this is to have better > support for auto-generated interrupt vector tables. The compiler sets > up all the hooks, the bfd pass stitches the tables together, and this > new linker map hook dumps the generated table info to the map file. > > * bfd/elf32-rx.c (get_symbol_value_maybe): New. > (rx_elf_relocate_section): If we find a reloc against > $tableentry$default$<name>, redirect it to the appropriate > $tableentry$<n>$. > (RX_Table_Info): New. > (rx_table_find): New. Check all tables and SEC_KEEP all sections > with table parts in them. > (rx_check_directives): New. > (rx_table_map_2): New. > (rx_table_map): New. > (rx_additional_link_map_text): New. Called to dump tables to the > map file. > * bfd/elf32-rx.h: New. This change doesn't build with the i686-linux-gnu host, mips-linux-gnu target, --enable-targets=all: cc1: warnings being treated as errors .../bfd/elf32-rx.c: In function 'rx_table_map': .../bfd/elf32-rx.c:3871: error: format '%08lx' expects type 'long unsigned int', but argument 5 has type 'bfd_vma' .../bfd/elf32-rx.c:3876: error: format '%08lx' expects type 'long unsigned int', but argument 4 has type 'bfd_vma' .../bfd/elf32-rx.c:3879: error: format '%08lx' expects type 'long unsigned int', but argument 3 has type 'bfd_vma' .../bfd/elf32-rx.c:3895: error: format '%08lx' expects type 'long unsigned int', but argument 3 has type 'bfd_vma' .../bfd/elf32-rx.c:3910: error: format '%08lx' expects type 'long unsigned int', but argument 3 has type 'bfd_vma' .../bfd/elf32-rx.c:3915: error: format '%08lx' expects type 'long unsigned int', but argument 3 has type 'bfd_vma' make[4]: *** [elf32-rx.lo] Error 1 Maciej ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-06-03 15:43 ` [rfc] new bfd hook: additional link map text Maciej W. Rozycki @ 2014-06-03 15:58 ` DJ Delorie 2014-06-03 16:20 ` Maciej W. Rozycki 2014-06-03 20:25 ` DJ Delorie 1 sibling, 1 reply; 19+ messages in thread From: DJ Delorie @ 2014-06-03 15:58 UTC (permalink / raw) To: Maciej W. Rozycki; +Cc: binutils There are platforms where bfd_vma *isn't* a long? Why? ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-06-03 15:58 ` DJ Delorie @ 2014-06-03 16:20 ` Maciej W. Rozycki 2014-06-03 16:25 ` DJ Delorie 0 siblings, 1 reply; 19+ messages in thread From: Maciej W. Rozycki @ 2014-06-03 16:20 UTC (permalink / raw) To: DJ Delorie; +Cc: binutils On Tue, 3 Jun 2014, DJ Delorie wrote: > There are platforms where bfd_vma *isn't* a long? Why? Because `long' is too short? You need to go `long long' if you have a BFD64 target and a 32-bit host. There's stuff like BFD_VMA_FMT, sprintf_vma, fprintf_vma, perhaps you could use it for portability? Maciej ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-06-03 16:20 ` Maciej W. Rozycki @ 2014-06-03 16:25 ` DJ Delorie 0 siblings, 0 replies; 19+ messages in thread From: DJ Delorie @ 2014-06-03 16:25 UTC (permalink / raw) To: Maciej W. Rozycki; +Cc: binutils Ah, ok. Will do. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-06-03 15:43 ` [rfc] new bfd hook: additional link map text Maciej W. Rozycki 2014-06-03 15:58 ` DJ Delorie @ 2014-06-03 20:25 ` DJ Delorie 2014-06-04 11:56 ` Maciej W. Rozycki 1 sibling, 1 reply; 19+ messages in thread From: DJ Delorie @ 2014-06-03 20:25 UTC (permalink / raw) To: Maciej W. Rozycki; +Cc: binutils I committed the obvious fix for this. Took me a while to reproduce it, as I missed the importance of the mips-linux-gnu target - an i686 host uses "long" for bfd_vma by default. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [rfc] new bfd hook: additional link map text 2014-06-03 20:25 ` DJ Delorie @ 2014-06-04 11:56 ` Maciej W. Rozycki 0 siblings, 0 replies; 19+ messages in thread From: Maciej W. Rozycki @ 2014-06-04 11:56 UTC (permalink / raw) To: DJ Delorie; +Cc: binutils On Tue, 3 Jun 2014, DJ Delorie wrote: > I committed the obvious fix for this. Took me a while to reproduce > it, as I missed the importance of the mips-linux-gnu target - an i686 > host uses "long" for bfd_vma by default. Thanks. I believe --enable-64-bit-bfd would do too, instead of picking mips-linux-gnu specifically as the target. Maciej ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2014-06-04 11:56 UTC | newest] Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-04-11 2:14 [rfc] new bfd hook: additional link map text DJ Delorie 2014-04-11 7:10 ` Tristan Gingold 2014-04-22 20:55 ` DJ Delorie 2014-05-06 15:15 ` DJ Delorie 2014-05-07 3:02 ` Alan Modra 2014-05-07 3:13 ` DJ Delorie 2014-05-10 2:33 ` DJ Delorie 2014-05-27 15:53 ` DJ Delorie 2014-05-27 16:20 ` Nicholas Clifton 2014-05-27 21:16 ` DJ Delorie 2014-05-28 13:13 ` Alan Modra 2014-05-27 22:04 ` Breakage with "[rfc] new bfd hook: additional link map text" Hans-Peter Nilsson 2014-05-27 23:06 ` DJ Delorie 2014-06-03 15:43 ` [rfc] new bfd hook: additional link map text Maciej W. Rozycki 2014-06-03 15:58 ` DJ Delorie 2014-06-03 16:20 ` Maciej W. Rozycki 2014-06-03 16:25 ` DJ Delorie 2014-06-03 20:25 ` DJ Delorie 2014-06-04 11:56 ` Maciej W. Rozycki
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).