Properly handle R_386_TLS_LDO_32 for PIE.
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 8 Apr 2011 16:14:49 +0000 (16:14 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 8 Apr 2011 16:14:49 +0000 (16:14 +0000)
bfd/

2011-04-08  H.J. Lu  <hongjiu.lu@intel.com>

PR ld/12654
* elf32-i386.c (elf_i386_relocate_section): Check !executable
instead of shared for R_386_TLS_LDO_32.

ld/testsuite/

2011-04-08  H.J. Lu  <hongjiu.lu@intel.com>

PR ld/12654
* ld-i386/i386.exp: Run tlspie2.

* ld-i386/tlspie2.d: New.
* ld-i386/tlspie2.s: Likewise.

bfd/ChangeLog
bfd/elf32-i386.c
ld/testsuite/ChangeLog
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/tlspie2.d [new file with mode: 0644]
ld/testsuite/ld-i386/tlspie2.s [new file with mode: 0644]

index ebc5e183da67800d8b7df0df46d23f0374d95c93..7d6534030c01bba37c57f8e56b4dfa1f870d3125 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-08  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/12654
+       * elf32-i386.c (elf_i386_relocate_section): Check !executable
+       instead of shared for R_386_TLS_LDO_32.
+
 2011-04-08  Tristan Gingold  <gingold@adacore.com>
 
        * Makefile.am (SOURCE_HFILES): Remove xcoff-target.h
index 693c8e89d2ee67ab985e05c57628533bdaa95241..1b76cb4a4540578d19092c50e61a72d328459fce 100644 (file)
@@ -4025,7 +4025,7 @@ elf_i386_relocate_section (bfd *output_bfd,
          break;
 
        case R_386_TLS_LDO_32:
-         if (info->shared || (input_section->flags & SEC_CODE) == 0)
+         if (!info->executable || (input_section->flags & SEC_CODE) == 0)
            relocation -= elf_i386_dtpoff_base (info);
          else
            /* When converting LDO to LE, we must negate.  */
index 7c81bcb711becd3180620b0e3d5599dbd9264aa1..f6081e1bda85c3b3eb3e0378aa7cb0a97a6eeb35 100644 (file)
@@ -1,3 +1,11 @@
+2011-04-08  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/12654
+       * ld-i386/i386.exp: Run tlspie2.
+
+       * ld-i386/tlspie2.d: New.
+       * ld-i386/tlspie2.s: Likewise.
+
 2011-04-06  Joseph Myers  <joseph@codesourcery.com>
 
        * ld-selective/selective.exp (xscale-*-*): Don't handle.
index ead0df166793a2c7d39a0f2da523a21b6c3bc90e..cc82e151332d6494d861c1489cc24486d3727107 100644 (file)
@@ -190,6 +190,7 @@ run_dump_test "protected1"
 run_dump_test "protected2"
 run_dump_test "protected3"
 run_dump_test "tlspie1"
+run_dump_test "tlspie2"
 run_dump_test "nogot1"
 run_dump_test "nogot2"
 run_dump_test "discarded1"
diff --git a/ld/testsuite/ld-i386/tlspie2.d b/ld/testsuite/ld-i386/tlspie2.d
new file mode 100644 (file)
index 0000000..16d6ae4
--- /dev/null
@@ -0,0 +1,13 @@
+#name: TLS with PIE
+#as: --32
+#ld: -melf_i386 -pie
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+188 <_start>:
+[      ]*[a-f0-9]+:    8d 05 fc ff ff ff       lea    0xfffffffc,%eax
+#pass
diff --git a/ld/testsuite/ld-i386/tlspie2.s b/ld/testsuite/ld-i386/tlspie2.s
new file mode 100644 (file)
index 0000000..a586430
--- /dev/null
@@ -0,0 +1,12 @@
+       .section        .tbss,"awT",@nobits
+       .align 4
+       .type   a, @object
+       .size   a, 4
+a:
+       .zero   4
+       .text
+.globl _start
+       .type   _start, @function
+_start:
+       leal    a@dtpoff, %eax
+       .size   _start, .-_start