This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Quick --gc-sections question
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Octoploid <cryptooctoploid at gmail dot com>, Binutils <binutils at sourceware dot org>
- Date: Wed, 29 Jan 2014 14:35:59 -0800
- Subject: Re: Quick --gc-sections question
- Authentication-results: sourceware.org; auth=none
- References: <CAOxViumdxWDOR1GRGdHkRUyMyOgZuEeu2vZwZz9AEkMWK5eJ9g at mail dot gmail dot com> <mcrpqh36687 dot fsf at dhcp-172-18-216-180 dot mtv dot corp dot google dot com> <CAOxViu=2wYP=RK0V9hvES1iXGZfRRH=TjduLLXK5yNeMGeZGvQ at mail dot gmail dot com> <20111108053530 dot GD14325 at bubble dot grove dot modra dot org>
On Mon, Nov 7, 2011 at 9:35 PM, Alan Modra <amodra@gmail.com> wrote:
> On Mon, Nov 07, 2011 at 09:50:26PM +0100, Octoploid wrote:
>> On Mon, Nov 7, 2011 at 9:13 PM, Ian Lance Taylor <iant@google.com> wrote:
>> > I'll note that this was recently fixed in gold. If --export-dynamic is
>> > passed to the linker, I think we should not garbage collect globally
>> > visible functions.
>
> Try this.
>
> * elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Mark syms in
> executables when export_dynamic.
>
> Index: bfd/elflink.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/elflink.c,v
> retrieving revision 1.428
> diff -u -p -r1.428 elflink.c
> --- bfd/elflink.c 19 Oct 2011 07:17:19 -0000 1.428
> +++ bfd/elflink.c 8 Nov 2011 05:31:11 -0000
> @@ -11947,7 +11947,7 @@ bfd_elf_gc_mark_dynamic_ref_symbol (stru
> if ((h->root.type == bfd_link_hash_defined
> || h->root.type == bfd_link_hash_defweak)
> && (h->ref_dynamic
> - || (!info->executable
> + || ((!info->executable || info->export_dynamic)
> && h->def_regular
> && ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
> && ELF_ST_VISIBILITY (h->other) != STV_HIDDEN
>
>
I checked in this patch to make sure that the bug stays fixed.
--
H.J.
--
commit 50a53d3ffecd6610fbfd40017224055ea252dea9
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Jan 29 14:30:41 2014 -0800
Add rdynamic-1 test
It is added for
commit 409ff343a402799563f71f938138b29f8baf7a1c
Author: Alan Modra <amodra@gmail.com>
Date: Tue Nov 8 13:49:11 2011 +0000
* elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Mark syms in
executables when export_dynamic.
* ld-elf/rdynamic-1.c: New file.
* ld-elf/rdynamic-1.rd: Likewise.
* ld-elf/shared.exp (build_tests): Add rdynamic-1.
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index d3a9f29..3cd1930 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2014-01-29 H.J. Lu <hongjiu.lu@intel.com>
+
+ * ld-elf/rdynamic-1.c: New file.
+ * ld-elf/rdynamic-1.rd: Likewise.
+
+ * ld-elf/shared.exp (build_tests): Add rdynamic-1.
+
2014-01-28 Nick Clifton <nickc@redhat.com>
PR binutils/16317
diff --git a/ld/testsuite/ld-elf/rdynamic-1.c b/ld/testsuite/ld-elf/rdynamic-1.c
new file mode 100644
index 0000000..7c9d1ab
--- /dev/null
+++ b/ld/testsuite/ld-elf/rdynamic-1.c
@@ -0,0 +1,10 @@
+void
+rdynamic ()
+{
+}
+
+int
+main ()
+{
+ return 0;
+}
diff --git a/ld/testsuite/ld-elf/rdynamic-1.rd
b/ld/testsuite/ld-elf/rdynamic-1.rd
new file mode 100644
index 0000000..dbf3602
--- /dev/null
+++ b/ld/testsuite/ld-elf/rdynamic-1.rd
@@ -0,0 +1,5 @@
+Symbol table '\.dynsym' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT +[0-9]+ +_?rdynamic
+#...
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index bbfd464..981ce71 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -224,6 +224,9 @@ set build_tests {
{"Build libpr2404b.a"
"" ""
{pr2404b.c} {} "libpr2404b.a"}
+ {"Build rdynamic-1"
+ "-rdynamic -Wl,--gc-sections" "-ffunction-sections"
+ {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"}
}
run_cc_link_tests $build_tests