From 9c1d7a087682074d585253ad38719ec2363eb2b7 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 8 Mar 2016 20:41:41 -0800 Subject: [PATCH] Don't create dynamic sections when relocatable 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 | 6 ++++++ bfd/elflink.c | 4 ++-- ld/ChangeLog | 6 ++++++ ld/testsuite/ld-elf/pr19789.d | 10 ++++++++++ ld/testsuite/ld-elf/pr19789.s | 9 +++++++++ 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 ld/testsuite/ld-elf/pr19789.d create mode 100644 ld/testsuite/ld-elf/pr19789.s diff --git a/bfd/ChangeLog b/bfd/ChangeLog index e2193a59f1a..fe08c0280c3 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2016-03-08 H.J. Lu + + 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 PR ld/19784 diff --git a/bfd/elflink.c b/bfd/elflink.c index ccff7808c3a..991efacfe1c 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -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) diff --git a/ld/ChangeLog b/ld/ChangeLog index 73f67b0ca3c..8776e4c8818 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2016-03-08 H.J. Lu + + PR ld/19789 + * testsuite/ld-elf/pr19789.d: New file. + * testsuite/ld-elf/pr19789.s: Likewise. + 2016-03-08 H.J. Lu PR ld/19784 diff --git a/ld/testsuite/ld-elf/pr19789.d b/ld/testsuite/ld-elf/pr19789.d new file mode 100644 index 00000000000..e7cc6c5c186 --- /dev/null +++ b/ld/testsuite/ld-elf/pr19789.d @@ -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 index 00000000000..31be1b04579 --- /dev/null +++ b/ld/testsuite/ld-elf/pr19789.s @@ -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 -- 2.30.2