This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] PR ld/19317: ld -r doesn't need plugin for slim lto object
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Thu, 10 Dec 2015 12:42:34 -0800
- Subject: Re: [PATCH] PR ld/19317: ld -r doesn't need plugin for slim lto object
- Authentication-results: sourceware.org; auth=none
- References: <20151210162127 dot GB10100 at intel dot com>
On Thu, Dec 10, 2015 at 8:21 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> 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));
This is what I checked in.
--
H.J.
From 48e418050505ccb0e2e98633927000c20e262b5b Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 10 Dec 2015 08:17:07 -0800
Subject: [PATCH] ld -r doesn't need plugin for slim lto object
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/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..fb951df 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,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
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