Don't create dynamic sections when relocatable
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 9 Mar 2016 04:41:41 +0000 (20:41 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 9 Mar 2016 04:45:52 +0000 (20:45 -0800)
Since dynamic sections aren't applicable to relocatable file, don't
create dynamic sections for -E/--dynamic-list when relocatable.

bfd/

PR ld/19789
* elflink.c (elf_link_add_object_symbols): Create dynamic sections
for -E/--dynamic-list only when not relocatable.

ld/

PR ld/19789
* testsuite/ld-elf/pr19789.d: New file.
* testsuite/ld-elf/pr19789.s: Likewise.

bfd/ChangeLog
bfd/elflink.c
ld/ChangeLog
ld/testsuite/ld-elf/pr19789.d [new file with mode: 0644]
ld/testsuite/ld-elf/pr19789.s [new file with mode: 0644]

index e2193a59f1a0753a238aa22c6bb116aa97091609..fe08c0280c366032c5f1dc5d59308b335cab45b4 100644 (file)
@@ -1,3 +1,9 @@
+2016-03-08  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/19789
+       * elflink.c (elf_link_add_object_symbols): Create dynamic sections
+       for -E/--dynamic-list only when not relocatable.
+
 2016-03-08  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/19784
index ccff7808c3a0ca6e0d9c4868b66f88cccba6c9ed..991efacfe1c96b25ad0e12cf376d2f91b7e30261 100644 (file)
@@ -3621,8 +3621,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
         make a shared library.  */
       if (!just_syms
          && (bfd_link_pic (info)
-             || info->export_dynamic
-             || info->dynamic)
+             || (!bfd_link_relocatable (info)
+                 && (info->export_dynamic || info->dynamic)))
          && is_elf_hash_table (htab)
          && info->output_bfd->xvec == abfd->xvec
          && !htab->dynamic_sections_created)
index 73f67b0ca3cacb0b2bfb8b65afefadfad4d23f8b..8776e4c8818f3c9929e26e962f37b425c80b1cec 100644 (file)
@@ -1,3 +1,9 @@
+2016-03-08  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/19789
+       * testsuite/ld-elf/pr19789.d: New file.
+       * testsuite/ld-elf/pr19789.s: Likewise.
+
 2016-03-08  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/19784
diff --git a/ld/testsuite/ld-elf/pr19789.d b/ld/testsuite/ld-elf/pr19789.d
new file mode 100644 (file)
index 0000000..e7cc6c5
--- /dev/null
@@ -0,0 +1,10 @@
+#ld: -r -E
+#readelf: -s --wide
+#target: *-*-linux* *-*-gnu* *-*-solaris*
+
+Symbol table '\.symtab' contains [0-9]+ entries:
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT +[0-9]+ +foo@@VERS.2
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT +[0-9]+ +foo@VERS.1
+#pass
diff --git a/ld/testsuite/ld-elf/pr19789.s b/ld/testsuite/ld-elf/pr19789.s
new file mode 100644 (file)
index 0000000..31be1b0
--- /dev/null
@@ -0,0 +1,9 @@
+       .text
+       .globl  __foo
+       .type   __foo, %function
+__foo:
+       .byte 0
+       .globl  __foo1
+       .set __foo1, __foo
+       .symver __foo,foo@@VERS.2
+       .symver __foo1,foo@VERS.1
This page took 0.034693 seconds and 4 git commands to generate.