binutils-gdb/ld/testsuite/ld-xtensa/tlspie.dd
Max Filippov 658ba81aef xtensa: bfd: fix TLS relocations generated for PIE
When generating TLS dynamic relocations the existing xtensa BFD code
treats linking to a PIE exactly as linking to a shared object, resulting
in generation of wrong relocations for TLS entries. Fix that and add
tests.

bfd/
	* elf32-xtensa.c (elf_xtensa_check_relocs): Use bfd_link_dll
	instead of bfd_link_pic. Add elf_xtensa_dynamic_symbol_p test
	when generating GOT entries.
	(elf_xtensa_relocate_section): Use bfd_link_dll instead of
	bfd_link_pic.
ld/
	* testsuite/ld-xtensa/tlspie.dd: New file.
	* testsuite/ld-xtensa/tlspie.rd: New file.
	* testsuite/ld-xtensa/tlspie.sd: New file.
	* testsuite/ld-xtensa/tlspie.td: New file.
	* testsuite/ld-xtensa/xtensa-linux.exp (TLS PIE transitions):
	New test.
2022-09-02 09:54:49 -07:00

67 lines
2.4 KiB
Plaintext

#source: tlsbin.s
#as:
#ld: -melf32xtensa
#objdump: -dRj.text
#target: xtensa*-*-linux*
.*: +file format elf32-xtensa-.e
Disassembly of section \.text:
#...
[0-9a-f]+ <_start>:
[0-9a-f]+: [0-9a-f]+[ ]+entry a1, 32
# GD -> IE because variable is not defined in executable
[0-9a-f]+: [0-9a-f]+[ ]+rur.threadptr a8
[0-9a-f]+: [0-9a-f]+[ ]+l32r a10, 1ec <.*> .*
[0-9a-f]+: [0-9a-f]+[ ]+add.* a10, a10, a8
# GD -> IE because variable is not defined in executable where
# the variable is referenced through IE too
[0-9a-f]+: [0-9a-f]+[ ]+rur.threadptr a8
[0-9a-f]+: [0-9a-f]+[ ]+l32r a10, 1f4 <.*> .*
[0-9a-f]+: [0-9a-f]+[ ]+add.* a10, a10, a8
# GD -> LE with global variable defined in executable
[0-9a-f]+: [0-9a-f]+[ ]+rur.threadptr a8
[0-9a-f]+: [0-9a-f]+[ ]+l32r a10, 1fc <.*> .*
[0-9a-f]+: [0-9a-f]+[ ]+add.* a10, a10, a8
# GD -> LE with local variable defined in executable
[0-9a-f]+: [0-9a-f]+[ ]+rur.threadptr a8
[0-9a-f]+: [0-9a-f]+[ ]+l32r a10, 204 <.*> .*
[0-9a-f]+: [0-9a-f]+[ ]+add.* a10, a10, a8
# GD -> LE with hidden variable defined in executable
[0-9a-f]+: [0-9a-f]+[ ]+rur.threadptr a8
[0-9a-f]+: [0-9a-f]+[ ]+l32r a10, 20c <.*> .*
[0-9a-f]+: [0-9a-f]+[ ]+add.* a10, a10, a8
# LD -> LE
[0-9a-f]+: [0-9a-f]+[ ]+nop.*
[0-9a-f]+: [0-9a-f]+[ ]+nop.*
[0-9a-f]+: [0-9a-f]+[ ]+rur.threadptr a10
[0-9a-f]+: [0-9a-f]+[ ]+l32r a12, 218 <.*> .*
[0-9a-f]+: [0-9a-f]+[ ]+add.* a12, a12, a10
[0-9a-f]+: [0-9a-f]+[ ]+l32r a13, 21c <.*> .*
[0-9a-f]+: [0-9a-f]+[ ]+add.* a13, a13, a10
# LD -> LE against hidden variables
[0-9a-f]+: [0-9a-f]+[ ]+l32r a12, 220 <.*> .*
[0-9a-f]+: [0-9a-f]+[ ]+add.* a12, a12, a10
[0-9a-f]+: [0-9a-f]+[ ]+l32r a13, 224 <.*> .*
[0-9a-f]+: [0-9a-f]+[ ]+add.* a13, a13, a10
#
# IE against global var
[0-9a-f]+: [0-9a-f]+[ ]+rur.threadptr a2
[0-9a-f]+: [0-9a-f]+[ ]+l32r a3, 228 <.*> .*
[0-9a-f]+: [0-9a-f]+[ ]+add.* a3, a3, a2
# IE -> LE against global var defined in exec
[0-9a-f]+: [0-9a-f]+[ ]+rur.threadptr a4
[0-9a-f]+: [0-9a-f]+[ ]+l32r a5, 22c <.*> .*
[0-9a-f]+: [0-9a-f]+[ ]+add.* a5, a5, a4
# IE -> LE against local var
[0-9a-f]+: [0-9a-f]+[ ]+rur.threadptr a6
[0-9a-f]+: [0-9a-f]+[ ]+l32r a7, 230 <.*> .*
[0-9a-f]+: [0-9a-f]+[ ]+add.* a7, a7, a6
# IE -> LE against hidden var
[0-9a-f]+: [0-9a-f]+[ ]+rur.threadptr a8
[0-9a-f]+: [0-9a-f]+[ ]+l32r a9, 234 <.*> .*
[0-9a-f]+: [0-9a-f]+[ ]+add.* a9, a9, a8
#
[0-9a-f]+: [0-9a-f]+[ ]+retw.*