[Bug ld/14915] --copy-dt-needed-entries not working when creating DSO
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 --- Comment #15 from cvs-commit at gcc dot gnu.org cvs-commit at gcc dot gnu.org 2013-01-21 13:49:19 UTC --- CVSROOT:/cvs/src Module name:src Branch: binutils-2_23-branch Changes by:amo...@sourceware.org2013-01-21 13:48:53 Modified files: bfd: ChangeLog bfdio.c cache.c elf-bfd.h elf-strtab.c elf.c elf32-i386.c elf32-ppc.c elf64-ppc.c elflink.c linker.c opncls.c binutils : ChangeLog readelf.c gas: ChangeLog dwarf2dbg.c sb.c write.c gas/config : tc-ppc.c tc-ppc.h gas/testsuite : ChangeLog gas/testsuite/gas/cfi: cfi-ppc-1.d cfi-ppc-1.s cfi.exp gas/testsuite/gas/ppc: 476.d 476.s a2.d a2.s altivec.d altivec.s altivec_and_spe.d astest.d astest2.d astest2_64.d astest64.d booke.d booke.s cell.d cell.s common.d common.s e500.d e500.s e500mc.d e500mc.s e500mc64_nop.d e500mc64_nop.s e5500_nop.d e5500_nop.s e6500.d e6500.s e6500_nop.d e6500_nop.s machine.d power4.d power4.s power4_32.d power4_32.s power6.d power6.s power7.d power7.s ppc.exp ppc750ps.d ppc750ps.s regnames.d simpshft.d test1elf32.d test1elf64.d titan.d titan.s vle-reloc.s vle-simple-1.s vle-simple-2.s vle-simple-3.s vle-simple-4.s vle-simple-5.s vle-simple-6.s vle.s vsx.d vsx.s include/opcode : ChangeLog ppc.h ld : ChangeLog ldexp.c ldexp.h ldlang.c ldmain.c lexsup.c plugin.c plugin.h ld/emultempl : elf32.em ld/testsuite : ChangeLog ld/testsuite/ld-gc: pr13683.d ld/testsuite/ld-plugin: plugin-2.d plugin-4.d ld/testsuite/ld-powerpc: apuinfo-nul.rd apuinfo.rd plt1.d powerpc.exp relax.d relaxr.d sdadyn.d tls.d tls.g tls.t tls32.d tls32.g tls32.t tlsexe.d tlsexe.g tlsexe.r tlsexe.t tlsexe32.d tlsexe32.g tlsexe32.r tlsexe32.t tlsexetoc.d tlsexetoc.g tlsexetoc.r tlsexetoc.t tlsmark.d tlsmark32.d tlsopt1.d tlsopt1_32.d tlsopt2.d tlsopt2_32.d tlsopt3.d tlsopt3_32.d tlsopt4.d tlsopt4_32.d tlsso.d tlsso.g tlsso.r tlsso.t tlsso32.d tlsso32.g tlsso32.r tlsso32.t tlstoc.d tlstoc.g tlstoc.t tlstocso.d tlstocso.g tlstocso.t tocopt.out opcodes: ChangeLog ppc-dis.c ppc-opc.c Added files: gas/testsuite/gas/ppc: altivec2.d altivec2.s Log message: PR 12549 PR 14493 PR 14567 PR 14662 PR 14758 PR 14813 PR 14904 PR 14915 PR 14926 PR 14950 PR 14962 Apply mainline patches Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=srconly_with_tag=binutils-2_23-branchr1=1.5758.2.37r2=1.5758.2.38 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/bfdio.c.diff?cvsroot=srconly_with_tag=binutils-2_23-branchr1=1.33r2=1.33.4.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cache.c.diff?cvsroot=srconly_with_tag=binutils-2_23-branchr1=1.41r2=1.41.4.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-bfd.h.diff?cvsroot=srconly_with_tag=binutils-2_23-branchr1=1.343.2.2r2=1.343.2.3 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-strtab.c.diff?cvsroot=srconly_with_tag=binutils-2_23-branchr1=1.16r2=1.16.20.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf.c.diff?cvsroot=srconly_with_tag=binutils-2_23-branchr1=1.568r2=1.568.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-i386.c.diff?cvsroot=srconly_with_tag=binutils-2_23-branchr1=1.279.4.3r2=1.279.4.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-ppc.c.diff?cvsroot=srconly_with_tag=binutils-2_23-branchr1=1.318.4.1r2=1.318.4.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-ppc.c.diff?cvsroot=srconly_with_tag=binutils-2_23-branchr1=1.390.4.3r2=1.390.4.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=srconly_with_tag=binutils-2_23-branchr1=1.450.4.2r2=1.450.4.3 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/linker.c.diff?cvsroot=srconly_with_tag=binutils-2_23-branchr1=1.95r2=1.95.4.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/opncls.c.diff?cvsroot=srconly_with_tag=binutils-2_23-branchr1=1.69r2=1.69.4.1
[Bug ld/14915] --copy-dt-needed-entries not working when creating DSO
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 H.J. Lu hjl.tools at gmail dot com changed: What|Removed |Added Status|NEW |RESOLVED Resolution||FIXED --- Comment #14 from H.J. Lu hjl.tools at gmail dot com 2012-12-06 15:09:50 UTC --- Fixed for 2.24. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/14915] --copy-dt-needed-entries not working when creating DSO
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 --- Comment #13 from cvs-commit at gcc dot gnu.org cvs-commit at gcc dot gnu.org 2012-12-06 00:25:27 UTC --- CVSROOT:/cvs/src Module name:src Changes by:h...@sourceware.org2012-12-06 00:25:19 Modified files: ld : ChangeLog ld/emultempl : elf32.em ld/testsuite : ChangeLog ld/testsuite/ld-elf: shared.exp Log message: Extend --copy-dt-needed-entries to creating DSO ld/ PR ld/14915 * emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Also check DT_NEEDED entries when creating shared object with --copy-dt-needed-entries. ld/testsuite/ PR ld/14915 * ld-elf/shared.exp (build_tests): Test --add-needed, --copy-dt-needed-entries, --no-add-needed and --no-copy-dt-needed-entries with -shared. Add tests for --no-add-needed and --no-copy-dt-needed-entries with -shared. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=srcr1=1.2519r2=1.2520 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emultempl/elf32.em.diff?cvsroot=srcr1=1.233r2=1.234 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=srcr1=1.1631r2=1.1632 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/shared.exp.diff?cvsroot=srcr1=1.24r2=1.25 -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/14915] --copy-dt-needed-entries not working
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 Michael Matz matz at suse dot de changed: What|Removed |Added CC||matz at suse dot de --- Comment #1 from Michael Matz matz at suse dot de 2012-12-04 14:06:26 UTC --- Behaviour also doesn't change if we include objects that refer to stuff from libm or libt1 into libt2. I tried to debug ld a bit to see where this is supposed to be handled but got lost after two hours. It seems that some handling of dt_needed entries in elf32.xm:gld*_after_open is only done for executables, but even creating an executable doesn't help. In any case, I couldn't find any code that really tries to add DT_NEEDED entries from referred libraries to the output file. The code in elflink.c:elf_link_add_object_symbols at least only adds to the htab-needed list on those entries (and 'libm.so.6' is included there), but doesn't actually call elf_add_dt_needed_tag on those entries (and nobody else does either). It certainly doesn't work as documented or expected (with my expectations). -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/14915] --copy-dt-needed-entries not working
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 --- Comment #2 from H.J. Lu hjl.tools at gmail dot com 2012-12-04 14:07:56 UTC --- Please show the output of gcc -o libt2.so -shared -Wl,--copy-dt-needed-entries -L. -lt1 -v We need to see all command-line options passed to linker. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/14915] --copy-dt-needed-entries not working
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 H.J. Lu hjl.tools at gmail dot com changed: What|Removed |Added Status|NEW |WAITING CC||hjl.tools at gmail dot com -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/14915] --copy-dt-needed-entries not working
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 H.J. Lu hjl.tools at gmail dot com changed: What|Removed |Added Status|WAITING |NEW --- Comment #4 from H.J. Lu hjl.tools at gmail dot com 2012-12-04 14:30:28 UTC --- This option is renamed from --add-needed: http://sourceware.org/ml/binutils/2004-07/msg00093.html -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/14915] --copy-dt-needed-entries not working
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 --- Comment #5 from Michael Matz matz at suse dot de 2012-12-04 14:39:58 UTC --- (In reply to comment #4) This option is renamed from --add-needed: http://sourceware.org/ml/binutils/2004-07/msg00093.html Yes, but why are you mentioning that? -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/14915] --copy-dt-needed-entries not working
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 --- Comment #6 from Richard Guenther rguenth at gcc dot gnu.org 2012-12-04 14:41:12 UTC --- (In reply to comment #5) (In reply to comment #4) This option is renamed from --add-needed: http://sourceware.org/ml/binutils/2004-07/msg00093.html Yes, but why are you mentioning that? Btw, I explicitely stated that even before the rename, with ld 2.18, it did not work as expected (using --[no-]add-needed). -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/14915] --copy-dt-needed-entries not working
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 --- Comment #7 from Michael Matz matz at suse dot de 2012-12-04 14:44:50 UTC --- (In reply to comment #5) (In reply to comment #4) This option is renamed from --add-needed: http://sourceware.org/ml/binutils/2004-07/msg00093.html Yes, but why are you mentioning that? In particular, from that thread is referred the GCC problem that you wanted to fix with adding --no-add-needed: http://gcc.gnu.org/ml/gcc/2004-04/msg01130.html The problem specifically was that libunwind was added to DT_NEEDED because it was itself DT_NEEDED by libgcc_s, and it was said that this was how the linker is supposed to work. Now, meanwhile the default got switched, i.e. --no-copy-dt-needed-entries is the default, but we're supposed to be able to switch back with --copy-dt-needed-entries. And this bug report is about the fact, that this doesn't work. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/14915] --copy-dt-needed-entries not working
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 --- Comment #8 from Michael Matz matz at suse dot de 2012-12-04 14:56:09 UTC --- Let's create a different testcase showing also similar symptoms of not correctly adding DT_NEEDED entries as documented, this time to search scopes: % cat bla.c extern double sin (double); double f (double i) { return sin (i); } % gcc -c -fPIC bla.c % ./ld/ld-new -shared -o libt1.so bla.o -lm -zdefs % readelf -d libt1.so | grep NEEDED 0x0001 (NEEDED) Shared library: [libm.so.6] Everything fine so far. Now we want to generate libt2 also referring to a libm function, want to link it only with libt1 and expect that there's some way to include libm into the search scopes with some option to ld. The documented option is --copy-dt-needed-entries, so: % cat bla2.c extern double f (double); extern double sin (double); double g (double i) { return f(i) + sin (i); } % gcc -c -fPIC bla2.c So, bla2 refers to functions of libt1 and to libm, but still: % ./ld/ld-new -shared -o libt2.so bla.o --copy-dt-needed-entries -L. -lt1 -z defs bla2.o: In function `g': bla2.c:(.text+0x22): undefined reference to `sin' -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/14915] --copy-dt-needed-entries not working
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 --- Comment #9 from H.J. Lu hjl.tools at gmail dot com 2012-12-04 18:21:46 UTC --- --copy-dt-needed-entries doesn't work when -shared is used. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/14915] --copy-dt-needed-entries not working when creating DSO
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 H.J. Lu hjl.tools at gmail dot com changed: What|Removed |Added Summary|--copy-dt-needed-entries|--copy-dt-needed-entries |not working |not working when creating ||DSO --- Comment #10 from H.J. Lu hjl.tools at gmail dot com 2012-12-04 18:28:14 UTC --- [hjl@gnu-6 pr14915]$ cat bla.c extern void bar (void); void f (void) { bar (); } [hjl@gnu-6 pr14915]$ cat bla2.c extern void f (void); extern void bar (void); int main (void) { f (); bar (); return 0; } [hjl@gnu-6 pr14915]$ cat bar.c void bar (void) { } [hjl@gnu-6 pr14915]$ make gcc -B./ -fPIC -c -o bla2.o bla2.c gcc -B./ -fPIC -c -o bla.o bla.c gcc -B./ -fPIC -c -o bar.o bar.c gcc -B./ -shared -o libbar.so bar.o -Wl,-z,defs gcc -B./ -shared -o libt1.so bla.o libbar.so -Wl,-z,defs gcc -B./ -o x bla2.o -Wl,--add-needed -L. -lt1 -Wl,-rpath-link=. -Wl,-z,defs gcc -B./ -shared -o libt2.so bla2.o -Wl,--add-needed -Wl,-rpath-link=. -L. -lt1 -Wl,-z,defs bla2.o: In function `main': bla2.c:(.text+0xa): undefined reference to `bar' collect2: error: ld returned 1 exit status make: *** [libt2.so] Error 1 [hjl@gnu-6 pr14915]$ -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/14915] --copy-dt-needed-entries not working when creating DSO
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 --- Comment #11 from H.J. Lu hjl.tools at gmail dot com 2012-12-04 18:54:53 UTC --- This: diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 6c84b82..875ac2c 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1181,8 +1181,6 @@ gld${EMULATION_NAME}_after_open (void) special action by the person doing the link. Note that the needed list can actually grow while we are stepping through this loop. */ - if (!link_info.executable) -return; needed = bfd_elf_get_needed_list (link_info.output_bfd, link_info); for (l = needed; l != NULL; l = l-next) { works for me. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/14915] --copy-dt-needed-entries not working when creating DSO
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 H.J. Lu hjl.tools at gmail dot com changed: What|Removed |Added URL||http://sourceware.org/ml/bi ||nutils/2012-12/msg00058.htm ||l --- Comment #12 from H.J. Lu hjl.tools at gmail dot com 2012-12-04 19:13:15 UTC --- A patch is posted at http://sourceware.org/ml/binutils/2012-12/msg00058.html -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/14915] --copy-dt-needed-entries not working
http://sourceware.org/bugzilla/show_bug.cgi?id=14915 --- Comment #3 from Michael Matz matz at suse dot de 2012-12-04 14:12:29 UTC --- (In reply to comment #2) gcc -o libt2.so -shared -Wl,--copy-dt-needed-entries -L. -lt1 -v /usr/lib64/gcc/x86_64-suse-linux/4.5/collect2 --build-id --eh-frame-hdr -m elf_x86_64 -shared -o libt2.so /usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/4.5/crtbeginS.o -L. -L/usr/lib64/gcc/x86_64-suse-linux/4.5 -L/usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.5/../../.. --copy-dt-needed-entries -lt1 -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib64/gcc/x86_64-suse-linux/4.5/crtendS.o /usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../lib64/crtn.o So, the --copy-dt-needed-entries argument is at the right place, right before -lt1. During my debugging I of course used this cmdline (well, substed collect2 with the right ld). Changing various options like removing libs or the --as-needed doesn't make a difference for the behaviour we expect. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are on the CC list for the bug. ___ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils