From cb7f4b298e5e0a3ab4fb6b13aa89e970478597bc Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 9 Sep 2019 15:23:27 +0930 Subject: [PATCH] Tidy ld/ldmisc.c The idea here is to not use elf-bfd.h and coff-bfd.h in generic linker code. bfd/ * targets.c (struct bfd_target): Add _bfd_group_name. (BFD_JUMP_TABLE): Likewise. * coffgen.c (bfd_coff_group_name): New function. * elf.c (bfd_elf_group_name): New function. * linker.c (_bfd_nolink_bfd_group_name): New function. * section.c (bfd_generic_group_name): New function. * elf-bfd.h (bfd_elf_group_name): Declare. * libbfd-in.h (_bfd_nolink_bfd_group_name): Declare. * libcoff-in.h (bfd_coff_group_name): Declare. * aout-target.h (MY_bfd_group_name): Define. * aout-tic30.c (MY_bfd_group_name): Define. * bfd.c (bfd_group_name): Define. * binary.c (binary_bfd_group_name): Define. * coff-alpha.c (_bfd_ecoff_bfd_group_name): Define. * coff-mips.c (_bfd_ecoff_bfd_group_name): Define. * coff-rs6000.c (_bfd_xcoff_bfd_group_name): Define. * coffcode.h (coff_bfd_group_name): Define. * elfxx-target.h (bfd_elfNN_bfd_group_name): Define. * i386msdos.c (msdos_bfd_group_name): Define. * ihex.c (ihex_bfd_group_name): Define. * mach-o-target.c (bfd_mach_o_bfd_group_name): Define. * mmo.c (mmo_bfd_group_name): Define. * pef.c (bfd_pef_bfd_group_name): Define. * plugin.c (bfd_plugin_bfd_group_name): Define. * ppcboot.c (ppcboot_bfd_group_name): Define. * som.c (som_bfd_group_name): Define. * srec.c (srec_bfd_group_name): Define. * tekhex.c (tekhex_bfd_group_name): Define. * verilog.c (verilog_bfd_group_name): Define. * vms-alpha.c (vms_bfd_group_name, alpha_vms_bfd_group_name): Define. * xsym.c (bfd_sym_bfd_group_name): Define. * coff64-rs6000.c (rs6000_xcoff64_vec): Init new field. (rs6000_xcoff64_aix_vec): Likewise. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. * libcoff.h: Regenerate. ld/ * ldmisc.c: Don't #include elf-bfd.h or coff-bfd.h. (vfinfo): Use bfd_group_name. --- bfd/ChangeLog | 39 +++++++++++++++++++++++++++++++++++++++ bfd/aout-target.h | 3 +++ bfd/aout-tic30.c | 3 +++ bfd/bfd-in2.h | 9 +++++++++ bfd/bfd.c | 3 +++ bfd/binary.c | 1 + bfd/coff-alpha.c | 1 + bfd/coff-mips.c | 1 + bfd/coff-rs6000.c | 1 + bfd/coff64-rs6000.c | 2 ++ bfd/coffcode.h | 4 ++++ bfd/coffgen.c | 11 +++++++++++ bfd/elf-bfd.h | 2 ++ bfd/elf.c | 8 ++++++++ bfd/elfxx-target.h | 4 ++++ bfd/i386msdos.c | 1 + bfd/ihex.c | 1 + bfd/libbfd-in.h | 2 ++ bfd/libbfd.h | 2 ++ bfd/libcoff-in.h | 3 ++- bfd/libcoff.h | 3 ++- bfd/linker.c | 7 +++++++ bfd/mach-o-target.c | 1 + bfd/mmo.c | 1 + bfd/pef.c | 1 + bfd/plugin.c | 1 + bfd/ppcboot.c | 1 + bfd/section.c | 18 ++++++++++++++++++ bfd/som.c | 1 + bfd/srec.c | 1 + bfd/targets.c | 4 ++++ bfd/tekhex.c | 1 + bfd/verilog.c | 1 + bfd/vms-alpha.c | 2 ++ bfd/xsym.c | 1 + ld/ChangeLog | 5 +++++ ld/ldmisc.c | 24 +++++++----------------- 37 files changed, 155 insertions(+), 19 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8b6b843a6f5..f498a91b88f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,42 @@ +2019-09-11 Alan Modra + + * targets.c (struct bfd_target): Add _bfd_group_name. + (BFD_JUMP_TABLE): Likewise. + * coffgen.c (bfd_coff_group_name): New function. + * elf.c (bfd_elf_group_name): New function. + * linker.c (_bfd_nolink_bfd_group_name): New function. + * section.c (bfd_generic_group_name): New function. + * elf-bfd.h (bfd_elf_group_name): Declare. + * libbfd-in.h (_bfd_nolink_bfd_group_name): Declare. + * libcoff-in.h (bfd_coff_group_name): Declare. + * aout-target.h (MY_bfd_group_name): Define. + * aout-tic30.c (MY_bfd_group_name): Define. + * bfd.c (bfd_group_name): Define. + * binary.c (binary_bfd_group_name): Define. + * coff-alpha.c (_bfd_ecoff_bfd_group_name): Define. + * coff-mips.c (_bfd_ecoff_bfd_group_name): Define. + * coff-rs6000.c (_bfd_xcoff_bfd_group_name): Define. + * coffcode.h (coff_bfd_group_name): Define. + * elfxx-target.h (bfd_elfNN_bfd_group_name): Define. + * i386msdos.c (msdos_bfd_group_name): Define. + * ihex.c (ihex_bfd_group_name): Define. + * mach-o-target.c (bfd_mach_o_bfd_group_name): Define. + * mmo.c (mmo_bfd_group_name): Define. + * pef.c (bfd_pef_bfd_group_name): Define. + * plugin.c (bfd_plugin_bfd_group_name): Define. + * ppcboot.c (ppcboot_bfd_group_name): Define. + * som.c (som_bfd_group_name): Define. + * srec.c (srec_bfd_group_name): Define. + * tekhex.c (tekhex_bfd_group_name): Define. + * verilog.c (verilog_bfd_group_name): Define. + * vms-alpha.c (vms_bfd_group_name, alpha_vms_bfd_group_name): Define. + * xsym.c (bfd_sym_bfd_group_name): Define. + * coff64-rs6000.c (rs6000_xcoff64_vec): Init new field. + (rs6000_xcoff64_aix_vec): Likewise. + * bfd-in2.h: Regenerate. + * libbfd.h: Regenerate. + * libcoff.h: Regenerate. + 2019-09-10 Nick Clifton PR 24907 diff --git a/bfd/aout-target.h b/bfd/aout-target.h index 99a82bb57a2..58de28faba8 100644 --- a/bfd/aout-target.h +++ b/bfd/aout-target.h @@ -502,6 +502,9 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info) #ifndef MY_bfd_is_group_section #define MY_bfd_is_group_section bfd_generic_is_group_section #endif +#ifndef MY_bfd_group_name +#define MY_bfd_group_name bfd_generic_group_name +#endif #ifndef MY_bfd_discard_group #define MY_bfd_discard_group bfd_generic_discard_group #endif diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c index 49463181f09..7cc6ba5f6cd 100644 --- a/bfd/aout-tic30.c +++ b/bfd/aout-tic30.c @@ -991,6 +991,9 @@ tic30_aout_set_arch_mach (bfd *abfd, #ifndef MY_bfd_is_group_section #define MY_bfd_is_group_section bfd_generic_is_group_section #endif +#ifndef MY_bfd_group_name +#define MY_bfd_group_name bfd_generic_group_name +#endif #ifndef MY_bfd_discard_group #define MY_bfd_discard_group bfd_generic_discard_group #endif diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 690ba9a6fdb..dc9b5daf946 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -2002,6 +2002,8 @@ bfd_boolean bfd_copy_private_section_data (ibfd, isection, obfd, osection)) bfd_boolean bfd_generic_is_group_section (bfd *, const asection *sec); +const char *bfd_generic_group_name (bfd *, const asection *sec); + bfd_boolean bfd_generic_discard_group (bfd *abfd, asection *group); /* Extracted from archures.c. */ @@ -7477,6 +7479,9 @@ bfd_boolean bfd_set_private_flags (bfd *abfd, flagword flags); #define bfd_is_group_section(abfd, sec) \ BFD_SEND (abfd, _bfd_is_group_section, (abfd, sec)) +#define bfd_group_name(abfd, sec) \ + BFD_SEND (abfd, _bfd_group_name, (abfd, sec)) + #define bfd_discard_group(abfd, sec) \ BFD_SEND (abfd, _bfd_discard_group, (abfd, sec)) @@ -7908,6 +7913,7 @@ typedef struct bfd_target NAME##_bfd_lookup_section_flags, \ NAME##_bfd_merge_sections, \ NAME##_bfd_is_group_section, \ + NAME##_bfd_group_name, \ NAME##_bfd_discard_group, \ NAME##_section_already_linked, \ NAME##_bfd_define_common_symbol, \ @@ -7966,6 +7972,9 @@ typedef struct bfd_target /* Is this section a member of a group? */ bfd_boolean (*_bfd_is_group_section) (bfd *, const struct bfd_section *); + /* The group name, if section is a member of a group. */ + const char *(*_bfd_group_name) (bfd *, const struct bfd_section *); + /* Discard members of a group. */ bfd_boolean (*_bfd_discard_group) (bfd *, struct bfd_section *); diff --git a/bfd/bfd.c b/bfd/bfd.c index f56a8d342fb..f14ec253fb7 100644 --- a/bfd/bfd.c +++ b/bfd/bfd.c @@ -1862,6 +1862,9 @@ DESCRIPTION .#define bfd_is_group_section(abfd, sec) \ . BFD_SEND (abfd, _bfd_is_group_section, (abfd, sec)) . +.#define bfd_group_name(abfd, sec) \ +. BFD_SEND (abfd, _bfd_group_name, (abfd, sec)) +. .#define bfd_discard_group(abfd, sec) \ . BFD_SEND (abfd, _bfd_discard_group, (abfd, sec)) . diff --git a/bfd/binary.c b/bfd/binary.c index 37f5f9f7363..eb87d11b6ea 100644 --- a/bfd/binary.c +++ b/bfd/binary.c @@ -307,6 +307,7 @@ binary_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, #define binary_bfd_lookup_section_flags bfd_generic_lookup_section_flags #define binary_bfd_merge_sections bfd_generic_merge_sections #define binary_bfd_is_group_section bfd_generic_is_group_section +#define binary_bfd_group_name bfd_generic_group_name #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 diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c index 726d20bfbbf..ee4a3eeded7 100644 --- a/bfd/coff-alpha.c +++ b/bfd/coff-alpha.c @@ -2390,6 +2390,7 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data = #define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections #define _bfd_ecoff_bfd_merge_sections bfd_generic_merge_sections #define _bfd_ecoff_bfd_is_group_section bfd_generic_is_group_section +#define _bfd_ecoff_bfd_group_name bfd_generic_group_name #define _bfd_ecoff_bfd_discard_group bfd_generic_discard_group #define _bfd_ecoff_section_already_linked \ _bfd_coff_section_already_linked diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c index 3ada9ceb0f9..a2dd9e1c4fc 100644 --- a/bfd/coff-mips.c +++ b/bfd/coff-mips.c @@ -1416,6 +1416,7 @@ static const struct ecoff_backend_data mips_ecoff_backend_data = #define _bfd_ecoff_bfd_merge_sections bfd_generic_merge_sections #define _bfd_ecoff_bfd_is_group_section bfd_generic_is_group_section +#define _bfd_ecoff_bfd_group_name bfd_generic_group_name #define _bfd_ecoff_bfd_discard_group bfd_generic_discard_group #define _bfd_ecoff_section_already_linked \ _bfd_coff_section_already_linked diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index 85e90a02545..4620254aaef 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -4057,6 +4057,7 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = { #define _bfd_xcoff_bfd_lookup_section_flags bfd_generic_lookup_section_flags #define _bfd_xcoff_bfd_merge_sections bfd_generic_merge_sections #define _bfd_xcoff_bfd_is_group_section bfd_generic_is_group_section +#define _bfd_xcoff_bfd_group_name bfd_generic_group_name #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 diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c index 6f0e358f4ac..b6b189fd2d7 100644 --- a/bfd/coff64-rs6000.c +++ b/bfd/coff64-rs6000.c @@ -2778,6 +2778,7 @@ const bfd_target rs6000_xcoff64_vec = bfd_generic_lookup_section_flags, bfd_generic_merge_sections, bfd_generic_is_group_section, + bfd_generic_group_name, bfd_generic_discard_group, _bfd_generic_section_already_linked, _bfd_xcoff_define_common_symbol, @@ -3040,6 +3041,7 @@ const bfd_target rs6000_xcoff64_aix_vec = bfd_generic_lookup_section_flags, bfd_generic_merge_sections, bfd_generic_is_group_section, + bfd_generic_group_name, bfd_generic_discard_group, _bfd_generic_section_already_linked, _bfd_xcoff_define_common_symbol, diff --git a/bfd/coffcode.h b/bfd/coffcode.h index c3f13300a43..054e45c960b 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -5751,6 +5751,10 @@ static bfd_coff_backend_data bigobj_swap_table = #define coff_bfd_is_group_section bfd_generic_is_group_section #endif +#ifndef coff_bfd_group_name +#define coff_bfd_group_name bfd_coff_group_name +#endif + #ifndef coff_bfd_discard_group #define coff_bfd_discard_group bfd_generic_discard_group #endif diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 5d61f39c8ce..209b01d5d01 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -3155,3 +3155,14 @@ bfd_coff_gc_sections (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) /* ... and mark SEC_EXCLUDE for those that go. */ return coff_gc_sweep (abfd, info); } + +/* Return name used to identify a comdat group. */ + +const char * +bfd_coff_group_name (bfd *abfd, const asection *sec) +{ + struct coff_comdat_info *ci = bfd_coff_get_comdat_section (abfd, sec); + if (ci != NULL) + return ci->name; + return NULL; +} diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 521d35debb0..4458ff7b2ae 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2111,6 +2111,8 @@ extern bfd_boolean _bfd_elf_match_sections_by_type (bfd *, const asection *, bfd *, const asection *); extern bfd_boolean bfd_elf_is_group_section (bfd *, const struct bfd_section *); +extern const char *bfd_elf_group_name + (bfd *, const struct bfd_section *); extern bfd_boolean _bfd_elf_section_already_linked (bfd *, asection *, struct bfd_link_info *); extern void bfd_elf_set_group_contents diff --git a/bfd/elf.c b/bfd/elf.c index 5a061c91107..ec4c643d59a 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -974,6 +974,14 @@ bfd_elf_is_group_section (bfd *abfd ATTRIBUTE_UNUSED, const asection *sec) return elf_next_in_group (sec) != NULL; } +const char * +bfd_elf_group_name (bfd *abfd ATTRIBUTE_UNUSED, const asection *sec) +{ + if (elf_sec_group (sec) != NULL) + return elf_group_name (sec); + return NULL; +} + static char * convert_debug_to_zdebug (bfd *abfd, const char *name) { diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index 0b737a4ffa9..78a1f6314d0 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -192,6 +192,10 @@ #define bfd_elfNN_bfd_is_group_section bfd_elf_is_group_section #endif +#ifndef bfd_elfNN_bfd_group_name +#define bfd_elfNN_bfd_group_name bfd_elf_group_name +#endif + #ifndef bfd_elfNN_bfd_discard_group #define bfd_elfNN_bfd_discard_group bfd_generic_discard_group #endif diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c index f70a6f364d1..9c4ab4cecec 100644 --- a/bfd/i386msdos.c +++ b/bfd/i386msdos.c @@ -226,6 +226,7 @@ msdos_set_section_contents (bfd *abfd, #define msdos_bfd_lookup_section_flags bfd_generic_lookup_section_flags #define msdos_bfd_merge_sections bfd_generic_merge_sections #define msdos_bfd_is_group_section bfd_generic_is_group_section +#define msdos_bfd_group_name bfd_generic_group_name #define msdos_bfd_discard_group bfd_generic_discard_group #define msdos_section_already_linked \ _bfd_generic_section_already_linked diff --git a/bfd/ihex.c b/bfd/ihex.c index 101e0a76155..09149089beb 100644 --- a/bfd/ihex.c +++ b/bfd/ihex.c @@ -962,6 +962,7 @@ ihex_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, #define ihex_bfd_lookup_section_flags bfd_generic_lookup_section_flags #define ihex_bfd_merge_sections bfd_generic_merge_sections #define ihex_bfd_is_group_section bfd_generic_is_group_section +#define ihex_bfd_group_name bfd_generic_group_name #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 diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index cac4d3b022e..f498ffd5e7a 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -523,6 +523,8 @@ extern bfd_boolean _bfd_nolink_bfd_lookup_section_flags #define _bfd_nolink_bfd_merge_sections _bfd_bool_bfd_link_false_error extern bfd_boolean _bfd_nolink_bfd_is_group_section (bfd *, const asection *) ATTRIBUTE_HIDDEN; +extern const char *_bfd_nolink_bfd_group_name + (bfd *, const asection *) ATTRIBUTE_HIDDEN; extern bfd_boolean _bfd_nolink_bfd_discard_group (bfd *, asection *) ATTRIBUTE_HIDDEN; extern struct bfd_link_hash_table *_bfd_nolink_bfd_link_hash_table_create diff --git a/bfd/libbfd.h b/bfd/libbfd.h index aabe247068e..2ea167ecb69 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -528,6 +528,8 @@ extern bfd_boolean _bfd_nolink_bfd_lookup_section_flags #define _bfd_nolink_bfd_merge_sections _bfd_bool_bfd_link_false_error extern bfd_boolean _bfd_nolink_bfd_is_group_section (bfd *, const asection *) ATTRIBUTE_HIDDEN; +extern const char *_bfd_nolink_bfd_group_name + (bfd *, const asection *) ATTRIBUTE_HIDDEN; extern bfd_boolean _bfd_nolink_bfd_discard_group (bfd *, asection *) ATTRIBUTE_HIDDEN; extern struct bfd_link_hash_table *_bfd_nolink_bfd_link_hash_table_create diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h index c75c9ac595f..783d54a88a4 100644 --- a/bfd/libcoff-in.h +++ b/bfd/libcoff-in.h @@ -577,7 +577,8 @@ extern bfd_boolean _bfd_coff_reloc_link_order struct bfd_link_order *); extern bfd_boolean bfd_coff_gc_sections (bfd *, struct bfd_link_info *); - +extern const char *bfd_coff_group_name + (bfd *, const asection *); #define coff_get_section_contents_in_window \ _bfd_generic_get_section_contents_in_window diff --git a/bfd/libcoff.h b/bfd/libcoff.h index d0e3d0dd903..f2613c2e77c 100644 --- a/bfd/libcoff.h +++ b/bfd/libcoff.h @@ -581,7 +581,8 @@ extern bfd_boolean _bfd_coff_reloc_link_order struct bfd_link_order *); extern bfd_boolean bfd_coff_gc_sections (bfd *, struct bfd_link_info *); - +extern const char *bfd_coff_group_name + (bfd *, const asection *); #define coff_get_section_contents_in_window \ _bfd_generic_get_section_contents_in_window diff --git a/bfd/linker.c b/bfd/linker.c index 1b71fcf8f0d..f6eef93259b 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -3461,6 +3461,13 @@ _bfd_nolink_bfd_is_group_section (bfd *abfd, return _bfd_bool_bfd_false_error (abfd); } +const char * +_bfd_nolink_bfd_group_name (bfd *abfd, + const asection *sec ATTRIBUTE_UNUSED) +{ + return _bfd_ptr_bfd_null_error (abfd); +} + bfd_boolean _bfd_nolink_bfd_discard_group (bfd *abfd, asection *sec ATTRIBUTE_UNUSED) { diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c index e02dd790182..e15e88f353c 100644 --- a/bfd/mach-o-target.c +++ b/bfd/mach-o-target.c @@ -52,6 +52,7 @@ #define bfd_mach_o_bfd_lookup_section_flags bfd_generic_lookup_section_flags #define bfd_mach_o_bfd_merge_sections bfd_generic_merge_sections #define bfd_mach_o_bfd_is_group_section bfd_generic_is_group_section +#define bfd_mach_o_bfd_group_name bfd_generic_group_name #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 diff --git a/bfd/mmo.c b/bfd/mmo.c index bd4303c531f..f48f9868fee 100644 --- a/bfd/mmo.c +++ b/bfd/mmo.c @@ -3311,6 +3311,7 @@ mmo_write_object_contents (bfd *abfd) #define mmo_bfd_relax_section bfd_generic_relax_section #define mmo_bfd_merge_sections bfd_generic_merge_sections #define mmo_bfd_is_group_section bfd_generic_is_group_section +#define mmo_bfd_group_name bfd_generic_group_name #define mmo_bfd_discard_group bfd_generic_discard_group #define mmo_section_already_linked \ _bfd_generic_section_already_linked diff --git a/bfd/pef.c b/bfd/pef.c index 8c66ca477d4..effa0764053 100644 --- a/bfd/pef.c +++ b/bfd/pef.c @@ -56,6 +56,7 @@ #define bfd_pef_bfd_lookup_section_flags bfd_generic_lookup_section_flags #define bfd_pef_bfd_merge_sections bfd_generic_merge_sections #define bfd_pef_bfd_is_group_section bfd_generic_is_group_section +#define bfd_pef_bfd_group_name bfd_generic_group_name #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 diff --git a/bfd/plugin.c b/bfd/plugin.c index 5f760e9c429..ca26005055e 100644 --- a/bfd/plugin.c +++ b/bfd/plugin.c @@ -102,6 +102,7 @@ dlerror (void) #define bfd_plugin_bfd_lookup_section_flags bfd_generic_lookup_section_flags #define bfd_plugin_bfd_merge_sections bfd_generic_merge_sections #define bfd_plugin_bfd_is_group_section bfd_generic_is_group_section +#define bfd_plugin_bfd_group_name bfd_generic_group_name #define bfd_plugin_bfd_discard_group bfd_generic_discard_group #define bfd_plugin_section_already_linked _bfd_generic_section_already_linked #define bfd_plugin_bfd_define_common_symbol bfd_generic_define_common_symbol diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c index 99db8234d1a..02132e7801b 100644 --- a/bfd/ppcboot.c +++ b/bfd/ppcboot.c @@ -456,6 +456,7 @@ ppcboot_bfd_print_private_bfd_data (bfd *abfd, void * farg) #define ppcboot_bfd_lookup_section_flags bfd_generic_lookup_section_flags #define ppcboot_bfd_merge_sections bfd_generic_merge_sections #define ppcboot_bfd_is_group_section bfd_generic_is_group_section +#define ppcboot_bfd_group_name bfd_generic_group_name #define ppcboot_bfd_discard_group bfd_generic_discard_group #define ppcboot_section_already_linked \ _bfd_generic_section_already_linked diff --git a/bfd/section.c b/bfd/section.c index 64636334ac9..74feb73be90 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -1662,6 +1662,24 @@ bfd_generic_is_group_section (bfd *abfd ATTRIBUTE_UNUSED, return FALSE; } +/* +FUNCTION + bfd_generic_group_name + +SYNOPSIS + const char *bfd_generic_group_name (bfd *, const asection *sec); + +DESCRIPTION + Returns group name if @var{sec} is a member of a group. +*/ + +const char * +bfd_generic_group_name (bfd *abfd ATTRIBUTE_UNUSED, + const asection *sec ATTRIBUTE_UNUSED) +{ + return NULL; +} + /* FUNCTION bfd_generic_discard_group diff --git a/bfd/som.c b/bfd/som.c index 0d17b3278a4..02a99a33607 100644 --- a/bfd/som.c +++ b/bfd/som.c @@ -6756,6 +6756,7 @@ som_bfd_link_split_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) #define som_bfd_lookup_section_flags bfd_generic_lookup_section_flags #define som_bfd_merge_sections bfd_generic_merge_sections #define som_bfd_is_group_section bfd_generic_is_group_section +#define som_bfd_group_name bfd_generic_group_name #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 diff --git a/bfd/srec.c b/bfd/srec.c index 77eaecd1113..218276837cc 100644 --- a/bfd/srec.c +++ b/bfd/srec.c @@ -1275,6 +1275,7 @@ srec_print_symbol (bfd *abfd, #define srec_bfd_lookup_section_flags bfd_generic_lookup_section_flags #define srec_bfd_merge_sections bfd_generic_merge_sections #define srec_bfd_is_group_section bfd_generic_is_group_section +#define srec_bfd_group_name bfd_generic_group_name #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 diff --git a/bfd/targets.c b/bfd/targets.c index 6b85c627980..09956994ec9 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -462,6 +462,7 @@ BFD_JUMP_TABLE macros. . NAME##_bfd_lookup_section_flags, \ . NAME##_bfd_merge_sections, \ . NAME##_bfd_is_group_section, \ +. NAME##_bfd_group_name, \ . NAME##_bfd_discard_group, \ . NAME##_section_already_linked, \ . NAME##_bfd_define_common_symbol, \ @@ -520,6 +521,9 @@ BFD_JUMP_TABLE macros. . {* Is this section a member of a group? *} . bfd_boolean (*_bfd_is_group_section) (bfd *, const struct bfd_section *); . +. {* The group name, if section is a member of a group. *} +. const char *(*_bfd_group_name) (bfd *, const struct bfd_section *); +. . {* Discard members of a group. *} . bfd_boolean (*_bfd_discard_group) (bfd *, struct bfd_section *); . diff --git a/bfd/tekhex.c b/bfd/tekhex.c index 386e33b24e4..fb03629182c 100644 --- a/bfd/tekhex.c +++ b/bfd/tekhex.c @@ -978,6 +978,7 @@ tekhex_print_symbol (bfd *abfd, #define tekhex_bfd_lookup_section_flags bfd_generic_lookup_section_flags #define tekhex_bfd_merge_sections bfd_generic_merge_sections #define tekhex_bfd_is_group_section bfd_generic_is_group_section +#define tekhex_bfd_group_name bfd_generic_group_name #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 diff --git a/bfd/verilog.c b/bfd/verilog.c index 252e240277a..a785e50a00a 100644 --- a/bfd/verilog.c +++ b/bfd/verilog.c @@ -368,6 +368,7 @@ verilog_mkobject (bfd *abfd) #define verilog_bfd_gc_sections bfd_generic_gc_sections #define verilog_bfd_merge_sections bfd_generic_merge_sections #define verilog_bfd_is_group_section bfd_generic_is_group_section +#define verilog_bfd_group_name bfd_generic_group_name #define verilog_bfd_discard_group bfd_generic_discard_group #define verilog_section_already_linked _bfd_generic_section_already_linked #define verilog_bfd_link_hash_table_create _bfd_generic_link_hash_table_create diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index 4e6f9c1c429..69822a2ce6a 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -9504,6 +9504,7 @@ bfd_vms_get_data (bfd *abfd) #define vms_bfd_copy_link_hash_symbol_type \ _bfd_generic_copy_link_hash_symbol_type #define vms_bfd_is_group_section bfd_generic_is_group_section +#define vms_bfd_group_name bfd_generic_group_name #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 @@ -9550,6 +9551,7 @@ bfd_vms_get_data (bfd *abfd) #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section +#define alpha_vms_bfd_group_name bfd_generic_group_name #define alpha_vms_bfd_discard_group bfd_generic_discard_group #define alpha_vms_section_already_linked \ _bfd_generic_section_already_linked diff --git a/bfd/xsym.c b/bfd/xsym.c index 67d91cb077d..cf4a67167a3 100644 --- a/bfd/xsym.c +++ b/bfd/xsym.c @@ -48,6 +48,7 @@ #define bfd_sym_bfd_lookup_section_flags bfd_generic_lookup_section_flags #define bfd_sym_bfd_merge_sections bfd_generic_merge_sections #define bfd_sym_bfd_is_group_section bfd_generic_is_group_section +#define bfd_sym_bfd_group_name bfd_generic_group_name #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 diff --git a/ld/ChangeLog b/ld/ChangeLog index d24973e0fa5..955d460d400 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2019-09-11 Alan Modra + + * ldmisc.c: Don't #include elf-bfd.h or coff-bfd.h. + (vfinfo): Use bfd_group_name. + 2019-09-11 Alan Modra * plugin.c (asymbol_from_plugin_symbol): Move code handling diff --git a/ld/ldmisc.c b/ld/ldmisc.c index f7ab7b5d99e..319f247e3be 100644 --- a/ld/ldmisc.c +++ b/ld/ldmisc.c @@ -35,8 +35,6 @@ #include "ldlex.h" #include "ldmain.h" #include "ldfile.h" -#include "elf-bfd.h" -#include "coff-bfd.h" /* %% literal % @@ -431,26 +429,18 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bfd_boolean is_warning) /* section name from a section */ asection *sec; bfd *abfd; - const char *group = NULL; - struct coff_comdat_info *ci; fmt++; sec = (asection *) args[arg_no].p; ++arg_count; - abfd = sec->owner; fprintf (fp, "%s", sec->name); - if (abfd != NULL - && bfd_get_flavour (abfd) == bfd_target_elf_flavour - && elf_next_in_group (sec) != NULL - && (sec->flags & SEC_GROUP) == 0) - group = elf_group_name (sec); - else if (abfd != NULL - && bfd_get_flavour (abfd) == bfd_target_coff_flavour - && (ci = bfd_coff_get_comdat_section (sec->owner, - sec)) != NULL) - group = ci->name; - if (group != NULL) - fprintf (fp, "[%s]", group); + abfd = sec->owner; + if (abfd != NULL) + { + const char *group = bfd_group_name (abfd, sec); + if (group != NULL) + fprintf (fp, "[%s]", group); + } } else if (*fmt == 'B') { -- 2.30.2