aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-mips-elf
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@mips.com>2018-07-11 17:44:45 +0100
committerMaciej W. Rozycki <macro@mips.com>2018-07-11 17:44:45 +0100
commit1cb83cac9a8974bdb12aac90018ad1165ba86274 (patch)
tree4f7e81df67ab99004599f21cddc7b57b8de736ea /ld/testsuite/ld-mips-elf
parent9143e72c6d4ddefbcb41c0f6361ad140354145ef (diff)
downloadgdb-1cb83cac9a8974bdb12aac90018ad1165ba86274.zip
gdb-1cb83cac9a8974bdb12aac90018ad1165ba86274.tar.gz
gdb-1cb83cac9a8974bdb12aac90018ad1165ba86274.tar.bz2
MIPS/BFD: Fix TLS relocation resolution for regular executables
Correct an issue with commit 0f20cc3522e7 ("TLS support for MIPS"), <https://sourceware.org/ml/binutils/2005-02/msg00607.html>, where a condition used to determine whether to use a dynamic symbol for GD, LD and IE TLS dynamic relocations against a symbol that has been defined locally has been incorrectly reversed. It's executables rather than dynamic shared objects where no symbol is required, because such symbols cannot be preempted and therefore their values (thread pointer offsets) are fixed at the static link time as is the associated module ID of the main executable, so the original condition should have been `shared' instead of `!shared'. This wrong condition was then later converted from `!shared' to `!bfd_link_pic', with commit 0e1862bb401f ("Add output_type to bfd_link_info"). Use the correct `bfd_link_dll' condition then, and adjust code for the dynamic symbol index possibly being -1 as with symbols that have been forced local, removing unnecessary dynamic relocations from dynamic regular executables. PIE executables are unaffected as the existing condition excluded them by chance due to the conversion mentioned above. Adjust test cases accordingly. bfd/ * elfxx-mips.c (mips_tls_got_relocs): Use `bfd_link_dll' rather than `!bfd_link_pic' in determining the dynamic symbol index. Avoid the index of -1. (mips_elf_initialize_tls_slots): Likewise. Flatten code by moving `dyn' to the beginning of the function block. ld/ * testsuite/ld-mips-elf/tlsdyn-o32.d: Update test for dynamic relocation removal. * testsuite/ld-mips-elf/tlsdyn-o32.got: Likewise. * testsuite/ld-mips-elf/tlsdyn-o32-1.d: Likewise. * testsuite/ld-mips-elf/tlsdyn-o32-1.got: Likewise. * testsuite/ld-mips-elf/tlsdyn-o32-2.d: Likewise. * testsuite/ld-mips-elf/tlsdyn-o32-2.got: Likewise. * testsuite/ld-mips-elf/tlsdyn-o32-3.d: Likewise. * testsuite/ld-mips-elf/tlsdyn-o32-3.got: Likewise.
Diffstat (limited to 'ld/testsuite/ld-mips-elf')
-rw-r--r--ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d4
-rw-r--r--ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got7
-rw-r--r--ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d4
-rw-r--r--ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got7
-rw-r--r--ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d4
-rw-r--r--ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got7
-rw-r--r--ld/testsuite/ld-mips-elf/tlsdyn-o32.d2
-rw-r--r--ld/testsuite/ld-mips-elf/tlsdyn-o32.got7
8 files changed, 15 insertions, 27 deletions
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d b/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d
index 17e42d0..47af453 100644
--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d
+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d
@@ -5,7 +5,7 @@ Disassembly of section .text:
.* <__start>:
.*: 3c1c0fc0 lui gp,0xfc0
- .*: 279c7b80 addiu gp,gp,31616
+ .*: 279c7ba0 addiu gp,gp,31648
.*: 0399e021 addu gp,gp,t9
.*: 27bdfff0 addiu sp,sp,-16
.*: afbe0008 sw s8,8\(sp\)
@@ -55,7 +55,7 @@ Disassembly of section .text:
.* <other>:
.*: 3c1c0fc0 lui gp,0xfc0
- .*: 279c7ac0 addiu gp,gp,31424
+ .*: 279c7ae0 addiu gp,gp,31456
.*: 0399e021 addu gp,gp,t9
.*: 27bdfff0 addiu sp,sp,-16
.*: afbe0008 sw s8,8\(sp\)
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got b/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got
index 508fed2..9160225 100644
--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got
+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got
@@ -4,15 +4,12 @@
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
00000000 R_MIPS_NONE \*ABS\*
-10000038 R_MIPS_TLS_DTPMOD32 tlsbin_gd@@Base
-1000003c R_MIPS_TLS_DTPREL32 tlsbin_gd@@Base
1000002c R_MIPS_TLS_DTPMOD32 tlsvar_gd@VER_1
10000030 R_MIPS_TLS_DTPREL32 tlsvar_gd@VER_1
10000040 R_MIPS_TLS_TPREL32 tlsvar_ie@VER_1
-10000034 R_MIPS_TLS_TPREL32 tlsbin_ie@@Base
Contents of section .got:
- 10000020 00000000 80000000 0040053c 00000000 .........@......
- 10000030 00000000 00000000 00000000 00000000 ................
+ 10000020 00000000 80000000 0040051c 00000000 .........@......
+ 10000030 00000000 ffff900c 00000001 ffff8008 ................
10000040 00000000 00000001 00000000 ............
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d b/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d
index 17e42d0..47af453 100644
--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d
+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d
@@ -5,7 +5,7 @@ Disassembly of section .text:
.* <__start>:
.*: 3c1c0fc0 lui gp,0xfc0
- .*: 279c7b80 addiu gp,gp,31616
+ .*: 279c7ba0 addiu gp,gp,31648
.*: 0399e021 addu gp,gp,t9
.*: 27bdfff0 addiu sp,sp,-16
.*: afbe0008 sw s8,8\(sp\)
@@ -55,7 +55,7 @@ Disassembly of section .text:
.* <other>:
.*: 3c1c0fc0 lui gp,0xfc0
- .*: 279c7ac0 addiu gp,gp,31424
+ .*: 279c7ae0 addiu gp,gp,31456
.*: 0399e021 addu gp,gp,t9
.*: 27bdfff0 addiu sp,sp,-16
.*: afbe0008 sw s8,8\(sp\)
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got b/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
index 4a97099..c7bfec9 100644
--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
@@ -4,15 +4,12 @@
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
00000000 R_MIPS_NONE \*ABS\*
-10000038 R_MIPS_TLS_DTPMOD32 tlsbin_gd@@Base
-1000003c R_MIPS_TLS_DTPREL32 tlsbin_gd@@Base
1000002c R_MIPS_TLS_DTPMOD32 tlsvar_gd@VER_1
10000030 R_MIPS_TLS_DTPREL32 tlsvar_gd@VER_1
10000040 R_MIPS_TLS_TPREL32 tlsvar_ie@VER_1
-10000034 R_MIPS_TLS_TPREL32 tlsbin_ie@@Base
Contents of section .got:
- 10000020 00000000 80000000 0040053c 00000000 .*
- 10000030 00000000 00000000 00000000 00000000 .*
+ 10000020 00000000 80000000 0040051c 00000000 .*
+ 10000030 00000000 ffff900c 00000001 ffff8008 .*
10000040 00000000 00000001 00000000 .*
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d b/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d
index fb3750a..db2f56c 100644
--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d
+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d
@@ -5,7 +5,7 @@ Disassembly of section .text:
.* <other>:
.*: 3c1c0fc0 lui gp,0xfc0
- .*: 279c7b80 addiu gp,gp,31616
+ .*: 279c7ba0 addiu gp,gp,31648
.*: 0399e021 addu gp,gp,t9
.*: 27bdfff0 addiu sp,sp,-16
.*: afbe0008 sw s8,8\(sp\)
@@ -51,7 +51,7 @@ Disassembly of section .text:
.* <__start>:
.*: 3c1c0fc0 lui gp,0xfc0
- .*: 279c7ad0 addiu gp,gp,31440
+ .*: 279c7af0 addiu gp,gp,31472
.*: 0399e021 addu gp,gp,t9
.*: 27bdfff0 addiu sp,sp,-16
.*: afbe0008 sw s8,8\(sp\)
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got b/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
index d96375c..87b54f5 100644
--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
@@ -4,15 +4,12 @@
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
00000000 R_MIPS_NONE \*ABS\*
-10000038 R_MIPS_TLS_DTPMOD32 tlsbin_gd@@Base
-1000003c R_MIPS_TLS_DTPREL32 tlsbin_gd@@Base
1000002c R_MIPS_TLS_DTPMOD32 tlsvar_gd@VER_1
10000030 R_MIPS_TLS_DTPREL32 tlsvar_gd@VER_1
10000040 R_MIPS_TLS_TPREL32 tlsvar_ie@VER_1
-10000034 R_MIPS_TLS_TPREL32 tlsbin_ie@@Base
Contents of section .got:
- 10000020 00000000 80000000 004005ec 00000000 .*
- 10000030 00000000 00000000 00000000 00000000 .*
+ 10000020 00000000 80000000 004005cc 00000000 .*
+ 10000030 00000000 ffff900c 00000001 ffff8008 .*
10000040 00000000 00000001 00000000 .*
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32.d b/ld/testsuite/ld-mips-elf/tlsdyn-o32.d
index e3f9ccb..688721f 100644
--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32.d
+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32.d
@@ -5,7 +5,7 @@ Disassembly of section .text:
.* <__start>:
.*: 3c1c0fc0 lui gp,0xfc0
- .*: 279c7be0 addiu gp,gp,31712
+ .*: 279c7c00 addiu gp,gp,31744
.*: 0399e021 addu gp,gp,t9
.*: 27bdfff0 addiu sp,sp,-16
.*: afbe0008 sw s8,8\(sp\)
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32.got b/ld/testsuite/ld-mips-elf/tlsdyn-o32.got
index 7942188..7c8f93b 100644
--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32.got
+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32.got
@@ -4,15 +4,12 @@ tmpdir/tls-dynamic-o32: file format elf32-tradbigmips
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
00000000 R_MIPS_NONE \*ABS\*
-10000044 R_MIPS_TLS_DTPMOD32 tlsbin_gd
-10000048 R_MIPS_TLS_DTPREL32 tlsbin_gd
10000030 R_MIPS_TLS_DTPMOD32 tlsvar_gd
10000034 R_MIPS_TLS_DTPREL32 tlsvar_gd
-1000002c R_MIPS_TLS_TPREL32 tlsbin_ie
10000040 R_MIPS_TLS_TPREL32 tlsvar_ie
Contents of section .got:
- 10000020 00000000 80000000 004004dc 00000000 .........@......
+ 10000020 00000000 80000000 004004bc ffff900c .........@......
10000030 00000000 00000000 00000001 00000000 ................
- 10000040 00000000 00000000 00000000 ............
+ 10000040 00000000 00000001 ffff8008 ............