From: Maciej W. Rozycki Date: Mon, 6 Aug 2012 22:45:18 +0000 (+0000) Subject: * ld-mips-elf/gp-hidden.rd: New test. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=43b5366be5820507e12426aa42705668231db6a3;p=binutils-gdb.git * 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. --- diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index cd71a9f23a1..19c101e8f7f 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,18 @@ +2012-08-06 Maciej W. Rozycki + + * 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. + 2012-08-06 Maciej W. Rozycki * ld-mips-elf/rel32-o32.d: Adjust section VMAs after the removal diff --git a/ld/testsuite/ld-mips-elf/gp-hidden-64.rd b/ld/testsuite/ld-mips-elf/gp-hidden-64.rd new file mode 100644 index 00000000000..133fd48afa4 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/gp-hidden-64.rd @@ -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 * diff --git a/ld/testsuite/ld-mips-elf/gp-hidden-lib-64.rd b/ld/testsuite/ld-mips-elf/gp-hidden-lib-64.rd new file mode 100644 index 00000000000..8dbba28158a --- /dev/null +++ b/ld/testsuite/ld-mips-elf/gp-hidden-lib-64.rd @@ -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 * diff --git a/ld/testsuite/ld-mips-elf/gp-hidden-lib.rd b/ld/testsuite/ld-mips-elf/gp-hidden-lib.rd new file mode 100644 index 00000000000..080dfe21719 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/gp-hidden-lib.rd @@ -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 * diff --git a/ld/testsuite/ld-mips-elf/gp-hidden-lib.s b/ld/testsuite/ld-mips-elf/gp-hidden-lib.s new file mode 100644 index 00000000000..988c3d342e5 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/gp-hidden-lib.s @@ -0,0 +1,6 @@ + .data + .globl bar + .type bar, @object +bar: + .dc.a _gp + .size bar, . - bar diff --git a/ld/testsuite/ld-mips-elf/gp-hidden-ver-64.rd b/ld/testsuite/ld-mips-elf/gp-hidden-ver-64.rd new file mode 100644 index 00000000000..1639211d76f --- /dev/null +++ b/ld/testsuite/ld-mips-elf/gp-hidden-ver-64.rd @@ -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 * diff --git a/ld/testsuite/ld-mips-elf/gp-hidden-ver.rd b/ld/testsuite/ld-mips-elf/gp-hidden-ver.rd new file mode 100644 index 00000000000..31ccd2bb179 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/gp-hidden-ver.rd @@ -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 diff --git a/ld/testsuite/ld-mips-elf/gp-hidden-ver.s b/ld/testsuite/ld-mips-elf/gp-hidden-ver.s new file mode 100644 index 00000000000..eb4acf7f5c1 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/gp-hidden-ver.s @@ -0,0 +1,7 @@ + .data + .globl foo + .type foo, @object +foo: + .dc.a bar + .dc.a _gp + .size foo, . - foo diff --git a/ld/testsuite/ld-mips-elf/gp-hidden-ver.ver b/ld/testsuite/ld-mips-elf/gp-hidden-ver.ver new file mode 100644 index 00000000000..b6b23651880 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/gp-hidden-ver.ver @@ -0,0 +1 @@ +{ global: foo; local: *; }; diff --git a/ld/testsuite/ld-mips-elf/gp-hidden.rd b/ld/testsuite/ld-mips-elf/gp-hidden.rd new file mode 100644 index 00000000000..62c9b378937 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/gp-hidden.rd @@ -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 diff --git a/ld/testsuite/ld-mips-elf/gp-hidden.s b/ld/testsuite/ld-mips-elf/gp-hidden.s new file mode 100644 index 00000000000..154dcdd6887 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/gp-hidden.s @@ -0,0 +1,7 @@ + .data + .globl blah + .type blah, @object +blah: + .dc.a foo + .dc.a _gp + .size blah, . - blah diff --git a/ld/testsuite/ld-mips-elf/gp-hidden.sd b/ld/testsuite/ld-mips-elf/gp-hidden.sd new file mode 100644 index 00000000000..2e9cfbf8f2d --- /dev/null +++ b/ld/testsuite/ld-mips-elf/gp-hidden.sd @@ -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 diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index d9430fffaa8..50e51c66600 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -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}"]] } }