Check the DYNAMIC bit for input shared objects
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 20 Jun 2017 03:30:20 +0000 (20:30 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 20 Jun 2017 03:30:20 +0000 (20:30 -0700)
Since the BFD section count may not be cleared for shared objects during
linking, we should check the DYNAMIC bit for input shared objects.

bfd/

PR ld/21626
* elf-properties.c (_bfd_elf_link_setup_gnu_properties): Check
the DYNAMIC bit instead of bfd_count_sections.

ld/

PR ld/21626
* testsuite/ld-i386/i386.exp: Run ld/21626 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.

bfd/ChangeLog
bfd/elf-properties.c
ld/ChangeLog
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-x86-64/x86-64.exp

index 5177bc749dc05daf3fb68462bbfaa8385a34a979..770fdf16a283ce5b5e87dcf006f3d839e215c502 100644 (file)
@@ -1,3 +1,9 @@
+2017-06-19  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/21626
+       * elf-properties.c (_bfd_elf_link_setup_gnu_properties): Check
+       the DYNAMIC bit instead of bfd_count_sections.
+
 2017-06-19  Nick Clifton  <nickc@redhat.com>
 
        PR binutils/21618
index 2d054dd8b45622d3cc5b95103d8fdf5398704420..13d620d9c47478e7906eecda22422b4d8568571d 100644 (file)
@@ -318,7 +318,7 @@ _bfd_elf_link_setup_gnu_properties (struct bfd_link_info *info)
   /* Find the first relocatable ELF input with GNU properties.  */
   for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link.next)
     if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
-       && bfd_count_sections (abfd) != 0
+       && (abfd->flags & DYNAMIC) == 0
        && elf_properties (abfd) != NULL)
       {
        has_properties = TRUE;
@@ -342,7 +342,7 @@ _bfd_elf_link_setup_gnu_properties (struct bfd_link_info *info)
 
   /* Merge .note.gnu.property sections.  */
   for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link.next)
-    if (abfd != first_pbfd && bfd_count_sections (abfd) != 0)
+    if (abfd != first_pbfd && (abfd->flags & DYNAMIC) == 0)
       {
        elf_property_list *null_ptr = NULL;
        elf_property_list **listp = &null_ptr;
index b16551f98e8500983c31f6f3ae95e82362ed391c..417c464b4effbe712370a804c279527cb32b596b 100644 (file)
@@ -1,3 +1,9 @@
+2017-06-19  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/21626
+       * testsuite/ld-i386/i386.exp: Run ld/21626 tests.
+       * testsuite/ld-x86-64/x86-64.exp: Likewise.
+
 2017-06-18  Alan Modra  <amodra@gmail.com>
 
        * testsuite/lib/ld-lib.exp (is_underscore_target): New.
index a92bd91072ac43c76ef6991ce84e6bc8bd56a63d..2e3c2249f51fbc133245ab4415af25e317be44cc 100644 (file)
@@ -1182,6 +1182,24 @@ run_ld_link_tests [list \
        {{objdump -dwr plt-pic2.dd}} \
        "plt-pic2.so" \
     ] \
+    [list \
+       "Build pr21626.so" \
+       "-shared -melf_i386" \
+       "" \
+       "--32" \
+       {property-x86-3.s} \
+       "" \
+       "pr21626.so" \
+    ] \
+    [list \
+       "Build pr21626" \
+       "-melf_i386 tmpdir/pr21626.so" \
+       "" \
+       "--32" \
+       {start.s foo.s} \
+       "" \
+       "pr21626" \
+    ] \
 ]
 
 # Linux only tests
index 079c161a6f4ab8f2406d33607e3ddb0def03d043..48d8ad2c6757a6a6f637f2d6f4004ed80ce4041a 100644 (file)
@@ -1368,6 +1368,24 @@ run_ld_link_tests [list \
        {{readelf -SW plt2.rd} {objdump -dwr plt2.dd}} \
        "plt2" \
     ] \
+    [list \
+       "Build pr21626.so" \
+       "-shared -melf_x86_64" \
+       "" \
+       "--64 -defsym __64_bit__=1" \
+       {property-x86-3.s} \
+       "" \
+       "pr21626.so" \
+    ] \
+    [list \
+       "Build pr21626" \
+       "-melf_x86_64 tmpdir/pr21626.so" \
+       "" \
+       "--64" \
+       {start.s foo.s} \
+       "" \
+       "pr21626" \
+    ] \
 ]
 
 # Linux only tests
This page took 0.033493 seconds and 4 git commands to generate.