* ld-mips-elf/tlsbin-o32.s, ld-mips-elf/mips-dyn.ld,
authorDaniel Jacobowitz <drow@false.org>
Wed, 2 Mar 2005 21:22:57 +0000 (21:22 +0000)
committerDaniel Jacobowitz <drow@false.org>
Wed, 2 Mar 2005 21:22:57 +0000 (21:22 +0000)
ld-mips-elf/tlslib-o32.got, ld-mips-elf/tlslib-o32.d,
ld-mips-elf/tlslib-o32.s, ld-mips-elf/mips-lib.ld,
ld-mips-elf/tlsbin-o32.got, ld-mips-elf/tlsdyn-o32.d,
ld-mips-elf/tlsdyn-o32.got, ld-mips-elf/tlsbin-o32.d,
ld-mips-elf/tlsdyn-o32.s, ld-mips-elf/tls-multi-got-1.got,
ld-mips-elf/tls-multi-got-1-1.s, ld-mips-elf/tls-multi-got-1.d,
ld-mips-elf/tls-multi-got-1.r, ld-mips-elf/tls-multi-got-1-2.s,
ld-mips-elf/tlslib-o32-ver.got, ld-mips-elf/tlslib.ver,
ld-mips-elf/tlslib-o32-hidden.got, ld-mips-elf/tlslib-hidden.ver,
ld-mips-elf/tlsdyn-o32-1.d, ld-mips-elf/tlsdyn-o32-3.got,
ld-mips-elf/tlsdyn-o32-2.d, ld-mips-elf/tlsdyn-o32-2.s,
ld-mips-elf/tlsdyn-o32-3.d, ld-mips-elf/tlsdyn-o32-1.got,
ld-mips-elf/tlsdyn-o32-2.got: New files.
* ld-mips-elf/mips-elf.exp: Run the new tests.

29 files changed:
ld/testsuite/ChangeLog
ld/testsuite/ld-mips-elf/mips-dyn.ld [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips-elf.exp
ld/testsuite/ld-mips-elf/mips-lib.ld [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tls-multi-got-1-1.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tls-multi-got-1-2.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tls-multi-got-1.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tls-multi-got-1.got [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tls-multi-got-1.r [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlsbin-o32.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlsbin-o32.got [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlsbin-o32.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlsdyn-o32-2.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlsdyn-o32.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlsdyn-o32.got [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlsdyn-o32.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlslib-hidden.ver [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlslib-o32-ver.got [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlslib-o32.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlslib-o32.got [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlslib-o32.s [new file with mode: 0644]
ld/testsuite/ld-mips-elf/tlslib.ver [new file with mode: 0644]

index d93c83f..e49ff3e 100644 (file)
@@ -1,3 +1,21 @@
+2005-03-02  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * ld-mips-elf/tlsbin-o32.s, ld-mips-elf/mips-dyn.ld,
+       ld-mips-elf/tlslib-o32.got, ld-mips-elf/tlslib-o32.d,
+       ld-mips-elf/tlslib-o32.s, ld-mips-elf/mips-lib.ld,
+       ld-mips-elf/tlsbin-o32.got, ld-mips-elf/tlsdyn-o32.d,
+       ld-mips-elf/tlsdyn-o32.got, ld-mips-elf/tlsbin-o32.d,
+       ld-mips-elf/tlsdyn-o32.s, ld-mips-elf/tls-multi-got-1.got,
+       ld-mips-elf/tls-multi-got-1-1.s, ld-mips-elf/tls-multi-got-1.d,
+       ld-mips-elf/tls-multi-got-1.r, ld-mips-elf/tls-multi-got-1-2.s,
+       ld-mips-elf/tlslib-o32-ver.got, ld-mips-elf/tlslib.ver,
+       ld-mips-elf/tlslib-o32-hidden.got, ld-mips-elf/tlslib-hidden.ver,
+       ld-mips-elf/tlsdyn-o32-1.d, ld-mips-elf/tlsdyn-o32-3.got,
+       ld-mips-elf/tlsdyn-o32-2.d, ld-mips-elf/tlsdyn-o32-2.s,
+       ld-mips-elf/tlsdyn-o32-3.d, ld-mips-elf/tlsdyn-o32-1.got,
+       ld-mips-elf/tlsdyn-o32-2.got: New files.
+       * ld-mips-elf/mips-elf.exp: Run the new tests.
+
 2005-03-01  Nick Clifton  <nickc@redhat.com>
 
        * ld-d10v/default_layout.d: Adjust expected offsets to allow for
diff --git a/ld/testsuite/ld-mips-elf/mips-dyn.ld b/ld/testsuite/ld-mips-elf/mips-dyn.ld
new file mode 100644 (file)
index 0000000..8f734d2
--- /dev/null
@@ -0,0 +1,223 @@
+/* Script for -z combreloc: combine and sort reloc sections */
+OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips",
+             "elf32-tradlittlemips")
+OUTPUT_ARCH(mips)
+ENTRY(__start)
+SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
+/* Do we need any of these for elf?
+   __DYNAMIC = 0;    */
+SECTIONS
+{
+  /* Read-only sections, merged into text segment: */
+  PROVIDE (__executable_start = 0x0400000); . = 0x0400000 + SIZEOF_HEADERS;
+  .interp         : { *(.interp) }
+  .reginfo        : { *(.reginfo) }
+  .dynamic        : { *(.dynamic) }
+  .hash           : { *(.hash) }
+  .dynsym         : { *(.dynsym) }
+  .dynstr         : { *(.dynstr) }
+  .gnu.version    : { *(.gnu.version) }
+  .gnu.version_d  : { *(.gnu.version_d) }
+  .gnu.version_r  : { *(.gnu.version_r) }
+  .rel.dyn        :
+    {
+      *(.rel.init)
+      *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
+      *(.rel.fini)
+      *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
+      *(.rel.data.rel.ro*)
+      *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
+      *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
+      *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
+      *(.rel.ctors)
+      *(.rel.dtors)
+      *(.rel.got)
+      *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*)
+      *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*)
+      *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*)
+      *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*)
+      *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
+    }
+  .rela.dyn       :
+    {
+      *(.rela.init)
+      *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
+      *(.rela.fini)
+      *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
+      *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
+      *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
+      *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
+      *(.rela.ctors)
+      *(.rela.dtors)
+      *(.rela.got)
+      *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
+      *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
+      *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
+      *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
+      *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
+    }
+  .rel.plt        : { *(.rel.plt) }
+  .rela.plt       : { *(.rela.plt) }
+  .init           :
+  {
+    KEEP (*(.init))
+  } =0
+  .plt            : { *(.plt) }
+  .text           :
+  {
+    _ftext = . ;
+    *(.text .stub .text.* .gnu.linkonce.t.*)
+    KEEP (*(.text.*personality*))
+    /* .gnu.warning sections are handled specially by elf32.em.  */
+    *(.gnu.warning)
+    *(.mips16.fn.*) *(.mips16.call.*)
+  } =0
+  .fini           :
+  {
+    KEEP (*(.fini))
+  } =0
+  PROVIDE (__etext = .);
+  PROVIDE (_etext = .);
+  PROVIDE (etext = .);
+  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
+  .rodata1        : { *(.rodata1) }
+  .sdata2         : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) }
+  .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
+  .eh_frame_hdr : { *(.eh_frame_hdr) }
+  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
+  .gcc_except_table   : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
+  /* Adjust the address for the data segment.  We want to adjust up to
+     the same address within the page on the next page up.  */
+  . = 0x10000000;
+  /* Exception handling  */
+  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
+  .gcc_except_table   : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
+  /* Thread Local Storage sections  */
+  .tdata         : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
+  .tbss                  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
+  /* Ensure the __preinit_array_start label is properly aligned.  We
+     could instead move the label definition inside the section, but
+     the linker would then create the section even if it turns out to
+     be empty, which isn't pretty.  */
+  . = ALIGN(32 / 8);
+  PROVIDE (__preinit_array_start = .);
+  .preinit_array     : { KEEP (*(.preinit_array)) }
+  PROVIDE (__preinit_array_end = .);
+  PROVIDE (__init_array_start = .);
+  .init_array     : { KEEP (*(.init_array)) }
+  PROVIDE (__init_array_end = .);
+  PROVIDE (__fini_array_start = .);
+  .fini_array     : { KEEP (*(.fini_array)) }
+  PROVIDE (__fini_array_end = .);
+  .ctors          :
+  {
+    /* gcc uses crtbegin.o to find the start of
+       the constructors, so we make sure it is
+       first.  Because this is a wildcard, it
+       doesn't matter if the user does not
+       actually link against crtbegin.o; the
+       linker won't look for a file to match a
+       wildcard.  The wildcard also means that it
+       doesn't matter which directory crtbegin.o
+       is in.  */
+    KEEP (*crtbegin*.o(.ctors))
+    /* We don't want to include the .ctor section from
+       from the crtend.o file until after the sorted ctors.
+       The .ctor section from the crtend file contains the
+       end of ctors marker and it must be last */
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
+    KEEP (*(SORT(.ctors.*)))
+    KEEP (*(.ctors))
+  }
+  .dtors          :
+  {
+    KEEP (*crtbegin*.o(.dtors))
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
+    KEEP (*(SORT(.dtors.*)))
+    KEEP (*(.dtors))
+  }
+  .jcr            : { KEEP (*(.jcr)) }
+  .data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) }
+  .data           :
+  {
+    _fdata = . ;
+    *(.data .data.* .gnu.linkonce.d.*)
+    KEEP (*(.gnu.linkonce.d.*personality*))
+    SORT(CONSTRUCTORS)
+  }
+  .data1          : { *(.data1) }
+  _gp = ALIGN(16) + 0x7ff0;
+  .got            : { *(.got.plt) *(.got) }
+  /* We want the small data sections together, so single-instruction offsets
+     can access them all, and initialized data all before uninitialized, so
+     we can shorten the on-disk segment size.  */
+  .sdata          :
+  {
+    *(.sdata .sdata.* .gnu.linkonce.s.*)
+  }
+  .lit8           : { *(.lit8) }
+  .lit4           : { *(.lit4) }
+  _edata = .;
+  PROVIDE (edata = .);
+  __bss_start = .;
+  _fbss = .;
+  .sbss           :
+  {
+    PROVIDE (__sbss_start = .);
+    PROVIDE (___sbss_start = .);
+    *(.dynsbss)
+    *(.sbss .sbss.* .gnu.linkonce.sb.*)
+    *(.scommon)
+    PROVIDE (__sbss_end = .);
+    PROVIDE (___sbss_end = .);
+  }
+  .bss            :
+  {
+   *(.dynbss)
+   *(.bss .bss.* .gnu.linkonce.b.*)
+   *(COMMON)
+   /* Align here to ensure that the .bss section occupies space up to
+      _end.  Align after .bss to ensure correct alignment even if the
+      .bss section disappears because there are no input sections.  */
+   . = ALIGN(32 / 8);
+  }
+  . = ALIGN(32 / 8);
+  _end = .;
+  PROVIDE (end = .);
+  /* Stabs debugging sections.  */
+  .stab          0 : { *(.stab) }
+  .stabstr       0 : { *(.stabstr) }
+  .stab.excl     0 : { *(.stab.excl) }
+  .stab.exclstr  0 : { *(.stab.exclstr) }
+  .stab.index    0 : { *(.stab.index) }
+  .stab.indexstr 0 : { *(.stab.indexstr) }
+  .comment       0 : { *(.comment) }
+  /* DWARF debug sections.
+     Symbols in the DWARF debugging sections are relative to the beginning
+     of the section so we begin them at 0.  */
+  /* DWARF 1 */
+  .debug          0 : { *(.debug) }
+  .line           0 : { *(.line) }
+  /* GNU DWARF 1 extensions */
+  .debug_srcinfo  0 : { *(.debug_srcinfo) }
+  .debug_sfnames  0 : { *(.debug_sfnames) }
+  /* DWARF 1.1 and DWARF 2 */
+  .debug_aranges  0 : { *(.debug_aranges) }
+  .debug_pubnames 0 : { *(.debug_pubnames) }
+  /* DWARF 2 */
+  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
+  .debug_abbrev   0 : { *(.debug_abbrev) }
+  .debug_line     0 : { *(.debug_line) }
+  .debug_frame    0 : { *(.debug_frame) }
+  .debug_str      0 : { *(.debug_str) }
+  .debug_loc      0 : { *(.debug_loc) }
+  .debug_macinfo  0 : { *(.debug_macinfo) }
+  /* SGI/MIPS DWARF 2 extensions */
+  .debug_weaknames 0 : { *(.debug_weaknames) }
+  .debug_funcnames 0 : { *(.debug_funcnames) }
+  .debug_typenames 0 : { *(.debug_typenames) }
+  .debug_varnames  0 : { *(.debug_varnames) }
+  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
+  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
+  /DISCARD/ : { *(.note.GNU-stack) }
+}
index 15574e7..6cc7d9a 100644 (file)
@@ -1,5 +1,5 @@
 # Expect script for MIPS ELF linker tests
-#   Copyright 2002, 2003 Free Software Foundation, Inc.
+#   Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 #
 # This file is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -99,3 +99,67 @@ run_dump_test "mips16-hilo"
 if {$has_newabi} {
     run_dump_test "mips16-hilo-n32"
 }
+
+# For tests which may involve multiple files, use run_ld_link_tests.
+
+# List contains test-items with 3 items followed by 2 lists:
+# 0:name 1:ld options 2:assembler options
+# 3:filenames of assembler files 4: action and options. 5: name of output file
+
+# Actions:
+# objdump: Apply objdump options on result.  Compare with regex (last arg).
+# nm: Apply nm options on result.  Compare with regex (last arg).
+# readelf: Apply readelf options on result.  Compare with regex (last arg).
+
+set mips_tls_tests {
+    {"Static executable with TLS" "-static -melf32btsmip -T mips-dyn.ld"
+     "-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s}
+     {{objdump {-dr -m mips:isa32r2} tlsbin-o32.d} {objdump -srj.got tlsbin-o32.got}}
+     "tls-static-o32"}
+    {"Shared library with TLS" "-shared -melf32btsmip -T mips-lib.ld"
+     "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
+     {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32.got}}
+     "tlslib-o32.so"}
+    {"Dynamic executable with TLS"
+     "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so"
+     "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s}
+     {{objdump {-dr -m mips:isa32r2} tlsdyn-o32.d} {objdump -Rsj.got tlsdyn-o32.got}}
+     "tls-dynamic-o32"}
+    {"Shared library with multiple GOTs and TLS"
+     "-shared -melf32btsmip -T mips-lib.ld"
+     "-EB -march=mips1 -32 -KPIC" {tls-multi-got-1-1.s tls-multi-got-1-2.s}
+     {{readelf {-d -r} tls-multi-got-1.r}
+      {objdump {-dr -m mips:isa32r2} tls-multi-got-1.d}
+      {objdump -Rsj.got tls-multi-got-1.got}}
+     "tlslib-multi.so"}
+    {"Shared library with TLS and versioning"
+     "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib.ver"
+     "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
+     {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-ver.got}}
+     "tlslib-o32-ver.so"}
+    {"Dynamic executable with TLS and versioning"
+     "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32-ver.so"
+     "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s tlsdyn-o32-2.s}
+     {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-1.d} {objdump -Rsj.got tlsdyn-o32-1.got}}
+     "tls-dynamic-o32-ver"}
+    {"Dynamic executable with TLS and versioning (order 2)"
+     "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32-2.o"
+     "-EB -march=mips1 -32 -KPIC" {}
+     {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-2.d} {objdump -Rsj.got tlsdyn-o32-2.got}}
+     "tls-dynamic-o32-ver-2"}
+    {"Dynamic executable with TLS and versioning (order 3)"
+     "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32-2.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32.o"
+     "-EB -march=mips1 -32 -KPIC" {}
+     {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-3.d} {objdump -Rsj.got tlsdyn-o32-3.got}}
+     "tls-dynamic-o32-ver-3"}
+    {"Shared library with TLS and hidden symbols"
+     "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib-hidden.ver"
+     "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
+     {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-hidden.got}}
+     "tlslib-o32-hidden.so"}
+}
+
+if {[istarget mips*-*-linux*]} {
+    run_ld_link_tests $mips_tls_tests
+}
+
diff --git a/ld/testsuite/ld-mips-elf/mips-lib.ld b/ld/testsuite/ld-mips-elf/mips-lib.ld
new file mode 100644 (file)
index 0000000..10b4140
--- /dev/null
@@ -0,0 +1,218 @@
+/* Script for --shared -z combreloc: shared library, combine & sort relocs */
+OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips",
+             "elf32-tradlittlemips")
+OUTPUT_ARCH(mips)
+ENTRY(__start)
+SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
+/* Do we need any of these for elf?
+   __DYNAMIC = 0;    */
+SECTIONS
+{
+  /* Read-only sections, merged into text segment: */
+  . = 0 + SIZEOF_HEADERS;
+  .reginfo        : { *(.reginfo) }
+  .dynamic        : { *(.dynamic) }
+  .hash           : { *(.hash) }
+  .dynsym         : { *(.dynsym) }
+  .dynstr         : { *(.dynstr) }
+  .gnu.version    : { *(.gnu.version) }
+  .gnu.version_d  : { *(.gnu.version_d) }
+  .gnu.version_r  : { *(.gnu.version_r) }
+  .rel.dyn        :
+    {
+      *(.rel.init)
+      *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
+      *(.rel.fini)
+      *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
+      *(.rel.data.rel.ro*)
+      *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
+      *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
+      *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
+      *(.rel.ctors)
+      *(.rel.dtors)
+      *(.rel.got)
+      *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*)
+      *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*)
+      *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*)
+      *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*)
+      *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
+    }
+  .rela.dyn       :
+    {
+      *(.rela.init)
+      *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
+      *(.rela.fini)
+      *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
+      *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
+      *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
+      *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
+      *(.rela.ctors)
+      *(.rela.dtors)
+      *(.rela.got)
+      *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
+      *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
+      *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
+      *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
+      *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
+    }
+  .rel.plt        : { *(.rel.plt) }
+  .rela.plt       : { *(.rela.plt) }
+  .init           :
+  {
+    KEEP (*(.init))
+  } =0
+  .plt            : { *(.plt) }
+  .text           :
+  {
+    _ftext = . ;
+    *(.text .stub .text.* .gnu.linkonce.t.*)
+    KEEP (*(.text.*personality*))
+    /* .gnu.warning sections are handled specially by elf32.em.  */
+    *(.gnu.warning)
+    *(.mips16.fn.*) *(.mips16.call.*)
+  } =0
+  .fini           :
+  {
+    KEEP (*(.fini))
+  } =0
+  PROVIDE (__etext = .);
+  PROVIDE (_etext = .);
+  PROVIDE (etext = .);
+  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
+  .rodata1        : { *(.rodata1) }
+  .eh_frame_hdr : { *(.eh_frame_hdr) }
+  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
+  .gcc_except_table   : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
+  /* Adjust the address for the data segment.  We want to adjust up to
+     the same address within the page on the next page up.  */
+  . = ALIGN (0x40000) - ((0x40000 - .) & (0x40000 - 1)); . = DATA_SEGMENT_ALIGN (0x40000, 0x1000);
+  /* Exception handling  */
+  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
+  .gcc_except_table   : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
+  /* Thread Local Storage sections  */
+  .tdata         : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
+  .tbss                  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
+  /* Ensure the __preinit_array_start label is properly aligned.  We
+     could instead move the label definition inside the section, but
+     the linker would then create the section even if it turns out to
+     be empty, which isn't pretty.  */
+  . = ALIGN(32 / 8);
+  .preinit_array     : { KEEP (*(.preinit_array)) }
+  .init_array     : { KEEP (*(.init_array)) }
+  .fini_array     : { KEEP (*(.fini_array)) }
+  .ctors          :
+  {
+    /* gcc uses crtbegin.o to find the start of
+       the constructors, so we make sure it is
+       first.  Because this is a wildcard, it
+       doesn't matter if the user does not
+       actually link against crtbegin.o; the
+       linker won't look for a file to match a
+       wildcard.  The wildcard also means that it
+       doesn't matter which directory crtbegin.o
+       is in.  */
+    KEEP (*crtbegin*.o(.ctors))
+    /* We don't want to include the .ctor section from
+       from the crtend.o file until after the sorted ctors.
+       The .ctor section from the crtend file contains the
+       end of ctors marker and it must be last */
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
+    KEEP (*(SORT(.ctors.*)))
+    KEEP (*(.ctors))
+  }
+  .dtors          :
+  {
+    KEEP (*crtbegin*.o(.dtors))
+    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
+    KEEP (*(SORT(.dtors.*)))
+    KEEP (*(.dtors))
+  }
+  .jcr            : { KEEP (*(.jcr)) }
+  .data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) }
+  . = DATA_SEGMENT_RELRO_END (0, .);
+  .data           :
+  {
+    _fdata = . ;
+    *(.data .data.* .gnu.linkonce.d.*)
+    KEEP (*(.gnu.linkonce.d.*personality*))
+    SORT(CONSTRUCTORS)
+  }
+  .data1          : { *(.data1) }
+  _gp = ALIGN(16) + 0x7ff0;
+  .got            : { *(.got.plt) *(.got) }
+  .sdata2         : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) }
+  .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
+  /* We want the small data sections together, so single-instruction offsets
+     can access them all, and initialized data all before uninitialized, so
+     we can shorten the on-disk segment size.  */
+  .sdata          :
+  {
+    *(.sdata .sdata.* .gnu.linkonce.s.*)
+  }
+  .lit8           : { *(.lit8) }
+  .lit4           : { *(.lit4) }
+  _edata = .;
+  PROVIDE (edata = .);
+  __bss_start = .;
+  _fbss = .;
+  .sbss           :
+  {
+    PROVIDE (__sbss_start = .);
+    PROVIDE (___sbss_start = .);
+    *(.dynsbss)
+    *(.sbss .sbss.* .gnu.linkonce.sb.*)
+    *(.scommon)
+    PROVIDE (__sbss_end = .);
+    PROVIDE (___sbss_end = .);
+  }
+  .bss            :
+  {
+   *(.dynbss)
+   *(.bss .bss.* .gnu.linkonce.b.*)
+   *(COMMON)
+   /* Align here to ensure that the .bss section occupies space up to
+      _end.  Align after .bss to ensure correct alignment even if the
+      .bss section disappears because there are no input sections.  */
+   . = ALIGN(32 / 8);
+  }
+  . = ALIGN(32 / 8);
+  _end = .;
+  PROVIDE (end = .);
+  . = DATA_SEGMENT_END (.);
+  /* Stabs debugging sections.  */
+  .stab          0 : { *(.stab) }
+  .stabstr       0 : { *(.stabstr) }
+  .stab.excl     0 : { *(.stab.excl) }
+  .stab.exclstr  0 : { *(.stab.exclstr) }
+  .stab.index    0 : { *(.stab.index) }
+  .stab.indexstr 0 : { *(.stab.indexstr) }
+  .comment       0 : { *(.comment) }
+  /* DWARF debug sections.
+     Symbols in the DWARF debugging sections are relative to the beginning
+     of the section so we begin them at 0.  */
+  /* DWARF 1 */
+  .debug          0 : { *(.debug) }
+  .line           0 : { *(.line) }
+  /* GNU DWARF 1 extensions */
+  .debug_srcinfo  0 : { *(.debug_srcinfo) }
+  .debug_sfnames  0 : { *(.debug_sfnames) }
+  /* DWARF 1.1 and DWARF 2 */
+  .debug_aranges  0 : { *(.debug_aranges) }
+  .debug_pubnames 0 : { *(.debug_pubnames) }
+  /* DWARF 2 */
+  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
+  .debug_abbrev   0 : { *(.debug_abbrev) }
+  .debug_line     0 : { *(.debug_line) }
+  .debug_frame    0 : { *(.debug_frame) }
+  .debug_str      0 : { *(.debug_str) }
+  .debug_loc      0 : { *(.debug_loc) }
+  .debug_macinfo  0 : { *(.debug_macinfo) }
+  /* SGI/MIPS DWARF 2 extensions */
+  .debug_weaknames 0 : { *(.debug_weaknames) }
+  .debug_funcnames 0 : { *(.debug_funcnames) }
+  .debug_typenames 0 : { *(.debug_typenames) }
+  .debug_varnames  0 : { *(.debug_varnames) }
+  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
+  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
+  /DISCARD/ : { *(.note.GNU-stack) }
+}
diff --git a/ld/testsuite/ld-mips-elf/tls-multi-got-1-1.s b/ld/testsuite/ld-mips-elf/tls-multi-got-1-1.s
new file mode 100644 (file)
index 0000000..60f6717
--- /dev/null
@@ -0,0 +1,39 @@
+.macro one_sym count
+.globl sym_1_\count
+sym_1_\count:
+       la      $2, sym_1_\count
+.endm
+
+.irp   thou,0,1,2,3,4,5,6,7,8,9
+.irp   hund,0,1,2,3,4,5,6,7,8,9
+.irp   tens,0,1,2,3,4,5,6,7,8,9
+.irp   ones,0,1,2,3,4,5,6,7,8,9
+one_sym        \thou\hund\tens\ones
+.endr
+.endr
+.endr
+.endr
+
+tls_bits_1:
+       addiu   $4,$28,%tlsgd(tlsvar_gd)
+       addiu   $4,$28,%tlsldm(tlsvar_ld)
+       addiu   $4,$2,%gottprel(tlsvar_ie)
+
+        .section                .tbss,"awT",@nobits
+        .align  2
+        .global tlsvar_gd
+        .type   tlsvar_gd,@object
+        .size   tlsvar_gd,4
+tlsvar_gd:
+        .space  4
+        .global tlsvar_ie
+        .type   tlsvar_ie,@object
+        .size   tlsvar_ie,4
+tlsvar_ie:
+        .space  4
+        .global tlsvar_ld
+        .hidden tlsvar_ld
+        .type   tlsvar_ld,@object
+        .size   tlsvar_ld,4
+tlsvar_ld:
+        .word   1
diff --git a/ld/testsuite/ld-mips-elf/tls-multi-got-1-2.s b/ld/testsuite/ld-mips-elf/tls-multi-got-1-2.s
new file mode 100644 (file)
index 0000000..6b04b98
--- /dev/null
@@ -0,0 +1,20 @@
+.macro one_sym count
+.globl sym_2_\count
+sym_2_\count:
+       la      $2, sym_2_\count
+.endm
+
+.irp   thou,0,1,2,3,4,5,6,7,8,9
+.irp   hund,0,1,2,3,4,5,6,7,8,9
+.irp   tens,0,1,2,3,4,5,6,7,8,9
+.irp   ones,0,1,2,3,4,5,6,7,8,9
+one_sym        \thou\hund\tens\ones
+.endr
+.endr
+.endr
+.endr
+
+tls_bits_2:
+       addiu   $4,$28,%tlsgd(tlsvar_gd)
+       addiu   $4,$28,%tlsldm(tlsvar_ld)
+       addiu   $4,$2,%gottprel(tlsvar_ie)
diff --git a/ld/testsuite/ld-mips-elf/tls-multi-got-1.d b/ld/testsuite/ld-mips-elf/tls-multi-got-1.d
new file mode 100644 (file)
index 0000000..0678685
--- /dev/null
@@ -0,0 +1,20 @@
+
+.*:     file format elf32-tradbigmips
+
+Disassembly of section .text:
+
+#...
+[0-9a-f]+ <tls_bits_1>:
+   [0-9a-f]+:  27841c90        addiu   a0,gp,7312
+   [0-9a-f]+:  27841c84        addiu   a0,gp,7300
+   [0-9a-f]+:  24441c8c        addiu   a0,v0,7308
+   [0-9a-f]+:  00000000        nop
+
+[0-9a-f]+ <sym_2_0000>:
+#...
+[0-9a-f]+ <tls_bits_2>:
+   [0-9a-f]+:  27841c90        addiu   a0,gp,7312
+   [0-9a-f]+:  27841c84        addiu   a0,gp,7300
+   [0-9a-f]+:  24441c8c        addiu   a0,v0,7308
+   [0-9a-f]+:  00000000        nop
+#pass
diff --git a/ld/testsuite/ld-mips-elf/tls-multi-got-1.got b/ld/testsuite/ld-mips-elf/tls-multi-got-1.got
new file mode 100644 (file)
index 0000000..49b3d90
--- /dev/null
@@ -0,0 +1,58 @@
+
+.*:     file format elf32-tradbigmips
+
+DYNAMIC RELOCATION RECORDS
+OFFSET   TYPE              VALUE 
+00000000 R_MIPS_NONE       \*ABS\*
+00149630 R_MIPS_TLS_DTPMOD32  \*ABS\*
+0013f9a8 R_MIPS_TLS_DTPMOD32  \*ABS\*
+0014963c R_MIPS_TLS_DTPMOD32  tlsvar_gd
+00149640 R_MIPS_TLS_DTPREL32  tlsvar_gd
+0013f9b4 R_MIPS_TLS_DTPMOD32  tlsvar_gd
+0013f9b8 R_MIPS_TLS_DTPREL32  tlsvar_gd
+00149638 R_MIPS_TLS_TPREL32  tlsvar_ie
+0013f9b0 R_MIPS_TLS_TPREL32  tlsvar_ie
+0013602c R_MIPS_REL32      sym_2_8355
+#...
+00142d4c R_MIPS_REL32      sym_1_0945
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+00000000 R_MIPS_NONE       \*ABS\*
+
+
+Contents of section .got:
+ 122480 00000000 80000000 00000000 00000000  ................
+ 122490 00000000 00000000 00000000 00000000  ................
+ 1224a0 00000000 00000000 00000000 00000000  ................
+ 1224b0 00000000 000e0aac 000d35f4 000d35e4  ..........5...5.
+#...
+ 13f990 00000000 00000000 00000000 00000000  ................
+ 13f9a0 00000000 00000000 00000000 00000000  ................
+ 13f9b0 00000000 00000000 00000000 00000000  ................
+ 13f9c0 80000000 00000000 00000000 00000000  ................
+#...
+ 149600 00000000 00000000 00000000 00000000  ................
+ 149610 00000000 00000000 00000000 00000000  ................
+ 149620 00000000 00000000 00000000 00000000  ................
+ 149630 00000000 00000000 00000000 00000000  ................
+ 149640 00000000                             ....            
+#pass
diff --git a/ld/testsuite/ld-mips-elf/tls-multi-got-1.r b/ld/testsuite/ld-mips-elf/tls-multi-got-1.r
new file mode 100644 (file)
index 0000000..84f7227
--- /dev/null
@@ -0,0 +1,61 @@
+
+Dynamic section at offset 0xec contains 19 entries:
+  Tag        Type                         Name/Value
+ 0x00000004 \(HASH\)                       0x1ac
+ 0x00000005 \(STRTAB\)                     0x71e08
+ 0x00000006 \(SYMTAB\)                     0x23ae8
+ 0x0000000a \(STRSZ\)                      220100 \(bytes\)
+ 0x0000000b \(SYMENT\)                     16 \(bytes\)
+ 0x00000015 \(DEBUG\)                      0x0
+ 0x00000003 \(PLTGOT\)                     0x122480
+ 0x00000011 \(REL\)                        0xa79cc
+ 0x00000012 \(RELSZ\)                      160072 \(bytes\)
+ 0x00000013 \(RELENT\)                     8 \(bytes\)
+ 0x70000001 \(MIPS_RLD_VERSION\)           1
+ 0x70000005 \(MIPS_FLAGS\)                 NOTPOT
+ 0x70000006 \(MIPS_BASE_ADDRESS\)          0
+ 0x7000000a \(MIPS_LOCAL_GOTNO\)           13
+ 0x70000011 \(MIPS_SYMTABNO\)              20018
+ 0x70000012 \(MIPS_UNREFEXTNO\)            15
+ 0x70000013 \(MIPS_GOTSYM\)                0x12
+ 0x0000001e \(FLAGS\)                      STATIC_TLS
+ 0x00000000 \(NULL\)                       0x0
+
+Relocation section '\.rel\.dyn' at offset 0x[0-9a-f]+ contains 20031 entries:
+ Offset     Info    Type            Sym.Value  Sym. Name
+00000000  00000000 R_MIPS_NONE      
+00149630  00000026 R_MIPS_TLS_DTPMOD
+0013f9a8  00000026 R_MIPS_TLS_DTPMOD
+0014963c  00000a26 R_MIPS_TLS_DTPMOD 00000000   tlsvar_gd
+00149640  00000a27 R_MIPS_TLS_DTPREL 00000000   tlsvar_gd
+0013f9b4  00000a26 R_MIPS_TLS_DTPMOD 00000000   tlsvar_gd
+0013f9b8  00000a27 R_MIPS_TLS_DTPREL 00000000   tlsvar_gd
+00149638  0000102f R_MIPS_TLS_TPREL3 00000004   tlsvar_ie
+0013f9b0  0000102f R_MIPS_TLS_TPREL3 00000004   tlsvar_ie
+0013602c  00001203 R_MIPS_REL32      000e0aac   sym_2_8355
+0014250c  00001303 R_MIPS_REL32      000d35f4   sym_1_4745
+#...
+00136a10  004e3003 R_MIPS_REL32      000da990   sym_2_2140
+00142d4c  004e3103 R_MIPS_REL32      000cfa94   sym_1_0945
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
+00000000  00000000 R_MIPS_NONE      
diff --git a/ld/testsuite/ld-mips-elf/tlsbin-o32.d b/ld/testsuite/ld-mips-elf/tlsbin-o32.d
new file mode 100644 (file)
index 0000000..d20ad22
--- /dev/null
@@ -0,0 +1,43 @@
+.*:     file format elf32-tradbigmips
+
+Disassembly of section .text:
+
+004000d0 <__start>:
+  4000d0:      3c1c0fc0        lui     gp,0xfc0
+  4000d4:      279c7f30        addiu   gp,gp,32560
+  4000d8:      0399e021        addu    gp,gp,t9
+  4000dc:      27bdfff0        addiu   sp,sp,-16
+  4000e0:      afbe0008        sw      s8,8\(sp\)
+  4000e4:      03a0f021        move    s8,sp
+  4000e8:      afbc0000        sw      gp,0\(sp\)
+  4000ec:      8f99802c        lw      t9,-32724\(gp\)
+  4000f0:      2784803c        addiu   a0,gp,-32708
+  4000f4:      0320f809        jalr    t9
+  4000f8:      00000000        nop
+  4000fc:      8fdc0000        lw      gp,0\(s8\)
+  400100:      00000000        nop
+  400104:      8f99802c        lw      t9,-32724\(gp\)
+  400108:      27848034        addiu   a0,gp,-32716
+  40010c:      0320f809        jalr    t9
+  400110:      00000000        nop
+  400114:      8fdc0000        lw      gp,0\(s8\)
+  400118:      00401021        move    v0,v0
+  40011c:      3c030000        lui     v1,0x0
+  400120:      24638000        addiu   v1,v1,-32768
+  400124:      00621821        addu    v1,v1,v0
+  400128:      7c02283b        rdhwr   v0,\$5
+  40012c:      8f838030        lw      v1,-32720\(gp\)
+  400130:      00000000        nop
+  400134:      00621821        addu    v1,v1,v0
+  400138:      7c02283b        rdhwr   v0,\$5
+  40013c:      3c030000        lui     v1,0x0
+  400140:      24639004        addiu   v1,v1,-28668
+  400144:      00621821        addu    v1,v1,v0
+  400148:      03c0e821        move    sp,s8
+  40014c:      8fbe0008        lw      s8,8\(sp\)
+  400150:      03e00008        jr      ra
+  400154:      27bd0010        addiu   sp,sp,16
+
+00400158 <__tls_get_addr>:
+  400158:      03e00008        jr      ra
+  40015c:      00000000        nop
diff --git a/ld/testsuite/ld-mips-elf/tlsbin-o32.got b/ld/testsuite/ld-mips-elf/tlsbin-o32.got
new file mode 100644 (file)
index 0000000..e924620
--- /dev/null
@@ -0,0 +1,8 @@
+
+.*:     file format elf32-tradbigmips
+
+Contents of section .got:
+ 10000010 00000000 80000000 00000000 00000000  ................
+ 10000020 00000000 00000000 00000000 00400158  .............@.X
+ 10000030 ffff900c 00000001 00000000 00000001  ................
+ 10000040 ffff8008                             ....            
diff --git a/ld/testsuite/ld-mips-elf/tlsbin-o32.s b/ld/testsuite/ld-mips-elf/tlsbin-o32.s
new file mode 100644 (file)
index 0000000..8ff9831
--- /dev/null
@@ -0,0 +1,89 @@
+       .file   1 "tlsbin-o32.s"
+       .abicalls
+       .text
+       .align  2
+       .globl  __start
+       .ent    __start
+       .type   __start,@function
+__start:
+       .frame  $fp,16,$31
+       .mask   0x40000000,-8
+       .fmask  0x00000000,0
+       .set    noreorder
+       .cpload $25
+       .set    reorder
+       addiu   $sp,$sp,-16
+       sw      $fp,8($sp)
+       move    $fp,$sp
+       .cprestore      0
+
+       # General Dynamic
+       lw      $25,%call16(__tls_get_addr)($28)
+       addiu   $4,$28,%tlsgd(tlsvar_gd)
+       jal     $25
+
+       # Local Dynamic
+       lw      $25,%call16(__tls_get_addr)($28)
+       addiu   $4,$28,%tlsldm(tlsvar_ld)
+       jal     $25
+
+       move    $2,$2           # Arbitrary instructions
+
+       lui     $3,%dtprel_hi(tlsvar_ld)
+       addiu   $3,$3,%dtprel_lo(tlsvar_ld)
+       addu    $3,$3,$2
+
+       # Initial Exec
+       .set    push
+       .set    mips32r2
+       rdhwr   $2, $5
+       .set    pop
+       lw      $3,%gottprel(tlsvar_ie)($28)
+       addu    $3,$3,$2
+
+       # Local Exec
+       .set    push
+       .set    mips32r2
+       rdhwr   $2, $5
+       .set    pop
+       lui     $3,%tprel_hi(tlsvar_le)
+       addiu   $3,$3,%tprel_lo(tlsvar_le)
+       addu    $3,$3,$2
+
+       move    $sp,$fp
+       lw      $fp,8($sp)
+       addiu   $sp,$sp,16
+       j       $31
+       .end    __start
+
+       .globl __tls_get_addr
+__tls_get_addr:
+       j $31
+
+       .section                .tbss,"awT",@nobits
+       .align  2
+       .global tlsvar_gd
+       .type   tlsvar_gd,@object
+       .size   tlsvar_gd,4
+tlsvar_gd:
+       .space  4
+       .global tlsvar_ie
+       .type   tlsvar_ie,@object
+       .size   tlsvar_ie,4
+tlsvar_ie:
+       .space  4
+
+       .section                .tdata,"awT"
+       .align  2
+       .global tlsvar_ld
+       .hidden tlsvar_ld
+       .type   tlsvar_ld,@object
+       .size   tlsvar_ld,4
+tlsvar_ld:
+       .word   1
+       .global tlsvar_le
+       .hidden tlsvar_le
+       .type   tlsvar_le,@object
+       .size   tlsvar_le,4
+tlsvar_le:
+       .word   1
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d b/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d
new file mode 100644 (file)
index 0000000..6edfa9f
--- /dev/null
@@ -0,0 +1,104 @@
+
+.*:     file format elf32-tradbigmips
+
+Disassembly of section .text:
+
+.* <__start>:
+  .*:  3c1c0fc0        lui     gp,0xfc0
+  .*:  279c7b60        addiu   gp,gp,31584
+  .*:  0399e021        addu    gp,gp,t9
+  .*:  27bdfff0        addiu   sp,sp,-16
+  .*:  afbe0008        sw      s8,8\(sp\)
+  .*:  03a0f021        move    s8,sp
+  .*:  afbc0000        sw      gp,0\(sp\)
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848044        addiu   a0,gp,-32700
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00000000        nop
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848038        addiu   a0,gp,-32712
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00000000        nop
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848030        addiu   a0,gp,-32720
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00401021        move    v0,v0
+  .*:  3c030000        lui     v1,0x0
+  .*:  24638000        addiu   v1,v1,-32768
+  .*:  00621821        addu    v1,v1,v0
+  .*:  7c02283b        rdhwr   v0,\$5
+  .*:  8f83804c        lw      v1,-32692\(gp\)
+  .*:  00000000        nop
+  .*:  00621821        addu    v1,v1,v0
+  .*:  8f838040        lw      v1,-32704\(gp\)
+  .*:  00000000        nop
+  .*:  00621821        addu    v1,v1,v0
+  .*:  7c02283b        rdhwr   v0,\$5
+  .*:  3c030000        lui     v1,0x0
+  .*:  24639004        addiu   v1,v1,-28668
+  .*:  00621821        addu    v1,v1,v0
+  .*:  03c0e821        move    sp,s8
+  .*:  8fbe0008        lw      s8,8\(sp\)
+  .*:  03e00008        jr      ra
+  .*:  27bd0010        addiu   sp,sp,16
+
+.* <__tls_get_addr>:
+  .*:  03e00008        jr      ra
+  .*:  00000000        nop
+       ...
+
+.* <other>:
+  .*:  3c1c0fc0        lui     gp,0xfc0
+  .*:  279c7aa0        addiu   gp,gp,31392
+  .*:  0399e021        addu    gp,gp,t9
+  .*:  27bdfff0        addiu   sp,sp,-16
+  .*:  afbe0008        sw      s8,8\(sp\)
+  .*:  03a0f021        move    s8,sp
+  .*:  afbc0000        sw      gp,0\(sp\)
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848044        addiu   a0,gp,-32700
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00000000        nop
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848038        addiu   a0,gp,-32712
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00000000        nop
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848030        addiu   a0,gp,-32720
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00401021        move    v0,v0
+  .*:  3c030000        lui     v1,0x0
+  .*:  24638000        addiu   v1,v1,-32768
+  .*:  00621821        addu    v1,v1,v0
+  .*:  7c02283b        rdhwr   v0,\$5
+  .*:  8f83804c        lw      v1,-32692\(gp\)
+  .*:  00000000        nop
+  .*:  00621821        addu    v1,v1,v0
+  .*:  8f838040        lw      v1,-32704\(gp\)
+  .*:  00000000        nop
+  .*:  00621821        addu    v1,v1,v0
+  .*:  7c02283b        rdhwr   v0,\$5
+  .*:  3c030000        lui     v1,0x0
+  .*:  24639004        addiu   v1,v1,-28668
+  .*:  00621821        addu    v1,v1,v0
+  .*:  03c0e821        move    sp,s8
+  .*:  8fbe0008        lw      s8,8\(sp\)
+  .*:  03e00008        jr      ra
+  .*:  27bd0010        addiu   sp,sp,16
+  .*:  00000000        nop
+Disassembly of section .MIPS.stubs:
+
+.* <.MIPS.stubs>:
+       ...
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got b/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got
new file mode 100644 (file)
index 0000000..b19f4d8
--- /dev/null
@@ -0,0 +1,19 @@
+
+.*:     file format elf32-tradbigmips
+
+DYNAMIC RELOCATION RECORDS
+OFFSET   TYPE              VALUE 
+00000000 R_MIPS_NONE       \*ABS\*
+10000054 R_MIPS_TLS_DTPMOD32  tlsbin_gd
+10000058 R_MIPS_TLS_DTPREL32  tlsbin_gd
+10000048 R_MIPS_TLS_DTPMOD32  tlsvar_gd
+1000004c R_MIPS_TLS_DTPREL32  tlsvar_gd
+10000050 R_MIPS_TLS_TPREL32  tlsvar_ie
+1000005c R_MIPS_TLS_TPREL32  tlsbin_ie
+
+
+Contents of section .got:
+ 10000020 00000000 80000000 00000000 00000000  ................
+ 10000030 00000000 00000000 00000000 0040055c  .............@..
+ 10000040 00000001 00000000 00000000 00000000  ................
+ 10000050 00000000 00000000 00000000 00000000  ................
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d b/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d
new file mode 100644 (file)
index 0000000..6edfa9f
--- /dev/null
@@ -0,0 +1,104 @@
+
+.*:     file format elf32-tradbigmips
+
+Disassembly of section .text:
+
+.* <__start>:
+  .*:  3c1c0fc0        lui     gp,0xfc0
+  .*:  279c7b60        addiu   gp,gp,31584
+  .*:  0399e021        addu    gp,gp,t9
+  .*:  27bdfff0        addiu   sp,sp,-16
+  .*:  afbe0008        sw      s8,8\(sp\)
+  .*:  03a0f021        move    s8,sp
+  .*:  afbc0000        sw      gp,0\(sp\)
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848044        addiu   a0,gp,-32700
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00000000        nop
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848038        addiu   a0,gp,-32712
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00000000        nop
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848030        addiu   a0,gp,-32720
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00401021        move    v0,v0
+  .*:  3c030000        lui     v1,0x0
+  .*:  24638000        addiu   v1,v1,-32768
+  .*:  00621821        addu    v1,v1,v0
+  .*:  7c02283b        rdhwr   v0,\$5
+  .*:  8f83804c        lw      v1,-32692\(gp\)
+  .*:  00000000        nop
+  .*:  00621821        addu    v1,v1,v0
+  .*:  8f838040        lw      v1,-32704\(gp\)
+  .*:  00000000        nop
+  .*:  00621821        addu    v1,v1,v0
+  .*:  7c02283b        rdhwr   v0,\$5
+  .*:  3c030000        lui     v1,0x0
+  .*:  24639004        addiu   v1,v1,-28668
+  .*:  00621821        addu    v1,v1,v0
+  .*:  03c0e821        move    sp,s8
+  .*:  8fbe0008        lw      s8,8\(sp\)
+  .*:  03e00008        jr      ra
+  .*:  27bd0010        addiu   sp,sp,16
+
+.* <__tls_get_addr>:
+  .*:  03e00008        jr      ra
+  .*:  00000000        nop
+       ...
+
+.* <other>:
+  .*:  3c1c0fc0        lui     gp,0xfc0
+  .*:  279c7aa0        addiu   gp,gp,31392
+  .*:  0399e021        addu    gp,gp,t9
+  .*:  27bdfff0        addiu   sp,sp,-16
+  .*:  afbe0008        sw      s8,8\(sp\)
+  .*:  03a0f021        move    s8,sp
+  .*:  afbc0000        sw      gp,0\(sp\)
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848044        addiu   a0,gp,-32700
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00000000        nop
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848038        addiu   a0,gp,-32712
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00000000        nop
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848030        addiu   a0,gp,-32720
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00401021        move    v0,v0
+  .*:  3c030000        lui     v1,0x0
+  .*:  24638000        addiu   v1,v1,-32768
+  .*:  00621821        addu    v1,v1,v0
+  .*:  7c02283b        rdhwr   v0,\$5
+  .*:  8f83804c        lw      v1,-32692\(gp\)
+  .*:  00000000        nop
+  .*:  00621821        addu    v1,v1,v0
+  .*:  8f838040        lw      v1,-32704\(gp\)
+  .*:  00000000        nop
+  .*:  00621821        addu    v1,v1,v0
+  .*:  7c02283b        rdhwr   v0,\$5
+  .*:  3c030000        lui     v1,0x0
+  .*:  24639004        addiu   v1,v1,-28668
+  .*:  00621821        addu    v1,v1,v0
+  .*:  03c0e821        move    sp,s8
+  .*:  8fbe0008        lw      s8,8\(sp\)
+  .*:  03e00008        jr      ra
+  .*:  27bd0010        addiu   sp,sp,16
+  .*:  00000000        nop
+Disassembly of section .MIPS.stubs:
+
+.* <.MIPS.stubs>:
+       ...
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got b/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
new file mode 100644 (file)
index 0000000..6ea06d3
--- /dev/null
@@ -0,0 +1,20 @@
+
+.*:     file format elf32-tradbigmips
+
+DYNAMIC RELOCATION RECORDS
+OFFSET   TYPE              VALUE 
+00000000 R_MIPS_NONE       \*ABS\*
+10000054 R_MIPS_TLS_DTPMOD32  tlsbin_gd
+10000058 R_MIPS_TLS_DTPREL32  tlsbin_gd
+10000048 R_MIPS_TLS_DTPMOD32  tlsvar_gd
+1000004c R_MIPS_TLS_DTPREL32  tlsvar_gd
+10000050 R_MIPS_TLS_TPREL32  tlsvar_ie
+1000005c R_MIPS_TLS_TPREL32  tlsbin_ie
+
+
+Contents of section .got:
+ 10000020 00000000 80000000 00000000 00000000  ................
+ 10000030 00000000 00000000 00000000 0040055c  .............@..
+ 10000040 00000001 00000000 00000000 00000000  ................
+ 10000050 00000000 00000000 00000000 00000000  ................
+ 10000060 00000000 00000000 00000000           ............    
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.s b/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.s
new file mode 100644 (file)
index 0000000..7943775
--- /dev/null
@@ -0,0 +1,64 @@
+       .file   1 "tlsbin-o32.s"
+       .abicalls
+       .text
+       .align  2
+       .globl  other
+       .ent    other
+       .type   other,@function
+other:
+       .frame  $fp,16,$31
+       .mask   0x40000000,-8
+       .fmask  0x00000000,0
+       .set    noreorder
+       .cpload $25
+       .set    reorder
+       addiu   $sp,$sp,-16
+       sw      $fp,8($sp)
+       move    $fp,$sp
+       .cprestore      0
+
+       # General Dynamic
+       lw      $25,%call16(__tls_get_addr)($28)
+       addiu   $4,$28,%tlsgd(tlsbin_gd)
+       jal     $25
+
+       lw      $25,%call16(__tls_get_addr)($28)
+       addiu   $4,$28,%tlsgd(tlsvar_gd)
+       jal     $25
+
+       # Local Dynamic
+       lw      $25,%call16(__tls_get_addr)($28)
+       addiu   $4,$28,%tlsldm(tlsbin_ld)
+       jal     $25
+
+       move    $2,$2           # Arbitrary instructions
+
+       lui     $3,%dtprel_hi(tlsbin_ld)
+       addiu   $3,$3,%dtprel_lo(tlsbin_ld)
+       addu    $3,$3,$2
+
+       # Initial Exec
+       .set    push
+       .set    mips32r2
+       rdhwr   $2, $5
+       .set    pop
+       lw      $3,%gottprel(tlsbin_ie)($28)
+       addu    $3,$3,$2
+
+       lw      $3,%gottprel(tlsvar_ie)($28)
+       addu    $3,$3,$2
+
+       # Local Exec
+       .set    push
+       .set    mips32r2
+       rdhwr   $2, $5
+       .set    pop
+       lui     $3,%tprel_hi(tlsbin_le)
+       addiu   $3,$3,%tprel_lo(tlsbin_le)
+       addu    $3,$3,$2
+
+       move    $sp,$fp
+       lw      $fp,8($sp)
+       addiu   $sp,$sp,16
+       j       $31
+       .end    other
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d b/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d
new file mode 100644 (file)
index 0000000..22b533e
--- /dev/null
@@ -0,0 +1,104 @@
+
+.*:     file format elf32-tradbigmips
+
+Disassembly of section .text:
+
+.* <other>:
+  .*:  3c1c0fc0        lui     gp,0xfc0
+  .*:  279c7b60        addiu   gp,gp,31584
+  .*:  0399e021        addu    gp,gp,t9
+  .*:  27bdfff0        addiu   sp,sp,-16
+  .*:  afbe0008        sw      s8,8\(sp\)
+  .*:  03a0f021        move    s8,sp
+  .*:  afbc0000        sw      gp,0\(sp\)
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848044        addiu   a0,gp,-32700
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00000000        nop
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848038        addiu   a0,gp,-32712
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00000000        nop
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848030        addiu   a0,gp,-32720
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00401021        move    v0,v0
+  .*:  3c030000        lui     v1,0x0
+  .*:  24638000        addiu   v1,v1,-32768
+  .*:  00621821        addu    v1,v1,v0
+  .*:  7c02283b        rdhwr   v0,\$5
+  .*:  8f83804c        lw      v1,-32692\(gp\)
+  .*:  00000000        nop
+  .*:  00621821        addu    v1,v1,v0
+  .*:  8f838040        lw      v1,-32704\(gp\)
+  .*:  00000000        nop
+  .*:  00621821        addu    v1,v1,v0
+  .*:  7c02283b        rdhwr   v0,\$5
+  .*:  3c030000        lui     v1,0x0
+  .*:  24639004        addiu   v1,v1,-28668
+  .*:  00621821        addu    v1,v1,v0
+  .*:  03c0e821        move    sp,s8
+  .*:  8fbe0008        lw      s8,8\(sp\)
+  .*:  03e00008        jr      ra
+  .*:  27bd0010        addiu   sp,sp,16
+  .*:  00000000        nop
+
+.* <__start>:
+  .*:  3c1c0fc0        lui     gp,0xfc0
+  .*:  279c7ab0        addiu   gp,gp,31408
+  .*:  0399e021        addu    gp,gp,t9
+  .*:  27bdfff0        addiu   sp,sp,-16
+  .*:  afbe0008        sw      s8,8\(sp\)
+  .*:  03a0f021        move    s8,sp
+  .*:  afbc0000        sw      gp,0\(sp\)
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848044        addiu   a0,gp,-32700
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00000000        nop
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848038        addiu   a0,gp,-32712
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00000000        nop
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848030        addiu   a0,gp,-32720
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00401021        move    v0,v0
+  .*:  3c030000        lui     v1,0x0
+  .*:  24638000        addiu   v1,v1,-32768
+  .*:  00621821        addu    v1,v1,v0
+  .*:  7c02283b        rdhwr   v0,\$5
+  .*:  8f83804c        lw      v1,-32692\(gp\)
+  .*:  00000000        nop
+  .*:  00621821        addu    v1,v1,v0
+  .*:  8f838040        lw      v1,-32704\(gp\)
+  .*:  00000000        nop
+  .*:  00621821        addu    v1,v1,v0
+  .*:  7c02283b        rdhwr   v0,\$5
+  .*:  3c030000        lui     v1,0x0
+  .*:  24639004        addiu   v1,v1,-28668
+  .*:  00621821        addu    v1,v1,v0
+  .*:  03c0e821        move    sp,s8
+  .*:  8fbe0008        lw      s8,8\(sp\)
+  .*:  03e00008        jr      ra
+  .*:  27bd0010        addiu   sp,sp,16
+
+.* <__tls_get_addr>:
+  .*:  03e00008        jr      ra
+  .*:  00000000        nop
+       ...
+Disassembly of section .MIPS.stubs:
+
+.* <.MIPS.stubs>:
+       ...
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got b/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
new file mode 100644 (file)
index 0000000..5759b9c
--- /dev/null
@@ -0,0 +1,20 @@
+
+.*:     file format elf32-tradbigmips
+
+DYNAMIC RELOCATION RECORDS
+OFFSET   TYPE              VALUE 
+00000000 R_MIPS_NONE       \*ABS\*
+10000054 R_MIPS_TLS_DTPMOD32  tlsbin_gd
+10000058 R_MIPS_TLS_DTPREL32  tlsbin_gd
+10000048 R_MIPS_TLS_DTPMOD32  tlsvar_gd
+1000004c R_MIPS_TLS_DTPREL32  tlsvar_gd
+10000050 R_MIPS_TLS_TPREL32  tlsvar_ie
+1000005c R_MIPS_TLS_TPREL32  tlsbin_ie
+
+
+Contents of section .got:
+ 10000020 00000000 80000000 00000000 00000000  ................
+ 10000030 00000000 00000000 00000000 0040060c  .............@..
+ 10000040 00000001 00000000 00000000 00000000  ................
+ 10000050 00000000 00000000 00000000 00000000  ................
+ 10000060 00000000 00000000 00000000           ............    
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32.d b/ld/testsuite/ld-mips-elf/tlsdyn-o32.d
new file mode 100644 (file)
index 0000000..3bba2c8
--- /dev/null
@@ -0,0 +1,58 @@
+
+.*:     file format elf32-tradbigmips
+
+Disassembly of section .text:
+
+.* <__start>:
+  .*:  3c1c0fc0        lui     gp,0xfc0
+  .*:  279c7b50        addiu   gp,gp,31568
+  .*:  0399e021        addu    gp,gp,t9
+  .*:  27bdfff0        addiu   sp,sp,-16
+  .*:  afbe0008        sw      s8,8\(sp\)
+  .*:  03a0f021        move    s8,sp
+  .*:  afbc0000        sw      gp,0\(sp\)
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848038        addiu   a0,gp,-32712
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00000000        nop
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848048        addiu   a0,gp,-32696
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00000000        nop
+  .*:  8f99802c        lw      t9,-32724\(gp\)
+  .*:  27848030        addiu   a0,gp,-32720
+  .*:  0320f809        jalr    t9
+  .*:  00000000        nop
+  .*:  8fdc0000        lw      gp,0\(s8\)
+  .*:  00401021        move    v0,v0
+  .*:  3c030000        lui     v1,0x0
+  .*:  24638000        addiu   v1,v1,-32768
+  .*:  00621821        addu    v1,v1,v0
+  .*:  7c02283b        rdhwr   v0,\$5
+  .*:  8f838044        lw      v1,-32700\(gp\)
+  .*:  00000000        nop
+  .*:  00621821        addu    v1,v1,v0
+  .*:  8f838040        lw      v1,-32704\(gp\)
+  .*:  00000000        nop
+  .*:  00621821        addu    v1,v1,v0
+  .*:  7c02283b        rdhwr   v0,\$5
+  .*:  3c030000        lui     v1,0x0
+  .*:  24639004        addiu   v1,v1,-28668
+  .*:  00621821        addu    v1,v1,v0
+  .*:  03c0e821        move    sp,s8
+  .*:  8fbe0008        lw      s8,8\(sp\)
+  .*:  03e00008        jr      ra
+  .*:  27bd0010        addiu   sp,sp,16
+
+.* <__tls_get_addr>:
+  .*:  03e00008        jr      ra
+  .*:  00000000        nop
+       ...
+Disassembly of section .MIPS.stubs:
+
+.* <.MIPS.stubs>:
+       ...
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32.got b/ld/testsuite/ld-mips-elf/tlsdyn-o32.got
new file mode 100644 (file)
index 0000000..aaed4ac
--- /dev/null
@@ -0,0 +1,19 @@
+
+tmpdir/tls-dynamic-o32:     file format elf32-tradbigmips
+
+DYNAMIC RELOCATION RECORDS
+OFFSET   TYPE              VALUE 
+00000000 R_MIPS_NONE       \*ABS\*
+10000048 R_MIPS_TLS_DTPMOD32  tlsbin_gd
+1000004c R_MIPS_TLS_DTPREL32  tlsbin_gd
+10000058 R_MIPS_TLS_DTPMOD32  tlsvar_gd
+1000005c R_MIPS_TLS_DTPREL32  tlsvar_gd
+10000054 R_MIPS_TLS_TPREL32  tlsbin_ie
+10000050 R_MIPS_TLS_TPREL32  tlsvar_ie
+
+
+Contents of section .got:
+ 10000020 00000000 80000000 00000000 00000000  ................
+ 10000030 00000000 00000000 00000000 0040056c  ................
+ 10000040 00000001 00000000 00000000 00000000  ................
+ 10000050 00000000 00000000 00000000 00000000  ................
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32.s b/ld/testsuite/ld-mips-elf/tlsdyn-o32.s
new file mode 100644 (file)
index 0000000..2924221
--- /dev/null
@@ -0,0 +1,96 @@
+       .file   1 "tlsbin-o32.s"
+       .abicalls
+       .text
+       .align  2
+       .globl  __start
+       .ent    __start
+       .type   __start,@function
+__start:
+       .frame  $fp,16,$31
+       .mask   0x40000000,-8
+       .fmask  0x00000000,0
+       .set    noreorder
+       .cpload $25
+       .set    reorder
+       addiu   $sp,$sp,-16
+       sw      $fp,8($sp)
+       move    $fp,$sp
+       .cprestore      0
+
+       # General Dynamic
+       lw      $25,%call16(__tls_get_addr)($28)
+       addiu   $4,$28,%tlsgd(tlsbin_gd)
+       jal     $25
+
+       lw      $25,%call16(__tls_get_addr)($28)
+       addiu   $4,$28,%tlsgd(tlsvar_gd)
+       jal     $25
+
+       # Local Dynamic
+       lw      $25,%call16(__tls_get_addr)($28)
+       addiu   $4,$28,%tlsldm(tlsbin_ld)
+       jal     $25
+
+       move    $2,$2           # Arbitrary instructions
+
+       lui     $3,%dtprel_hi(tlsbin_ld)
+       addiu   $3,$3,%dtprel_lo(tlsbin_ld)
+       addu    $3,$3,$2
+
+       # Initial Exec
+       .set    push
+       .set    mips32r2
+       rdhwr   $2, $5
+       .set    pop
+       lw      $3,%gottprel(tlsbin_ie)($28)
+       addu    $3,$3,$2
+
+       lw      $3,%gottprel(tlsvar_ie)($28)
+       addu    $3,$3,$2
+
+       # Local Exec
+       .set    push
+       .set    mips32r2
+       rdhwr   $2, $5
+       .set    pop
+       lui     $3,%tprel_hi(tlsbin_le)
+       addiu   $3,$3,%tprel_lo(tlsbin_le)
+       addu    $3,$3,$2
+
+       move    $sp,$fp
+       lw      $fp,8($sp)
+       addiu   $sp,$sp,16
+       j       $31
+       .end    __start
+
+       .globl __tls_get_addr
+__tls_get_addr:
+       j $31
+
+       .section                .tbss,"awT",@nobits
+       .align  2
+       .global tlsbin_gd
+       .type   tlsbin_gd,@object
+       .size   tlsbin_gd,4
+tlsbin_gd:
+       .space  4
+       .global tlsbin_ie
+       .type   tlsbin_ie,@object
+       .size   tlsbin_ie,4
+tlsbin_ie:
+       .space  4
+
+       .section                .tdata,"awT"
+       .align  2
+       .global tlsbin_ld
+       .hidden tlsbin_ld
+       .type   tlsbin_ld,@object
+       .size   tlsbin_ld,4
+tlsbin_ld:
+       .word   1
+       .global tlsbin_le
+       .hidden tlsbin_le
+       .type   tlsbin_le,@object
+       .size   tlsbin_le,4
+tlsbin_le:
+       .word   1
diff --git a/ld/testsuite/ld-mips-elf/tlslib-hidden.ver b/ld/testsuite/ld-mips-elf/tlslib-hidden.ver
new file mode 100644 (file)
index 0000000..e59012f
--- /dev/null
@@ -0,0 +1,3 @@
+VER_1 {
+  local: *;
+};
diff --git a/ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got b/ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got
new file mode 100644 (file)
index 0000000..d642805
--- /dev/null
@@ -0,0 +1,16 @@
+
+.*:     file format elf32-tradbigmips
+
+DYNAMIC RELOCATION RECORDS
+OFFSET   TYPE              VALUE 
+00000000 R_MIPS_NONE       \*ABS\*
+0004043c R_MIPS_TLS_DTPMOD32  \*ABS\*
+00040434 R_MIPS_TLS_DTPMOD32  \*ABS\*
+00040430 R_MIPS_TLS_TPREL32  \*ABS\*
+
+
+Contents of section .got:
+ 40410 00000000 80000000 00000000 00000000  ................
+ 40420 00000000 00000000 00000000 000003e0  ................
+ 40430 00000008 00000000 00000000 00000000  ................
+ 40440 ffff8004                             ....            
diff --git a/ld/testsuite/ld-mips-elf/tlslib-o32-ver.got b/ld/testsuite/ld-mips-elf/tlslib-o32-ver.got
new file mode 100644 (file)
index 0000000..60198b7
--- /dev/null
@@ -0,0 +1,17 @@
+
+.*:     file format elf32-tradbigmips
+
+DYNAMIC RELOCATION RECORDS
+OFFSET   TYPE              VALUE 
+00000000 R_MIPS_NONE       \*ABS\*
+000405e4 R_MIPS_TLS_DTPMOD32  \*ABS\*
+000405ec R_MIPS_TLS_DTPMOD32  tlsvar_gd
+000405f0 R_MIPS_TLS_DTPREL32  tlsvar_gd
+000405e0 R_MIPS_TLS_TPREL32  tlsvar_ie
+
+
+Contents of section .got:
+ 405c0 00000000 80000000 00000000 00000000  ................
+ 405d0 00000000 00000000 00000000 00000590  ................
+ 405e0 00000000 00000000 00000000 00000000  ................
+ 405f0 00000000                             ....            
diff --git a/ld/testsuite/ld-mips-elf/tlslib-o32.d b/ld/testsuite/ld-mips-elf/tlslib-o32.d
new file mode 100644 (file)
index 0000000..32fd7e3
--- /dev/null
@@ -0,0 +1,45 @@
+
+.*:     file format elf32-tradbigmips
+
+Disassembly of section .text:
+
+.* <fn>:
+ .*:   3c1c0005        lui     gp,0x5
+ .*:   279c80a0        addiu   gp,gp,-32608
+ .*:   0399e021        addu    gp,gp,t9
+ .*:   27bdfff0        addiu   sp,sp,-16
+ .*:   afbe0008        sw      s8,8\(sp\)
+ .*:   03a0f021        move    s8,sp
+ .*:   afbc0000        sw      gp,0\(sp\)
+ .*:   8f99802c        lw      t9,-32724\(gp\)
+ .*:   2784803c        addiu   a0,gp,-32708
+ .*:   0320f809        jalr    t9
+ .*:   00000000        nop
+ .*:   8fdc0000        lw      gp,0\(s8\)
+ .*:   00000000        nop
+ .*:   8f99802c        lw      t9,-32724\(gp\)
+ .*:   27848034        addiu   a0,gp,-32716
+ .*:   0320f809        jalr    t9
+ .*:   00000000        nop
+ .*:   8fdc0000        lw      gp,0\(s8\)
+ .*:   00401021        move    v0,v0
+ .*:   3c030000        lui     v1,0x0
+ .*:   24638000        addiu   v1,v1,-32768
+ .*:   00621821        addu    v1,v1,v0
+ .*:   7c02283b        rdhwr   v0,\$5
+ .*:   8f838030        lw      v1,-32720\(gp\)
+ .*:   00000000        nop
+ .*:   00621821        addu    v1,v1,v0
+ .*:   03c0e821        move    sp,s8
+ .*:   8fbe0008        lw      s8,8\(sp\)
+ .*:   03e00008        jr      ra
+ .*:   27bd0010        addiu   sp,sp,16
+       ...
+Disassembly of section .MIPS.stubs:
+
+.* <.MIPS.stubs>:
+ .*:   8f998010        lw      t9,-32752\(gp\)
+ .*:   03e07821        move    t7,ra
+ .*:   0320f809        jalr    t9
+ .*:   241800.*        li      t8,.*
+       ...
diff --git a/ld/testsuite/ld-mips-elf/tlslib-o32.got b/ld/testsuite/ld-mips-elf/tlslib-o32.got
new file mode 100644 (file)
index 0000000..cb49c2b
--- /dev/null
@@ -0,0 +1,17 @@
+
+tmpdir/tlslib-o32.so:     file format elf32-tradbigmips
+
+DYNAMIC RELOCATION RECORDS
+OFFSET   TYPE              VALUE 
+00000000 R_MIPS_NONE       \*ABS\*
+00040534 R_MIPS_TLS_DTPMOD32  \*ABS\*
+0004053c R_MIPS_TLS_DTPMOD32  tlsvar_gd
+00040540 R_MIPS_TLS_DTPREL32  tlsvar_gd
+00040530 R_MIPS_TLS_TPREL32  tlsvar_ie
+
+
+Contents of section .got:
+ 40510 00000000 80000000 00000000 00000000  ................
+ 40520 00000000 00000000 00000000 000004e0  ................
+ 40530 00000000 00000000 00000000 00000000  ................
+ 40540 00000000                             ....            
diff --git a/ld/testsuite/ld-mips-elf/tlslib-o32.s b/ld/testsuite/ld-mips-elf/tlslib-o32.s
new file mode 100644 (file)
index 0000000..c15829f
--- /dev/null
@@ -0,0 +1,70 @@
+       .file   1 "tlslib-o32.s"
+       .abicalls
+       .text
+       .align  2
+       .globl  fn
+       .ent    fn
+       .type   fn,@function
+fn:
+       .frame  $fp,16,$31
+       .mask   0x40000000,-8
+       .fmask  0x00000000,0
+       .set    noreorder
+       .cpload $25
+       .set    reorder
+       addiu   $sp,$sp,-16
+       sw      $fp,8($sp)
+       move    $fp,$sp
+       .cprestore      0
+
+       # General Dynamic
+       lw      $25,%call16(__tls_get_addr)($28)
+       addiu   $4,$28,%tlsgd(tlsvar_gd)
+       jal     $25
+
+       # Local Dynamic
+       lw      $25,%call16(__tls_get_addr)($28)
+       addiu   $4,$28,%tlsldm(tlsvar_ld)
+       jal     $25
+
+       move    $2,$2           # Arbitrary instructions
+
+       lui     $3,%dtprel_hi(tlsvar_ld)
+       addiu   $3,$3,%dtprel_lo(tlsvar_ld)
+       addu    $3,$3,$2
+
+       # Initial Exec
+       .set    push
+       .set    mips32r2
+       rdhwr   $2, $5
+       .set    pop
+       lw      $3,%gottprel(tlsvar_ie)($28)
+       addu    $3,$3,$2
+
+       move    $sp,$fp
+       lw      $fp,8($sp)
+       addiu   $sp,$sp,16
+       j       $31
+       .end    fn
+
+       .section                .tbss,"awT",@nobits
+       .align  2
+       .global tlsvar_gd
+       .type   tlsvar_gd,@object
+       .size   tlsvar_gd,4
+tlsvar_gd:
+       .space  4
+       .global tlsvar_ie
+       .type   tlsvar_ie,@object
+       .size   tlsvar_ie,4
+tlsvar_ie:
+       .space  4
+
+       .section                .tdata,"awT"
+       .align  2
+       .global tlsvar_ld
+       .hidden tlsvar_ld
+       .type   tlsvar_ld,@object
+       .size   tlsvar_ld,4
+tlsvar_ld:
+       .word   1
diff --git a/ld/testsuite/ld-mips-elf/tlslib.ver b/ld/testsuite/ld-mips-elf/tlslib.ver
new file mode 100644 (file)
index 0000000..441c525
--- /dev/null
@@ -0,0 +1,3 @@
+VER_1 {
+  global: *;
+};