binutils-gdb/ld/testsuite/ld-sparc
Alan Modra f26a32876b 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.
2019-07-13 09:57:50 +09:30
..
got-hidden32.s PR ld/22972 on SPARC. 2018-03-28 12:17:15 +02:00
got-hidden64.s PR ld/22972 on SPARC. 2018-03-28 12:17:15 +02:00
gotop32.dd Update more ld testcases after PR ld/17975 fix 2015-02-16 08:35:17 -08:00
gotop32.rd Define various symbols conditionally in shared libraries 2018-06-08 20:17:34 +09:30
gotop32.s
gotop32.sd
gotop32.td Pad only text sections at end by default 2015-02-28 22:26:56 +10:30
gotop64.dd Update more ld testcases after PR ld/17975 fix 2015-02-16 08:35:17 -08:00
gotop64.rd Define various symbols conditionally in shared libraries 2018-06-08 20:17:34 +09:30
gotop64.s
gotop64.sd
gotop64.td Pad only text sections at end by default 2015-02-28 22:26:56 +10:30
gotop-hidden.c PR ld/22972 on SPARC. 2018-03-28 12:17:15 +02:00
pass.out PR ld/22972 on SPARC. 2018-03-28 12:17:15 +02:00
sparc.exp Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
tlsg32.s
tlsg32.sd
tlsg64.s
tlsg64.sd
tlslib.s
tlslib.ver Fix PR ld/22727 (TLS breakage in PIC/PIE mode on SPARC). 2018-01-25 12:16:06 +01:00
tlsnopic.s
tlspic.s
tlspie32.dd Fix PR ld/22263 on SPARC. 2018-02-06 18:17:39 +01:00
tlspie32.s Fix PR ld/22263 on SPARC. 2018-02-06 18:17:39 +01:00
tlspie64.dd Fix PR ld/22263 on SPARC. 2018-02-06 18:17:39 +01:00
tlspie64.s Fix PR ld/22263 on SPARC. 2018-02-06 18:17:39 +01:00
tlssunbin32.dd Fix PR ld/22727 (TLS breakage in PIC/PIE mode on SPARC). 2018-01-25 12:16:06 +01:00
tlssunbin32.rd Define various symbols conditionally in shared libraries 2018-06-08 20:17:34 +09:30
tlssunbin32.s
tlssunbin32.sd Fix PR ld/22727 (TLS breakage in PIC/PIE mode on SPARC). 2018-01-25 12:16:06 +01:00
tlssunbin32.td
tlssunbin64.dd Fix PR ld/22727 (TLS breakage in PIC/PIE mode on SPARC). 2018-01-25 12:16:06 +01:00
tlssunbin64.rd Define various symbols conditionally in shared libraries 2018-06-08 20:17:34 +09:30
tlssunbin64.s
tlssunbin64.sd Fix PR ld/22727 (TLS breakage in PIC/PIE mode on SPARC). 2018-01-25 12:16:06 +01:00
tlssunbin64.td
tlssunbinpic32.s
tlssunbinpic64.s
tlssunnopic32.dd
tlssunnopic32.rd Dynamic TLS section symbols 2019-07-13 09:57:50 +09:30
tlssunnopic32.s
tlssunnopic32.sd
tlssunnopic64.dd ld: fix regressions with rett instructions in sparc tests. 2017-04-24 05:31:31 -07:00
tlssunnopic64.rd Dynamic TLS section symbols 2019-07-13 09:57:50 +09:30
tlssunnopic64.s
tlssunnopic64.sd
tlssunpic32.dd
tlssunpic32.rd Dynamic TLS section symbols 2019-07-13 09:57:50 +09:30
tlssunpic32.s
tlssunpic32.sd
tlssunpic32.td
tlssunpic64.dd ld: fix regressions with rett instructions in sparc tests. 2017-04-24 05:31:31 -07:00
tlssunpic64.rd Dynamic TLS section symbols 2019-07-13 09:57:50 +09:30
tlssunpic64.s
tlssunpic64.sd
tlssunpic64.td
vxworks1-lib.dd
vxworks1-lib.nd
vxworks1-lib.rd readelf ngettext fixes 2017-11-07 17:01:16 +10:30
vxworks1-lib.s
vxworks1-lib.td
vxworks1-static.d ld error/warning messages 2018-02-26 10:51:12 +10:30
vxworks1.dd
vxworks1.ld
vxworks1.rd
vxworks1.s
vxworks2-static.sd
vxworks2.s
vxworks2.sd
wdispcall.dd bfd,ld: Continue after partially-successful relaxed call relocations in sparc. 2016-12-04 22:59:18 -08:00
wdispcall.s bfd,ld: Continue after partially-successful relaxed call relocations in sparc. 2016-12-04 22:59:18 -08:00