bfd/
authorJakub Jelinek <jakub@redhat.com>
Tue, 1 Oct 2002 09:10:46 +0000 (09:10 +0000)
committerJakub Jelinek <jakub@redhat.com>
Tue, 1 Oct 2002 09:10:46 +0000 (09:10 +0000)
* elf32-i386.c (elf_i386_relocate_section): Resolve R_386_TLS_LDO_32
to st_value + addend in non-code sections.
* elf64-x86-64.c (elf64_x86_64_relocate_section): Resolve
R_X86_64_DTPOFF32 to st_value + addend in non-code sections.

ld/testsuite/
* ld-i386/i386.exp: Add tlsg test.
* ld-i386/tlsg.s: New test.
* ld-i386/tlsg.sd: New test.
* ld-i386/tlsbin.dd: Change LD into LD -> LE in comments.
* ld-i386/tlsbinpic.s: Likewise.
* ld-x86-64/x86-64.exp: Add tlsg test.
* ld-x86-64/tlsg.s: New test.
* ld-x86-64/tlsg.sd: New test.
* ld-x86-64/tlsbin.dd: Change LD into LD -> LE in comments.
* ld-x86-64/tlsbinpic.s: Likewise.

14 files changed:
bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf64-x86-64.c
ld/testsuite/ChangeLog
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/tlsbin.dd
ld/testsuite/ld-i386/tlsbinpic.s
ld/testsuite/ld-i386/tlsg.s [new file with mode: 0644]
ld/testsuite/ld-i386/tlsg.sd [new file with mode: 0644]
ld/testsuite/ld-x86-64/tlsbin.dd
ld/testsuite/ld-x86-64/tlsbinpic.s
ld/testsuite/ld-x86-64/tlsg.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/tlsg.sd [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

index f4fb4e00e6016eca1b4c6e5ec43b3146023a6a71..9ce67794579e3c5d782f606c9e2f72919ee890ea 100644 (file)
@@ -1,3 +1,10 @@
+2002-10-01  Jakub Jelinek  <jakub@redhat.com>
+
+       * elf32-i386.c (elf_i386_relocate_section): Resolve R_386_TLS_LDO_32
+       to st_value + addend in non-code sections.
+       * elf64-x86-64.c (elf64_x86_64_relocate_section): Resolve
+       R_X86_64_DTPOFF32 to st_value + addend in non-code sections.
+
 2002-09-30  Gavin Romig-Koch  <gavin@redhat.com>
             Ken Raeburn  <raeburn@cygnus.com>
             Aldy Hernandez  <aldyh@redhat.com>
index b71d78eb073dbb46a9f1fb893499153966c0c3ba..6bd277e6368bea4821a05f1fb58e8e3e156068a5 100644 (file)
@@ -2926,7 +2926,7 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
          break;
 
        case R_386_TLS_LDO_32:
-         if (info->shared)
+         if (info->shared || (input_section->flags & SEC_CODE) == 0)
            relocation -= dtpoff_base (info);
          else
            /* When converting LDO to LE, we must negate.  */
index fa2f2ee5ec1ebf17d4ddf8b801b0a36f033e88c4..2f92eae38a47497648410781d5661a2bdb7a33d1 100644 (file)
@@ -2496,7 +2496,7 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
          break;
 
        case R_X86_64_DTPOFF32:
-         if (info->shared)
+         if (info->shared || (input_section->flags & SEC_CODE) == 0)
            relocation -= dtpoff_base (info);
          else
            relocation = tpoff (info, relocation);
index 35dda7b4d33090020f70a25192588657fad9a4e2..55a1208bd71efc354b73e08caf73da0fa61c967f 100644 (file)
@@ -1,3 +1,16 @@
+2002-10-01  Jakub Jelinek  <jakub@redhat.com>
+
+       * ld-i386/i386.exp: Add tlsg test.
+       * ld-i386/tlsg.s: New test.
+       * ld-i386/tlsg.sd: New test.
+       * ld-i386/tlsbin.dd: Change LD into LD -> LE in comments.
+       * ld-i386/tlsbinpic.s: Likewise.
+       * ld-x86-64/x86-64.exp: Add tlsg test.
+       * ld-x86-64/tlsg.s: New test.
+       * ld-x86-64/tlsg.sd: New test.
+       * ld-x86-64/tlsbin.dd: Change LD into LD -> LE in comments.
+       * ld-x86-64/tlsbinpic.s: Likewise.
+
 2002-09-30  Alan Modra  <amodra@bigpond.net.au>
 
        * ld-powerpc/powerpc.exp: Restrict to 32 bit ELF.
index 15821ebdbfee6652e7494d1b44755918c3ad52f5..795efc218dbdafd92d89e92ad32ce40f066fcbad 100644 (file)
@@ -52,6 +52,9 @@ set i386tests {
      "--32" {tlsnopic1.s tlsnopic2.s}
      {{readelf -Ssrl tlsnopic.rd} {objdump -drj.text tlsnopic.dd}
       {objdump -sj.got tlsnopic.sd}} "libtlsnopic.so"}
+    {"TLS in debug sections" "-melf_i386"
+     "--32" {tlsg.s}
+     {{objdump -sj.debug_foobar tlsg.sd}} "tlsg"}
     {"Reloc section order" "-shared -melf_i386" "--32" {reloc.s}
      {{objdump -hw reloc.d}} "reloc.so"}
 }
index 9ad0cc3ed32244ba71c7aaf7205cd61193473a73..83c34092273eef6592974d8d853a607dea1e5f23 100644 (file)
@@ -89,7 +89,7 @@ Disassembly of section .text:
  8049082:      90[     ]+nop *
  8049083:      90[     ]+nop *
  8049084:      90[     ]+nop *
-#  LD
+#  LD -> LE
  8049085:      65 a1 00 00 00 00[      ]+mov    %gs:0x0,%eax
  804908b:      90[     ]+nop *
  804908c:      8d 74 26 00[    ]+lea    0x0\(%esi,1\),%esi
@@ -105,7 +105,7 @@ Disassembly of section .text:
  80490a1:      90[     ]+nop *
  80490a2:      90[     ]+nop *
  80490a3:      90[     ]+nop *
-#  LD against hidden variables
+#  LD -> LE against hidden variables
  80490a4:      65 a1 00 00 00 00[      ]+mov    %gs:0x0,%eax
  80490aa:      90[     ]+nop *
  80490ab:      8d 74 26 00[    ]+lea    0x0\(%esi,1\),%esi
index 027773a3e97849d2fabdecf5395341d3ef9bced1..c6b6efa1d9affcc7d71dde445bdf0ba4f59ec4a3 100644 (file)
@@ -83,7 +83,7 @@ fn2:
        call    ___tls_get_addr@plt
        nop;nop;nop;nop
 
-       /* LD */
+       /* LD -> LE */
        leal    sl1@tlsldm(%ebx), %eax
        call    ___tls_get_addr@PLT
        nop;nop
@@ -92,7 +92,7 @@ fn2:
        leal    sl2@dtpoff(%eax), %ecx
        nop;nop;nop;nop
 
-       /* LD against hidden variables */
+       /* LD -> LE against hidden variables */
        leal    sh1@tlsldm(%ebx), %eax
        call    ___tls_get_addr@PLT
        nop;nop
diff --git a/ld/testsuite/ld-i386/tlsg.s b/ld/testsuite/ld-i386/tlsg.s
new file mode 100644 (file)
index 0000000..b8e1a5d
--- /dev/null
@@ -0,0 +1,12 @@
+       .section        .tbss,"awT",@nobits
+       .align 4
+       .skip   24
+       .type   a,@object
+       .size   a,4
+a:
+       .zero   4
+       .text
+       .globl  _start
+_start:
+       .section        .debug_foobar
+       .long   a@dtpoff
diff --git a/ld/testsuite/ld-i386/tlsg.sd b/ld/testsuite/ld-i386/tlsg.sd
new file mode 100644 (file)
index 0000000..d794762
--- /dev/null
@@ -0,0 +1,10 @@
+#source: tlsg.s
+#as: --32
+#ld: -melf_i386
+#objdump: -sj.debug_foobar
+#target: i?86-*-*
+
+.*: +file format elf32-i386
+
+Contents of section .debug_foobar:
+ 0+ 18000000  +.*
index 288b2cd187db5d55696db26aab3e8319be3bc65d..c6aef681529b0b017b62428548dba445357b77bf 100644 (file)
@@ -67,7 +67,7 @@ Disassembly of section .text:
   401065:      90[     ]+nop *
   401066:      90[     ]+nop *
   401067:      90[     ]+nop *
-#  LD
+#  LD -> LE
   401068:      66 66 66 64 48 8b 04[   ]+mov    %fs:0x0,%rax
   40106f:      25 00 00 00 00 *
   401074:      90[     ]+nop *
@@ -82,7 +82,7 @@ Disassembly of section .text:
   401087:      90[     ]+nop *
   401088:      90[     ]+nop *
   401089:      90[     ]+nop *
-#  LD against hidden variables
+#  LD -> LE against hidden variables
   40108a:      66 66 66 64 48 8b 04[   ]+mov    %fs:0x0,%rax
   401091:      25 00 00 00 00 *
   401096:      90[     ]+nop *
index da6085f233d01c2b17e7aee5a2bfe71f5bd6d509..0f5765a52ffa89faa3d3190328ddacdfc706e4f0 100644 (file)
@@ -70,7 +70,7 @@ fn2:
        call    __tls_get_addr@plt
        nop;nop;nop;nop
 
-       /* LD */
+       /* LD -> LE */
        leaq    sl1@tlsld(%rip), %rdi
        call    __tls_get_addr@plt
        nop;nop
@@ -79,7 +79,7 @@ fn2:
        leaq    sl2@dtpoff+2(%rax), %r9
        nop;nop;nop;nop
 
-       /* LD against hidden variables */
+       /* LD -> LE against hidden variables */
        leaq    sh1@tlsld(%rip), %rdi
        call    __tls_get_addr@plt
        nop;nop
diff --git a/ld/testsuite/ld-x86-64/tlsg.s b/ld/testsuite/ld-x86-64/tlsg.s
new file mode 100644 (file)
index 0000000..048e98f
--- /dev/null
@@ -0,0 +1,12 @@
+       .section        .tbss,"awT",@nobits
+       .align 4
+       .skip   24
+       .type   a,@object
+       .size   a,4
+a:
+       .zero   4
+       .text
+       .globl  _start
+_start:
+       .section        .debug_foobar
+       .long   a@dtpoff, 0
diff --git a/ld/testsuite/ld-x86-64/tlsg.sd b/ld/testsuite/ld-x86-64/tlsg.sd
new file mode 100644 (file)
index 0000000..4eaf3cd
--- /dev/null
@@ -0,0 +1,10 @@
+#source: tlsg.s
+#as: --64
+#ld: -melf_x86_64
+#objdump: -sj.debug_foobar
+#target: x86_64-*-*
+
+.*: +file format elf64-x86-64
+
+Contents of section .debug_foobar:
+ 0+ 18000000 0+  +.*
index edfae9a78208efe18ea6608fdda72032cc25e8bc..1bbae430c2bdf3da27a9c282d10a693e18c4f9a9 100644 (file)
@@ -46,6 +46,9 @@ set x86_64tests {
      {{readelf -WSsrl tlsbin.rd} {objdump -drj.text tlsbin.dd}
       {objdump -sj.got tlsbin.sd} {objdump -sj.tdata tlsbin.td}}
       "tlsbin"}
+    {"TLS in debug sections" "-melf_x86_64"
+     "--64" {tlsg.s}
+     {{objdump -sj.debug_foobar tlsg.sd}} "tlsg"}
 }
 
 run_ld_link_tests $x86_64tests