]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR27311, (symbol from plugin): undefined reference, hidden sym
authorAlan Modra <amodra@gmail.com>
Thu, 4 Feb 2021 03:26:34 +0000 (13:56 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 4 Feb 2021 06:21:31 +0000 (16:51 +1030)
bfd/
PR 27311
* elflink.c (elf_link_add_object_symbols): Don't pull in as-needed
libraries for IR references on pass over libraries after LTO
recompilation.
ld/
* testsuite/ld-plugin/pr27311d.c: New test.
* testsuite/ld-plugin/lto.exp: Rename pr27311 to pr27311-1, compile
and link new test as pr27311-2.

(cherry picked from commit 7d409ac001cce916661d345bff01ed589991e762)

bfd/ChangeLog
bfd/elflink.c
ld/ChangeLog
ld/testsuite/ld-plugin/lto.exp
ld/testsuite/ld-plugin/pr27311d.c [new file with mode: 0644]

index e2a34164f695643d6eed76a25d399756153603c9..c5cbad5d881a6b04af285a9dbccb7baecd1dbc53 100644 (file)
@@ -1,3 +1,10 @@
+2021-02-04  Alan Modra  <amodra@gmail.com>
+
+       PR 27311
+       * elflink.c (elf_link_add_object_symbols): Don't pull in as-needed
+       libraries for IR references on pass over libraries after LTO
+       recompilation.
+
 2021-02-03  Alan Modra  <amodra@gmail.com>
 
        PR 27311
index da288f3f2accba955fbaca003aa535b354fe7b86..7afbc5b1072d310986988ddd8a387c9bb2780264 100644 (file)
@@ -5279,6 +5279,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
                   && h->ref_regular_nonweak)
                  || (old_bfd != NULL
                      && (old_bfd->flags & BFD_PLUGIN) != 0
+                     && !info->lto_all_symbols_read
                      && bind != STB_WEAK)
                  || (h->ref_dynamic_nonweak
                      && (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0
index fbb7d5094f270d586dc512c6254b7ecc242058e2..c299fb158676de051284928b8e697deaf421aabf 100644 (file)
@@ -1,3 +1,9 @@
+2021-02-04  Alan Modra  <amodra@gmail.com>
+
+       * testsuite/ld-plugin/pr27311d.c: New test.
+       * testsuite/ld-plugin/lto.exp: Rename pr27311 to pr27311-1, compile
+       and link new test as pr27311-2.
+
 2021-02-03  Alan Modra  <amodra@gmail.com>
 
        Apply from mainline
index 878d9e776aeb01e21b863e749f358efe58b4381a..3a59e37bc92b4af09fbc86382deb570dcc7f6aad 100644 (file)
@@ -424,9 +424,15 @@ set lto_link_elf_tests [list \
   [list {pr27311c.o} \
    {} {-flto} \
    {pr27311c.c} {} {} {c}] \
-  [list {pr27311} \
+  [list {pr27311d.o} \
+   {} {-flto} \
+   {pr27311d.c} {} {} {c}] \
+  [list {pr27311-1} \
    {tmpdir/pr27311c.o -Wl,--no-as-needed,--rpath-link=. tmpdir/pr27311b.so} {} \
-   {dummy.c} {{readelf {--dyn-syms --wide} pr27311.d}} {pr27311}] \
+   {dummy.c} {{readelf {--dyn-syms --wide} pr27311.d}} {pr27311-1}] \
+  [list {pr27311-2} \
+   {tmpdir/pr27311d.o -Wl,--no-as-needed,--rpath-link=. tmpdir/pr27311b.so} {} \
+   {dummy.c} {{readelf {--dyn-syms --wide} pr27311.d}} {pr27311-2}] \
 ]
 
 # PR 14918 checks that libgcc is not spuriously included in a shared link of
diff --git a/ld/testsuite/ld-plugin/pr27311d.c b/ld/testsuite/ld-plugin/pr27311d.c
new file mode 100644 (file)
index 0000000..11e4ba4
--- /dev/null
@@ -0,0 +1,5 @@
+__attribute__((visibility("hidden"))) void inlib1(void) {}
+int main()
+{
+  return 0;
+}