+2019-05-21 Faraz Shahbazker <fshahbazker@wavecomp.com>
+
+ * elfxx-mips.c (_bfd_mips_elf_check_relocs): Generate error
+ for TLS_TPREL_HI16(/LO16) relocations in shared library.
+
2019-05-21 Faraz Shahbazker <fshahbazker@wavecomp.com>
* elfxx-mips.c (_bfd_mips_elf_check_relocs): Add NULL pointer
{
switch (r_type)
{
+ case R_MIPS_TLS_TPREL_HI16:
+ case R_MIPS16_TLS_TPREL_HI16:
+ case R_MICROMIPS_TLS_TPREL_HI16:
+ case R_MIPS_TLS_TPREL_LO16:
+ case R_MIPS16_TLS_TPREL_LO16:
+ case R_MICROMIPS_TLS_TPREL_LO16:
+ /* These are okay in PIE, but not in a shared library. */
+ if (bfd_link_executable (info))
+ break;
+
+ /* FALLTHROUGH */
+
case R_MIPS16_HI16:
case R_MIPS_HI16:
case R_MIPS_HIGHER:
+2019-05-21 Faraz Shahbazker <fshahbazker@wavecomp.com>
+
+ * testsuite/ld-mips-elf/pic-reloc-5.s: Add tests for
+ %tprel_hi and %tprel_lo relocations.
+ * testsuite/ld-mips-elf/pic-reloc-6.s: Likewise.
+ * testsuite/ld-mips-elf/pic-reloc-5.d: Update accordingly.
+ * testsuite/ld-mips-elf/pic-reloc-6.d: Likewise.
+ * testsuite/ld-mips-elf/pic-reloc-tls.ld: New test linker
+ script file.
+
2019-05-21 Faraz Shahbazker <fshahbazker@wavecomp.com>
* testsuite/ld-mips-elf/pic-reloc-5.d: New test.
#name: MIPS PIC relocation 5
-#ld: -shared -T pic-reloc-ordinary.ld
+#ld: -shared -T pic-reloc-tls.ld
#target: [check_shared_lib_support]
#error: \A[^\n]*: in function `foo':\n
#error: \(\.text\+0x0\): relocation R_(MICRO|)MIPS_HI16 against `a local symbol' cannot be used when making a shared object; recompile with -fPIC\n
-#error: \(\.text\+0x8\): relocation R_(MICRO|)MIPS_HI16 against `bar' cannot be used when making a shared object; recompile with -fPIC\Z
+#error: \(\.text\+0x8\): relocation R_(MICRO|)MIPS_HI16 against `bar' cannot be used when making a shared object; recompile with -fPIC\n
+#error: \(\.text\+0x10\): relocation R_(MICRO|)MIPS_TLS_TPREL_HI16 against `a local symbol' cannot be used when making a shared object; recompile with -fPIC\n
+#error: \(\.text\+0x14\): relocation R_(MICRO|)MIPS_TLS_TPREL_LO16 against `a local symbol' cannot be used when making a shared object; recompile with -fPIC\n
+#error: \(\.text\+0x18\): relocation R_(MICRO|)MIPS_TLS_TPREL_HI16 against `global_tls' cannot be used when making a shared object; recompile with -fPIC\n
+#error: \(\.text\+0x1c\): relocation R_(MICRO|)MIPS_TLS_TPREL_LO16 against `global_tls' cannot be used when making a shared object; recompile with -fPIC\Z
.text
.globl foo
+ .globl global_tls
.ent foo
foo:
$LCL:
addiu $2, %lo($LCL)
lui $2, %hi(bar)
addiu $2, %lo(bar)
+ lui $a0,%tprel_hi(local_tls)
+ addiu $a0,$a0,%tprel_lo(local_tls)
+ lui $a0,%tprel_hi(global_tls)
+ addiu $a0,$a0,%tprel_lo(global_tls)
.end foo
+ .type local_tls,%object
+ .type global_tls,%object
+ .section .tbss,"awT",@nobits
+local_tls:
+ .word
+global_tls:
+ .word
#name: MIPS PIC relocation 6 (MIPS16)
-#ld: -shared -T pic-reloc-ordinary.ld
+#ld: -shared -T pic-reloc-tls.ld
#target: [check_shared_lib_support]
#as: -mips16
#error: \A[^\n]*: in function `foo':\n
#error: \(\.text\+0x0\): relocation R_MIPS16_HI16 against `a local symbol' cannot be used when making a shared object; recompile with -fPIC\n
-#error: \(\.text\+0x8\): relocation R_MIPS16_HI16 against `bar' cannot be used when making a shared object; recompile with -fPIC\Z
+#error: \(\.text\+0x8\): relocation R_MIPS16_HI16 against `bar' cannot be used when making a shared object; recompile with -fPIC\n
+#error: \(\.text\+0x10\): relocation R_MIPS16_TLS_TPREL_HI16 against `a local symbol' cannot be used when making a shared object; recompile with -fPIC\n
+#error: \(\.text\+0x14\): relocation R_MIPS16_TLS_TPREL_LO16 against `a local symbol' cannot be used when making a shared object; recompile with -fPIC\n
+#error: \(\.text\+0x18\): relocation R_MIPS16_TLS_TPREL_HI16 against `global_tls' cannot be used when making a shared object; recompile with -fPIC\n
+#error: \(\.text\+0x1c\): relocation R_MIPS16_TLS_TPREL_LO16 against `global_tls' cannot be used when making a shared object; recompile with -fPIC\Z
.text
.globl foo
+ .globl global_tls
.ent foo
foo:
$LCL:
addiu $2, %lo($LCL)
li $2, %hi(bar)
addiu $2, %lo(bar)
+ li $a0,%tprel_hi(local_tls)
+ lw $a1,%tprel_lo(local_tls)($a0)
+ li $a0,%tprel_hi(global_tls)
+ lw $a1,%tprel_lo(global_tls)($a0)
.end foo
+ .type local_tls,%object
+ .type global_tls,%object
+ .section .tbss,"awT",@nobits
+local_tls:
+ .word
+global_tls:
+ .word
--- /dev/null
+SECTIONS
+{
+ bar = foo;
+ .text : { *(.text) }
+ .tbss : { *(.tbss) }
+ /DISCARD/ : { *(*) }
+}