aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorClément Chigot <clement.chigot@atos.net>2021-03-11 11:08:19 +0100
committerAlan Modra <amodra@gmail.com>2021-03-12 22:47:23 +1030
commit4a403be0c1b4540e22c8c608ea0bfecbf0f85e51 (patch)
tree3908b8d38af9e56e3fd960da596c4d600f5915c5 /ld
parent2c1bef53dee85aede31e6de6fa8276d6869f6512 (diff)
downloadgdb-4a403be0c1b4540e22c8c608ea0bfecbf0f85e51.zip
gdb-4a403be0c1b4540e22c8c608ea0bfecbf0f85e51.tar.gz
gdb-4a403be0c1b4540e22c8c608ea0bfecbf0f85e51.tar.bz2
aix: implement R_TOCU and R_TOCL relocations
Implement support for largetoc on XCOFF. R_TOCU and R_TOCL are referenced by the new BFD defines: BFD_RELOC_PPC_TOC16_HI and BFD_RELOC_PPC_TOC16_LO. A new toc storage class is added XMC_TE. In order to correctly handle R_TOCU, the logic behind xcoff_reloc_type_toc is changed to compute the whole TOC offset instead of just the difference between the "link" offset and the "assembly" offset. In gas, add a function to transform addis format used by AIX "addis RT, D(RA)" into the ELF format "addis RT, RA, SI". bfd/ * reloc.c (BFD_RELOC_PPC_TOC16_HI, BFD_RELOC_PPC_TOC16_LO): New relocations. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. * coff-rs6000.c (xcoff_calculate_relocation): Call xcoff_reloc_type_toc for R_TOCU and R_TOCL. (xcoff_howto_table): Remove src_mask for TOC relocations. Add R_TOCU and R_TOCL howtos. (_bfd_xcoff_reloc_type_lookup): Add cases for BFD_RELOC_PPC_TOC16_HI and BFD_RELOC_PPC_TOC16_LO. (xcoff_reloc_type_toc): Compute the whole offset. Implement R_TOCU and R_TOCL. * coff64-rs6000.c (xcoff64_calculate_relocation): Likewise. (xcoff64_howto_table): Likewise. (xcoff64_reloc_type_lookup): Likewise. gas/ * config/tc-ppc.c (ppc_xcoff_suffix): New function. (MAP, MAP32, MAP64): New macros for XCOFF. (ppc_xcoff_fixup_addis): New function. (ppc_is_toc_sym): Handle XMC_TE. (fixup_size): Add cases for BFD_RELOC_PPC_TOC16_HI and BFD_RELOC_PPC_TOC16_LO. (md_assemble): Call ppc_xcoff_fixup_addis for XCOFF. (ppc_change_csect): Handle XMC_TE. (ppc_tc): Enable .tc symbols to have only a XMC_TC or XMC_TE storage class. (ppc_symbol_new_hook): Handle XMC_TE. (ppc_frob_symbol): Likewise. (ppc_fix_adjustable): Likewise. (md_apply_fix): Handle BFD_RELOC_PPC_TOC16_HI and BFD_RELOC_PPC_TOC16_LO. ld/ * scripttempl/aix.sc: Add .te to .data section. * testsuite/ld-powerpc/aix52.exp: Add test structure for AIX7+. Add aix-largetoc-1 test. * testsuite/ld-powerpc/aix-largetoc-1-32.d: New test. * testsuite/ld-powerpc/aix-largetoc-1-64.d: New test. * testsuite/ld-powerpc/aix-largetoc-1.ex: New test. * testsuite/ld-powerpc/aix-largetoc-1.s: New test.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog10
-rw-r--r--ld/scripttempl/aix.sc1
-rw-r--r--ld/testsuite/ld-powerpc/aix-largetoc-1-32.d20
-rw-r--r--ld/testsuite/ld-powerpc/aix-largetoc-1-64.d20
-rw-r--r--ld/testsuite/ld-powerpc/aix-largetoc-1.ex1
-rw-r--r--ld/testsuite/ld-powerpc/aix-largetoc-1.s25
-rw-r--r--ld/testsuite/ld-powerpc/aix52.exp17
7 files changed, 94 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index acb8aab..024ea0d 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,13 @@
+2021-03-12 Clément Chigot <clement.chigot@atos.net>
+
+ * scripttempl/aix.sc: Add .te to .data section.
+ * testsuite/ld-powerpc/aix52.exp: Add test structure for AIX7+.
+ Add aix-largetoc-1 test.
+ * testsuite/ld-powerpc/aix-largetoc-1-32.d: New test.
+ * testsuite/ld-powerpc/aix-largetoc-1-64.d: New test.
+ * testsuite/ld-powerpc/aix-largetoc-1.ex: New test.
+ * testsuite/ld-powerpc/aix-largetoc-1.s: New test.
+
2021-03-12 Alan Modra <amodra@gmail.com>
* testsuite/ld-gc/gc.exp: Pass "-image-base 0" to ld for PE, and
diff --git a/ld/scripttempl/aix.sc b/ld/scripttempl/aix.sc
index abf15fc..aa129d9 100644
--- a/ld/scripttempl/aix.sc
+++ b/ld/scripttempl/aix.sc
@@ -52,6 +52,7 @@ SECTIONS
*(.tc0)
*(.tc)
*(.td)
+ *(.te)
${RELOCATING+PROVIDE (_edata = .);}
}
.bss : {
diff --git a/ld/testsuite/ld-powerpc/aix-largetoc-1-32.d b/ld/testsuite/ld-powerpc/aix-largetoc-1-32.d
new file mode 100644
index 0000000..d39bc69
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/aix-largetoc-1-32.d
@@ -0,0 +1,20 @@
+#source: aix-largetoc-1.s
+#as: -a32
+#ld: -b32 -shared -bE:aix-largetoc-1.ex
+#objdump: -dr
+#target: [is_xcoff_format]
+
+.*
+
+Disassembly of section \.text:
+
+.* <\.foo>:
+.*: 3d 22 00 00 cau r9,r2,0
+.*: R_TOCU a-.*
+.*: 39 29 00 00 cal r9,0\(r9\)
+.*: R_TOCL a-.*
+.*: 3d 22 00 00 cau r9,r2,0
+.*: R_TOCU b-.*
+.*: 39 29 00 04 cal r9,4\(r9\)
+.*: R_TOCL b-.*
+#...
diff --git a/ld/testsuite/ld-powerpc/aix-largetoc-1-64.d b/ld/testsuite/ld-powerpc/aix-largetoc-1-64.d
new file mode 100644
index 0000000..daf6e0f
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/aix-largetoc-1-64.d
@@ -0,0 +1,20 @@
+#source: aix-largetoc-1.s
+#as: -a64
+#ld: -b64 -shared -bE:aix-largetoc-1.ex
+#objdump: -dr
+#target: [is_xcoff_format]
+
+.*
+
+Disassembly of section \.text:
+
+.* <\.foo>:
+.*: 3d 22 00 00 addis r9,r2,0
+.*: R_TOCU a-.*
+.*: 39 29 00 00 addi r9,r9,0
+.*: R_TOCL a-.*
+.*: 3d 22 00 00 addis r9,r2,0
+.*: R_TOCU b-.*
+.*: 39 29 00 08 addi r9,r9,8
+.*: R_TOCL b-.*
+#...
diff --git a/ld/testsuite/ld-powerpc/aix-largetoc-1.ex b/ld/testsuite/ld-powerpc/aix-largetoc-1.ex
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/aix-largetoc-1.ex
@@ -0,0 +1 @@
+foo
diff --git a/ld/testsuite/ld-powerpc/aix-largetoc-1.s b/ld/testsuite/ld-powerpc/aix-largetoc-1.s
new file mode 100644
index 0000000..2783903
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/aix-largetoc-1.s
@@ -0,0 +1,25 @@
+ .globl a
+ .csect .data[RW]
+a:
+ .long 1
+ .toc
+ .tc a[TE],a
+ .tc b[TE],a
+
+ .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 .text[PR]
+.foo:
+ addis 9,a[TE]@u(2)
+ la 9,a[TE]@l(9)
+
+ addis 9,b[TE]@u(2)
+ la 9,b[TE]@l(9)
diff --git a/ld/testsuite/ld-powerpc/aix52.exp b/ld/testsuite/ld-powerpc/aix52.exp
index d5e8b2f..3dfbae0 100644
--- a/ld/testsuite/ld-powerpc/aix52.exp
+++ b/ld/testsuite/ld-powerpc/aix52.exp
@@ -266,3 +266,20 @@ run_dump_test "aix-glink-3-32"
run_dump_test "aix-glink-3-64"
run_dump_test "aix-weak-3-32"
run_dump_test "aix-weak-3-64"
+
+
+# Tests added for features in AIX 7+.
+
+set aix7tests {
+ {"Large TOC test 1" "-shared -bE:aix-largetoc-1.ex"
+ "" {aix-largetoc-1.s}
+ {{objdump -dr aix-largetoc-1-SIZE.d}}
+ "aix-largetoc-1.so"}
+}
+
+foreach test $aix7tests {
+ foreach { name ldopts asopts sources tools output } $test {
+ run_aix_test 32 $name $ldopts $asopts $sources $tools $output
+ run_aix_test 64 $name $ldopts $asopts $sources $tools $output
+ }
+}