ld -r doesn't need plugin for slim lto object
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 10 Dec 2015 20:35:35 +0000 (12:35 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 10 Dec 2015 20:35:50 +0000 (12:35 -0800)
Plugin isn't required on slim lto object for relocatable link.

bfd/

PR ld/19317
* linker.c (_bfd_generic_link_add_one_symbol): Don't complain
plugin needed to handle slim lto object for relocatable link.

ld/testsuite/

PR ld/19317
* ld-plugin/lto.exp (lto_no_fat): New.
(lto_link_tests): Add a test for PR ld/19317.
(lto_run_tests): Likewise.
(run_ld_link_tests): Likewise.

bfd/ChangeLog
bfd/linker.c
ld/testsuite/ChangeLog
ld/testsuite/ld-plugin/lto.exp
ld/testsuite/ld-plugin/pr19317.c [new file with mode: 0644]
ld/testsuite/ld-plugin/pr19317.out [new file with mode: 0644]

index a306cca..85f3ed4 100644 (file)
@@ -1,3 +1,9 @@
+2015-12-10  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/19317
+       * linker.c (_bfd_generic_link_add_one_symbol): Don't complain
+       plugin needed to handle slim lto object for relocatable link.
+
 2015-12-09  Sandra Loosemore  <sandra@codesourcery.com>
 
        * elf32-nios2.c (nios2_elf32_finish_dynamic_sections): Correct
index 86a7a19..6c59102 100644 (file)
@@ -1475,7 +1475,8 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info,
   else if (bfd_is_com_section (section))
     {
       row = COMMON_ROW;
-      if (strcmp (name, "__gnu_lto_slim") == 0)
+      if (!bfd_link_relocatable (info)
+         && strcmp (name, "__gnu_lto_slim") == 0)
        (*_bfd_error_handler)
          (_("%s: plugin needed to handle lto object"),
           bfd_get_filename (abfd));
index 38d9c77..3ce86d6 100644 (file)
@@ -1,3 +1,11 @@
+2015-12-10  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/19317
+       * ld-plugin/lto.exp (lto_no_fat): New.
+       (lto_link_tests): Add a test for PR ld/19317.
+       (lto_run_tests): Likewise.
+       (run_ld_link_tests): Likewise.
+
 2015-12-07  Jan Beulich  <jbeulich@suse.com>
 
        * ld-elf/gabiend.rt: Accept any alignment.
index 81e72b4..fb951df 100644 (file)
@@ -55,8 +55,10 @@ foreach plug $plugin_names {
     }
 }
 set lto_fat ""
+set lto_no_fat ""
 if { [check_lto_fat_available] } {
   set lto_fat "-ffat-lto-objects"
+  set lto_no_fat "-fno-fat-lto-objects"
 }
 
 # Simple LTO tests and generate input files for complex LTO tests.
@@ -178,6 +180,9 @@ set lto_link_tests [list \
   [list "PR ld/pr16846(2)" \
    "-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846c.o tmpdir/pr16846b.o" "" \
    {dummy.c} {} "pr16846b.exe"] \
+  [list "PR ld/19317 (1)" \
+   "$plug_opt" "-flto $lto_no_fat" \
+   {pr19317.c} {} "libpr19317.a"] \
 ]
 
 if { [at_least_gcc_version 4 7] } {
@@ -324,6 +329,9 @@ set lto_run_tests [list \
   [list "PR ld/15323 (4)" \
    "-O2 -flto tmpdir/pr15323a-r.o" "" \
    {dummy.c} "pr15323a.exe" "pr15323.out" "-flto -O2" "c"] \
+  [list "PR ld/19317 (3)" \
+   "-O2 -flto tmpdir/pr19317-r.o" "" \
+   {dummy.c} "pr19317.exe" "pr19317.out" "-flto -O2" "c"] \
 ]
 
 if { [at_least_gcc_version 4 7] } {
@@ -424,6 +432,12 @@ remote_exec host "mv" "tmpdir/dump tmpdir/lto-5.o"
 
 run_cc_link_tests $lto_link_symbol_tests
 
+run_ld_link_tests [list \
+  [list "PR ld/19317 (2)" \
+   "-r tmpdir/pr19317.o" "" "" \
+   {dummy.s} {} "pr19317-r.o"] \
+]
+
 # The following tests require running the executable generated by ld.
 if ![isnative] {
     return
diff --git a/ld/testsuite/ld-plugin/pr19317.c b/ld/testsuite/ld-plugin/pr19317.c
new file mode 100644 (file)
index 0000000..7189d88
--- /dev/null
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int
+main ()
+{
+  printf ("OK\n");
+  return 0;
+}
diff --git a/ld/testsuite/ld-plugin/pr19317.out b/ld/testsuite/ld-plugin/pr19317.out
new file mode 100644 (file)
index 0000000..d86bac9
--- /dev/null
@@ -0,0 +1 @@
+OK