Define __start/__stop symbols when there is only a dynamic def

H.J. Lu hjl.tools@gmail.com
Wed Jan 31 22:58:00 GMT 2018


On Wed, Jan 31, 2018 at 5:45 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Jan 31, 2018 at 5:41 AM, Michael Matz <matz@suse.de> wrote:
>> Hi,
>>
>> On Wed, 31 Jan 2018, H.J. Lu wrote:
>>
>>> On Wed, Jan 31, 2018 at 5:02 AM, Michael Matz <matz@suse.de> wrote:
>>> > Hi,
>>> >
>>> > On Wed, 31 Jan 2018, Alan Modra wrote:
>>> >
>>> >> On Tue, Jan 30, 2018 at 07:56:59PM -0800, H.J. Lu wrote:
>>> >> > I think we should check ref_dynamic, not def_dynamic, for __start/__stiop
>>> >> > symbols.
>>> >>
>>> >> Yes, I've thought about it a bit more and I think that would be
>>> >> better.
>>> >
>>> > Only checking ref_dynamic would mean that my testcase doesn't work
>>> > anymore.  I.e. the pacemaker situation wouldn't be improved and we could
>>> > have spared the whole merry-go-round.
>>>
>>> Are you really sure that your testcase:
>>>
>>> https://sourceware.org/ml/binutils/2018-01/msg00432.html
>>>
>>> doesn't have a reference from shared object?
>>
>> Before writing my mail I've checked that testcase, so: yes, I'm sure it
>> doesn't work with just checking ref_dynamic.
>>
>> I've pushed the testcase and the fix approved by Alan, so you can have a
>> look yourself.
>
> Great.  I hope we finally nailed it :-).
>

I checked in this patch.

-- 
H.J.
--From f000c2b940e82736d8a58387d73ac48bc38a4220 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 31 Jan 2018 12:42:28 -0800
Subject: [PATCH] Fix testsuite/ld-elf/pr21964-5.c

Mark my_var as used.  Otherwise it fails at -O2.

* testsuite/ld-elf/pr21964-5.c (my_var): Mark as used.
---
 ld/ChangeLog                    | 4 ++++
 ld/testsuite/ld-elf/pr21964-5.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index ba42294a9a..2db90b5157 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,7 @@
+2018-01-31  H.J. Lu  <hongjiu.lu@intel.com>
+
+ * testsuite/ld-elf/pr21964-5.c (my_var): Mark as used.
+
 2018-01-31  Maciej W. Rozycki  <macro@mips.com>

  * testsuite/ld-elf/shared.exp: Fix a typo s/scrip/script/.
diff --git a/ld/testsuite/ld-elf/pr21964-5.c b/ld/testsuite/ld-elf/pr21964-5.c
index 56ed5a9eed..bc77422a56 100644
--- a/ld/testsuite/ld-elf/pr21964-5.c
+++ b/ld/testsuite/ld-elf/pr21964-5.c
@@ -9,7 +9,7 @@ extern int __start___verbose[];
 extern int __stop___verbose[];
 int bar (void)
 {
-  static int my_var __attribute__((section("__verbose"))) = 6;
+  static int my_var __attribute__((section("__verbose"), used)) = 6;
   int *ptr;
   ptr = (int*) dlsym(RTLD_DEFAULT, "__start___verbose");
   if (!ptr || *ptr != 6)
--



More information about the Binutils mailing list