MIPS/BFD: Fix TLS relocation resolution for regular executables
authorMaciej W. Rozycki <macro@mips.com>
Wed, 11 Jul 2018 16:44:45 +0000 (17:44 +0100)
committerMaciej W. Rozycki <macro@mips.com>
Wed, 11 Jul 2018 16:44:45 +0000 (17:44 +0100)
commit1cb83cac9a8974bdb12aac90018ad1165ba86274
tree4f7e81df67ab99004599f21cddc7b57b8de736ea
parent9143e72c6d4ddefbcb41c0f6361ad140354145ef
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.
bfd/ChangeLog
bfd/elfxx-mips.c
ld/ChangeLog
ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d
ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got
ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d
ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d
ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
ld/testsuite/ld-mips-elf/tlsdyn-o32.d
ld/testsuite/ld-mips-elf/tlsdyn-o32.got
This page took 0.025915 seconds and 4 git commands to generate.