XCOFF: add support for TLS relocations on hidden symbols
authorClément Chigot <clement.chigot@atos.net>
Fri, 17 Dec 2021 13:46:01 +0000 (14:46 +0100)
committerClément Chigot <clement.chigot@atos.net>
Mon, 10 Jan 2022 08:14:57 +0000 (09:14 +0100)
commit3c5038247c8a5fcff18fd81249b0801a95569939
tree2705a789bb9771f4d0f6f8709e390bc5666b9070
parent4cfa9e3f28c8c5156b9773cc94192233947d351c
XCOFF: add support for TLS relocations on hidden symbols

This patch adds support for TLS relocation targeting C_HIDEXT symbols.
In gas, TLS relocations, except R_TLSM and R_TLMSL, must keep the value
of their target symbol.
In ld, it simply ensures that internal TLS symbols are added to the
linker hash table for xcoff_reloc_type_tls.

It also improves the tests made by both.

bfd/ChangeLog:

* coff-rs6000.c (xcoff_howto_table): Fix name of R_TLSML.
(xcoff_reloc_type_tls): Replace the error when h is NULL by
an assert.
(xcoff_complain_overflow_unsigned_func): Adjust comments.
* coff64-rs6000.c (xcoff64_howto_table): Fix name of R_TLSML.
* xcofflink.c (xcoff_link_add_symbols_to_hash_table): New
function.
(xcoff_link_add_symbols): Add C_HIDEXT TLS symbols to the linker
hash table.

gas/ChangeLog:

* config/tc-ppc.c (md_apply_fix): Enable support for TLS
relocation over internal symbols.
* testsuite/gas/ppc/aix.exp: Replace xcoff-tlms by xcoff-tls.
* testsuite/gas/ppc/xcoff-tlsm-32.d: Removed.
* testsuite/gas/ppc/xcoff-tlsm-64.d: Removed.
* testsuite/gas/ppc/xcoff-tlsm.s: Removed.
* testsuite/gas/ppc/xcoff-tls-32.d: New test.
* testsuite/gas/ppc/xcoff-tls-64.d: New test.
* testsuite/gas/ppc/xcoff-tls.s: New test.

ld/ChangeLog:

* testsuite/ld-powerpc/aix52.exp: Improve aix-tls-reloc test.
* testsuite/ld-powerpc/aix-tls-reloc.s: Likewise.
* testsuite/ld-powerpc/aix-tls-reloc-32.d: Removed.
* testsuite/ld-powerpc/aix-tls-reloc-64.d: Removed.
* testsuite/ld-powerpc/aix-tls-reloc-32.dd: New test.
* testsuite/ld-powerpc/aix-tls-reloc-32.dt: New test.
* testsuite/ld-powerpc/aix-tls-reloc-64.dd: New test.
* testsuite/ld-powerpc/aix-tls-reloc-64.dt: New test.
19 files changed:
bfd/coff-rs6000.c
bfd/coff64-rs6000.c
bfd/xcofflink.c
gas/config/tc-ppc.c
gas/testsuite/gas/ppc/aix.exp
gas/testsuite/gas/ppc/xcoff-tls-32.d [new file with mode: 0644]
gas/testsuite/gas/ppc/xcoff-tls-64.d [new file with mode: 0644]
gas/testsuite/gas/ppc/xcoff-tls.s [new file with mode: 0644]
gas/testsuite/gas/ppc/xcoff-tlsm-32.d [deleted file]
gas/testsuite/gas/ppc/xcoff-tlsm-64.d [deleted file]
gas/testsuite/gas/ppc/xcoff-tlsm.s [deleted file]
ld/testsuite/ld-powerpc/aix-tls-reloc-32.d [deleted file]
ld/testsuite/ld-powerpc/aix-tls-reloc-32.dd [new file with mode: 0644]
ld/testsuite/ld-powerpc/aix-tls-reloc-32.dt [new file with mode: 0644]
ld/testsuite/ld-powerpc/aix-tls-reloc-64.d [deleted file]
ld/testsuite/ld-powerpc/aix-tls-reloc-64.dd [new file with mode: 0644]
ld/testsuite/ld-powerpc/aix-tls-reloc-64.dt [new file with mode: 0644]
ld/testsuite/ld-powerpc/aix-tls-reloc.s
ld/testsuite/ld-powerpc/aix52.exp