Skip to content

Commit b71c7a5

Browse files
committed
PR27311, (symbol from plugin): undefined reference, hidden sym
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 7d409ac)
1 parent 401fafe commit b71c7a5

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

bfd/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2021-02-04 Alan Modra <amodra@gmail.com>
2+
3+
PR 27311
4+
* elflink.c (elf_link_add_object_symbols): Don't pull in as-needed
5+
libraries for IR references on pass over libraries after LTO
6+
recompilation.
7+
18
2021-02-03 Alan Modra <amodra@gmail.com>
29

310
PR 27311

bfd/elflink.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5279,6 +5279,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
52795279
&& h->ref_regular_nonweak)
52805280
|| (old_bfd != NULL
52815281
&& (old_bfd->flags & BFD_PLUGIN) != 0
5282+
&& !info->lto_all_symbols_read
52825283
&& bind != STB_WEAK)
52835284
|| (h->ref_dynamic_nonweak
52845285
&& (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0

ld/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2021-02-04 Alan Modra <amodra@gmail.com>
2+
3+
* testsuite/ld-plugin/pr27311d.c: New test.
4+
* testsuite/ld-plugin/lto.exp: Rename pr27311 to pr27311-1, compile
5+
and link new test as pr27311-2.
6+
17
2021-02-03 Alan Modra <amodra@gmail.com>
28

39
Apply from mainline

ld/testsuite/ld-plugin/lto.exp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,15 @@ set lto_link_elf_tests [list \
424424
[list {pr27311c.o} \
425425
{} {-flto} \
426426
{pr27311c.c} {} {} {c}] \
427-
[list {pr27311} \
427+
[list {pr27311d.o} \
428+
{} {-flto} \
429+
{pr27311d.c} {} {} {c}] \
430+
[list {pr27311-1} \
428431
{tmpdir/pr27311c.o -Wl,--no-as-needed,--rpath-link=. tmpdir/pr27311b.so} {} \
429-
{dummy.c} {{readelf {--dyn-syms --wide} pr27311.d}} {pr27311}] \
432+
{dummy.c} {{readelf {--dyn-syms --wide} pr27311.d}} {pr27311-1}] \
433+
[list {pr27311-2} \
434+
{tmpdir/pr27311d.o -Wl,--no-as-needed,--rpath-link=. tmpdir/pr27311b.so} {} \
435+
{dummy.c} {{readelf {--dyn-syms --wide} pr27311.d}} {pr27311-2}] \
430436
]
431437

432438
# PR 14918 checks that libgcc is not spuriously included in a shared link of

ld/testsuite/ld-plugin/pr27311d.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__attribute__((visibility("hidden"))) void inlib1(void) {}
2+
int main()
3+
{
4+
return 0;
5+
}

0 commit comments

Comments
 (0)