+2019-09-11  Alan Modra  <amodra@gmail.com>
+
+       * 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  <nickc@redhat.com>
 
        PR 24907
 
 #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
 
 #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
 
                  (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.  */
 #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))
 
   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, \
   /* 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 *);
 
 
 .#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))
 .
 
 #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
 
 #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
 
 #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
 
 #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
 
     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,
     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,
 
 #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
 
   /* ... 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;
+}
 
   (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
 
   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)
 {
 
 #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
 
 #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
 
 #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
 
 #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
 
 #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
 
    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
 
    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
 
   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)
 {
 
 #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
 
 #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
 
 #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
 
 #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
 
 #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
 
   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
 
 #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
 
 #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
 
 .  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, \
 .  {* 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 *);
 .
 
 #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
 
 #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
 
 #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
 #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
 
 #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
 
+2019-09-11  Alan Modra  <amodra@gmail.com>
+
+       * ldmisc.c: Don't #include elf-bfd.h or coff-bfd.h.
+       (vfinfo): Use bfd_group_name.
+
 2019-09-11  Alan Modra  <amodra@gmail.com>
 
        * plugin.c (asymbol_from_plugin_symbol): Move code handling
 
 #include "ldlex.h"
 #include "ldmain.h"
 #include "ldfile.h"
-#include "elf-bfd.h"
-#include "coff-bfd.h"
 
 /*
  %% literal %
                  /* 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')
                {