This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] PR ld/19317: ld -r doesn't need plugin for slim lto object


Plugin isn't required on slim lto object for relocatable link.

OK for master?

H.J.
---
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.
	(run_ld_link_tests): Likewise.
	(lto_link_tests): Add a test for PR ld/19317.
	(lto_run_tests): Likewise.
---
 bfd/linker.c                       |  3 ++-
 ld/testsuite/ld-plugin/lto.exp     | 14 ++++++++++++++
 ld/testsuite/ld-plugin/pr19317.c   |  8 ++++++++
 ld/testsuite/ld-plugin/pr19317.out |  1 +
 4 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 ld/testsuite/ld-plugin/pr19317.c
 create mode 100644 ld/testsuite/ld-plugin/pr19317.out

diff --git a/bfd/linker.c b/bfd/linker.c
index 86a7a19..6c59102 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -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));
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 81e72b4..1c5b21c 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -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,15 @@ 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"] \
+]
+
+run_ld_link_tests [list \
+  [list "PR ld/19317 (2)" \
+   "-r tmpdir/pr19317.o" "" "" \
+   {dummy.s} {} "pr19317-r.o"] \
 ]
 
 if { [at_least_gcc_version 4 7] } {
@@ -324,6 +335,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] } {
diff --git a/ld/testsuite/ld-plugin/pr19317.c b/ld/testsuite/ld-plugin/pr19317.c
new file mode 100644
index 0000000..7189d88
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr19317.c
@@ -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
index 0000000..d86bac9
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr19317.out
@@ -0,0 +1 @@
+OK
-- 
2.5.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]