xtensa: bfd: fix TLS relocations generated for PIE
authorMax Filippov <jcmvbkbc@gmail.com>
Tue, 23 Aug 2022 12:25:55 +0000 (05:25 -0700)
committerMax Filippov <jcmvbkbc@gmail.com>
Fri, 2 Sep 2022 16:54:49 +0000 (09:54 -0700)
commit658ba81aef5e85a08d67eb211a43c6db775a36b3
treee30b2f29188986cd78114d6ac2bc0cbf36487498
parent1a51864b467c2d65bd37c3bc9cbab2cf1ee6a039
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.
bfd/elf32-xtensa.c
ld/testsuite/ld-xtensa/tlspie.dd [new file with mode: 0644]
ld/testsuite/ld-xtensa/tlspie.rd [new file with mode: 0644]
ld/testsuite/ld-xtensa/tlspie.sd [new file with mode: 0644]
ld/testsuite/ld-xtensa/tlspie.td [new file with mode: 0644]
ld/testsuite/ld-xtensa/xtensa-linux.exp