[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 Alan Modra changed: What|Removed |Added Target Milestone|--- |2.35 --- Comment #15 from Alan Modra --- The bug has been around forever so it isn't a regression. From that angle there is no reason to backport. Also, the fix isn't trivial. So I'm not inclined to backport to 2.34. -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 Romain Geissler changed: What|Removed |Added CC||romain.geissler at amadeus dot com --- Comment #14 from Romain Geissler --- Hi, Do you think this shall be backported to branch 2.34, or can it wait until 2.35 in 6 months ? Cheers, Romain -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 --- Comment #13 from cvs-commit at gcc dot gnu.org --- The master branch has been updated by H.J. Lu : https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3312f67c0957196e41db149343d04ee7b30cdc65 commit 3312f67c0957196e41db149343d04ee7b30cdc65 Author: H.J. Lu Date: Wed Feb 26 03:56:28 2020 -0800 ld: Add PR ld/25593 tests PR ld/25593 * testsuite/ld-plugin/lto.exp: Run PR ld/25593 tests. * testsuite/ld-plugin/pr25593.d: New file. * testsuite/ld-plugin/pr25593a-1.c: Likewise. * testsuite/ld-plugin/pr25593a-2.c: Likewise. * testsuite/ld-plugin/pr25593b.c: Likewise. * testsuite/ld-plugin/pr25593c.c: Likewise. * testsuite/ld-plugin/pr25593d.c: Likewise. * testsuite/ld-plugin/pr25593e.c: Likewise. -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 Alan Modra changed: What|Removed |Added Status|ASSIGNED|RESOLVED CC|amodra at gmail dot com| Resolution|--- |FIXED --- Comment #12 from Alan Modra --- Should now be fixed. -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 --- Comment #11 from cvs-commit at gcc dot gnu.org --- The master branch has been updated by Alan Modra : https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e310298cf3fc02112ac0018260748828affa4061 commit e310298cf3fc02112ac0018260748828affa4061 Author: Alan Modra Date: Tue Feb 25 12:50:10 2020 +1030 PR25593, --as-needed breaks DT_NEEDED order with linker plugin This patch delays setting up DT_NEEDED dynamic tags until all object files and libraries have been opened and their symbols processed, rather than adding the tags while processing symbols. Tags are ordered according to the position of the associated library on the command line and linker scripts. It is still possible with --as-needed libs that are mentioned more than once for tags to be ordered according to which mention was needed. For example with "--as-needed a.so b.so c.so b.so" when b.so is not needed by a.so or any other prior object file but is needed by c.so, the order of tags will be "A C B". bfd/ PR 25593 * elf-bfd.h (struct elf_link_hash_table): Rename "loaded" to "dyn_loaded". (bfd_elf_add_dt_needed_tag): Declare. * elf-strtab.c (_bfd_elf_strtab_restore): Handle NULL buf. * elflink.c (bfd_elf_add_dt_needed_tag): Make global and rename from elf_add_dt_needed_tag. Remove soname and doit param. (elf_link_add_object_symbols): Don't use elf_add_dt_needed_tag to see whether as-needed lib is already loaded, use dyn_loaded list instead. When saving and restoring around as-needed lib handle possibility that dynstr has not been initialised. Don't add DT_NEEDED tags here. Limit dyn_loaded list to dynamic libs. Mark libs loaded via DT_NEEDED entries of other libs with DYN_NO_NEEDED if they should not be mentioned in DT_NEEDED of the output. (elf_link_check_versioned_symbol): Remove now unneccesary DYNAMIC check when traversing dyn_loaded list. ld/ PR 25593 * ldelf.c (ldelf_try_needed): Add DT_NEEDED lib to input_bfds. (ldelf_after_open): Save state of input_bfds list before loading DT_NEEDED libs. Traverse input_bfds list adding DT_NEEDED tags. Restore input_bfds list. * testsuite/ld-cris/gotplt1.d: Adjust for changed .dynstr order. -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 H.J. Lu changed: What|Removed |Added Attachment #12320|0 |1 is obsolete|| --- Comment #10 from H.J. Lu --- Created attachment 12321 --> https://sourceware.org/bugzilla/attachment.cgi?id=12321&action=edit A patch for testcases -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 H.J. Lu changed: What|Removed |Added Attachment #12318|0 |1 is obsolete|| --- Comment #9 from H.J. Lu --- Created attachment 12320 --> https://sourceware.org/bugzilla/attachment.cgi?id=12320&action=edit A patch for testcases -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 Alan Modra changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at sourceware dot org |amodra at gmail dot com --- Comment #8 from Alan Modra --- Created attachment 12319 --> https://sourceware.org/bugzilla/attachment.cgi?id=12319&action=edit delay adding dt_needed tags This is what I'm testing at the moment. -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 --- Comment #7 from H.J. Lu --- (In reply to Alan Modra from comment #6) > By "won't work" I mean won't preserve the original order of libraries. By > the look of it, if you are linking --as-needed t.o a.so b,so c.so with a t.o > that is lto and requires all three libraries, then your patch will result in > dt_needed entries in the order c.so, b.so, a.so. I will see what I can do. -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 --- Comment #6 from Alan Modra --- By "won't work" I mean won't preserve the original order of libraries. By the look of it, if you are linking --as-needed t.o a.so b,so c.so with a t.o that is lto and requires all three libraries, then your patch will result in dt_needed entries in the order c.so, b.so, a.so. -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 --- Comment #5 from H.J. Lu --- (In reply to Alan Modra from comment #4) > My guess is that a simple patch like that won't work when you have more > libraries > and/or a mix of lto/non-lto objects. My patch places newly discovered DT_NEEDED library by LTO plugin before non-LTO ones. This should make LTO case similar to without. -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 Alan Modra changed: What|Removed |Added CC||amodra at gmail dot com --- Comment #4 from Alan Modra --- My guess is that a simple patch like that won't work when you have more libraries and/or a mix of lto/non-lto objects. -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 --- Comment #3 from H.J. Lu --- Created attachment 12318 --> https://sourceware.org/bugzilla/attachment.cgi?id=12318&action=edit Try this -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 --- Comment #2 from H.J. Lu --- (In reply to Richard Biener from comment #0) > echo 'void foo() {}' > libt.c > echo 'void foo(); int main() { foo(); }' > t.c > gcc -o libt.so -shared libt.c -Wl,-soname,libt.so -fPIC -flto > gcc -c t.c -flto > gcc -Wl,--as-needed t.o libt.so > readelf -d a.out | grep NEEDED > 0x0001 (NEEDED) Shared library: [libc.so.6] > 0x0001 (NEEDED) Shared library: [libt.so] > > but libc has to come last so the program can use RTLD_NEXT to arrive at > symbols from libc. Works fine with gold. [hjl@gnu-cfl-2 pr25593]$ make gcc -flto -c -o t.o t.c gcc -fPIC -c -o libt.o libt.c ld -shared -o libt.so libt.o gcc -Wl,--as-needed -o x t.o libt.so readelf -d x | grep NEEDED 0x0001 (NEEDED) Shared library: [libc.so.6] 0x0001 (NEEDED) Shared library: [libt.so] [hjl@gnu-cfl-2 pr25593]$ rm libt.so [hjl@gnu-cfl-2 pr25593]$ make LD=ld.gold ld.gold -shared -o libt.so libt.o gcc -Wl,--as-needed -o x t.o libt.so readelf -d x | grep NEEDED 0x0001 (NEEDED) Shared library: [libc.so.6] 0x0001 (NEEDED) Shared library: [libt.so] [hjl@gnu-cfl-2 pr25593]$ rm libt.so [hjl@gnu-cfl-2 pr25593]$ make LD=gcc gcc -shared -o libt.so libt.o gcc -Wl,--as-needed -o x t.o libt.so readelf -d x | grep NEEDED 0x0001 (NEEDED) Shared library: [libc.so.6] 0x0001 (NEEDED) Shared library: [libt.so] [hjl@gnu-cfl-2 pr25593]$ gcc -Wl,--as-needed -o x t.o libt.so -fuse-ld=gold [hjl@gnu-cfl-2 pr25593]$ make readelf -d x | grep NEEDED 0x0001 (NEEDED) Shared library: [libt.so] 0x0001 (NEEDED) Shared library: [libc.so.6] [hjl@gnu-cfl-2 pr25593]$ ld needs to check DT_NEEDED of libt.so. -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 Michael Matz changed: What|Removed |Added CC||matz at suse dot de --- Comment #1 from Michael Matz --- Just to be explicit: also works fine without -flto when compiling t.c. -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 Fabian Vogt changed: What|Removed |Added CC||fab...@ritter-vogt.de -- You are receiving this mail because: You are on the CC list for the bug.
[Bug ld/25593] --as-needed breaks DT_NEEDED order with linker plugin
https://sourceware.org/bugzilla/show_bug.cgi?id=25593 Richard Biener changed: What|Removed |Added CC||hjl.tools at gmail dot com See Also||https://bugzilla.suse.com/s ||how_bug.cgi?id=1163744 -- You are receiving this mail because: You are on the CC list for the bug.