public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Octoploid <cryptooctoploid@gmail.com>,
	Binutils <binutils@sourceware.org>
Subject: Re: Quick --gc-sections question
Date: Wed, 29 Jan 2014 22:36:00 -0000	[thread overview]
Message-ID: <CAMe9rOr8WJ+nGgAYSkkosywjooqcoz+-pCbZy4gcQv8W_Q78fQ@mail.gmail.com> (raw)
In-Reply-To: <20111108053530.GD14325@bubble.grove.modra.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

      parent reply	other threads:[~2014-01-29 22:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-07 19:25 Octoploid
2011-11-07 20:14 ` Ian Lance Taylor
2011-11-07 20:50   ` Octoploid
2011-11-08  5:35     ` Alan Modra
2011-11-08  7:36       ` Octoploid
2014-01-29 22:36       ` H.J. Lu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMe9rOr8WJ+nGgAYSkkosywjooqcoz+-pCbZy4gcQv8W_Q78fQ@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=cryptooctoploid@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).