aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-mips-elf
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-07-11 22:08:39 +0930
committerAlan Modra <amodra@gmail.com>2019-07-13 09:57:50 +0930
commitf26a32876ba49b2d5537beccea2a38bc544e9732 (patch)
treed336701d832c5984d9027a6b371e9acc7c6eb772 /ld/testsuite/ld-mips-elf
parent7b2438015ca87297b2796c662182f796bb5358c2 (diff)
downloadfsf-binutils-gdb-f26a32876ba49b2d5537beccea2a38bc544e9732.zip
fsf-binutils-gdb-f26a32876ba49b2d5537beccea2a38bc544e9732.tar.gz
fsf-binutils-gdb-f26a32876ba49b2d5537beccea2a38bc544e9732.tar.bz2
Dynamic TLS section symbols
It is possible to create shared libraries on PowerPC using -ftls-model=inital-exec or -ftls-model=local-exec. The first is half reasonable, getting you a shared library that can't be dlopen'd but otherwise is reasonable. The second is quite bad. Not only do you lose being able to dlopen, the library also has dynamic text relocations. Worse, the TPREL16_LO, TPREL16_HA and other TPREL16 dynamic relocs emitted were wrong, resulting in wrong values being applied by ld.so. Using the first TLS section symbol in dynamic relocations for local TLS symbols doesn't work. It's wrong because TLS symbols used by TLS relocs have values relative to the TLS segment, whereas the TLS section symbols are addresses. This patch instead uses a symbol index of zero which is used elsewhere by PowerPC on dynamic TLS relocs. It's not strictly ABI compliant to use a non-TLS symbol with TLS relocs but symbol index zero can be interpreted as "no symbol". Not using the first TLS section symbol means it doesn't need to be dynamic. The patch also fixes a further problem with PowerPC32 dynamic TPREL16* relocs, which shouldn't have the symbol value in the addend as we do for non-TLS symbols. bfd/ * elflink.c (_bfd_elf_omit_section_dynsym_default): Don't keep tls_sec. (_bfd_elf_init_1_index_section): Prefer not using TLS sections. (_bfd_elf_init_2_index_sections): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): When emitting dynamic relocations for local TLS symbols, use STN_UNDEF as the relocation symbol. * elf32-ppc.c (ppc_elf_relocate_section): Likewise, and don't leave TLS symbol value in the addend. ld/ * testsuite/ld-powerpc/tlsso.r: Update. * testsuite/ld-powerpc/tlsso32.g: Update. * testsuite/ld-powerpc/tlsso32.r: Update. * testsuite/ld-powerpc/tlstocso.r: Update. * testsuite/ld-cris/tls-dso-dtpoffd2.d: Update. * testsuite/ld-cris/tls-dso-dtpoffd4.d: Update. * testsuite/ld-cris/tls-dso-tpoffgotcomm1.d: Update. * testsuite/ld-cris/tls-gd-1.d: Update. * testsuite/ld-cris/tls-gd-1h.d: Update. * testsuite/ld-cris/tls-gd-2.d: Update. * testsuite/ld-cris/tls-gd-2h.d: Update. * testsuite/ld-cris/tls-ie-10.d: Update. * testsuite/ld-cris/tls-ie-11.d: Update. * testsuite/ld-cris/tls-ie-8.d: Update. * testsuite/ld-cris/tls-ie-9.d: Update. * testsuite/ld-cris/tls-js1.d: Update. * testsuite/ld-cris/tls-ld-4.d: Update. * testsuite/ld-cris/tls-ld-5.d: Update. * testsuite/ld-cris/tls-ld-6.d: Update. * testsuite/ld-cris/tls-ld-7.d: Update. * testsuite/ld-cris/tls-ldgd-14.d: Update. * testsuite/ld-cris/tls-ldgd-15.d: Update. * testsuite/ld-cris/tls-ldgdx-14.d: Update. * testsuite/ld-cris/tls-ldgdx-15.d: Update. * testsuite/ld-cris/tls-local-54.d: Update. * testsuite/ld-cris/tls-local-60.d: Update. * testsuite/ld-cris/tls-local-61.d: Update. * testsuite/ld-cris/tls-local-63.d: Update. * testsuite/ld-cris/tls-local-64.d: Update. * testsuite/ld-cris/tls-ok-30.d: Update. * testsuite/ld-cris/tls-ok-32.d: Update. * testsuite/ld-cris/tls-ok-34.d: Update. * testsuite/ld-mips-elf/tls-multi-got-1.got: Update. * testsuite/ld-mips-elf/tls-multi-got-1.r: Update. * testsuite/ld-mips-elf/tlsdyn-pie-o32.d: Update. * testsuite/ld-mips-elf/tlsdyn-pie-o32.got: Update. * testsuite/ld-mips-elf/tlslib-o32-hidden.got: Update. * testsuite/ld-mips-elf/tlslib-o32-ver.got: Update. * testsuite/ld-mips-elf/tlslib-o32.got: Update. * testsuite/ld-s390/tlspic.rd: Update. * testsuite/ld-s390/tlspic_64.rd: Update. * testsuite/ld-sparc/tlssunnopic32.rd: Update. * testsuite/ld-sparc/tlssunnopic64.rd: Update. * testsuite/ld-sparc/tlssunpic32.rd: Update. * testsuite/ld-sparc/tlssunpic64.rd: Update.
Diffstat (limited to 'ld/testsuite/ld-mips-elf')
-rw-r--r--ld/testsuite/ld-mips-elf/tls-multi-got-1.got34
-rw-r--r--ld/testsuite/ld-mips-elf/tls-multi-got-1.r16
-rw-r--r--ld/testsuite/ld-mips-elf/tlsdyn-pie-o32.d2
-rw-r--r--ld/testsuite/ld-mips-elf/tlsdyn-pie-o32.got2
-rw-r--r--ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got10
-rw-r--r--ld/testsuite/ld-mips-elf/tlslib-o32-ver.got12
-rw-r--r--ld/testsuite/ld-mips-elf/tlslib-o32.got12
7 files changed, 44 insertions, 44 deletions
diff --git a/ld/testsuite/ld-mips-elf/tls-multi-got-1.got b/ld/testsuite/ld-mips-elf/tls-multi-got-1.got
index a7b8b1c..dc960c3 100644
--- a/ld/testsuite/ld-mips-elf/tls-multi-got-1.got
+++ b/ld/testsuite/ld-mips-elf/tls-multi-got-1.got
@@ -4,33 +4,33 @@
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
00000000 R_MIPS_NONE \*ABS\*
-0013f800 R_MIPS_TLS_DTPMOD32 \*ABS\*
-0014945c R_MIPS_TLS_DTPMOD32 \*ABS\*
-0013f808 R_MIPS_TLS_DTPMOD32 tlsvar_gd
-0013f80c R_MIPS_TLS_DTPREL32 tlsvar_gd
-00149468 R_MIPS_TLS_DTPMOD32 tlsvar_gd
-0014946c R_MIPS_TLS_DTPREL32 tlsvar_gd
-0013f810 R_MIPS_TLS_TPREL32 tlsvar_ie
-00149464 R_MIPS_TLS_TPREL32 tlsvar_ie
-00143e88 R_MIPS_REL32 sym_1_9526
+0013f7f0 R_MIPS_TLS_DTPMOD32 \*ABS\*
+0014944c R_MIPS_TLS_DTPMOD32 \*ABS\*
+0013f7f8 R_MIPS_TLS_DTPMOD32 tlsvar_gd
+0013f7fc R_MIPS_TLS_DTPREL32 tlsvar_gd
+00149458 R_MIPS_TLS_DTPMOD32 tlsvar_gd
+0014945c R_MIPS_TLS_DTPREL32 tlsvar_gd
+0013f800 R_MIPS_TLS_TPREL32 tlsvar_ie
+00149454 R_MIPS_TLS_TPREL32 tlsvar_ie
+00143e78 R_MIPS_REL32 sym_1_9526
#...
-00139a64 R_MIPS_REL32 sym_2_8654
+00139a54 R_MIPS_REL32 sym_2_8654
Contents of section .got:
- 122330 00000000 80000000 000d7f58 000d65b4 .*
- 122340 000d1f64 000d5fd0 000d5a08 000d1980 .*
+ 122320 00000000 80000000 000d7f48 000d65a4 .*
+ 122330 000d1f54 000d5fc0 000d59f8 000d1970 .*
#...
- 135bb0 000cf1c4 000e0e08 00000000 80000000 .*
- 135bc0 00000000 00000000 00000000 00000000 .*
+ 135ba0 000cf1b4 000e0df8 00000000 80000000 .*
+ 135bb0 00000000 00000000 00000000 00000000 .*
#...
+ 13f7e0 00000000 00000000 00000000 00000000 .*
13f7f0 00000000 00000000 00000000 00000000 .*
- 13f800 00000000 00000000 00000000 00000000 .*
- 13f810 00000000 00000000 80000000 00000000 .*
+ 13f800 00000000 00000000 80000000 00000000 .*
#...
+ 149410 00000000 00000000 00000000 00000000 .*
149420 00000000 00000000 00000000 00000000 .*
149430 00000000 00000000 00000000 00000000 .*
149440 00000000 00000000 00000000 00000000 .*
149450 00000000 00000000 00000000 00000000 .*
- 149460 00000000 00000000 00000000 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
index bb4f4ac..a928a95 100644
--- a/ld/testsuite/ld-mips-elf/tls-multi-got-1.r
+++ b/ld/testsuite/ld-mips-elf/tls-multi-got-1.r
@@ -6,17 +6,17 @@ Dynamic section at offset .* contains 18 entries:
0x00000006 \(SYMTAB\).*
0x0000000a \(STRSZ\) 220065 \(bytes\)
0x0000000b \(SYMENT\) 16 \(bytes\)
- 0x00000003 \(PLTGOT\) 0x122330
- 0x00000011 \(REL\) 0xa7938
+ 0x00000003 \(PLTGOT\) 0x122320
+ 0x00000011 \(REL\) 0xa7924
0x00000012 \(RELSZ\) 160072 \(bytes\)
0x00000013 \(RELENT\) 8 \(bytes\)
0x70000001 \(MIPS_RLD_VERSION\) 1
0x70000005 \(MIPS_FLAGS\) NOTPOT
0x70000006 \(MIPS_BASE_ADDRESS\) 0x0
0x7000000a \(MIPS_LOCAL_GOTNO\) 2
- 0x70000011 \(MIPS_SYMTABNO\) 20011
+ 0x70000011 \(MIPS_SYMTABNO\) 20010
0x70000012 \(MIPS_UNREFEXTNO\) 12
- 0x70000013 \(MIPS_GOTSYM\) 0xb
+ 0x70000013 \(MIPS_GOTSYM\) 0xa
0x0000001e \(FLAGS\) STATIC_TLS
0x00000000 \(NULL\) 0x0
@@ -31,8 +31,8 @@ Relocation section '\.rel\.dyn' at offset 0x[0-9a-f]+ contains 20009 entries:
[0-9a-f ]+R_MIPS_TLS_DTPREL 00000004 tlsvar_gd
[0-9a-f ]+R_MIPS_TLS_TPREL3 00000008 tlsvar_ie
[0-9a-f ]+R_MIPS_TLS_TPREL3 00000008 tlsvar_ie
-[0-9a-f ]+R_MIPS_REL32 000d7f58 sym_1_9526
-[0-9a-f ]+R_MIPS_REL32 000d65b4 sym_1_7885
+[0-9a-f ]+R_MIPS_REL32 000d7f48 sym_1_9526
+[0-9a-f ]+R_MIPS_REL32 000d65a4 sym_1_7885
#...
-[0-9a-f ]+R_MIPS_REL32 000cf1c4 sym_1_0465
-[0-9a-f ]+R_MIPS_REL32 000e0e08 sym_2_8654
+[0-9a-f ]+R_MIPS_REL32 000cf1b4 sym_1_0465
+[0-9a-f ]+R_MIPS_REL32 000e0df8 sym_2_8654
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-pie-o32.d b/ld/testsuite/ld-mips-elf/tlsdyn-pie-o32.d
index 4df024f..c5ad168 100644
--- a/ld/testsuite/ld-mips-elf/tlsdyn-pie-o32.d
+++ b/ld/testsuite/ld-mips-elf/tlsdyn-pie-o32.d
@@ -4,7 +4,7 @@ Disassembly of section \.text:
.* <__start>:
.*: 3c1c0fc0 lui gp,0xfc0
- .*: 279c7bd0 addiu gp,gp,31696
+ .*: 279c7be0 addiu gp,gp,31712
.*: 0399e021 addu gp,gp,t9
.*: 27bdfff0 addiu sp,sp,-16
.*: afbe0008 sw s8,8\(sp\)
diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-pie-o32.got b/ld/testsuite/ld-mips-elf/tlsdyn-pie-o32.got
index c5dd695..2b75ce1 100644
--- a/ld/testsuite/ld-mips-elf/tlsdyn-pie-o32.got
+++ b/ld/testsuite/ld-mips-elf/tlsdyn-pie-o32.got
@@ -8,6 +8,6 @@ OFFSET TYPE VALUE
10000040 R_MIPS_TLS_TPREL32 tlsvar_ie
Contents of section .got:
- 10000020 00000000 80000000 004004ec ffff900c .*
+ 10000020 00000000 80000000 004004dc ffff900c .*
10000030 00000000 00000000 00000001 00000000 .*
10000040 00000000 00000001 ffff8008 .*
diff --git a/ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got b/ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got
index a746031..e8ed1ac 100644
--- a/ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got
+++ b/ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got
@@ -4,11 +4,11 @@
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
00000000 R_MIPS_NONE \*ABS\*
-0004039c R_MIPS_TLS_TPREL32 \*ABS\*
-000403a0 R_MIPS_TLS_DTPMOD32 \*ABS\*
-000403a8 R_MIPS_TLS_DTPMOD32 \*ABS\*
+0004038c R_MIPS_TLS_TPREL32 \*ABS\*
+00040390 R_MIPS_TLS_DTPMOD32 \*ABS\*
+00040398 R_MIPS_TLS_DTPMOD32 \*ABS\*
Contents of section .got:
- 40390 00000000 80000000 00000360 00000008 ................
- 403a0 00000000 ffff8004 00000000 00000000 ................
+ 40380 00000000 80000000 00000350 00000008 .*
+ 40390 00000000 ffff8004 00000000 00000000 .*
diff --git a/ld/testsuite/ld-mips-elf/tlslib-o32-ver.got b/ld/testsuite/ld-mips-elf/tlslib-o32-ver.got
index 17a6385..b685e06 100644
--- a/ld/testsuite/ld-mips-elf/tlslib-o32-ver.got
+++ b/ld/testsuite/ld-mips-elf/tlslib-o32-ver.got
@@ -4,12 +4,12 @@
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
00000000 R_MIPS_NONE \*ABS\*
-000404b8 R_MIPS_TLS_DTPMOD32 \*ABS\*
-000404b0 R_MIPS_TLS_DTPMOD32 tlsvar_gd@@VER_1
-000404b4 R_MIPS_TLS_DTPREL32 tlsvar_gd@@VER_1
-000404ac R_MIPS_TLS_TPREL32 tlsvar_ie@@VER_1
+000404a8 R_MIPS_TLS_DTPMOD32 \*ABS\*
+000404a0 R_MIPS_TLS_DTPMOD32 tlsvar_gd@@VER_1
+000404a4 R_MIPS_TLS_DTPREL32 tlsvar_gd@@VER_1
+0004049c R_MIPS_TLS_TPREL32 tlsvar_ie@@VER_1
Contents of section .got:
- 404a0 00000000 80000000 00000470 00000000 ................
- 404b0 00000000 00000000 00000000 00000000 ................
+ 40490 00000000 80000000 00000460 00000000 .*
+ 404a0 00000000 00000000 00000000 00000000 .*
diff --git a/ld/testsuite/ld-mips-elf/tlslib-o32.got b/ld/testsuite/ld-mips-elf/tlslib-o32.got
index a389c30..8f10e53 100644
--- a/ld/testsuite/ld-mips-elf/tlslib-o32.got
+++ b/ld/testsuite/ld-mips-elf/tlslib-o32.got
@@ -4,12 +4,12 @@ tmpdir/tlslib-o32.so: file format elf32-tradbigmips
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
00000000 R_MIPS_NONE \*ABS\*
-00040428 R_MIPS_TLS_DTPMOD32 \*ABS\*
-00040420 R_MIPS_TLS_DTPMOD32 tlsvar_gd
-00040424 R_MIPS_TLS_DTPREL32 tlsvar_gd
-0004041c R_MIPS_TLS_TPREL32 tlsvar_ie
+00040418 R_MIPS_TLS_DTPMOD32 \*ABS\*
+00040410 R_MIPS_TLS_DTPMOD32 tlsvar_gd
+00040414 R_MIPS_TLS_DTPREL32 tlsvar_gd
+0004040c R_MIPS_TLS_TPREL32 tlsvar_ie
Contents of section .got:
- 40410 00000000 80000000 000003e0 00000000 ................
- 40420 00000000 00000000 00000000 00000000 ................
+ 40400 00000000 80000000 000003d0 00000000 .*
+ 40410 00000000 00000000 00000000 00000000 .*