aboutsummaryrefslogtreecommitdiff
path: root/bfd/coff-rs6000.c
diff options
context:
space:
mode:
authorClément Chigot <clement.chigot@atos.net>2021-12-17 14:46:01 +0100
committerClément Chigot <clement.chigot@atos.net>2022-01-10 09:14:57 +0100
commit3c5038247c8a5fcff18fd81249b0801a95569939 (patch)
tree2705a789bb9771f4d0f6f8709e390bc5666b9070 /bfd/coff-rs6000.c
parent4cfa9e3f28c8c5156b9773cc94192233947d351c (diff)
downloadgdb-3c5038247c8a5fcff18fd81249b0801a95569939.zip
gdb-3c5038247c8a5fcff18fd81249b0801a95569939.tar.gz
gdb-3c5038247c8a5fcff18fd81249b0801a95569939.tar.bz2
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.
Diffstat (limited to 'bfd/coff-rs6000.c')
-rw-r--r--bfd/coff-rs6000.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 3248670..97e84a4 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -1106,7 +1106,7 @@ reloc_howto_type xcoff_howto_table[] =
0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
0, /* special_function */
- "R_TLSM", /* name */
+ "R_TLSML", /* name */
true, /* partial_inplace */
0xffffffff, /* src_mask */
0xffffffff, /* dst_mask */
@@ -3236,27 +3236,19 @@ xcoff_reloc_type_tls (bfd *input_bfd ATTRIBUTE_UNUSED,
h = obj_xcoff_sym_hashes (input_bfd)[rel->r_symndx];
- /* FIXME: R_TLSML is targeting a internal TOC symbol, which will
- make the following checks failing. It should be moved with
- R_TLSM bellow once it works. */
+ /* R_TLSML is handled by the loader but must be from a
+ TOC entry targeting itslef. This is already verified in
+ xcoff_link_add_symbols.
+ The value must be 0. */
if (howto->type == R_TLSML)
{
*relocation = 0;
return true;
}
- /* FIXME: h is sometimes null, if the TLS symbol is not exported. */
- if (!h)
- {
- char vaddr_buf[128];
-
- sprintf_vma (vaddr_buf, rel->r_vaddr);
- _bfd_error_handler
- (_("%pB: TLS relocation at 0x%s over internal symbols (C_HIDEXT) not yet possible\n"),
- input_bfd, vaddr_buf);
- return false;
- }
-
+ /* The target symbol should always be available even if it's not
+ exported. */
+ BFD_ASSERT (h != NULL);
/* TLS relocations must target a TLS symbol. */
if (h->smclas != XMC_TL && h->smclas != XMC_UL)
@@ -3286,9 +3278,8 @@ xcoff_reloc_type_tls (bfd *input_bfd ATTRIBUTE_UNUSED,
return false;
}
- /* R_TLSM and R_TLSML are relocations used by the loader.
- The value must be 0.
- FIXME: move R_TLSML here. */
+ /* R_TLSM are relocations used by the loader.
+ The value must be 0. */
if (howto->type == R_TLSM)
{
*relocation = 0;
@@ -3621,10 +3612,10 @@ xcoff_complain_overflow_unsigned_func (bfd *input_bfd,
R_TLS_LE:
Thread-local storage relocation using local-exec model.
- R_TLS:
+ R_TLSM:
Tread-local storage relocation used by the loader.
- R_TLSM:
+ R_TLSML:
Tread-local storage relocation used by the loader.
R_TOCU: