aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
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 /ld/testsuite
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 'ld/testsuite')
-rw-r--r--ld/testsuite/ld-powerpc/aix-tls-reloc-32.d35
-rw-r--r--ld/testsuite/ld-powerpc/aix-tls-reloc-32.dd101
-rw-r--r--ld/testsuite/ld-powerpc/aix-tls-reloc-32.dt18
-rw-r--r--ld/testsuite/ld-powerpc/aix-tls-reloc-64.d31
-rw-r--r--ld/testsuite/ld-powerpc/aix-tls-reloc-64.dd119
-rw-r--r--ld/testsuite/ld-powerpc/aix-tls-reloc-64.dt23
-rw-r--r--ld/testsuite/ld-powerpc/aix-tls-reloc.s154
-rw-r--r--ld/testsuite/ld-powerpc/aix52.exp3
8 files changed, 381 insertions, 103 deletions
diff --git a/ld/testsuite/ld-powerpc/aix-tls-reloc-32.d b/ld/testsuite/ld-powerpc/aix-tls-reloc-32.d
deleted file mode 100644
index 5103de5..0000000
--- a/ld/testsuite/ld-powerpc/aix-tls-reloc-32.d
+++ /dev/null
@@ -1,35 +0,0 @@
-#source: aix-tls-reloc.s
-#as: -a32
-#ld: -b32 -shared -bE:aix-tls-reloc.ex
-#objdump: -dr
-#target: [is_xcoff_format]
-
-.*
-
-Disassembly of section \.text:
-
-.* <\.foo>:
-.*: 80 82 00 00 l r4,0\(r2\)
-.*: R_TOC gd-.*
-.*: 80 62 00 04 l r3,4\(r2\)
-.*: R_TOC .gd-.*
-.*: 48 00 00 03 bla 0 <\.foo-.*>
-.*: R_BA_26 __tls_get_addr
-.*: 80 62 00 0c l r3,12\(r2\)
-.*: R_TOC _\$TLSML-.*
-.*: 48 00 00 03 bla 0 <\.foo-.*>
-.*: R_BA_26 __tls_get_mod
-.*: 80 82 00 08 l r4,8\(r2\)
-.*: R_TOC ld-.*
-.*: 7c a3 22 14 cax r5,r3,r4
-.*: 48 00 00 03 bla 0 <\.foo-.*>
-.*: R_BA_26 __get_tpointer
-.*: 80 82 00 10 l r4,16\(r2\)
-.*: R_TOC ie-.*
-.*: 7c a3 22 14 cax r5,r3,r4
-.*: 48 00 00 03 bla 0 <\.foo-.*>
-.*: R_BA_26 __get_tpointer
-.*: 80 82 00 14 l r4,20\(r2\)
-.*: R_TOC le-.*
-.*: 7c a3 22 14 cax r5,r3,r4
-.*
diff --git a/ld/testsuite/ld-powerpc/aix-tls-reloc-32.dd b/ld/testsuite/ld-powerpc/aix-tls-reloc-32.dd
new file mode 100644
index 0000000..001a7f0
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/aix-tls-reloc-32.dd
@@ -0,0 +1,101 @@
+#source: aix-tls-reloc.s
+#as: -a32
+#ld: -b32 -shared -bE:aix-tls-reloc.ex
+#objdump: -dr -j.data
+#target: [is_xcoff_format]
+
+.*
+
+
+Disassembly of section .data:
+
+.* <foo>:
+.*
+.*
+.*
+.*
+.*
+
+.* <TOC>:
+.*: ff ff 88 00 .*
+.*: R_TLS tdata_ext.*
+
+.* <.tdata_ext_gd>:
+.*: 00 00 00 00 .*
+.*: R_TLSM tdata_ext.*
+
+.* <tdata_ext_ld>:
+.*: ff ff 88 00 .*
+.*: R_TLS_LD tdata_ext.*
+
+.* <tdata_ext_ie>:
+.*: ff ff 88 00 .*
+.*: R_TLS_IE tdata_ext.*
+
+.* <tdata_ext_le>:
+.*: ff ff 88 00 .*
+.*: R_TLS_LE tdata_ext.*
+
+.* <tdata_int1_gd>:
+.*: ff ff 88 04 .*
+.*: R_TLS tdata_int_csect.*
+
+.* <.tdata_int1_gd>:
+.*: 00 00 00 00 .*
+.*: R_TLSM tdata_int_csect.*
+
+.* <tdata_int1_ld>:
+.*: ff ff 88 04 .*
+.*: R_TLS_LD tdata_int_csect.*
+
+.* <tdata_int1_ie>:
+.*: ff ff 88 04 .*
+.*: R_TLS_IE tdata_int_csect.*
+
+.* <tdata_int1_le>:
+.*: ff ff 88 04 .*
+.*: R_TLS_LE tdata_int_csect.*
+
+.* <tdata_int2_gd>:
+.*: ff ff 88 08 .*
+.*: R_TLS tdata_int_csect.*
+
+.* <.tdata_int2_gd>:
+.*: 00 00 00 00 .*
+.*: R_TLSM tdata_int_csect.*
+
+.* <tdata_int2_ld>:
+.*: ff ff 88 08 .*
+.*: R_TLS_LD tdata_int_csect.*
+
+.* <tdata_int2_ie>:
+.*: ff ff 88 08 .*
+.*: R_TLS_IE tdata_int_csect.*
+
+.* <tdata_int2_le>:
+.*: ff ff 88 08 .*
+.*: R_TLS_LE tdata_int_csect.*
+
+.* <tbss_ext_gd>:
+.*: ff ff 88 10 .*
+.*: R_TLS tbss_ext.*
+
+.* <.tbss_ext_gd>:
+.*: 00 00 00 00 .*
+.*: R_TLSM tbss_ext.*
+
+.* <tbss_ext_ld>:
+.*: ff ff 88 10 .*
+.*: R_TLS_LD tbss_ext.*
+
+.* <tbss_ext_ie>:
+.*: ff ff 88 10 .*
+.*: R_TLS_IE tbss_ext.*
+
+.* <tbss_ext_le>:
+.*: ff ff 88 10 .*
+.*: R_TLS_LE tbss_ext.*
+
+.* <_\$TLSML>:
+ ...
+.*: R_TLSML _\$TLSML.*
diff --git a/ld/testsuite/ld-powerpc/aix-tls-reloc-32.dt b/ld/testsuite/ld-powerpc/aix-tls-reloc-32.dt
new file mode 100644
index 0000000..91ceb66
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/aix-tls-reloc-32.dt
@@ -0,0 +1,18 @@
+
+tmpdir/aix-tls-reloc.so: file format aixcoff-rs6000
+
+
+Disassembly of section .tdata:
+
+ffff8800 <tdata_ext>:
+ffff8800: 00 00 00 01 .long 0x1
+
+ffff8804 <tdata_int_csect>:
+ffff8804: 00 00 00 02 .long 0x2
+ffff8808: 00 00 00 03 .long 0x3
+ffff880c: 00 00 00 00 .long 0x0
+
+Disassembly of section .tbss:
+
+ffff8810 <tbss_ext>:
+ ...
diff --git a/ld/testsuite/ld-powerpc/aix-tls-reloc-64.d b/ld/testsuite/ld-powerpc/aix-tls-reloc-64.d
deleted file mode 100644
index 71f6302..0000000
--- a/ld/testsuite/ld-powerpc/aix-tls-reloc-64.d
+++ /dev/null
@@ -1,31 +0,0 @@
-#source: aix-tls-reloc.s
-#as: -a32
-#ld: -b32 -shared -bE:aix-tls-reloc.ex
-#objdump: -dr
-#target: [is_xcoff_format]
-
-.*
-
-Disassembly of section \.text:
-
-.* <\.foo>:
-.*: e8 82 00 00 ld r4,0\(r2\)
-.*: R_TOC gd-.*
-.*: e8 62 00 08 ld r3,8\(r2\)
-.*: R_TOC .gd-.*
-.*: 48 00 00 03 bla 0 <\.foo-.*>
-.*: R_BA_26 __tls_get_addr
-.*: e8 62 00 18 ld r3,24\(r2\)
-.*: R_TOC _\$TLSML-.*
-.*: 48 00 00 03 bla 0 <\.foo-.*>
-.*: R_BA_26 __tls_get_mod
-.*: 80 82 00 10 lwz r4,16\(r2\)
-.*: R_TOC ld-.*
-.*: 7c a3 22 14 add r5,r3,r4
-.*: e8 82 00 20 ld r4,32\(r2\)
-.*: R_TOC ie-.*
-.*: 7c a4 6a 14 add r5,r4,r13
-.*: e8 82 00 28 ld r4,40\(r2\)
-.*: R_TOC le-.*
-.*: 7c a3 6a 14 add r5,r3,r13
-.*
diff --git a/ld/testsuite/ld-powerpc/aix-tls-reloc-64.dd b/ld/testsuite/ld-powerpc/aix-tls-reloc-64.dd
new file mode 100644
index 0000000..dc0c48d
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/aix-tls-reloc-64.dd
@@ -0,0 +1,119 @@
+#source: aix-tls-reloc.s
+#as: -a64
+#ld: -b64 -shared -bE:aix-tls-reloc.ex
+#objdump: -dr -j.data
+#target: [is_xcoff_format]
+
+.*
+
+
+Disassembly of section .data:
+
+.* <foo>:
+.*
+.*
+.*
+.*
+.*
+.*
+.*
+
+.* <TOC>:
+.*: ff ff ff ff .*
+.*: R_TLS tdata_ext.*
+.*: ff ff 88 00 .*
+
+.* <.tdata_ext_gd>:
+ ...
+.*: R_TLSM tdata_ext.*
+
+.*<tdata_ext_ld>:
+.*: ff ff ff ff .*
+.*: R_TLS_LD tdata_ext.*
+.*: ff ff 88 00 .*
+
+.* <tdata_ext_ie>:
+.*: ff ff ff ff .*
+.*: R_TLS_IE tdata_ext.*
+.*: ff ff 88 00 .*
+
+.* <tdata_ext_le>:
+.*: ff ff ff ff .*
+.*: R_TLS_LE tdata_ext.*
+.*: ff ff 88 00 .*
+
+.* <tdata_int1_gd>:
+.*: ff ff ff ff .*
+.*: R_TLS tdata_int_csect.*
+.*: ff ff 88 04 .*
+
+.* <.tdata_int1_gd>:
+ ...
+.*: R_TLSM tdata_int_csect.*
+
+.* <tdata_int1_ld>:
+.*: ff ff ff ff .*
+.*: R_TLS_LD tdata_int_csect.*
+.*: ff ff 88 04 .*
+
+.* <tdata_int1_ie>:
+.*: ff ff ff ff .*
+.*: R_TLS_IE tdata_int_csect.*
+.*: ff ff 88 04 .*
+
+.* <tdata_int1_le>:
+.*: ff ff ff ff .*
+.*: R_TLS_LE tdata_int_csect.*
+.*: ff ff 88 04 .*
+
+.* <tdata_int2_gd>:
+.*: ff ff ff ff .*
+.*: R_TLS tdata_int_csect.*
+.*: ff ff 88 08 .*
+
+.* <.tdata_int2_gd>:
+ ...
+.*: R_TLSM tdata_int_csect.*
+
+.* <tdata_int2_ld>:
+.*: ff ff ff ff .*
+.*: R_TLS_LD tdata_int_csect.*
+.*: ff ff 88 08 .*
+
+.* <tdata_int2_ie>:
+.*: ff ff ff ff .*
+.*: R_TLS_IE tdata_int_csect.*
+.*: ff ff 88 08 .*
+
+.* <tdata_int2_le>:
+.*: ff ff ff ff .*
+.*: R_TLS_LE tdata_int_csect.*
+.*: ff ff 88 08 .*
+
+.* <tbss_ext_gd>:
+.*: ff ff ff ff .*
+.*: R_TLS tbss_ext.*
+.*: ff ff 88 10 .*
+
+.* <.tbss_ext_gd>:
+ ...
+.*: R_TLSM tbss_ext.*
+
+.* <tbss_ext_ld>:
+.*: ff ff ff ff .*
+.*: R_TLS_LD tbss_ext.*
+.*: ff ff 88 10 .*
+
+.* <tbss_ext_ie>:
+.*: ff ff ff ff .*
+.*: R_TLS_IE tbss_ext.*
+.*: ff ff 88 10 .*
+
+.* <tbss_ext_le>:
+.*: ff ff ff ff .*
+.*: R_TLS_LE tbss_ext.*
+.*: ff ff 88 10 .*
+
+.* <_\$TLSML>:
+ ...
+.*: R_TLSML _\$TLSML.*
diff --git a/ld/testsuite/ld-powerpc/aix-tls-reloc-64.dt b/ld/testsuite/ld-powerpc/aix-tls-reloc-64.dt
new file mode 100644
index 0000000..9ddc573
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/aix-tls-reloc-64.dt
@@ -0,0 +1,23 @@
+#source: aix-tls-reloc.s
+#as: -a64
+#ld: -b64 -shared -bE:aix-tls-reloc.ex
+#objdump: -d -j.tdata -j.tbss
+#target: [is_xcoff_format]
+
+.*
+
+
+Disassembly of section .tdata:
+
+ffffffffffff8800 <tdata_ext>:
+ffffffffffff8800:.*
+
+ffffffffffff8804 <tdata_int_csect>:
+ffffffffffff8804:.*
+ffffffffffff8808:.*
+ffffffffffff880c:.*
+
+Disassembly of section .tbss:
+
+ffffffffffff8810 <tbss_ext>:
+ ...
diff --git a/ld/testsuite/ld-powerpc/aix-tls-reloc.s b/ld/testsuite/ld-powerpc/aix-tls-reloc.s
index 62ef73c..062fc94 100644
--- a/ld/testsuite/ld-powerpc/aix-tls-reloc.s
+++ b/ld/testsuite/ld-powerpc/aix-tls-reloc.s
@@ -1,65 +1,147 @@
- .globl bar[TL]
- .csect bar[TL]
+# An external tdata symbol
+ .globl tdata_ext[TL]
+ .csect tdata_ext[TL]
.long 1
+ .csect tdata_int_csect[TL]
+# A first internal tdata symbol
+tdata_int1:
+ .long 2
+# A second internal tdata symbol
+tdata_int2:
+ .long 3
+
+# Two external tbss symbols.
+# XCOFF doesn't seem to allow internal tbss
+# (or bss) symbols.
+ .comm tbss_ext[UL],8
+
.toc
- .tc gd[TC],bar[TL]
- .tc .gd[TC],bar[TL]@m
- .tc ld[TC],bar[TL]@ld
- .tc mh[TC],mh[TC]@ml
- .tc ie[TC],bar[TL]@ie
- .tc le[TC],bar[TL]@le
+# TC entries targeting the external tdata symbol
+# Their value should be "tdata_ext" address,
+# except TLSM value which must be 0.
+# Their relocations should target it.
+ .tc tdata_ext_gd[TC],tdata_ext[TL]
+ .tc .tdata_ext_gd[TC],tdata_ext[TL]@m
+ .tc tdata_ext_ld[TC],tdata_ext[TL]@ld
+ .tc tdata_ext_ie[TC],tdata_ext[TL]@ie
+ .tc tdata_ext_le[TC],tdata_ext[TL]@le
- .globl foo
- .globl .foo
- .csect foo[DS],3
-foo:
- .if size == 32
- .long .foo, TOC[tc0], 0
- .else
- .llong .foo, TOC[tc0], 0
- .endif
+# TC entries targeting internal tdata symbols.
+# Their value should be "tdata_int1" or "tdata_int2"
+# addresses, except TLSM value which must be 0.
+# Their relocations should target "tdata_int_csect".
+ .tc tdata_int1_gd[TC],tdata_int1
+ .tc .tdata_int1_gd[TC],tdata_int1@m
+ .tc tdata_int1_ld[TC],tdata_int1@ld
+ .tc tdata_int1_ie[TC],tdata_int1@ie
+ .tc tdata_int1_le[TC],tdata_int1@le
+ .tc tdata_int2_gd[TC],tdata_int2
+ .tc .tdata_int2_gd[TC],tdata_int2@m
+ .tc tdata_int2_ld[TC],tdata_int2@ld
+ .tc tdata_int2_ie[TC],tdata_int2@ie
+ .tc tdata_int2_le[TC],tdata_int2@le
- .csect foo[PR]
-.foo:
- #GD
+# TC entries targeting the external tdata symbol
+# Their value should be "tbss_ext" address,
+# except TLSM value which must be 0.
+# Their relocations should target "tbss_ext".
+ .tc tbss_ext_gd[TC],tbss_ext[UL]
+ .tc .tbss_ext_gd[TC],tbss_ext[UL]@m
+ .tc tbss_ext_ld[TC],tbss_ext[UL]@ld
+ .tc tbss_ext_ie[TC],tbss_ext[UL]@ie
+ .tc tbss_ext_le[TC],tbss_ext[UL]@le
+
+# Module entry
+ .tc mh[TC],mh[TC]@ml
+ .rename mh[TC], "_$TLSML" # Symbol for the module handle
+
+# Macros
+ .macro gd_macro,sym
.if size == 32
- lwz 4, gd[TC](2)
- lwz 3, .gd[TC](2)
+ lwz 4, \sym\()[TC](2)
+ lwz 3, .\sym\()[TC](2)
.else
- ld 4, gd[TC](2)
- ld 3, .gd[TC](2)
+ ld 4, \sym\()[TC](2)
+ ld 3, .\sym\()[TC](2)
.endif
bla __tls_get_addr
+ .endm
- #LD
+ .macro ld_macro, sym
.if size == 32
- lwz 3, mh[TC](2)
+ lwz 4, \sym\()[TC](2)
.else
- ld 3, mh[TC](2)
+ ld 4, \sym\()[TC](2)
.endif
- bla __tls_get_mod
- lwz 4, ld[TC](2)
add 5,3,4
+ .endm
- #IE
+ .macro ie_macro, sym
.if size == 32
bla __get_tpointer
- lwz 4, ie[TC](2)
+ lwz 4, \sym\()[TC](2)
add 5,3,4
.else
- ld 4, ie[TC](2)
+ ld 4, \sym\()[TC](2)
add 5,4,13
.endif
+ .endm
- #LE
+ .macro le_macro, sym
.if size == 32
bla __get_tpointer
- lwz 4, le[TC](2)
+ lwz 4, \sym\()[TC](2)
add 5,3,4
.else
- ld 4, le[TC](2)
+ ld 4, \sym\()[TC](2)
add 5,3,13
.endif
+ .endm
+
+
+# As TLS relocations are made in for TC symbols,
+# this function only aims to avoid garbage collection
+# of these symbols, especially hidden ones.
+ .globl foo
+ .globl .foo
+ .csect foo[DS],3
+foo:
+ .if size == 32
+ .long .foo, TOC[tc0], 0
+ .else
+ .llong .foo, TOC[tc0], 0
+ .endif
+
+ .csect foo[PR]
+.foo:
+ # External syms
+ #GD
+ gd_macro tdata_ext_gd
+ gd_macro tdata_int1_gd
+ gd_macro tdata_int2_gd
+ gd_macro tbss_ext_gd
+
+ #LD
+ .if size == 32
+ lwz 3, mh[TC](2)
+ .else
+ ld 3, mh[TC](2)
+ .endif
+ bla __tls_get_mod
+ ld_macro tdata_ext_ld
+ ld_macro tdata_int1_ld
+ ld_macro tdata_int2_ld
+ ld_macro tbss_ext_ld
-.rename mh[TC], "_$TLSML" # Symbol for the module handle
+ #IE
+ ie_macro tdata_ext_ie
+ ie_macro tdata_int1_ie
+ ie_macro tdata_int2_ie
+ ie_macro tbss_ext_ie
+
+ #LE
+ le_macro tdata_ext_le
+ le_macro tdata_int1_le
+ le_macro tdata_int2_le
+ le_macro tbss_ext_le
diff --git a/ld/testsuite/ld-powerpc/aix52.exp b/ld/testsuite/ld-powerpc/aix52.exp
index 8dccce5..b49f3f5 100644
--- a/ld/testsuite/ld-powerpc/aix52.exp
+++ b/ld/testsuite/ld-powerpc/aix52.exp
@@ -284,7 +284,8 @@ set aix7tests {
{"TLS relocations" "-shared -bE:aix-tls-reloc.ex"
"" {aix-tls-reloc.s}
- {{objdump -dr aix-tls-reloc-SIZE.d}}
+ {{objdump {-dr -j.data} aix-tls-reloc-SIZE.dd}
+ {objdump {-dr -j.tdata -j.tbss} aix-tls-reloc-SIZE.dt}}
"aix-tls-reloc.so"}
{"TLS section" "-shared -bE:aix-tls-section.ex"