]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Merge remote-tracking branch 'origin/hjl/linux/master' into hjl/linux/applied
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 10 Oct 2014 18:02:55 +0000 (11:02 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 10 Oct 2014 18:02:55 +0000 (11:02 -0700)
61 files changed:
1  2 
.gitattributes
ChangeLog.lto-mixed
bfd/archive.c
bfd/bfd-in2.h
bfd/bfd.c
bfd/elf-bfd.h
bfd/elf.c
bfd/elf32-i386.c
bfd/elf32-mips.c
bfd/elf64-ia64-vms.c
bfd/elf64-x86-64.c
bfd/elfcode.h
bfd/elflink.c
bfd/elfn32-mips.c
bfd/elfnn-ia64.c
bfd/format.c
bfd/linker.c
bfd/opncls.c
bfd/plugin.c
bfd/plugin.h
bfd/section.c
bfd/syms.c
binutils/nm.c
binutils/objcopy.c
binutils/objdump.c
binutils/readelf.c
gas/config/obj-elf.c
gas/doc/as.texinfo
gas/symbols.c
gas/symbols.h
gas/testsuite/gas/elf/elf.exp
gas/testsuite/gas/elf/type.e
include/bfdlink.h
include/elf/common.h
ld/emulparams/elf_x86_64.sh
ld/emultempl/aarch64elf.em
ld/emultempl/alphaelf.em
ld/emultempl/armelf.em
ld/emultempl/elf32.em
ld/emultempl/ppc64elf.em
ld/emultempl/spuelf.em
ld/ld.texinfo
ld/ldfile.c
ld/ldlang.c
ld/ldlang.h
ld/ldlex.h
ld/ldmain.c
ld/ldmain.h
ld/lexsup.c
ld/plugin.c
ld/plugin.h
ld/scripttempl/armbpabi.sc
ld/scripttempl/elf.sc
ld/scripttempl/elf32sh-symbian.sc
ld/scripttempl/elf64hppa.sc
ld/scripttempl/elfxtensa.sc
ld/scripttempl/mep.sc
ld/scripttempl/pe.sc
ld/scripttempl/pep.sc
ld/testsuite/ld-elf/shared.exp
ld/testsuite/ld-plugin/lto.exp

diff --cc .gitattributes
index 15caafcf45711c658217db66862e93e56615e31a,06d51d28a950eef3ff497041f15e7b5c64dfdaf9..f7bb8f6af302177e918753619e48859780eca865
@@@ -1,8 -1,20 +1,29 @@@
+ # -*- conf -*-
+ ## Set merge driver for ChangeLog files 
+ # See gnulib's lib/git-merge-changelog.c (or git-merge-changelog(1))
+ # for per-user setup instructions.
+ #
+ # The short version of this (optional) procedure is:
+ # 
+ # (1) Install git-merge-changelog (this is the tricky part!)
+ #
+ # (2) Add something like the following to your ~/.gitconfig:
+ #
+ # [merge "merge-changelog"]
+ #         name = GNU-style ChangeLog merge driver
+ #         driver = git-merge-changelog %O %A %B
+ #
+ # (3) Enjoy mostly effortless ChangeLog merges, at least until the
+ #     file gets renamed again ...
+ ChangeLog       merge=merge-changelog
++
 +.cvsignore export-ignore
 +.gitattributes export-ignore
 +.gitignore export-ignore
 +gdb export-ignore
 +libdecnumber export-ignore
 +readline export-ignore
 +sim export-ignore
 +include/gdb -export-ignore
index f3ca7be5d356748b7e0854a705a72b0eeaa84d10,0000000000000000000000000000000000000000..bdbabeada4aecbd546b905fec96d45406de08381
mode 100644,000000..100644
--- /dev/null
@@@ -1,315 -1,0 +1,317 @@@
- 2011-05-14  H.J. Lu  <hongjiu.lu@intel.com>
-       PR ld/12758
-       * elflink.c (elf_link_add_archive_symbols): Don't load the IR
-       archive member twice.
 +bfd/
 +
++2014-03-07  H.J. Lu  <hongjiu.lu@intel.com>
++
++      * format.c (bfd_check_format_matches): Don't check the plugin
++      target twice.
++
 +2013-02-15  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * ldlang.c (lang_finish): Take a bfd_boolean argument to support
 +      object-only output.
 +      (cmdline_emit_object_only_section): Pass TRUE to lang_finish.
 +
 +      * ldlang.h (lang_finish): Updated.
 +
 +      * ldmain.c (main): Pass FALSE to lang_finish.
 +
 +2012-10-25  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      PR ld/14747
 +      * elflink.c (_bfd_elf_fix_symbol_flags): Check symbol for linker
 +      created section instead.
 +
 +2012-10-25  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      PR ld/14747
 +      * elflink.c (_bfd_elf_fix_symbol_flags): Never mark
 +      _GLOBAL_OFFSET_TABLE_, _PROCEDURE_LINKAGE_TABLE_ nor _DYNAMIC
 +      undefined.
 +
 +2012-06-28  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      PR ld/14272
 +      * elflink.c (_bfd_elf_fix_symbol_flags): Mark the plugin symbol
 +      undefined if it is referenced from a non-IR file.
 +
 +2012-06-04  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * plugin.c (add_symbols): Set tdata.plugin_data before calling
 +      bfd_plugin_get_symbols_in_object_only.
 +
 +2011-10-16  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * plugin.c (add_symbols): Call
 +      bfd_plugin_get_symbols_in_object_only.
 +      (bfd_plugin_get_symtab_upper_bound): Don't call
 +      bfd_plugin_get_symbols_in_object_only.
 +
 +2011-10-16  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * plugin.c (bfd_plugin_get_symbols_in_object_only): Optimized.
 +
 +2011-10-16  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * plugin.c (bfd_plugin_get_symbols_in_object_only): Properly
 +      remove the object only section file.
 +
 +2011-10-15  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      PR ld/13298
 +      * opncls.c (bfd_extract_object_only_section): New.
 +
 +      * plugin.c (add_symbols): Initialize object_only_syms and
 +      object_only_nsyms.
 +      (bfd_plugin_fake_text_section): New.
 +      (bfd_plugin_fake_common_section): Likewise.
 +      (bfd_plugin_get_symbols_in_object_only): Likewise.
 +      (bfd_plugin_get_symtab_upper_bound): Call
 +      bfd_plugin_get_symbols_in_object_only and add symbols from
 +      object only section.
 +      (bfd_plugin_canonicalize_symtab): Remove fake_section and
 +      fake_common_section.  Use bfd_plugin_fake_text_section and
 +      bfd_plugin_fake_common_section.  Set udata.p to NULL.  Copy
 +      symbols from object only section.
 +
 +      * plugin.h (plugin_data_struct): Add object_only_nsyms and
 +      object_only_syms.
 +
 +      * bfd-in2.h: Regenerated.
 +
-       * plugin.c (plugin_opt_plugin_arg): Ignore -pass-through=.
-       (plugin_maybe_claim): Call cmdline_check_object_only_section
-       on claimed IR files.
 +2011-04-19  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * bfd.c (bfd_lto_object_type): New.
 +      (bfd): Add object_only_section and lto_type.
 +      (bfd_group_signature): New.
 +
 +      * elf.c (special_sections_g): Add .gnu_object_only.
 +
 +      * format.c (bfd_set_lto_type): New.
 +      (bfd_check_format_matches): Use it.
 +
 +      * section.c (GNU_OBJECT_ONLY_SECTION_NAME): New.
 +
 +      * bfd-in2.h: Regenerated.
 +
 +binutils/
 +
 +2011-04-19  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * objcopy.c (group_signature): Removed.
 +      (is_strip_section): Replace group_signature with
 +      bfd_group_signature.
 +      (setup_section): Likewise.
 +
 +      * readelf.c (get_section_type_name): Handle SHT_GNU_OBJECT_ONLY.
 +
 +gas/testsuite/
 +
 +2011-04-19  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * gas/elf/section9.s: Add the .gnu_object_only test.
 +      * gas/elf/section9.d: Updated.
 +
 +include/
 +
 +2011-04-19  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * bfdlink.h (bfd_link_info): Add emit_gnu_object_only and
 +      emitting_gnu_object_only.
 +
 +include/elf/
 +
 +2011-04-19  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * common.h (SHT_GNU_OBJECT_ONLY): New.
 +
 +ld/
 +
 +2014-01-11  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * ldlang.c (cmdline_add_object_only_section): Save BFD filename
 +      to be used after bfd_close ().
 +
 +2012-10-20  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * ldlang.c (lang_process): Replace trace_file_tries with
 +      verbose.
 +
 +2012-08-14  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * emultempl/aarch64elf.em (gld${EMULATION_NAME}_finish): Renamed
 +      to ...
 +      (aarch64_finish): This.  Replace finish_default with
 +      gld${EMULATION_NAME}_finish.
 +      (LDEMUL_FINISH): Set to aarch64_finish.
 +
 +2011-10-15  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      PR ld/13298
 +      * ldlang.c (cmdline_extract_object_only_section): Call
 +      bfd_extract_object_only_section.
 +
 +2011-05-17  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * ldlang.c (cmdline_remove_object_only_files): Return if
 +      ENABLE_PLUGINS is undefined or plugin_save_temps is true.
 +
 +2011-05-15  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * ldlex.h (option_values): Add OPTION_PLUGIN_SAVE_TEMPS.
 +      * lexsup.c (ld_options): Add -plugin-save-temps.
 +      (parse_args): Handle OPTION_PLUGIN_SAVE_TEMPS.
 +
 +      * plugin.c (plugin_save_temps): New.
 +      (plugin_call_cleanup): Don't call plugin cleanup_handler if
 +      plugin_save_temps is true.
 +
 +      * plugin.h (plugin_save_temps): New.
 +
 +2011-05-14  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      PR ld/12760
 +      * ldmain.c (warning_callback): Don't warn plugin dummy.
 +
 +2011-04-19  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      * emultempl/alphaelf.em (alpha_finish): Replace finish_default
 +      with gld${EMULATION_NAME}_finish.
 +
 +      * emultempl/armelf.em (gld${EMULATION_NAME}_finish): Renamed
 +      to ...
 +      (arm_finish): This.  Replace finish_default with
 +      gld${EMULATION_NAME}_finish.
 +      (LDEMUL_FINISH): Set to arm_finish.
 +
 +      * emultempl/elf32.em (gld${EMULATION_NAME}_finish): New.
 +      (orphan_init_done): Likewise.
 +      (ld_${EMULATION_NAME}_emulation): Use gld${EMULATION_NAME}_finish.
 +      (gld${EMULATION_NAME}_place_orphan): Initialize hold.
 +
 +      * emultempl/ppc64elf.em (gld${EMULATION_NAME}_finish): Renamed
 +      to ...
 +      (ppc_finish): This.  Replace finish_default with
 +      gld${EMULATION_NAME}_finish.
 +      (LDEMUL_FINISH): Set to ppc_finish.
 +
 +      * emultempl/spuelf.em (gld${EMULATION_NAME}_finish): Renamed
 +      to ...
 +      (spu_finish): This.  Replace finish_default with
 +      gld${EMULATION_NAME}_finish.
 +      (LDEMUL_FINISH): Set to spu_finish.
 +
 +      * ldfile.c (ldfile_try_open_bfd): Call
 +      cmdline_check_object_only_section.
 +
 +      * ldlang.c: Include "ldwrite.h" and elf-bfd.h.
 +      * ldlang.c (cmdline_object_only_file_list): New.
 +      (cmdline_object_only_archive_list): Likewise.
 +      (cmdline_temp_object_only_list): Likewise.
 +      (cmdline_lists_init): Likewise.
 +      (cmdline_list_new): Likewise.
 +      (cmdline_list_append): Likewise.
 +      (print_cmdline_list): Likewise.
 +      (cmdline_on_object_only_archive_list_p): Likewise.
 +      (cmdline_object_only_list_append): Likewise.
 +      (cmdline_get_object_only_input_files): Likewise.
 +      (cmdline_arg): Likewise.
 +      (setup_section): Likewise.
 +      (copy_section): Likewise.
 +      (cmdline_fopen_temp): Likewise.
 +      (cmdline_add_object_only_section): Likewise.
 +      (cmdline_emit_object_only_section): Likewise.
 +      (cmdline_extract_object_only_section): Likewise.
 +      (cmdline_check_object_only_section): Likewise.
 +      (cmdline_remove_object_only_files): Likewise.
 +      (lang_init): Take a bfd_boolean argument to supprt object-only
 +      output.  Call cmdline_lists_init.
 +      (load_symbols): Call cmdline_on_object_only_archive_list_p
 +      to check if an archive member should be loaded.
 +      (lang_process): Handle object-only link.
 +
 +      * ldlang.h (lang_init): Take a bfd_boolean argument.
 +      (cmdline_enum_type): New.
 +      (cmdline_header_type): Likewise.
 +      (cmdline_file_type): Likewise.
 +      (cmdline_bfd_type): Likewise.
 +      (cmdline_union_type): Likewise.
 +      (cmdline_list_type): Likewise.
 +      (cmdline_emit_object_only_section): Likewise.
 +      (cmdline_check_object_only_section): Likewise.
 +      (cmdline_remove_object_only_files): Likewise.
 +
 +      * ldmain.c (main): Call xatexit with
 +      cmdline_remove_object_only_files.  Pass FALSE to lang_init.
 +      Use ld_parse_linker_script.  Set link_info.output_bfd to NULL
 +      after close.  Call cmdline_emit_object_only_section if needed.
 +      (add_archive_element): Call cmdline_check_object_only_section.
 +      (ld_parse_linker_script): New.
 +
 +      * ldmain.h (ld_parse_linker_script): New.
 +
++      * plugin.c (plugin_maybe_claim): Call
++      cmdline_check_object_only_section on claimed IR files.
 +
 +      * scripttempl/armbpabi.sc: Also discard .gnu_object_only
 +      sections.
 +      * scripttempl/elf.sc: Likewise.
 +      * scripttempl/elf32sh-symbian.sc: Likewise.
 +      * scripttempl/elf64hppa.sc: Likewise.
 +      * scripttempl/elfxtensa.sc: Likewise.
 +      * scripttempl/mep.sc: Likewise.
 +      * scripttempl/pe.sc: Likewise.
 +      * scripttempl/pep.sc: Likewise.
 +
 +ld/testsuite/
 +
++2014-03-07  H.J. Lu  <hongjiu.lu@intel.com>
++
++      * ld-plugin/lto.exp: Add test for nm on mixed LTO/non-LTO object.
++
 +2012-12-05  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      PR ld/14918
 +      * ld-plugin/lto.exp (lto_link_elf_tests): Add PR ld/14918 test.
 +
 +      * ld-plugin/pr14918.c: New file.
 +      * ld-plugin/pr14918.d: Likewise.
 +
 +2011-01-22  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      PR ld/12365
 +      * ld-plugin/pr12365a.c: New file.
 +      * ld-plugin/pr12365b.c: Likewise.
 +      * ld-plugin/pr12365c.c: Likewise.
 +
 +      * ld-plugin/lto.exp (lto_link_tests): Prepare for the PR ld/12365
 +      test.
 +      Run the PR ld/12365 test.
 +
 +2011-01-22  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      PR ld/12430
 +      * ld-plugin/lto-10.out: New file.
 +      * ld-plugin/lto-10a.c: Likewise.
 +      * ld-plugin/lto-10b.c: Likewise.
 +      * ld-plugin/lto-10r.d: Likewise.
 +
 +      * ld-plugin/lto.exp (lto_link_tests): Prepare for "LTO 10".
 +      (lto_run_tests): Add "LTO 10".
 +      Run lto-10r and create tmpdir/lto-10.o.
 +
 +2011-01-22  H.J. Lu  <hongjiu.lu@intel.com>
 +
 +      PR ld/12291
 +      * ld-plugin/lto-4.out: Likewise.
 +      * ld-plugin/lto-4a.c: Likewise.
 +      * ld-plugin/lto-4b.c: Likewise.
 +      * ld-plugin/lto-4c.c: Likewise.
 +      * ld-plugin/lto-4r-a.d: Likewise.
 +      * ld-plugin/lto-4r-b.d: Likewise.
 +      * ld-plugin/lto-4r-c.d: Likewise.
 +      * ld-plugin/lto-4r-d.d: Likewise.
 +
 +      * ld-plugin/lto.exp (lto_link_tests): Prepare for "LTO 4[acd]"
 +      and "lto-4r-[abcd]" tests.
 +      (lto_run_tests): Add "LTO 4[acd]" tests.
 +      Build liblto-4.a.  Run "lto-4r-[abcd]" tests.
diff --cc bfd/archive.c
Simple merge
diff --cc bfd/bfd-in2.h
index 6643bc1edfd5b79fbcda5f123cdafb38a3a877e8,a40a14a1526f89c92a441d5aeff7c66f2a1188ab..1e81dd30b685dd654b1f5eb9e464ee80226d22b2
@@@ -6158,19 -6274,8 +6284,16 @@@ enum bfd_directio
      both_direction = 3
    };
  
 +enum bfd_lto_object_type
 +  {
 +    lto_non_object,
 +    lto_non_ir_object,
 +    lto_ir_object,
 +    lto_mixed_object
 +  };
 +
  struct bfd
  {
-   /* A unique identifier of the BFD  */
-   unsigned int id;
    /* The filename the application opened the BFD with.  */
    const char *filename;
  
    (BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_LINKER_CREATED \
     | BFD_PLUGIN | BFD_TRADITIONAL_FORMAT | BFD_DETERMINISTIC_OUTPUT)
  
+   /* Is the file descriptor being cached?  That is, can it be closed as
+      needed, and re-opened when accessed later?  */
+   unsigned int cacheable : 1;
+   /* Marks whether there was a default target specified when the
+      BFD was opened. This is used to select which matching algorithm
+      to use to choose the back end.  */
+   unsigned int target_defaulted : 1;
+   /* ... and here: (``once'' means at least once).  */
+   unsigned int opened_once : 1;
+   /* Set if we have a locally maintained mtime value, rather than
+      getting it from the file each time.  */
+   unsigned int mtime_set : 1;
+   /* Flag set if symbols from this BFD should not be exported.  */
+   unsigned int no_export : 1;
+   /* Remember when output has begun, to stop strange things
+      from happening.  */
+   unsigned int output_has_begun : 1;
+   /* Have archive map.  */
+   unsigned int has_armap : 1;
+   /* Set if this is a thin archive.  */
+   unsigned int is_thin_archive : 1;
+   /* Set if only required symbols should be added in the link hash table for
+      this object.  Used by VMS linkers.  */
+   unsigned int selective_search : 1;
+   /* Set if this is the linker output BFD.  */
+   unsigned int is_linker_output : 1;
++  /* LTO object type.  */
++  unsigned int lto_type : 2;
++
    /* Currently my_archive is tested before adding origin to
       anything. I believe that this can become always an add of
       origin, with origin set to 0 for non archive files.  */
diff --cc bfd/bfd.c
index 2ef48a7e9189ac5e055e0f02dfde502eb5dc7042,8b609115064ca7a356f4bc3a3ccc3a73d2b43890..537433c25e18ce5f4b5e63451c928fd140d3cbc1
+++ b/bfd/bfd.c
@@@ -44,19 -44,8 +44,16 @@@ CODE_FRAGMEN
  .    both_direction = 3
  .  };
  .
 +.enum bfd_lto_object_type
 +.  {
 +.    lto_non_object,
 +.    lto_non_ir_object,
 +.    lto_ir_object,
 +.    lto_mixed_object
 +.  };
 +.
  .struct bfd
  .{
- .  {* A unique identifier of the BFD  *}
- .  unsigned int id;
- .
  .  {* The filename the application opened the BFD with.  *}
  .  const char *filename;
  .
  .  (BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_LINKER_CREATED \
  .   | BFD_PLUGIN | BFD_TRADITIONAL_FORMAT | BFD_DETERMINISTIC_OUTPUT)
  .
+ .  {* Is the file descriptor being cached?  That is, can it be closed as
+ .     needed, and re-opened when accessed later?  *}
+ .  unsigned int cacheable : 1;
+ .
+ .  {* Marks whether there was a default target specified when the
+ .     BFD was opened. This is used to select which matching algorithm
+ .     to use to choose the back end.  *}
+ .  unsigned int target_defaulted : 1;
+ .
+ .  {* ... and here: (``once'' means at least once).  *}
+ .  unsigned int opened_once : 1;
+ .
+ .  {* Set if we have a locally maintained mtime value, rather than
+ .     getting it from the file each time.  *}
+ .  unsigned int mtime_set : 1;
+ .
+ .  {* Flag set if symbols from this BFD should not be exported.  *}
+ .  unsigned int no_export : 1;
+ .
+ .  {* Remember when output has begun, to stop strange things
+ .     from happening.  *}
+ .  unsigned int output_has_begun : 1;
+ .
+ .  {* Have archive map.  *}
+ .  unsigned int has_armap : 1;
+ .
+ .  {* Set if this is a thin archive.  *}
+ .  unsigned int is_thin_archive : 1;
+ .
+ .  {* Set if only required symbols should be added in the link hash table for
+ .     this object.  Used by VMS linkers.  *}
+ .  unsigned int selective_search : 1;
+ .
+ .  {* Set if this is the linker output BFD.  *}
+ .  unsigned int is_linker_output : 1;
+ .
++.  {* LTO object type.  *}
++.  unsigned int lto_type : 2;
++.
  .  {* Currently my_archive is tested before adding origin to
  .     anything. I believe that this can become always an add of
  .     origin, with origin set to 0 for non archive files.  *}
diff --cc bfd/elf-bfd.h
Simple merge
diff --cc bfd/elf.c
Simple merge
index e932d6fc4c219584d69c292246c215c45b5d48b4,a00d47cb5b8cbb850994fb9a9ba98d2261d07da1..c441ea59b45ac187477052c3e73d6452a9d8c977
@@@ -5042,11 -5048,10 +5073,11 @@@ elf_i386_add_symbol_hook (bfd * abfd
          || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE))
      elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
  
 -  return TRUE;
 +  return _bfd_elf_add_sharable_symbol (abfd, info, sym, namep, flagsp,
 +                                     secp, valp);
  }
  
- #define TARGET_LITTLE_SYM             bfd_elf32_i386_vec
+ #define TARGET_LITTLE_SYM             i386_elf32_vec
  #define TARGET_LITTLE_NAME            "elf32-i386"
  #define ELF_ARCH                      bfd_arch_i386
  #define ELF_TARGET_ID                 I386_ELF_DATA
Simple merge
Simple merge
index 5b81e4d9a16fbf26d32ed8f008e16266218af4e2,9d18a545a9f7f313db81e7d23bb8bc8e13ccf519..4ec1533020ce93bd6fb7c7836273d3085330e272
@@@ -2994,8 -3137,8 +3155,9 @@@ elf_x86_64_size_dynamic_sections (bfd *
          || s == htab->elf.sgotplt
          || s == htab->elf.iplt
          || s == htab->elf.igotplt
+         || s == htab->plt_bnd
          || s == htab->plt_eh_frame
 +        || s == htab->sdynsharablebss
          || s == htab->sdynbss)
        {
          /* Strip this section if we don't need it; see the
diff --cc bfd/elfcode.h
Simple merge
diff --cc bfd/elflink.c
index 3ab468f03b8c417aaead52100bcfee71d0274ef1,d33efe0e8733a3f081d9391e6b22f9a2d1d6e3b8..26ab8ce139a9bdd1660b0ba7d4d726a2c753c706
@@@ -1786,8 -1723,8 +1764,8 @@@ nondefault
    size_change_ok = FALSE;
    tmp_sec = sec;
    if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &tmp_sec, &value,
-                             &hi, oldsecondary, NULL, NULL, NULL, &skip,
 -                            &hi, poldbfd, NULL, NULL, &skip, &override,
 -                            &type_change_ok, &size_change_ok))
++                            &hi, oldsecondary, poldbfd, NULL, NULL, &skip,
 +                            &override, &type_change_ok, &size_change_ok))
      return FALSE;
  
    if (skip)
@@@ -4170,8 -4073,18 +4147,18 @@@ error_free_dyn
              name = newname;
            }
  
+         /* If this symbol has default visibility and the user has
+            requested we not re-export it, then mark it as hidden.  */
+         if (definition
+             && !dynamic
+             && (abfd->no_export
+                 || (abfd->my_archive && abfd->my_archive->no_export))
+             && ELF_ST_VISIBILITY (isym->st_other) != STV_INTERNAL)
+           isym->st_other = (STV_HIDDEN
+                             | (isym->st_other & ~ELF_ST_VISIBILITY (-1)));
          if (!_bfd_elf_merge_symbol (abfd, info, name, isym, &sec, &value,
 -                                    sym_hash, &old_bfd, &old_weak,
 +                                    sym_hash, FALSE, &old_bfd, &old_weak,
                                      &old_alignment, &skip, &override,
                                      &type_change_ok, &size_change_ok))
            goto error_free_vers;
@@@ -5142,26 -5024,16 +5115,27 @@@ elf_link_add_archive_symbols (bfd *abfd
                 map alone.  Instead we must read in the element's symbol
                 table and check that to see what kind of symbol definition
                 this is.  */
 -            if (! elf_link_is_defined_archive_symbol (abfd, symdef))
 +            if (! elf_link_is_defined_archive_symbol (abfd, symdef,
 +                                                      FALSE))
                continue;
            }
 -        else if (h->root.type != bfd_link_hash_undefined)
 +        /* Keep searching if a definition is secondary.  */
 +        else if (h->root.type != bfd_link_hash_undefined
 +                 && !h->root.secondary)
            {
              if (h->root.type != bfd_link_hash_undefweak)
-               defined[i] = TRUE;
+               /* Symbol must be defined.  Don't check it again.  */
+               included[i] = TRUE;
              continue;
            }
 +        else if (h->root.secondary
 +                 && h->root.type == bfd_link_hash_defweak)
 +          {
 +            /* Ignore another secondary definition.  */
 +            if (! elf_link_is_defined_archive_symbol (abfd, symdef,
 +                                                      TRUE))
 +              continue;
 +          }
  
          /* We need to include this archive member.  */
          element = _bfd_get_elt_at_filepos (abfd, symdef->file_offset);
Simple merge
Simple merge
diff --cc bfd/format.c
index b0fb4831e99ee6b91bb56d022ec167c2810120b8,c4bc94403864d70fcc0f698afe22adc0fcdc065f..63ad2e69986133cb543017f9ac4f3e00301d2cf1
@@@ -231,6 -203,6 +230,9 @@@ bfd_boolea
  bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
  {
    extern const bfd_target binary_vec;
++#if BFD_SUPPORTS_PLUGINS
++  extern const bfd_target plugin_vec;
++#endif
    const bfd_target * const *target;
    const bfd_target **matching_vector = NULL;
    const bfd_target *save_targ, *right_targ, *ar_right_targ, *match_targ;
          || (*target)->match_priority > best_match)
        continue;
  
++#if BFD_SUPPORTS_PLUGINS
++      /* Since the plugin target is explicitly specified when a BFD file
++       is opened,  don't check it twice.  */
++      if (*target == &plugin_vec)
++      continue;
++#endif
++
        /* If we already tried a match, the bfd is modified and may
         have sections attached, which will confuse the next
         _bfd_check_format call.  */
diff --cc bfd/linker.c
index d6a996bbe973d49fd96bc6e1c016668d83493cc6,abdf5b0e2645cbc169ade263088e4c597516aad4..9cb5cc4d91dd72146ec74c59faaa4090a1cad463
@@@ -1576,8 -1442,8 +1442,9 @@@ _bfd_generic_link_add_one_symbol (struc
  {
    enum link_row row;
    struct bfd_link_hash_entry *h;
+   struct bfd_link_hash_entry *inh = NULL;
    bfd_boolean cycle;
 +  unsigned int secondary;
  
    BFD_ASSERT (section != NULL);
  
diff --cc bfd/opncls.c
Simple merge
diff --cc bfd/plugin.c
Simple merge
diff --cc bfd/plugin.h
Simple merge
diff --cc bfd/section.c
Simple merge
diff --cc bfd/syms.c
Simple merge
diff --cc binutils/nm.c
Simple merge
Simple merge
Simple merge
index 19ff6f2537ec0e3848f5fd7e2921e5bbe769e9e5,d9c12cc8da619bd53b4a6713fdb99f1e940d875e..368b0f6b37f329d7dbb6fda0643fb4aabb78a2ef
@@@ -1415,9 -1387,6 +1413,9 @@@ dump_relocations (FILE * file
                    name = strtab + psym->st_name;
  
                  len = print_symbol (width, name);
-                   printf (sym_info == symbol_public ? "@@%s" : "@%s", 
 +                if (version_string)
++                  printf (sym_info == symbol_public ? "@@%s" : "@%s",
 +                          version_string);
                  printf ("()%-*s", len <= width ? (width + 1) - len : 1, " ");
                }
              else
              else if (psym->st_name >= strtablen)
                printf (_("<corrupt string table index: %3ld>"), psym->st_name);
              else
 -              print_symbol (22, strtab + psym->st_name);
 +              {
 +                print_symbol (22, strtab + psym->st_name);
 +                if (version_string)
-                   printf (sym_info == symbol_public ? "@@%s" : "@%s", 
++                  printf (sym_info == symbol_public ? "@@%s" : "@%s",
 +                          version_string);
 +              }
  
              if (is_rela)
                {
Simple merge
Simple merge
diff --cc gas/symbols.c
Simple merge
diff --cc gas/symbols.h
Simple merge
Simple merge
index 2968fd0565961b253e1d1c3d5d99b0fd41cfe983,a1159bf4fbc4a12606a3fe71dbc424d8684beb3d..d4c0548b8602d5640b8ccc640b9b17ad2da8d50b
@@@ -1,9 -1,7 +1,9 @@@
-  +.: 0+0 +1 +FUNC +LOCAL +DEFAULT +. function
-  +.: 0+1 +1 +IFUNC +LOCAL +DEFAULT +. indirect_function
-  +.: 0+0 +1 +OBJECT +LOCAL +DEFAULT +. object
-  +.: 0+1 +1 +TLS +LOCAL +DEFAULT +. tls_object
-  +..: 0+2 +1 +NOTYPE +LOCAL +DEFAULT +. notype
-  +.: 0+2 +1 +FUNC +SECOND +DEFAULT +. secondary_function
-  +..: 0+3 +1 +OBJECT +UNIQUE +DEFAULT +. unique_global
-  +..: 0+4 +1 +OBJECT +SECOND +DEFAULT +. secondary_object
-  +..: 0+1 +1 +(COMMON|OBJECT) +GLOBAL +DEFAULT +COM common
+  +.+: 0+0 +1 +FUNC +LOCAL +DEFAULT +. function
+  +.+: 0+1 +1 +IFUNC +LOCAL +DEFAULT +. indirect_function
+  +.+: 0+0 +1 +OBJECT +LOCAL +DEFAULT +. object
+  +.+: 0+1 +1 +TLS +LOCAL +DEFAULT +. tls_object
+  +.+: 0+2 +1 +NOTYPE +LOCAL +DEFAULT +. notype
++ +.+: 0+2 +1 +FUNC +SECOND +DEFAULT +. secondary_function
+  +.+: 0+3 +1 +OBJECT +UNIQUE +DEFAULT +. unique_global
++ +.+: 0+4 +1 +OBJECT +SECOND +DEFAULT +. secondary_object
+  +.+: 0+1 +1 +(COMMON|OBJECT) +GLOBAL +DEFAULT +COM common
Simple merge
Simple merge
index e9cd47975ba42a7c51285e82d185afb28992d54c,d8cb6bfbf35806c4f61f36452c3c221d565f8283..0ef63e4f5a5807bdf1ed94f3ead32e91e66ad3e8
@@@ -16,7 -16,8 +16,9 @@@ LARGE_SECTIONS=ye
  LARGE_BSS_AFTER_BSS=
  SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 24 ? 24 : 0"
  IREL_IN_PLT=
+ # Reuse TINY_READONLY_SECTION which is placed right after .plt section.
+ TINY_READONLY_SECTION=".plt.bnd      ${RELOCATING-0} : { *(.plt.bnd) }"
 +SHARABLE_SECTIONS=yes
  
  if [ "x${host}" = "x${target}" ]; then
    case " $EMULATION_LIBPATH " in
Simple merge
Simple merge
Simple merge
Simple merge
index d54c914e2a69de584eaae9218670e45bab4f83d1,914fc52183cc9bd16dcd5f8cdac0ff4034fcc7fc..23d592c358dd14973e3a452ccf158ddeb63bd52c
@@@ -530,39 -523,38 +523,38 @@@ gld${EMULATION_NAME}_after_allocation (
  /* Final emulation specific call.  */
  
  static void
 -gld${EMULATION_NAME}_finish (void)
 +ppc_finish (void)
  {
+   char *msg = NULL;
+   char *line, *endline;
    /* e_entry on PowerPC64 points to the function descriptor for
       _start.  If _start is missing, default to the first function
       descriptor in the .opd section.  */
-   entry_section = ".opd";
-   if (stub_added)
+   if ((elf_elfheader (link_info.output_bfd)->e_flags & EF_PPC64_ABI) == 1)
+     entry_section = ".opd";
+   if (params.emit_stub_syms < 0)
+     params.emit_stub_syms = 1;
+   if (stub_file != NULL
+       && !link_info.relocatable
+       && !ppc64_elf_build_stubs (&link_info, config.stats ? &msg : NULL))
+     einfo ("%X%P: can not build stubs: %E\n");
+   fflush (stdout);
+   for (line = msg; line != NULL; line = endline)
      {
-       char *msg = NULL;
-       char *line, *endline;
-       if (emit_stub_syms < 0)
-       emit_stub_syms = 1;
-       if (!ppc64_elf_build_stubs (emit_stub_syms, &link_info,
-                                 config.stats ? &msg : NULL))
-       einfo ("%X%P: can not build stubs: %E\n");
-       fflush (stdout);
-       for (line = msg; line != NULL; line = endline)
-       {
-         endline = strchr (line, '\n');
-         if (endline != NULL)
-           *endline++ = '\0';
-         fprintf (stderr, "%s: %s\n", program_name, line);
-       }
-       fflush (stderr);
-       if (msg != NULL)
-       free (msg);
+       endline = strchr (line, '\n');
+       if (endline != NULL)
+       *endline++ = '\0';
+       fprintf (stderr, "%s: %s\n", program_name, line);
      }
+   fflush (stderr);
+   if (msg != NULL)
+     free (msg);
  
    ppc64_elf_restore_symbols (&link_info);
 -  finish_default ();
 +  gld${EMULATION_NAME}_finish ();
  }
  
  
Simple merge
diff --cc ld/ld.texinfo
Simple merge
diff --cc ld/ldfile.c
Simple merge
diff --cc ld/ldlang.c
index a04a11964ac013f2d90c862dc8f4a2b871271ba2,899f71086d897af876bfa03b8e48365122e03a57..342a547aeae00b0d4e46549e034c7d272428f27c
@@@ -1251,11 -1234,9 +1249,10 @@@ lang_init (bfd_boolean object_only
  }
  
  void
 -lang_finish (void)
 +lang_finish (bfd_boolean object_only)
  {
-   bfd_link_hash_table_free (link_info.output_bfd, link_info.hash);
 -  bfd_hash_table_free (&lang_definedness_table);
 +  if (!object_only)
 +    bfd_hash_table_free (&lang_definedness_table);
    output_section_statement_table_free ();
  }
  
@@@ -6716,38 -6721,7 +6743,38 @@@ lang_process (void
          open_input_bfds (statement_list.head, OPEN_BFD_RESCAN);
        }
      }
 +  else
  #endif /* ENABLE_PLUGINS */
-       for (p = link_info.input_bfds; p != (bfd *) NULL; p = p->link_next)
 +    if (link_info.relocatable)
 +    {
 +      /* Check if .gnu_object_only section should be created.  */
 +      bfd *p;
 +      int object_type;
 +
 +      object_type = 0;
++      for (p = link_info.input_bfds; p != (bfd *) NULL; p = p->link.next)
 +      {
 +        object_type |= 1 << p->lto_type;
 +        if ((object_type & (1 << lto_mixed_object)) != 0
 +            || ((object_type
 +                 & (1 << lto_non_ir_object
 +                    | 1 << lto_ir_object))
 +                == (1 << lto_non_ir_object | 1 << lto_ir_object)))
 +          {
 +            link_info.emit_gnu_object_only = TRUE;
 +            break;
 +          }
 +      }
 +
 +      if (verbose
 +        && (cmdline_object_only_file_list.head
 +            || cmdline_object_only_archive_list.head))
 +      {
 +        info_msg (_("Object-only input files:\n "));
 +        print_cmdline_list (cmdline_object_only_file_list.head);
 +        print_cmdline_list (cmdline_object_only_archive_list.head);
 +      }
 +    }
  
    link_info.gc_sym_list = &entry_symbol;
    if (entry_symbol.name == NULL)
diff --cc ld/ldlang.h
index ad3f255cfa585335d42fccf4fe5080cf49bdd645,5f6faae5bc59dde28623dd5bf55d73d42057359c..0b334e0c0a46d986b19882762bafeb195911f0a6
@@@ -515,10 -520,12 +520,12 @@@ extern lang_statement_list_type input_f
  extern int lang_statement_iteration;
  extern struct asneeded_minfo **asneeded_list_tail;
  
+ extern void (*output_bfd_hash_table_free_fn) (struct bfd_link_hash_table *);
  extern void lang_init
 -  (void);
 +  (bfd_boolean);
  extern void lang_finish
 -  (void);
 +  (bfd_boolean);
  extern lang_memory_region_type * lang_memory_region_lookup
    (const char * const, bfd_boolean);
  extern void lang_memory_region_alias
diff --cc ld/ldlex.h
Simple merge
diff --cc ld/ldmain.c
index 9499912a689a525a05cd48c19ab0cf82f6f57f49,bc24957b2a287b17fa624e15d44745697e2f7bda..e7a4296b8605e92289d2e6e1eb91504cd766c560
@@@ -403,8 -432,15 +410,15 @@@ main (int argc, char **argv
      output_cref (config.map_file != NULL ? config.map_file : stdout);
    if (nocrossref_list != NULL)
      check_nocrossrefs ();
+ #if 0
+   {
+     struct bfd_link_hash_entry * h;
  
 -  lang_finish ();
+     h = bfd_link_hash_lookup (link_info.hash, "__image_base__", 0,0,1);
+     fprintf (stderr, "lookup = %p val %lx\n", h, h ? h->u.def.value : 1);
+   }
+ #endif
 +  lang_finish (FALSE);
  
    /* Even if we're producing relocatable output, some non-fatal errors should
       be reported in the exit status.  (What non-fatal errors, if any, do we
diff --cc ld/ldmain.h
Simple merge
diff --cc ld/lexsup.c
Simple merge
diff --cc ld/plugin.c
Simple merge
diff --cc ld/plugin.h
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index da5f8e455882ea4ea8ffde4be5f0ee5739791a5a,b55856a2462580ce3e3262e23d647c992130951f..00a4983c448591be546ca2eb9dfc447424f35099
@@@ -224,15 -240,12 +240,21 @@@ set build_tests 
    {"Build libpr2404b.a"
     "" ""
     {pr2404b.c} {} "libpr2404b.a"}
+   {"Build rdynamic-1"
+    "-rdynamic -Wl,--gc-sections" "-ffunction-sections"
+    {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"}
+   {"Build dynamic-1"
+    "-Wl,--dynamic-list,dynamic-1.syms -Wl,--gc-sections" "-ffunction-sections"
+    {dynamic-1.c} {{readelf {-s} dynamic-1.rd}} "dynamic-1"}
 +  {"Build libpr16496a.so"
 +   "-shared -Wl,--version-script=pr16496a.map" "-fPIC"
 +   {pr16496a.c} {} "libpr16496a.so"}
 +  {"Build libpr16496b.a"
 +   "" "-fPIC"
 +   {pr16496b.c} {} "libpr16496b.a"}
 +  {"Build libpr16496b.so"
 +   "-shared tmpdir/pr16496b.o tmpdir/libpr16496a.so" ""
 +   {dummy.c} {{objdump {-R} pr16496b.od}} "libpr16496b.so"}
  }
  
  run_cc_link_tests $build_tests
index 7972272b973c417c7718ea0f9437bb49e2d81503,031752ddf15f049583d59baba8fd5362697414f4..e6b768c6c21e0ec9549255f019ecb28b76b01830
@@@ -39,282 -38,291 +38,324 @@@ proc restore_notify { } 
    set CXXFLAGS "$saved_CXXFLAGS"
  }
  
- # Simple LTO tests and generate input files for complex LTO tests.
- set lto_link_tests {
-   {"LTO 1"
-    "-O2 -flto -fuse-linker-plugin" "-flto -fuse-linker-plugin"
-    {lto-1a.c lto-1b.c} {} "lto-1.exe"}
-   {"Build libdummy.a 2"
-    "" "-O2 -flto -fuse-linker-plugin"
-    {lto-2.c} {} "libdummy.a"}
-   {"LTO 2"
-    "-static -O2 -flto -fuse-linker-plugin tmpdir/lto-2.o -lm" ""
-    {dummy.c} {} "lto-2.exe"}
-   {"Build libdummy.a 3a"
-    "" "-flto"
-    {lto-3a.c} {} "libdummy.a"}
-   {"Build libdummy.a 3c"
-    "" "-O2"
-    {lto-3c.c} {} "libdummy.a"}
-   {"Build liblto-3.a"
-    "" "-flto -ffat-lto-objects"
-    {lto-3b.c} {} "liblto-3.a"}
-   {"Build libdummy.a 4a"
-    "" "-flto"
-    {lto-4a.c} {} "libdummy.a"}
-   {"Build libdummy.a 4b"
-    "" "-O2"
-    {lto-4b.c} {} "libdummy.a"}
-   {"Build libdummy.a 4c"
-    "" "-O2"
-    {lto-4c.c} {} "libdummy.a"}
-   {"Build libdummy.a 5a"
-    "" "-flto"
-    {lto-5a.c} {} "libdummy.a"}
-   {"Build libdummy.a 5b"
-    "" "-flto"
-    {lto-5b.c} {} "libdummy.a"}
-   {"LTO 6"
-    "-O2 -flto -fuse-linker-plugin" ""
-    {lto-6.c} {} "lto-6.exe" "c"}
-   {"Build libdummy.a PR ld/12365"
-    "" "-flto -O2"
-    {pr12365a.c pr12365b.c pr12365c.c} {} "libdummy.a"}
-   {"Build libdummy.a 9"
-    "" "-O2 -finline -flto"
-    {lto-9.cc} {} "libdummy.a"}
-   {"Build libdummy.a 10a"
-    "" "-O2"
-    {lto-10a.c} {} "libdummy.a"}
-   {"Build libdummy.a 10b"
-    "" "-O2 -flto"
-    {lto-10b.c} {} "libdummy.a"}
-   {"Build libdummy.a 11a"
-    "" "-O -flto"
-    {lto-11a.c} {} "libdummy.a"}
-   {"Build libdummy.a 11b"
-    "" "-O -flto"
-    {lto-11b.c} {} "libdummy.a"}
-   {"Build libdummy.a 11c"
-    "" "-O"
-    {lto-11c.c} {} "libdummy.a"}
-   {"Build liblto-12.a"
-    "" "-O2 -flto"
-    {lto-12c.c} {} "liblto-12.a"}
-   {"Build libdummy.a 12"
-    "" "-O2 -flto"
-    {lto-12a.c lto-12b.c} {} "libdummy.a"}
-   {"Build libdummy.a 13"
-    "" "-O2 -flto"
-    {lto-13a.c lto-13b.c} {} "libdummy.a"}
-   {"Build liblto-13.a"
-    "" "-O2"
-    {lto-13c.c} {} "liblto-13.a"}
-   {"Build libdummy.a 14a"
-    "" "-flto"
-    {lto-14a.c lto-14b.c} {} "libdummy.a"}
-   {"Build liblto-14.a"
-    "" "-flto"
-    {lto-14c.c} {} "liblto-14.a"}
-   {"Build libdummy.a 15a"
-    "" "-flto"
-    {lto-15a.c} {} "libdummy.a"}
-   {"Build liblto-15.a"
-    "" "-flto"
-    {lto-15b.c} {} "liblto-15.a"}
-   {"PR ld/12696"
-    "-O2 -flto -fuse-linker-plugin -r -nostdlib" "-O2 -flto"
-    {pr12696-1.cc} {} "pr12696-1r.o" "c"}
-   {"Build libdummy.a PR ld/12758"
-    "" ""
-    {pr12758a.s} {} "libdummy.a"}
-   {"Build libpr12758.a"
-    "" "-flto -O2 -ffat-lto-objects"
-    {pr12758b.c} {} "libpr12758.a"}
-   {"PR ld/12758"
-    "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" ""
-    {dummy.c} {} "pr12758.exe"}
-   {"Build libdummy.a PR ld/12760"
-    "" ""
-    {pr12760a.c} {} "libdummy.a"}
-   {"Build libpr12760.a"
-    "" "-flto -O2 -ffat-lto-objects"
-    {pr12760b.c} {} "libpr12760.a"}
-   {"PR ld/12760"
-    "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12760a.o -Wl,--start-group tmpdir/libpr12760.a -Wl,--end-group" ""
-    {dummy.c} {} "pr12760.exe" "c" "warning: Bad bar"}
-   {"Build libpr13183.a"
-    "-T" "-flto -O2 -ffat-lto-objects"
-    {pr13183a.c} {} "libpr13183.a"}
-   {"Build libdummy.a PR ld/13183"
-    "" "-flto -O2"
-    {pr13183b.c} {} "libdummy.a"}
-   {"Build libdummy.a PR ld/13201"
-    "" "-flto -O2"
-    {pr13201.c} {} "libdummy.a"}
-   {"PR ld/13287"
-    "-flto -fuse-linker-plugin -Wl,--as-needed" "-flto"
-    {pr13287.cc} {} "pr13287.exe" "c++"}
-   {"PR ld/15323"
-    "" "-O2"
-    {pr15323a.c} {} "libdummy.a" "c"}
+ set plugin_names {
+     liblto_plugin.so
+     liblto_plugin-0.dll
+     cyglto_plugin-0.dll
+ }
+ set plug_opt ""
+ foreach plug $plugin_names {
+     set plug_so [run_host_cmd $CC "--print-prog-name $plug"]
+     if { $plug_so eq $plug } then {
+       set plug_so [run_host_cmd $CC "--print-file-name $plug"]
+     }
+     if { $plug_so ne $plug } then {
+       set plug_opt "--plugin $plug_so"
+       break
+     }
+ }
+ set lto_fat ""
+ if { [check_lto_fat_available] } {
+   set lto_fat "-ffat-lto-objects"
  }
  
+ # Simple LTO tests and generate input files for complex LTO tests.
+ set lto_link_tests [list \
+   [list "LTO 1" \
+    "-O2 -flto -fuse-linker-plugin" "-flto -fuse-linker-plugin" \
+    {lto-1a.c lto-1b.c} {} "lto-1.exe"] \
+   [list "Compile 2" \
+    "" "-O2 -flto -fuse-linker-plugin" \
+    {lto-2.c} {} ""] \
+   [list "LTO 2" \
+    "-static -O2 -flto -fuse-linker-plugin tmpdir/lto-2.o -lm" "" \
+    {dummy.c} {} "lto-2.exe"] \
+   [list "Compile 3a" \
+    "" "-flto" \
+    {lto-3a.c} {} ""] \
+   [list "Compile 3c" \
+    "" "-O2" \
+    {lto-3c.c} {} ""] \
+   [list "Build liblto-3.a" \
+    "" "-flto $lto_fat" \
+    {lto-3b.c} {} "liblto-3.a"] \
++  [list "Compile 4a" \
++   "" "-flto $lto_fat" \
++   {lto-4a.c} {} ""] \
++  [list "Compile 4b" \
++   "" "-O2" \
++   {lto-4b.c} {} ""] \
++  [list "Compile 4c" \
++   "" "-O2" \
++   {lto-4c.c} {} ""] \
+   [list "Compile 5a" \
+    "" "-flto $lto_fat" \
+    {lto-5a.c} {} ""] \
+   [list "Compile 5b" \
+    "" "-flto $lto_fat" \
+    {lto-5b.c} {} ""] \
+   [list "LTO 6" \
+    "-O2 -flto -fuse-linker-plugin" "" \
+    {lto-6.c} {} "lto-6.exe" "c"] \
++  [list "Compile PR ld/12365" \
++   "" "-flto -O2 $lto_fat" \
++   {pr12365a.c pr12365b.c pr12365c.c} {} ""] \
+   [list "Compile 9" \
+    "" "-O2 -finline -flto" \
+    {lto-9.cc} {} "" "c++"] \
++  [list "Compile 10a" \
++   "" "-O2" \
++   {lto-10a.c} {} ""] \
++  [list "Compile 10b" \
++   "" "-O2 -flto $lto_fat" \
++   {lto-10b.c} {} ""] \
+   [list "Compile 11a" \
+    "" "-O -flto" \
+    {lto-11a.c} {} ""] \
+   [list "Compile 11b" \
+    "" "-O -flto" \
+    {lto-11b.c} {} ""] \
+   [list "Compile 11c" \
+    "" "-O" \
+    {lto-11c.c} {} ""] \
+   [list "Build liblto-12.a" \
+    "$plug_opt" "-O2 -flto" \
+    {lto-12c.c} {} "liblto-12.a"] \
+   [list "Compile 12" \
+    "" "-O2 -flto" \
+    {lto-12a.c lto-12b.c} {} ""] \
+   [list "Compile 13" \
+    "" "-O2 -flto" \
+    {lto-13a.c lto-13b.c} {} ""] \
+   [list "Build liblto-13.a" \
+    "" "-O2" \
+    {lto-13c.c} {} "liblto-13.a"] \
+   [list "Compile 14a" \
+    "" "-flto" \
+    {lto-14a.c lto-14b.c} {} ""] \
+   [list "Build liblto-14.a" \
+    "$plug_opt" "-flto" \
+    {lto-14c.c} {} "liblto-14.a"] \
+   [list "Compile 15a" \
+    "" "-flto" \
+    {lto-15a.c} {} ""] \
+   [list "Build liblto-15.a" \
+    "$plug_opt" "-flto" \
+    {lto-15b.c} {} "liblto-15.a"] \
+   [list "PR ld/12696" \
+    "-O2 -flto -fuse-linker-plugin -r -nostdlib" "-O2 -flto" \
+    {pr12696-1.cc} {} "pr12696-1r.o" "c++"] \
+   [list "Compile PR ld/12758" \
+    "" "" \
+    {pr12758a.s} {} ""] \
+   [list "Build libpr12758.a" \
+    "" "-flto -O2 $lto_fat" \
+    {pr12758b.c} {} "libpr12758.a"] \
+   [list "PR ld/12758" \
+    "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" "" \
+    {dummy.c} {} "pr12758.exe"] \
+   [list "Compile PR ld/12760" \
+    "" "-g -O0" \
+    {pr12760a.c} {} ""] \
+   [list "Build libpr12760.a" \
+    "" "-flto -O2 $lto_fat" \
+    {pr12760b.c} {} "libpr12760.a"] \
+   [list "PR ld/12760" \
+    "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12760a.o -Wl,--start-group tmpdir/libpr12760.a -Wl,--end-group" "" \
+    {dummy.c} {} "pr12760.exe" "c" "pr12760a.c:6: warning: Bad bar"] \
+   [list "Build libpr13183.a" \
+    "-T" "-flto -O2 $lto_fat" \
+    {pr13183a.c} {} "libpr13183.a"] \
+   [list "Compile PR ld/13183" \
+    "" "-flto -O2" \
+    {pr13183b.c} {} ""] \
+   [list "Compile PR ld/13201" \
+    "" "-flto -O2" \
+    {pr13201.c} {} ""] \
+   [list "PR ld/13287" \
+    "-flto -fuse-linker-plugin -Wl,--as-needed" "-flto" \
+    {pr13287.cc} {} "pr13287.exe" "c++"] \
+   [list "PR ld/15323" \
+    "" "-O2" \
+    {pr15323a.c} {} "" "c"] \
+   [list "Compile(1) PR ld/pr16846" \
+    "" "-flto" \
+    {pr16846a.c pr16846b.c} {} ""] \
+   [list "Compile(2) PR ld/pr16846" \
+    "" "" \
+    {pr16846c.c} {} ""] \
+   [list "PR ld/pr16846(1)" \
+    "-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846b.o tmpdir/pr16846c.o" "" \
+    {dummy.c} {} "pr16846a.exe"] \
+   [list "PR ld/pr16846(2)" \
+    "-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846c.o tmpdir/pr16846b.o" "" \
+    {dummy.c} {} "pr16846b.exe"] \
+ ]
  if { [at_least_gcc_version 4 7] } {
-     set lto_link_tests [concat $lto_link_tests {
-       {"Build libdummy.a PR ld/12942 (1)"
-        "" "-flto -O2"
-        {pr12942a.cc pr12942c.cc} {} "libdummy.a" "c++"}
-       {"Build libdummy.a PR ld/12942 (2)"
-        "" "-O0"
-        {pr12942b.cc} {} "libdummy.a" "c++"}
-     }]
+     set lto_link_tests [concat $lto_link_tests [list \
+       [list "Compile PR ld/12942 (1)" \
+        "" "-flto -O2" \
+        {pr12942a.cc pr12942c.cc} {} "" "c++"] \
+       [list "Compile PR ld/12942 (2)" \
+        "" "-O0" \
+        {pr12942b.cc} {} "" "c++"] \
+     ]]
  }
  
  # Generate input files for complex LTO tests for ELF.
- set lto_link_elf_tests {
-   {"Build libdummy.a 7"
-    "" "-flto -O2"
-    {lto-7a.c lto-7b.c lto-7c.c} {} "libdummy.a"}
-   {"Build liblto-7.so"
-    "-shared" "-O2 -fpic"
-    {lto-7d.c} {} "liblto-7.so" "c"}
-   {"Build libdummy.a 8a"
-    "" "-O2"
-    {lto-8a.c} {} "libdummy.a"}
-   {"Build libdummy.a 8b"
-    "" "-flto -O2"
-    {lto-8b.c} {} "libdummy.a"}
-   {"Build liblto-17a.so"
-    "-shared -O2 -fpic -flto -fuse-linker-plugin" "-O2 -fpic -flto"
-    {lto-17a.c} {{"nm" {} "lto-17a.d"}} "liblto-17a.so" "c"}
-   {"Build liblto-17b.so 1"
-    "-shared -O2 -fpic -flto -fuse-linker-plugin tmpdir/lto-17a.o" "-O2 -fpic -flto"
-    {lto-17b.c} {{"nm" {} "lto-17b-1.d"}} "liblto-17b.so"}
-   {"Build liblto-17b.so 2"
-    "-shared -O2 -fpic -flto -fuse-linker-plugin tmpdir/lto-17a.o" "-O2 -fpic -flto"
-    {lto-17b.c} {{"nm" {} "lto-17b-2.d"}} "liblto-17b.so"}
-   {"PR ld/12982"
-    "-O2 -flto -fuse-linker-plugin" "-O2 -flto"
-    {pr12982.c} {{"readelf" {-l --wide} "pr12982.d"}} "pr12982.exe"}
-   {"PR ld/12975"
-    "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib -Wl,-version-script,pr12975.t" "-O2 -flto"
-    {pr12975.c} {{"readelf" {-s --wide} "pr12975.d"}} "pr12975.so" "c"}
-   {"PR ld/13229"
-    "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -finline -fno-early-inlining -flto"
-    {pr13229.cc} {{"readelf" {-s --wide} "pr13229.d"}} "pr13229.so" "c++"}
-   {"PR ld/13244"
-    "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -fno-early-inlining -flto"
-    {pr13244.c} {{"readelf" {-s --wide} "pr13244.d"}} "pr13244.so" "c"}
-   {"Build libpr15146a.a"
-    "" "-flto -O2"
-    {pr15146a.c} {} "lib15146a.a"}
-   {"Build pr15146b.so"
-    "-shared" "-O2 -fpic"
-    {pr15146b.c} {} "pr15146b.so" "c"}
-   {"Build pr15146c.so"
-    "-shared -Wl,--no-as-needed tmpdir/pr15146b.so" "-O2 -fpic"
-    {pr15146c.c} {} "pr15146c.so" "c"}
-   {"PR ld/15146 (1)"
-    "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146a.o tmpdir/pr15146c.so" ""
-    {dummy.c} {{"readelf" {-d} "pr15146.d"}} "pr15146a.exe"}
-   {"Build libpr15146d.a"
-    "" "-flto -O2"
-    {pr15146d.c} {} "lib15146d.a"}
-   {"Build libpr15146d.a"
-    "" "-flto -O2"
-    {pr15146d.c} {} "lib15146d.a"}
-   {"PR ld/14918"
-    "-flto" "-flto"
-    {pr14918.c} {{"readelf" {-d --wide} "pr14918.d"}} "pr14918.exe" "c"}
- }
+ set lto_link_elf_tests [list \
+   [list "Compile 7" \
+    "" "-flto -O2" \
+    {lto-7a.c lto-7b.c lto-7c.c} {} ""] \
+   [list "Build liblto-7.so" \
+    "-shared" "-O2 -fpic" \
+    {lto-7d.c} {} "liblto-7.so" "c"] \
+   [list "Compile 8a" \
+    "" "-O2" \
+    {lto-8a.c} {} ""] \
+   [list "Compile 8b" \
+    "" "-flto -O2" \
+    {lto-8b.c} {} ""] \
+   [list "Build liblto-17a.so" \
+    "-shared -O2 -fpic -flto -fuse-linker-plugin" "-O2 -fpic -flto" \
+    {lto-17a.c} {{"nm" {} "lto-17a.d"}} "liblto-17a.so" "c"] \
+   [list "Build liblto-17b.so 1" \
+    "-shared -O2 -fpic -flto -fuse-linker-plugin tmpdir/lto-17a.o" "-O2 -fpic -flto" \
+    {lto-17b.c} {{"nm" {} "lto-17b-1.d"}} "liblto-17b.so"] \
+   [list "Build liblto-17b.so 2" \
+    "-shared -O2 -fpic -flto -fuse-linker-plugin tmpdir/lto-17a.o" "-O2 -fpic -flto" \
+    {lto-17b.c} {{"nm" {} "lto-17b-2.d"}} "liblto-17b.so"] \
+   [list "PR ld/12982" \
+    "-O2 -flto -fuse-linker-plugin" "-O2 -flto" \
+    {pr12982.c} {{"readelf" {-l --wide} "pr12982.d"}} "pr12982.exe"] \
+   [list "PR ld/12975" \
+    "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib -Wl,-version-script,pr12975.t" "-O2 -flto" \
+    {pr12975.c} {{"readelf" {-s --wide} "pr12975.d"}} "pr12975.so" "c"] \
+   [list "PR ld/13229" \
+    "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -finline -fno-early-inlining -flto" \
+    {pr13229.cc} {{"readelf" {-s --wide} "pr13229.d"}} "pr13229.so" "c++"] \
+   [list "PR ld/13244" \
+    "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -fno-early-inlining -flto" \
+    {pr13244.c} {{"readelf" {-s --wide} "pr13244.d"}} "pr13244.so" "c"] \
+   [list "Build libpr15146a.a" \
+    "$plug_opt" "-flto -O2" \
+    {pr15146a.c} {} "lib15146a.a"] \
+   [list "Build pr15146b.so" \
+    "-shared" "-O2 -fpic" \
+    {pr15146b.c} {} "pr15146b.so" "c"] \
+   [list "Build pr15146c.so" \
+    "-shared -Wl,--no-as-needed tmpdir/pr15146b.so" "-O2 -fpic" \
+    {pr15146c.c} {} "pr15146c.so" "c"] \
+   [list "PR ld/15146 (1)" \
+    "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146a.o tmpdir/pr15146c.so" "" \
+    {dummy.c} {{"readelf" {-d} "pr15146.d"}} "pr15146a.exe"] \
+   [list "Build libpr15146d.a" \
+    "$plug_opt" "-flto -O2" \
+    {pr15146d.c} {} "lib15146d.a"] \
+   [list "Build libpr16746a.a" \
+    "" "" \
+    {pr16746a.c pr16746b.c} {} "lib15146a.a"] \
+   [list "Build libpr16746b.a" \
+    "$plug_opt" "-O2 -flto" \
+    {pr16746c.c pr16746d.c} {} "lib15146b.a"] \
+   [list "PR ld/16746 (1)" \
+    "-O2 -flto -fuse-linker-plugin tmpdir/pr16746a.o tmpdir/pr16746c.o" "-O2 -flto" \
+    {dummy.c} {} "pr16746a.exe"] \
+   [list "PR ld/16746 (2)" \
+    "-O2 -flto -fuse-linker-plugin tmpdir/pr16746c.o tmpdir/pr16746a.o" "-O2 -flto" \
+    {dummy.c} {} "pr16746b.exe"] \
++  [list "PR ld/14918" \
++   "-flto" "-flto" \
++   {pr14918.c} {{"readelf" {-d --wide} "pr14918.d"}} "pr14918.exe" "c"] \
+ ]
  
  # Check final symbols in executables.
- set lto_link_symbol_tests {
-   {"LTO 3 symbol"
-    "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/liblto-3.a" ""
-    {dummy.c} {{"nm" {} "lto-3.d"}} "lto-3.exe" "c"}
-   {"LTO 5 symbol"
-    "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" ""
-    {dummy.c} {{"nm" {} "lto-5.d"}} "lto-5.exe" "c"}
-   {"LTO 9 symbol"
-    "-O2 -flto -fuse-linker-plugin tmpdir/lto-9.o" ""
-    {dummy.c} {{"nm" {-C} "lto-9.d"}} "lto-9.exe" "c++"}
-   {"LTO 16a symbol"
-    "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin" "-flto"
-    {lto-16a.c} {{"nm" {} "lto-16a.d"}} "lto-16.exe" "c"}
-   {"LTO 16b symbol"
-    "-O2 -Wl,-e,foo -u bar -nostdlib -flto -fuse-linker-plugin" "-flto"
-    {lto-16a.c lto-16b.c} {{"nm" {} "lto-16b.d"}} "lto-16b.exe" "c"}
-   {"PR ld/13183"
-    "-O2 -flto -fuse-linker-plugin tmpdir/pr13183b.o tmpdir/libpr13183.a" ""
-    {dummy.c} {{"nm" {} "pr13183.d"}} "pr13183.exe" "c"}
- }
+ set lto_link_symbol_tests [list \
+   [list "LTO 3 symbol" \
+    "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/liblto-3.a" "" \
+    {dummy.c} {{"nm" {} "lto-3.d"}} "lto-3.exe" "c"] \
+   [list "LTO 5 symbol" \
+    "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" "" \
+    {dummy.c} {{"nm" {} "lto-5.d"}} "lto-5.exe" "c"] \
+   [list "LTO 9 symbol" \
+    "-O2 -flto -fuse-linker-plugin tmpdir/lto-9.o" "" \
+    {dummy.c} {{"nm" {-C} "lto-9.d"}} "lto-9.exe" "c++"] \
+   [list "LTO 16a symbol" \
+    "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin" "-flto" \
+    {lto-16a.c} {{"nm" {} "lto-16a.d"}} "lto-16.exe" "c"] \
+   [list "LTO 16b symbol" \
+    "-O2 -Wl,-e,foo -u bar -nostdlib -flto -fuse-linker-plugin" "-flto" \
+    {lto-16a.c lto-16b.c} {{"nm" {} "lto-16b.d"}} "lto-16b.exe" "c"] \
+   [list "PR ld/13183" \
+    "-O2 -flto -fuse-linker-plugin tmpdir/pr13183b.o tmpdir/libpr13183.a" "" \
+    {dummy.c} {{"nm" {} "pr13183.d"}} "pr13183.exe" "c"] \
+ ]
  
  # LTO run-time tests.
- set lto_run_tests {
-   {"LTO 3a"
-    "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/liblto-3.a" ""
-    {dummy.c} "lto-3b.exe" "lto-3.out" "" "c"}
-   {"LTO 3b"
-    "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/lto-3.o" ""
-    {dummy.c} "lto-3c.exe" "lto-3.out" "" "c"}
-   {"LTO 3c"
-    "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o -Wl,--whole-archive tmpdir/liblto-3.a -Wl,--no-whole-archive tmpdir/liblto-3.a" ""
-    {dummy.c} "lto-3d.exe" "lto-3.out" "" "c"}
-   {"LTO 4a"
-    "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-a.o" ""
-    {dummy.c} "lto-4a.exe" "lto-4.out" "" "c"}
-   {"LTO 4c"
-    "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-c.o" ""
-    {dummy.c} "lto-4c.exe" "lto-4.out" "" "c"}
-   {"LTO 4d"
-    "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-d.o" ""
-    {dummy.c} "lto-4d.exe" "lto-4.out" "" "c"}
-   {"LTO 5"
-    "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" ""
-    {dummy.c} "lto-5.exe" "lto-5.out" "" "c"}
-   {"LTO 10"
-    "-O2 -flto -fuse-linker-plugin tmpdir/lto-10.o" ""
-    {dummy.c} "lto-10.exe" "lto-10.out" "" "c"}
-   {"LTO 11"
-    "-O -flto -fuse-linker-plugin tmpdir/liblto-11.a" ""
-    {dummy.c} "lto-11.exe" "lto-11.out" "" "c"}
-   {"LTO 12a"
-    "-O -flto -fuse-linker-plugin tmpdir/lto-12a.o tmpdir/liblto-12.a tmpdir/lto-12b.o" ""
-    {dummy.c} "lto-12a.exe" "lto-12.out" "" "c"}
-   {"LTO 12b"
-    "-O -flto -fuse-linker-plugin tmpdir/lto-12a.o tmpdir/lto-12b.o tmpdir/liblto-12.a" ""
-    {dummy.c} "lto-12b.exe" "lto-12.out" "" "c"}
-   {"LTO 13"
-    "-O -flto -fuse-linker-plugin tmpdir/lto-13a.o tmpdir/liblto-13.a tmpdir/lto-13b.o" ""
-    {dummy.c} "lto-13.exe" "lto-13.out" "" "c"}
-   {"LTO 14"
-    "-O2 -flto -fuse-linker-plugin tmpdir/lto-14a.o -Wl,--whole-archive tmpdir/liblto-14.a -Wl,--no-whole-archive tmpdir/lto-14b.o" ""
-    {dummy.c} "lto-14.exe" "lto-14.out" "" "c"}
-   {"LTO 15"
-    "-O2 -flto -fuse-linker-plugin -Wl,--start-group tmpdir/liblto-15.a tmpdir/lto-15a.o -Wl,--end-group" ""
-    {dummy.c} "lto-15.exe" "lto-15.out" "" "c"}
-   {"PR ld/13066"
-    "-O2 -flto -fuse-linker-plugin" ""
-    {pr13066.cc} "pr13066.exe" "pr13066.out" "" "c++"}
-   {"PR ld/13201"
-    "-O2 -flto -fuse-linker-plugin -Wl,--as-needed tmpdir/pr13201.o -lm" ""
-    {dummy.c} "pr13201.exe" "pr13201.out" "" "c"}
-   {"PR ld/15323"
-    "-O2 -flto -fuse-linker-plugin tmpdir/pr15323a.o" ""
-    {pr15323b.c} "pr15323.exe" "pr15323.out" "-flto -O2" "c"}
- }
+ set lto_run_tests [list \
+   [list "LTO 3a" \
+    "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/liblto-3.a" "" \
+    {dummy.c} "lto-3b.exe" "lto-3.out" "" "c"] \
+   [list "LTO 3b" \
+    "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o tmpdir/lto-3.o" "" \
+    {dummy.c} "lto-3c.exe" "lto-3.out" "" "c"] \
+   [list "LTO 3c" \
+    "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o -Wl,--whole-archive tmpdir/liblto-3.a -Wl,--no-whole-archive tmpdir/liblto-3.a" "" \
+    {dummy.c} "lto-3d.exe" "lto-3.out" "" "c"] \
++  [list "LTO 4a" \
++   "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-a.o" "" \
++   {dummy.c} "lto-4a.exe" "lto-4.out" "" "c"] \
++  [list "LTO 4c" \
++   "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-c.o" "" \
++   {dummy.c} "lto-4c.exe" "lto-4.out" "" "c"] \
++  [list "LTO 4d" \
++   "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-d.o" "" \
++   {dummy.c} "lto-4d.exe" "lto-4.out" "" "c"] \
+   [list "LTO 5" \
+    "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" "" \
+    {dummy.c} "lto-5.exe" "lto-5.out" "" "c"] \
++  [list "LTO 10" \
++   "-O2 -flto -fuse-linker-plugin tmpdir/lto-10.o" "" \
++   {dummy.c} "lto-10.exe" "lto-10.out" "" "c"] \
+   [list "LTO 11" \
+    "-O -flto -fuse-linker-plugin tmpdir/liblto-11.a" "" \
+    {dummy.c} "lto-11.exe" "lto-11.out" "" "c"] \
+   [list "LTO 12a" \
+    "-O -flto -fuse-linker-plugin tmpdir/lto-12a.o tmpdir/liblto-12.a tmpdir/lto-12b.o" "" \
+    {dummy.c} "lto-12a.exe" "lto-12.out" "" "c"] \
+   [list "LTO 12b" \
+    "-O -flto -fuse-linker-plugin tmpdir/lto-12a.o tmpdir/lto-12b.o tmpdir/liblto-12.a" "" \
+    {dummy.c} "lto-12b.exe" "lto-12.out" "" "c"] \
+   [list "LTO 13" \
+    "-O -flto -fuse-linker-plugin tmpdir/lto-13a.o tmpdir/liblto-13.a tmpdir/lto-13b.o" "" \
+    {dummy.c} "lto-13.exe" "lto-13.out" "" "c"] \
+   [list "LTO 14" \
+    "-O2 -flto -fuse-linker-plugin tmpdir/lto-14a.o -Wl,--whole-archive tmpdir/liblto-14.a -Wl,--no-whole-archive tmpdir/lto-14b.o" "" \
+    {dummy.c} "lto-14.exe" "lto-14.out" "" "c"] \
+   [list "LTO 15" \
+    "-O2 -flto -fuse-linker-plugin -Wl,--start-group tmpdir/liblto-15.a tmpdir/lto-15a.o -Wl,--end-group" "" \
+    {dummy.c} "lto-15.exe" "lto-15.out" "" "c"] \
+   [list "PR ld/13066" \
+    "-O2 -flto -fuse-linker-plugin" "" \
+    {pr13066.cc} "pr13066.exe" "pr13066.out" "" "c++"] \
+   [list "PR ld/13201" \
+    "-O2 -flto -fuse-linker-plugin -Wl,--as-needed tmpdir/pr13201.o -lm" "" \
+    {dummy.c} "pr13201.exe" "pr13201.out" "" "c"] \
+   [list "PR ld/15323" \
+    "-O2 -flto -fuse-linker-plugin tmpdir/pr15323a.o" "" \
+    {pr15323b.c} "pr15323.exe" "pr15323.out" "-flto -O2" "c"] \
+ ]
  
  if { [at_least_gcc_version 4 7] } {
-     set lto_run_tests [concat $lto_run_tests {
-       {"PR ld/12942 (1)"
-        "-O2 -flto -fuse-linker-plugin tmpdir/pr12942a.o tmpdir/pr12942b.o" ""
-        {dummy.c} "pr12942a.exe" "pr12942.out" "" "c++"}
-       {"PR ld/12942 (2)"
-        "-O2 -flto -fuse-linker-plugin tmpdir/pr12942a.o tmpdir/pr12942c.o" ""
-        {dummy.c} "pr12942c.exe" "pr12942.out" "" "c++"}
-     }]
+     set lto_run_tests [concat $lto_run_tests [list \
+       [list "PR ld/12942 (1)" \
+        "-O2 -flto -fuse-linker-plugin tmpdir/pr12942a.o tmpdir/pr12942b.o" "" \
+        {dummy.c} "pr12942a.exe" "pr12942.out" "" "c++"] \
+       [list "PR ld/12942 (2)" \
+        "-O2 -flto -fuse-linker-plugin tmpdir/pr12942a.o tmpdir/pr12942c.o" "" \
+        {dummy.c} "pr12942c.exe" "pr12942.out" "" "c++"] \
+     ]]
  }
  
  # LTO run-time tests for ELF
@@@ -342,20 -350,25 +383,34 @@@ if { [is_elf_format] && [check_lto_shar
      } {
        fail $testname
      }
+     set testname "PR ld/16746 (3)"
+     set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746b.o tmpdir/pr16746d.o"]
+     if { [ regexp "warning: foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
+       pass $testname
+     } {
+       fail $testname
+     }
+     set testname "PR ld/16746 (4)"
+     set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746d.o tmpdir/pr16746b.o"]
+     if { [ regexp "warning: foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
+       pass $testname
+     } {
+       fail $testname
+     }
  }
  
 +set testname "Build liblto-4.a"
 +remote_file host delete "tmpdir/liblto-4.a"
 +set catch_output [run_host_cmd "$ar" "rc tmpdir/liblto-4.a tmpdir/lto-4a.o tmpdir/lto-4b.o tmpdir/lto-4c.o"]
 +if {![string match "" $catch_output]} {
 +    unresolved $testname
 +    restore_notify
 +    return
 +}
 +
  set testname "Build liblto-11.a"
  remote_file host delete "tmpdir/liblto-11.a"
- set catch_output [run_host_cmd "$ar" "rc tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
+ set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
  if {![string match "" $catch_output]} {
      unresolved $testname
      restore_notify
  
  if { [at_least_gcc_version 4 7] } {
      # Check expected LTO linker errors.
-     set exec_output [run_host_cmd "$CC" "$gcc_gas_flag $gcc_ld_flag -O2 -flto -fuse-linker-plugin tmpdir/pr12365a.o tmpdir/pr12365b.o tmpdir/pr12365c.o"]
 +    set testname "PR ld/12365"
++    set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin tmpdir/pr12365a.o tmpdir/pr12365b.o tmpdir/pr12365c.o"]
 +    if { [ regexp "undefined reference to `my_bcopy'" $exec_output ] } {
 +      pass $testname
 +    } {
 +      fail $testname
 +    }
      set testname "PR ld/12942 (3)"
-     set exec_output [run_host_cmd "$CXX" "$gcc_gas_flag $gcc_ld_flag -O2 -flto -fuse-linker-plugin tmpdir/pr12942b.o tmpdir/pr12942a.o"]
+     set exec_output [run_host_cmd "$CXX" "-O2 -flto -fuse-linker-plugin tmpdir/pr12942b.o tmpdir/pr12942a.o"]
      if { [ regexp "undefined reference to `link_error\\(\\)'" $exec_output ] } {
          pass $testname
      } {
  # Run "ld -r" to generate inputs for complex LTO tests.
  run_dump_test "lto-3r"
  remote_exec host "mv" "tmpdir/dump tmpdir/lto-3.o"
 +run_dump_test "lto-4r-a"
 +remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-a.o"
 +run_dump_test "lto-4r-b"
 +remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-b.o"
 +run_dump_test "lto-4r-c"
 +remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-c.o"
 +run_dump_test "lto-4r-d"
 +remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-d.o"
  run_dump_test "lto-5r"
  remote_exec host "mv" "tmpdir/dump tmpdir/lto-5.o"
 +run_dump_test "lto-10r"
 +remote_exec host "mv" "tmpdir/dump tmpdir/lto-10.o"
++set testname "nm mixed object"
++set lto_plugin [run_host_cmd "$CC" "-print-prog-name=liblto_plugin.so tmpdir/lto-10.o"]
++if { [ regexp "liblto_plugin.so" $lto_plugin ] } {
++    set exec_output [run_host_cmd "$NM" "--plugin $lto_plugin tmpdir/lto-10.o"]
++    if { [ regexp "T main" $exec_output ] } {
++      pass $testname
++    } {
++      fail $testname
++    }
++} {
++    fail $testname
++ }
  
  run_cc_link_tests $lto_link_symbol_tests