PowerPC64 inline PLT call tests

Alan Modra amodra@gmail.com
Sun Aug 16 13:30:10 GMT 2020


	* testsuite/ld-powerpc/inline.s,
	* testsuite/ld-powerpc/inline-1.d,
	* testsuite/ld-powerpc/inline-2.d,
	* testsuite/ld-powerpc/inline-3.d,
	* testsuite/ld-powerpc/inline-4.d,
	* testsuite/ld-powerpc/inlinepcrel.s,
	* testsuite/ld-powerpc/inlinepcrel-1.d,
	* testsuite/ld-powerpc/inlinepcrel-2.d,
	* testsuite/ld-powerpc/inlinepcrel-3.d: New tests.
	* testsuite/ld-powerpc/powerpc.exp: Run them.

diff --git a/ld/testsuite/ld-powerpc/inline-1.d b/ld/testsuite/ld-powerpc/inline-1.d
new file mode 100644
index 0000000000..988b39043c
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/inline-1.d
@@ -0,0 +1,19 @@
+#source: inline.s
+#as: -a64
+#ld: -melf64ppc -shared --hash-style=gnu
+#objdump: -dr
+
+.*
+
+Disassembly of section \.text:
+
+.*:
+.*:	(f8 41 00 18|18 00 41 f8) 	std     r2,24\(r1\)
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(e9 82 80 18|18 80 82 e9) 	ld      r12,-32744\(r2\)
+.*:	(7d 89 03 a6|a6 03 89 7d) 	mtctr   r12
+.*:	(4e 80 04 21|21 04 80 4e) 	bctrl
+.*:	(e8 41 00 18|18 00 41 e8) 	ld      r2,24\(r1\)
+#...
+.* <my_func@plt>:
+.*:	(4b .. .. ..|.. .. .. 4b) 	b       .* <__glink_PLTresolve>
diff --git a/ld/testsuite/ld-powerpc/inline-2.d b/ld/testsuite/ld-powerpc/inline-2.d
new file mode 100644
index 0000000000..d57174add7
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/inline-2.d
@@ -0,0 +1,20 @@
+#source: inline.s
+#as: -a64
+#ld: -melf64ppc --hash-style=gnu
+#ld_after_inputfiles: tmpdir/funv2.so
+#objdump: -dr
+
+.*
+
+Disassembly of section \.text:
+
+.*:
+.*:	(f8 41 00 18|18 00 41 f8) 	std     r2,24\(r1\)
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(e9 82 80 18|18 80 82 e9) 	ld      r12,-32744\(r2\)
+.*:	(7d 89 03 a6|a6 03 89 7d) 	mtctr   r12
+.*:	(4e 80 04 21|21 04 80 4e) 	bctrl
+.*:	(e8 41 00 18|18 00 41 e8) 	ld      r2,24\(r1\)
+#...
+.* <my_func@plt>:
+.*:	(4b .. .. ..|.. .. .. 4b) 	b       .* <__glink_PLTresolve>
diff --git a/ld/testsuite/ld-powerpc/inline-3.d b/ld/testsuite/ld-powerpc/inline-3.d
new file mode 100644
index 0000000000..cb859116e6
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/inline-3.d
@@ -0,0 +1,20 @@
+#source: inline.s
+#source: funv2.s
+#as: -a64
+#ld: -melf64ppc --hash-style=gnu
+#objdump: -dr
+
+.*
+
+Disassembly of section \.text:
+
+.*:
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(48 .. .. ..|.. .. .. 48) 	bl      .* <my_func>
+.*:	(60 00 00 00|00 00 00 60) 	nop
+
+.* <my_func>:
+.*:	(4e 80 00 20|20 00 80 4e) 	blr
diff --git a/ld/testsuite/ld-powerpc/inline-4.d b/ld/testsuite/ld-powerpc/inline-4.d
new file mode 100644
index 0000000000..5e51c0335e
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/inline-4.d
@@ -0,0 +1,20 @@
+#source: inline.s
+#as: -a64
+#ld: -melf64ppc --no-toc-opt --hash-style=gnu
+#ld_after_inputfiles: tmpdir/funv2.so
+#objdump: -dr
+
+.*
+
+Disassembly of section \.text:
+
+.*:
+.*:	(f8 41 00 18|18 00 41 f8) 	std     r2,24\(r1\)
+.*:	(3d 82 00 00|00 00 82 3d) 	addis   r12,r2,0
+.*:	(e9 8c 80 18|18 80 8c e9) 	ld      r12,-32744\(r12\)
+.*:	(7d 89 03 a6|a6 03 89 7d) 	mtctr   r12
+.*:	(4e 80 04 21|21 04 80 4e) 	bctrl
+.*:	(e8 41 00 18|18 00 41 e8) 	ld      r2,24\(r1\)
+#...
+.* <my_func@plt>:
+.*:	(4b .. .. ..|.. .. .. 4b) 	b       .* <__glink_PLTresolve>
diff --git a/ld/testsuite/ld-powerpc/inline.s b/ld/testsuite/ld-powerpc/inline.s
new file mode 100644
index 0000000000..462e702010
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/inline.s
@@ -0,0 +1,12 @@
+	.text
+	.globl _start
+_start:
+	std 2,24(1)
+	.reloc .-4,R_PPC64_PLTSEQ,my_func
+	addis 12,2,my_func@plt@ha  # .reloc .,R_PPC64_PLT16_HA,my_func
+	ld 12,my_func@plt@l(12)    # .reloc .,R_PPC64_PLT16_LO_DS,my_func
+	mtctr 12
+	.reloc .-4,R_PPC64_PLTSEQ,my_func
+	bctrl
+	.reloc .-4,R_PPC64_PLTCALL,my_func
+	ld 2,24(1)
diff --git a/ld/testsuite/ld-powerpc/inlinepcrel-1.d b/ld/testsuite/ld-powerpc/inlinepcrel-1.d
new file mode 100644
index 0000000000..7dcb3ad7aa
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/inlinepcrel-1.d
@@ -0,0 +1,17 @@
+#source: inlinepcrel.s
+#as: -a64 -mpower10
+#ld: -melf64ppc -shared --hash-style=gnu
+#objdump: -dr -Mpower10
+
+.*
+
+Disassembly of section \.text:
+
+.*:
+.*:	(04 10 00 01|01 00 10 04) 	pld     r12,65944
+.*:	(e5 80 01 98|98 01 80 e5) 
+.*:	(7d 89 03 a6|a6 03 89 7d) 	mtctr   r12
+.*:	(4e 80 04 21|21 04 80 4e) 	bctrl
+#...
+.* <my_func@plt>:
+.*:	(4b .. .. ..|.. .. .. 4b) 	b       .* <__glink_PLTresolve>
diff --git a/ld/testsuite/ld-powerpc/inlinepcrel-2.d b/ld/testsuite/ld-powerpc/inlinepcrel-2.d
new file mode 100644
index 0000000000..5e901dcb25
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/inlinepcrel-2.d
@@ -0,0 +1,18 @@
+#source: inlinepcrel.s
+#as: -a64 -mpower10
+#ld: -melf64ppc --hash-style=gnu
+#ld_after_inputfiles: tmpdir/funv2.so
+#objdump: -dr -Mpower10
+
+.*
+
+Disassembly of section \.text:
+
+.*:
+.*:	(04 10 00 01|01 00 10 04) 	pld     r12,66072
+.*:	(e5 80 02 18|18 02 80 e5) 
+.*:	(7d 89 03 a6|a6 03 89 7d) 	mtctr   r12
+.*:	(4e 80 04 21|21 04 80 4e) 	bctrl
+#...
+.* <my_func@plt>:
+.*:	(4b .. .. ..|.. .. .. 4b) 	b       .* <__glink_PLTresolve>
diff --git a/ld/testsuite/ld-powerpc/inlinepcrel-3.d b/ld/testsuite/ld-powerpc/inlinepcrel-3.d
new file mode 100644
index 0000000000..31fc15e397
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/inlinepcrel-3.d
@@ -0,0 +1,18 @@
+#source: inlinepcrel.s
+#source: funv2.s
+#as: -a64 -mpower10
+#ld: -melf64ppc --hash-style=gnu
+#objdump: -dr -Mpower10
+
+.*
+
+Disassembly of section \.text:
+
+.*:
+.*:	(07 00 00 00|00 00 00 07) 	pnop
+.*:	(00 00 00 00|00 00 00 00) 
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(48 .. .. ..|.. .. .. 48) 	bl      .* <my_func>
+
+.* <my_func>:
+.*:	(4e 80 00 20|20 00 80 4e) 	blr
diff --git a/ld/testsuite/ld-powerpc/inlinepcrel.s b/ld/testsuite/ld-powerpc/inlinepcrel.s
new file mode 100644
index 0000000000..37aee8a1ec
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/inlinepcrel.s
@@ -0,0 +1,9 @@
+	.text
+	.globl _start
+_start:
+	pld 12,0(0),1
+	.reloc .-8,R_PPC64_PLT_PCREL34_NOTOC,my_func
+	mtctr 12
+	.reloc .-4,R_PPC64_PLTSEQ_NOTOC,my_func
+	bctrl
+	.reloc .-4,R_PPC64_PLTCALL_NOTOC,my_func
diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp
index 9b1ee13019..a4c060a877 100644
--- a/ld/testsuite/ld-powerpc/powerpc.exp
+++ b/ld/testsuite/ld-powerpc/powerpc.exp
@@ -408,6 +408,13 @@ if [ supports_ppc64 ] then {
     run_dump_test "callstub-2"
     run_dump_test "callstub-3"
     run_dump_test "callstub-4"
+    run_dump_test "inline-1"
+    run_dump_test "inline-2"
+    run_dump_test "inline-3"
+    run_dump_test "inline-4"
+    run_dump_test "inlinepcrel-1"
+    run_dump_test "inlinepcrel-2"
+    run_dump_test "inlinepcrel-3"
     run_dump_test "tlsgd"
     run_dump_test "tlsld"
     run_dump_test "tlsie"

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list