* [PATCH 3/4] MIPS/Linux/LD/test: _gp scope ABI conformance tests
@ 2012-08-03 18:02 Maciej W. Rozycki
2012-08-05 7:18 ` Richard Sandiford
0 siblings, 1 reply; 2+ messages in thread
From: Maciej W. Rozycki @ 2012-08-03 18:02 UTC (permalink / raw)
To: binutils; +Cc: Richard Sandiford
Hi,
Complementing the change to correct the scope of the _gp special symbol,
here's a set of tests to verify that a set of shared libraries and a
binary that relies on _gp can be linked successfully in the presence of a
version script and that the resulting scope of _gp is limited to the
defining objects. This test case has been converted from the example
originally provided.
This passes for the usual 23 MIPS targets (the test case is ELF-only of
course). OK to apply?
2012-08-03 Maciej W. Rozycki <macro@codesourcery.com>
ld/testsuite/
* ld-mips-elf/gp-hidden.rd: New test.
* ld-mips-elf/gp-hidden.sd: New test.
* ld-mips-elf/gp-hidden-lib.rd: New test.
* ld-mips-elf/gp-hidden-ver.rd: New test.
* ld-mips-elf/gp-hidden-64.rd: New test.
* ld-mips-elf/gp-hidden-lib-64.rd: New test.
* ld-mips-elf/gp-hidden-ver-64.rd: New test.
* ld-mips-elf/gp-hidden.s: New test source.
* ld-mips-elf/gp-hidden-lib.s: New test source.
* ld-mips-elf/gp-hidden-ver.s: New test source.
* ld-mips-elf/gp-hidden-ver.ver: New test version script.
* ld-mips-elf/mips-elf.exp: Run the new tests.
Maciej
binutils-mips-gp-test.diff
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-lib.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-lib.s 2012-08-03 00:35:18.171478815 +0100
@@ -0,0 +1,6 @@
+ .data
+ .globl bar
+ .type bar, @object
+bar:
+ .dc.a _gp
+ .size bar, . - bar
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-ver.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-ver.s 2012-08-03 00:35:18.171478815 +0100
@@ -0,0 +1,7 @@
+ .data
+ .globl foo
+ .type foo, @object
+foo:
+ .dc.a bar
+ .dc.a _gp
+ .size foo, . - foo
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-ver.ver
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-ver.ver 2012-08-03 00:35:18.191780032 +0100
@@ -0,0 +1 @@
+{ global: foo; local: *; };
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden.s 2012-08-03 00:35:18.191780032 +0100
@@ -0,0 +1,7 @@
+ .data
+ .globl blah
+ .type blah, @object
+blah:
+ .dc.a foo
+ .dc.a _gp
+ .size blah, . - blah
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-64.rd
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-64.rd 2012-08-03 00:35:18.191780032 +0100
@@ -0,0 +1,9 @@
+
+Relocation section '\.rel\.dyn' at offset .* contains 2 entries:
+ *Offset * Info * Type * Sym\. *Value * Sym\. *Name
+[0-9a-f]+ * 0+00000000 * R_MIPS_NONE *
+ * Type2: R_MIPS_NONE *
+ * Type3: R_MIPS_NONE *
+[0-9a-f]+ * [0-9a-f]+00001203 * R_MIPS_REL32 * [0-9a-f]+ * foo
+ * Type2: R_MIPS_64 *
+ * Type3: R_MIPS_NONE *
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-lib-64.rd
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-lib-64.rd 2012-08-03 00:35:18.191780032 +0100
@@ -0,0 +1,10 @@
+
+Relocation section '\.rel\.dyn' at offset .* contains 2 entries:
+ *Offset * Info * Type * Sym\. *Value * Sym\. *Name
+[0-9a-f]+ * 0+00000000 * R_MIPS_NONE *
+ * Type2: R_MIPS_NONE *
+ * Type3: R_MIPS_NONE *
+# This must be an absolute relocation, there must not be a _gp reference.
+[0-9a-f]+ * 0+00001203 * R_MIPS_REL32 *
+ * Type2: R_MIPS_64 *
+ * Type3: R_MIPS_NONE *
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-lib.rd
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-lib.rd 2012-08-03 00:35:18.201761759 +0100
@@ -0,0 +1,6 @@
+
+Relocation section '\.rel\.dyn' at offset .* contains 2 entries:
+ *Offset * Info * Type * Sym\. *Value * Sym\. *Name
+[0-9a-f]+ * 0+00 * R_MIPS_NONE *
+# This must be an absolute relocation, there must not be a _gp reference.
+[0-9a-f]+ * 0+03 * R_MIPS_REL32 *
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-ver-64.rd
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-ver-64.rd 2012-08-03 00:35:18.201761759 +0100
@@ -0,0 +1,13 @@
+
+Relocation section '\.rel\.dyn' at offset .* contains 3 entries:
+ *Offset * Info * Type * Sym\. *Value * Sym\. *Name
+[0-9a-f]+ * 0+00000000 * R_MIPS_NONE *
+ * Type2: R_MIPS_NONE *
+ * Type3: R_MIPS_NONE *
+# This must be an absolute relocation, there must not be a _gp reference.
+[0-9a-f]+ * 0+00001203 * R_MIPS_REL32 *
+ * Type2: R_MIPS_64 *
+ * Type3: R_MIPS_NONE *
+[0-9a-f]+ * [0-9a-f]+00001203 * R_MIPS_REL32 * [0-9a-f]+ * bar
+ * Type2: R_MIPS_64 *
+ * Type3: R_MIPS_NONE *
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-ver.rd
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden-ver.rd 2012-08-03 00:35:18.211765009 +0100
@@ -0,0 +1,7 @@
+
+Relocation section '\.rel\.dyn' at offset .* contains 3 entries:
+ *Offset * Info * Type * Sym\. *Value * Sym\. *Name
+[0-9a-f]+ * 0+00 * R_MIPS_NONE *
+# This must be an absolute relocation, there must not be a _gp reference.
+[0-9a-f]+ * 0+03 * R_MIPS_REL32 *
+[0-9a-f]+ * [0-9a-f]+03 * R_MIPS_REL32 * [0-9a-f]+ * bar
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden.rd
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden.rd 2012-08-03 00:35:18.211765009 +0100
@@ -0,0 +1,5 @@
+
+Relocation section '\.rel\.dyn' at offset .* contains 2 entries:
+ *Offset * Info * Type * Sym\. *Value * Sym\. *Name
+[0-9a-f]+ * 0+00 * R_MIPS_NONE *
+[0-9a-f]+ * [0-9a-f]+03 * R_MIPS_REL32 * [0-9a-f]+ * foo
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden.sd
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/gp-hidden.sd 2012-08-03 00:35:18.211765009 +0100
@@ -0,0 +1,9 @@
+
+Symbol table '.dynsym' contains [0-9]+ entries:
+ * Num: * Value * Size * Type * Bind * Vis * Ndx * Name
+#...
+Symbol table '.symtab' contains [0-9]+ entries:
+ * Num: * Value * Size * Type * Bind * Vis * Ndx * Name
+#...
+ * [0-9a-f]+: * [0-9a-f]+ * 0 * NOTYPE * LOCAL * DEFAULT * ABS * _gp
+#pass
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/mips-elf.exp
===================================================================
--- binutils-fsf-trunk-quilt.orig/ld/testsuite/ld-mips-elf/mips-elf.exp 2012-08-02 15:42:25.000000000 +0100
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/mips-elf.exp 2012-08-03 01:15:09.490520227 +0100
@@ -328,6 +328,44 @@ if { $linux_gnu } {
"readelf --symbols pic-and-nonpic-6-${abi}.nd" \
"readelf -d pic-and-nonpic-6-${abi}.ad"] \
"pic-and-nonpic-6-${abi}"]]
+
+ # This checks whether our linker scripts get the scope of _gp right,
+ # and must therefore use default scripts. If they don't, then -- in
+ # addition to dumps failing to match -- the final link fails with:
+ #
+ # ld: gp-hidden.o: undefined reference to symbol '_gp'
+ # ld: note: '_gp' is defined in DSO ./tmpdir/gp-hidden-lib-${abi}.so
+ # so try adding it to the linker command line
+ #
+ set suff64 [string map {o32 "" n32 "" n64 -64} $abi]
+ run_ld_link_tests [list \
+ [list \
+ "_gp scope test ($abi shared library)" \
+ "$abi_ldflags($abi) -shared" \
+ "$abi_asflags($abi) -KPIC" \
+ { gp-hidden-lib.s } \
+ [list \
+ "readelf --relocs gp-hidden-lib${suff64}.rd" \
+ "readelf --syms gp-hidden.sd"] \
+ "gp-hidden-lib-${abi}.so"] \
+ [list \
+ "_gp scope test ($abi versioned library)" \
+ "$abi_ldflags($abi) -shared -version-script gp-hidden-ver.ver tmpdir/gp-hidden-lib-${abi}.so" \
+ "$abi_asflags($abi) -KPIC" \
+ { gp-hidden-ver.s } \
+ [list \
+ "readelf --relocs gp-hidden-ver${suff64}.rd" \
+ "readelf --syms gp-hidden.sd"] \
+ "gp-hidden-ver-${abi}.so"] \
+ [list \
+ "_gp scope test ($abi executable)" \
+ "$abi_ldflags($abi) -e 0 -rpath-link . tmpdir/gp-hidden-ver-${abi}.so" \
+ "$abi_asflags($abi) -call_nonpic" \
+ { gp-hidden.s } \
+ [list \
+ "readelf --relocs gp-hidden${suff64}.rd" \
+ "readelf --syms gp-hidden.sd"] \
+ "gp-hidden-${abi}"]]
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 3/4] MIPS/Linux/LD/test: _gp scope ABI conformance tests
2012-08-03 18:02 [PATCH 3/4] MIPS/Linux/LD/test: _gp scope ABI conformance tests Maciej W. Rozycki
@ 2012-08-05 7:18 ` Richard Sandiford
0 siblings, 0 replies; 2+ messages in thread
From: Richard Sandiford @ 2012-08-05 7:18 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: binutils
"Maciej W. Rozycki" <macro@codesourcery.com> writes:
> ld/testsuite/
> * ld-mips-elf/gp-hidden.rd: New test.
> * ld-mips-elf/gp-hidden.sd: New test.
> * ld-mips-elf/gp-hidden-lib.rd: New test.
> * ld-mips-elf/gp-hidden-ver.rd: New test.
> * ld-mips-elf/gp-hidden-64.rd: New test.
> * ld-mips-elf/gp-hidden-lib-64.rd: New test.
> * ld-mips-elf/gp-hidden-ver-64.rd: New test.
> * ld-mips-elf/gp-hidden.s: New test source.
> * ld-mips-elf/gp-hidden-lib.s: New test source.
> * ld-mips-elf/gp-hidden-ver.s: New test source.
> * ld-mips-elf/gp-hidden-ver.ver: New test version script.
> * ld-mips-elf/mips-elf.exp: Run the new tests.
OK.
Richard
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-08-05 7:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-03 18:02 [PATCH 3/4] MIPS/Linux/LD/test: _gp scope ABI conformance tests Maciej W. Rozycki
2012-08-05 7:18 ` Richard Sandiford
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).