From 29a9f53e857c5d55df852d0a5d5c41a9247c16a2 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 27 Aug 2014 07:39:48 -0700 Subject: [PATCH] Don't attach dynamic sections to input from ld --just-symbols bfd/ PR ld/17313 * elflink.c (elf_link_add_object_symbols): Don't attach dynamic sections to input from ld --just-symbols. 2014-08-27 H.J. Lu PR ld/17313 * ld-i386/i386.exp (i386tests): Add tests for PR ld/17313. * ld-x86-64/x86-64.exp (x86_64tests): Likewise. --- bfd/ChangeLog | 6 ++++++ bfd/elflink.c | 15 ++++++++++----- ld/testsuite/ChangeLog | 6 ++++++ ld/testsuite/ld-i386/i386.exp | 4 ++++ ld/testsuite/ld-x86-64/x86-64.exp | 4 ++++ 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9635195..3f81ba4 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2014-08-27 H.J. Lu + + PR ld/17313 + * elflink.c (elf_link_add_object_symbols): Don't attach dynamic + sections to input from ld --just-symbols. + 2014-08-26 DJ Delorie * elf32-rl78.c (rl78_elf_relax_section): Disambiguate test for diff --git a/bfd/elflink.c b/bfd/elflink.c index 658e584..c1e7948 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -3339,6 +3339,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) bfd_size_type old_dynstr_size = 0; size_t tabsize = 0; asection *s; + bfd_boolean just_syms; htab = elf_hash_table (info); bed = get_elf_backend_data (abfd); @@ -3442,15 +3443,20 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) } } + just_syms = ((s = abfd->sections) != NULL + && s->sec_info_type == SEC_INFO_TYPE_JUST_SYMS); + add_needed = TRUE; if (! dynamic) { /* If we are creating a shared library, create all the dynamic sections immediately. We need to attach them to something, so we attach them to this BFD, provided it is the right - format. FIXME: If there are no input BFD's of the same - format as the output, we can't make a shared library. */ - if (info->shared + format and is not from ld --just-symbols. FIXME: If there + are no input BFD's of the same format as the output, we can't + make a shared library. */ + if (!just_syms + && info->shared && is_elf_hash_table (htab) && info->output_bfd->xvec == abfd->xvec && !htab->dynamic_sections_created) @@ -3470,8 +3476,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) /* ld --just-symbols and dynamic objects don't mix very well. ld shouldn't allow it. */ - if ((s = abfd->sections) != NULL - && s->sec_info_type == SEC_INFO_TYPE_JUST_SYMS) + if (just_syms) abort (); /* If this dynamic lib was specified on the command line with diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 6f5ff5e..a7bde81 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-08-27 H.J. Lu + + PR ld/17313 + * ld-i386/i386.exp (i386tests): Add tests for PR ld/17313. + * ld-x86-64/x86-64.exp (x86_64tests): Likewise. + 2014-08-26 Jiong Wang * ld-aarch64/copy-relocs-so.s: New test file. diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index 4d22182..875c816 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -183,6 +183,10 @@ set i386tests { {"TLS IE->LE transition" "-melf_i386" "" "--32" {tlsie1.s} {{objdump -dwr tlsie1.dd}} "tlsie1"} + {"PR ld/17313 (1)" "-melf_i386" "" + "--32" {zero.s} {} ""} + {"PR ld/17313 (2)" "-melf_i386 -shared --just-symbols=tmpdir/zero.o" "" + "--32" {lea1.s} {} "libpr17313.so"} } # So as to avoid rewriting every last test case here in a nacl variant, diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index f6c392b..a9af367 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -136,6 +136,10 @@ set x86_64tests { {"build 32-bit object with 33 locals" "-melf_x86_64 -e 0" "" "--32" {32bit.s} {{ ld incompatible.l }} "dummy" } {"build 64-bit object" "-melf_x86_64 -e 0 --defsym foo=1" "" "--64" {64bit.s} {} "dummy" } {"link mixed objects" "-melf_x86_64 -e 0 tmpdir/32bit.o tmpdir/64bit.o" "" "" {} { { ld incompatible.l } } "mixed"} + {"PR ld/17313 (1)" "-melf_x86_64" "" + "--64" {dummy.s} {} ""} + {"PR ld/17313 (2)" "-melf_x86_64 -shared --just-symbols=tmpdir/dummy.o" "" + "--64" {lea1.s} {} "libpr17313.so"} } # So as to avoid rewriting every last test case here in a nacl variant, -- 2.7.4