This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix 16846, LTO mismatched TLS reference


On Wed, Apr 16, 2014 at 8:37 PM, Alan Modra <amodra@gmail.com> wrote:
> On Thu, Apr 17, 2014 at 09:48:19AM +0930, Alan Modra wrote:
>> On Wed, Apr 16, 2014 at 08:16:28AM -0700, H.J. Lu wrote:
>> > On Wed, Apr 16, 2014 at 2:44 AM, Alan Modra <amodra@gmail.com> wrote:
>> > > I think this is all we need to fix pr16848.  HJ, do you see anything
>> > > more we should do here?  I'm wondering why we have type_change_ok
>> > > when oldbfd is the plugin.
>> >
>> > It is because there is no symbol type in plugin.
>>
>> That is precisely why you should *not* need to set type_change_ok!
>> If the old symbol is STT_NOTYPE, then it will not cause a warning
>> that "type of symbol ... changed".  The following seems to be good,
>> but I wanted to ask you first since this is your code..
>
> Oops, sorry.  The TLS checking is yours, the part I'm questioning was
> a patch of mine in 2011.
> https://sourceware.org/ml/binutils/2011-06/msg00238.html
>
> So I'm committing this to fix my mistake.
>
>>       PR 16846
>>       * elflink.c (_bfd_elf_merge_symbol): Ignore TLS mismatch when
>>       current bfd is a plugin.  Don't always set type_change_ok
>>       when old bfd is a plugin.
>

I checked in this patch to add tests for the fix.

-- 
H.J.
---
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 5ac4d37..6fb55b2 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2014-04-22  H.J. Lu  <hongjiu.lu@intel.com>
+
+ PR ld/16846
+ * ld-plugin/lto.exp (lto_link_tests): Add tests for PR ld/16846.
+ * ld-plugin/pr16846a.c: New file.
+ * ld-plugin/pr16846b.c: Likewise.
+ * ld-plugin/pr16846c.c: Likewise.
+
 2014-04-22  Christian Svensson  <blue@cmd.nu>

  * ld-discard/extern.d: Remove openrisc and or32 support.  Add
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 1a525fc..6ff474e 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -139,6 +139,18 @@ set lto_link_tests {
   {"PR ld/15323"
    "" "-O2"
    {pr15323a.c} {} "libdummy.a" "c"}
+  {"Build libdummy.a(1) PR ld/pr16846"
+   "" "-flto"
+   {pr16846a.c pr16846b.c} {} "libdummy.a"}
+  {"Build libdummy.a(2) PR ld/pr16846"
+   "" ""
+   {pr16846c.c} {} "libdummy.a"}
+  {"PR ld/pr16846(1)"
+   "-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846b.o
tmpdir/pr16846c.o" ""
+   {dummy.c} {} "pr16846a.exe"}
+  {"PR ld/pr16846(2)"
+   "-flto -fuse-linker-plugin tmpdir/pr16846a.o tmpdir/pr16846c.o
tmpdir/pr16846b.o" ""
+   {dummy.c} {} "pr16846b.exe"}
 }

 if { [at_least_gcc_version 4 7] } {
diff --git a/ld/testsuite/ld-plugin/pr16846a.c
b/ld/testsuite/ld-plugin/pr16846a.c
new file mode 100644
index 0000000..2f119a4
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr16846a.c
@@ -0,0 +1,7 @@
+extern int bar (void);
+
+int
+main ()
+{
+  return bar ();
+}
diff --git a/ld/testsuite/ld-plugin/pr16846b.c
b/ld/testsuite/ld-plugin/pr16846b.c
new file mode 100644
index 0000000..bd8ddf3
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr16846b.c
@@ -0,0 +1,7 @@
+extern __thread int foo;
+
+int
+bar (void)
+{
+  return foo;
+}
diff --git a/ld/testsuite/ld-plugin/pr16846c.c
b/ld/testsuite/ld-plugin/pr16846c.c
new file mode 100644
index 0000000..3f39c5b
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr16846c.c
@@ -0,0 +1 @@
+__thread int foo;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]