diff options
author | Maciej W. Rozycki <macro@linux-mips.org> | 2012-08-28 20:29:19 +0000 |
---|---|---|
committer | Maciej W. Rozycki <macro@linux-mips.org> | 2012-08-28 20:29:19 +0000 |
commit | a521a3297bbef0833cf3ff845699cb7976a89a8d (patch) | |
tree | 572e9c1b33628deac4e529dc3d0616984e9f35d6 /ld/testsuite | |
parent | 14acf4dcaee3b0cee94b481b220d38fc4ff6ae5c (diff) | |
download | gdb-a521a3297bbef0833cf3ff845699cb7976a89a8d.zip gdb-a521a3297bbef0833cf3ff845699cb7976a89a8d.tar.gz gdb-a521a3297bbef0833cf3ff845699cb7976a89a8d.tar.bz2 |
* ld-elf/export-class.sd: New test.
* ld-elf/export-class.vd: New test.
* ld-elf/export-class-def.s: New test source.
* ld-elf/export-class-dep.s: New test source.
* ld-elf/export-class-lib.s: New test source.
* ld-elf/export-class-ref.s: New test source.
* ld-elf/export-class-lib.ver: New test version script.
* ld-elf/export-class.exp: New test script.
* ld-arm/arm-export-class.rd: New test.
* ld-arm/arm-export-class.xd: New test.
* ld-arm/export-class.exp: New test script.
* ld-i386/i386-export-class.rd: New test.
* ld-i386/i386-export-class.xd: New test.
* ld-i386/export-class.exp: New test script.
* ld-mips-elf/mips-32-export-class.rd: New test.
* ld-mips-elf/mips-32-export-class.xd: New test.
* ld-mips-elf/mips-64-export-class.rd: New test.
* ld-mips-elf/mips-64-export-class.xd: New test.
* ld-mips-elf/export-class.exp: New test script.
* ld-powerpc/powerpc-32-export-class.rd: New test.
* ld-powerpc/powerpc-32-export-class.xd: New test.
* ld-powerpc/powerpc-64-export-class.rd: New test.
* ld-powerpc/powerpc-64-export-class.xd: New test.
* ld-powerpc/export-class.exp: New test script.
* ld-x86-64/x86-64-64-export-class.rd: New test.
* ld-x86-64/x86-64-x32-export-class.rd: New test.
* ld-x86-64/export-class.exp: New test script.
Diffstat (limited to 'ld/testsuite')
28 files changed, 854 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index e6c2ae0..eca4181 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,33 @@ +2012-08-28 Maciej W. Rozycki <macro@codesourcery.com> + + * ld-elf/export-class.sd: New test. + * ld-elf/export-class.vd: New test. + * ld-elf/export-class-def.s: New test source. + * ld-elf/export-class-dep.s: New test source. + * ld-elf/export-class-lib.s: New test source. + * ld-elf/export-class-ref.s: New test source. + * ld-elf/export-class-lib.ver: New test version script. + * ld-elf/export-class.exp: New test script. + * ld-arm/arm-export-class.rd: New test. + * ld-arm/arm-export-class.xd: New test. + * ld-arm/export-class.exp: New test script. + * ld-i386/i386-export-class.rd: New test. + * ld-i386/i386-export-class.xd: New test. + * ld-i386/export-class.exp: New test script. + * ld-mips-elf/mips-32-export-class.rd: New test. + * ld-mips-elf/mips-32-export-class.xd: New test. + * ld-mips-elf/mips-64-export-class.rd: New test. + * ld-mips-elf/mips-64-export-class.xd: New test. + * ld-mips-elf/export-class.exp: New test script. + * ld-powerpc/powerpc-32-export-class.rd: New test. + * ld-powerpc/powerpc-32-export-class.xd: New test. + * ld-powerpc/powerpc-64-export-class.rd: New test. + * ld-powerpc/powerpc-64-export-class.xd: New test. + * ld-powerpc/export-class.exp: New test script. + * ld-x86-64/x86-64-64-export-class.rd: New test. + * ld-x86-64/x86-64-x32-export-class.rd: New test. + * ld-x86-64/export-class.exp: New test script. + 2012-08-24 H.J. Lu <hongjiu.lu@intel.com> * ld-elf/exclude3a.d: Remove target and use failif. diff --git a/ld/testsuite/ld-arm/arm-export-class.rd b/ld/testsuite/ld-arm/arm-export-class.rd new file mode 100644 index 0000000..78d5d1e --- /dev/null +++ b/ld/testsuite/ld-arm/arm-export-class.rd @@ -0,0 +1,11 @@ +Relocation section '\.rel\.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries: + * Offset * Info * Type * Sym\. *Value * Sym\. * Name +12340010 00000017 R_ARM_RELATIVE * +12340020 00000017 R_ARM_RELATIVE * +12340060 00000017 R_ARM_RELATIVE * +12340070 00000017 R_ARM_RELATIVE * +12340080 00000017 R_ARM_RELATIVE * +12340090 00000017 R_ARM_RELATIVE * +12340000 [0-9a-f]+02 R_ARM_ABS32 123400a0 protected_baz +12340040 [0-9a-f]+02 R_ARM_ABS32 123400a0 protected_foo +12340050 [0-9a-f]+02 R_ARM_ABS32 123400a0 protected_bar diff --git a/ld/testsuite/ld-arm/arm-export-class.xd b/ld/testsuite/ld-arm/arm-export-class.xd new file mode 100644 index 0000000..a797f20 --- /dev/null +++ b/ld/testsuite/ld-arm/arm-export-class.xd @@ -0,0 +1,11 @@ +Hex dump of section '\.data': + 0x12340000 00000000 00000000 00000000 00000000 .* + 0x12340010 a0003412 00000000 00000000 00000000 .* + 0x12340020 a0003412 00000000 00000000 00000000 .* + 0x12340030 00000000 00000000 00000000 00000000 .* + 0x12340040 00000000 00000000 00000000 00000000 .* + 0x12340050 00000000 00000000 00000000 00000000 .* + 0x12340060 a0003412 00000000 00000000 00000000 .* + 0x12340070 a0003412 00000000 00000000 00000000 .* + 0x12340080 a0003412 00000000 00000000 00000000 .* + 0x12340090 a0003412 00000000 00000000 00000000 .* diff --git a/ld/testsuite/ld-arm/export-class.exp b/ld/testsuite/ld-arm/export-class.exp new file mode 100644 index 0000000..2f8e866 --- /dev/null +++ b/ld/testsuite/ld-arm/export-class.exp @@ -0,0 +1,80 @@ +# Expect script for symbol export classes, ARM variation. +# +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. +# + +# +# Written by Maciej W. Rozycki <macro@codesourcery.com> +# + +# Exclude non-Linux targets; feel free to include your favorite one +# if you like. +if { ![istarget arm*-*-linux*] } { + return +} + +set testname "ARM symbol export class test" + +# Build an auxiliary shared object with conflicting versioned symbol +# definitions. +run_ld_link_tests [list \ + [list \ + "$testname (auxiliary shared object)" \ + "-marmelf_linux_eabi -shared -version-script ../ld-elf/export-class-lib.ver" \ + "-EL" \ + { ../ld-elf/export-class-lib.s } \ + {} \ + "arm-export-class-lib.so" \ + ] \ +] + +# Build a static object that pulls symbol definitions. It has to come +# first before the auxiliary shared object and other static objects on +# the linker's command line and hence we need to build it separately. +run_ld_link_tests [list \ + [list \ + "$testname (initial static object)" \ + "-marmelf_linux_eabi -r" \ + "-EL" \ + { ../ld-elf/export-class-ref.s } \ + {} \ + "arm-export-class-ref-r.o" \ + ] \ +] + +# Build static objects that satisfy symbol dependencies and preempt +# shared-object symbol definitions, and link all the objects built into +# the final shared object. The command-line order of objects linked is +# important to make sure the linker correctly preempts versioned symbols +# from the auxiliary shared object and is as follows: ref, lib, dep, def. +# Get a dump to make sure symbol dependencies are resolved internally. +run_ld_link_tests [list \ + [list \ + "$testname (final shared object)" \ + "-marmelf_linux_eabi -shared -Tdata=0x12340000 tmpdir/arm-export-class-ref-r.o tmpdir/arm-export-class-lib.so" \ + "-EL" \ + { ../ld-elf/export-class-dep.s ../ld-elf/export-class-def.s } \ + { \ + { readelf -r arm-export-class.rd } \ + { readelf "-x .data" arm-export-class.xd } \ + } \ + "arm-export-class.so" \ + ] \ +] diff --git a/ld/testsuite/ld-elf/export-class-def.s b/ld/testsuite/ld-elf/export-class-def.s new file mode 100644 index 0000000..90f908f --- /dev/null +++ b/ld/testsuite/ld-elf/export-class-def.s @@ -0,0 +1,25 @@ + .data + .balign 32 + .xdef protected_bar + .protected protected_bar +protected_bar: + .balign 32 + .xdef protected_foo + .protected protected_foo +protected_foo: + .balign 32 + .xdef hidden_bar + .hidden hidden_bar +hidden_bar: + .balign 32 + .xdef hidden_foo + .hidden hidden_foo +hidden_foo: + .balign 32 + .xdef internal_bar + .internal internal_bar +internal_bar: + .balign 32 + .xdef internal_foo + .internal internal_foo +internal_foo: diff --git a/ld/testsuite/ld-elf/export-class-dep.s b/ld/testsuite/ld-elf/export-class-dep.s new file mode 100644 index 0000000..e987898 --- /dev/null +++ b/ld/testsuite/ld-elf/export-class-dep.s @@ -0,0 +1,25 @@ + .data + .balign 16 + .dc.a protected_foo + .balign 16 + .dc.a protected_bar + .balign 16 + .dc.a hidden_foo + .balign 16 + .dc.a hidden_bar + .balign 16 + .dc.a internal_foo + .balign 16 + .dc.a internal_bar + .balign 32 + .xdef protected_baz + .protected protected_baz +protected_baz: + .balign 32 + .xdef hidden_baz + .hidden hidden_baz +hidden_baz: + .balign 32 + .xdef internal_baz + .internal internal_baz +internal_baz: diff --git a/ld/testsuite/ld-elf/export-class-lib.s b/ld/testsuite/ld-elf/export-class-lib.s new file mode 100644 index 0000000..b3f3f05 --- /dev/null +++ b/ld/testsuite/ld-elf/export-class-lib.s @@ -0,0 +1,10 @@ + .data + .balign 16 + .xdef protected_foo +protected_foo: + .balign 16 + .xdef hidden_foo +hidden_foo: + .balign 16 + .xdef internal_foo +internal_foo: diff --git a/ld/testsuite/ld-elf/export-class-lib.ver b/ld/testsuite/ld-elf/export-class-lib.ver new file mode 100644 index 0000000..a9dbfdc --- /dev/null +++ b/ld/testsuite/ld-elf/export-class-lib.ver @@ -0,0 +1 @@ +GCC_3.0 { global: *_foo; }; diff --git a/ld/testsuite/ld-elf/export-class-ref.s b/ld/testsuite/ld-elf/export-class-ref.s new file mode 100644 index 0000000..4e45c02 --- /dev/null +++ b/ld/testsuite/ld-elf/export-class-ref.s @@ -0,0 +1,7 @@ + .data + .balign 16 + .dc.a protected_baz + .balign 16 + .dc.a hidden_baz + .balign 16 + .dc.a internal_baz diff --git a/ld/testsuite/ld-elf/export-class.exp b/ld/testsuite/ld-elf/export-class.exp new file mode 100644 index 0000000..81ce55a --- /dev/null +++ b/ld/testsuite/ld-elf/export-class.exp @@ -0,0 +1,87 @@ +# Expect script for symbol export classes. +# +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. +# + +# +# Written by Maciej W. Rozycki <macro@codesourcery.com> +# + +# Exclude non-ELF targets. +if { ![is_elf_format] } { + return +} + +# Exclude some more targets; feel free to include your favorite one +# if you like. +if { ![istarget *-*-linux*] + && ![istarget *-*-nacl*] + && ![istarget *-*-gnu*] } { + return +} + +set testname "Symbol export class test" + +# Build an auxiliary shared object with conflicting versioned symbol +# definitions. +run_ld_link_tests [list \ + [list \ + "$testname (auxiliary shared object)" \ + "-shared -version-script export-class-lib.ver" \ + "" \ + { export-class-lib.s } \ + {} \ + "export-class-lib.so" \ + ] \ +] + +# Build a static object that pulls symbol definitions. It has to come +# first before the auxiliary shared object and other static objects on +# the linker's command line and hence we need to build it separately. +run_ld_link_tests [list \ + [list \ + "$testname (initial static object)" \ + "-r" \ + "" \ + { export-class-ref.s } \ + {} \ + "export-class-ref-r.o" \ + ] \ +] + +# Build static objects that satisfy symbol dependencies and preempt +# shared-object symbol definitions, and link all the objects built into +# the final shared object. The command-line order of objects linked is +# important to make sure the linker correctly preempts versioned symbols +# from the auxiliary shared object and is as follows: ref, lib, dep, def. +# Get a dump to make sure symbol dependencies are resolved internally. +run_ld_link_tests [list \ + [list \ + "$testname (final shared object)" \ + "-shared -Tdata=0x12340000 tmpdir/export-class-ref-r.o tmpdir/export-class-lib.so" \ + "" \ + { export-class-dep.s export-class-def.s } \ + { \ + { readelf -s export-class.sd } \ + { readelf -V export-class.vd } \ + } \ + "export-class.so" \ + ] \ +] diff --git a/ld/testsuite/ld-elf/export-class.sd b/ld/testsuite/ld-elf/export-class.sd new file mode 100644 index 0000000..bd5c549 --- /dev/null +++ b/ld/testsuite/ld-elf/export-class.sd @@ -0,0 +1,32 @@ +Symbol table '\.dynsym' contains [0-9]+ entries: + * Num: * Value * Size * Type * Bind * Vis * Ndx * Name +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * GLOBAL * PROTECTED * [0-9]+ * protected_foo +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * GLOBAL * PROTECTED * [0-9]+ * protected_bar +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * GLOBAL * PROTECTED * [0-9]+ * protected_baz +#... +Symbol table '\.symtab' contains [0-9]+ entries: + * Num: * Value * Size * Type * Bind * Vis * Ndx * Name +#... + * [0-9a-f]+: * 0*12340000 * 0 * SECTION * LOCAL * DEFAULT * [0-9]+ * +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * LOCAL * DEFAULT * [0-9]+ * hidden_foo +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * LOCAL * DEFAULT * [0-9]+ * internal_baz +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * LOCAL * DEFAULT * [0-9]+ * internal_bar +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * LOCAL * DEFAULT * [0-9]+ * internal_foo +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * LOCAL * DEFAULT * [0-9]+ * hidden_bar +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * LOCAL * DEFAULT * [0-9]+ * hidden_baz +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * GLOBAL * PROTECTED * [0-9]+ * protected_foo +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * GLOBAL * PROTECTED * [0-9]+ * protected_bar +#... + * [0-9a-f]+: * 0*123400a0 * 0 * NOTYPE * GLOBAL * PROTECTED * [0-9]+ * protected_baz +#pass diff --git a/ld/testsuite/ld-elf/export-class.vd b/ld/testsuite/ld-elf/export-class.vd new file mode 100644 index 0000000..1a87494 --- /dev/null +++ b/ld/testsuite/ld-elf/export-class.vd @@ -0,0 +1 @@ +No version information found in this file\. diff --git a/ld/testsuite/ld-i386/export-class.exp b/ld/testsuite/ld-i386/export-class.exp new file mode 100644 index 0000000..cd96b4b --- /dev/null +++ b/ld/testsuite/ld-i386/export-class.exp @@ -0,0 +1,85 @@ +# Expect script for symbol export classes, i386 variation. +# +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. +# + +# +# Written by Maciej W. Rozycki <macro@codesourcery.com> +# + +# Exclude non-ELF targets. +if { ![is_elf_format] } { + return +} + +# Exclude non-Linux targets; feel free to include your favorite one +# if you like. +if { ![istarget i?86-*-linux*] } { + return +} + +set testname "i386 symbol export class test" + +# Build an auxiliary shared object with conflicting versioned symbol +# definitions. +run_ld_link_tests [list \ + [list \ + "$testname (auxiliary shared object)" \ + "-shared -version-script ../ld-elf/export-class-lib.ver" \ + "" \ + { ../ld-elf/export-class-lib.s } \ + {} \ + "i386-export-class-lib.so" \ + ] \ +] + +# Build a static object that pulls symbol definitions. It has to come +# first before the auxiliary shared object and other static objects on +# the linker's command line and hence we need to build it separately. +run_ld_link_tests [list \ + [list \ + "$testname (initial static object)" \ + "-r" \ + "" \ + { ../ld-elf/export-class-ref.s } \ + {} \ + "i386-export-class-ref-r.o" \ + ] \ +] + +# Build static objects that satisfy symbol dependencies and preempt +# shared-object symbol definitions, and link all the objects built into +# the final shared object. The command-line order of objects linked is +# important to make sure the linker correctly preempts versioned symbols +# from the auxiliary shared object and is as follows: ref, lib, dep, def. +# Get a dump to make sure symbol dependencies are resolved internally. +run_ld_link_tests [list \ + [list \ + "$testname (final shared object)" \ + "-shared -Tdata=0x12340000 tmpdir/i386-export-class-ref-r.o tmpdir/i386-export-class-lib.so" \ + "" \ + { ../ld-elf/export-class-dep.s ../ld-elf/export-class-def.s } \ + { \ + { readelf -r i386-export-class.rd } \ + { readelf "-x .data" i386-export-class.xd } \ + } \ + "i386-export-class.so" \ + ] \ +] diff --git a/ld/testsuite/ld-i386/i386-export-class.rd b/ld/testsuite/ld-i386/i386-export-class.rd new file mode 100644 index 0000000..d7beade --- /dev/null +++ b/ld/testsuite/ld-i386/i386-export-class.rd @@ -0,0 +1,11 @@ +Relocation section '\.rel\.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries: + * Offset * Info * Type * Sym\. *Value * Sym\. * Name +12340010 00000008 R_386_RELATIVE * +12340020 00000008 R_386_RELATIVE * +12340060 00000008 R_386_RELATIVE * +12340070 00000008 R_386_RELATIVE * +12340080 00000008 R_386_RELATIVE * +12340090 00000008 R_386_RELATIVE * +12340000 [0-9a-f]+01 R_386_32 123400a0 protected_baz +12340040 [0-9a-f]+01 R_386_32 123400a0 protected_foo +12340050 [0-9a-f]+01 R_386_32 123400a0 protected_bar diff --git a/ld/testsuite/ld-i386/i386-export-class.xd b/ld/testsuite/ld-i386/i386-export-class.xd new file mode 100644 index 0000000..a797f20 --- /dev/null +++ b/ld/testsuite/ld-i386/i386-export-class.xd @@ -0,0 +1,11 @@ +Hex dump of section '\.data': + 0x12340000 00000000 00000000 00000000 00000000 .* + 0x12340010 a0003412 00000000 00000000 00000000 .* + 0x12340020 a0003412 00000000 00000000 00000000 .* + 0x12340030 00000000 00000000 00000000 00000000 .* + 0x12340040 00000000 00000000 00000000 00000000 .* + 0x12340050 00000000 00000000 00000000 00000000 .* + 0x12340060 a0003412 00000000 00000000 00000000 .* + 0x12340070 a0003412 00000000 00000000 00000000 .* + 0x12340080 a0003412 00000000 00000000 00000000 .* + 0x12340090 a0003412 00000000 00000000 00000000 .* diff --git a/ld/testsuite/ld-mips-elf/export-class.exp b/ld/testsuite/ld-mips-elf/export-class.exp new file mode 100644 index 0000000..b7ce07c --- /dev/null +++ b/ld/testsuite/ld-mips-elf/export-class.exp @@ -0,0 +1,96 @@ +# Expect script for symbol export classes, MIPS variation. +# +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. +# + +# +# Written by Maciej W. Rozycki <macro@codesourcery.com> +# + +# Exclude non-Linux targets; feel free to include your favorite one +# if you like. +if { ![istarget mips*-*-linux*] } { + return +} + +proc mips_export_class_test { abi flag emul } { + + set testname "MIPS $abi symbol export class test" + + set dump [string map {o32 32 n32 32 n64 64} $abi] + + set AFLAGS "$flag -EB" + set LDFLAGS "-m$emul" + + # Build an auxiliary shared object with conflicting versioned symbol + # definitions. + run_ld_link_tests [list \ + [list \ + "$testname (auxiliary shared object)" \ + "$LDFLAGS -shared -version-script ../ld-elf/export-class-lib.ver" \ + "$AFLAGS" \ + { ../ld-elf/export-class-lib.s } \ + {} \ + "mips-$abi-export-class-lib.so" \ + ] \ + ] + + # Build a static object that pulls symbol definitions. It has to come + # first before the auxiliary shared object and other static objects on + # the linker's command line and hence we need to build it separately. + run_ld_link_tests [list \ + [list \ + "$testname (initial static object)" \ + "$LDFLAGS -r" \ + "$AFLAGS" \ + { ../ld-elf/export-class-ref.s } \ + {} \ + "mips-$abi-export-class-ref-r.o" \ + ] \ + ] + + # Build static objects that satisfy symbol dependencies and preempt + # shared-object symbol definitions, and link all the objects built into + # the final shared object. The command-line order of objects linked is + # important to make sure the linker correctly preempts versioned symbols + # from the auxiliary shared object and is as follows: ref, lib, dep, def. + # Get a dump to make sure symbol dependencies are resolved internally. + run_ld_link_tests [list \ + [list \ + "$testname (final shared object)" \ + "$LDFLAGS -shared -Tdata=0x12340000 tmpdir/mips-$abi-export-class-ref-r.o tmpdir/mips-$abi-export-class-lib.so" \ + "$AFLAGS" \ + { ../ld-elf/export-class-dep.s ../ld-elf/export-class-def.s } \ + [list \ + [list readelf -r mips-$dump-export-class.rd] \ + [list readelf "-x .data" mips-$dump-export-class.xd] \ + ] \ + "mips-$abi-export-class.so" \ + ] \ + ] +} + +# For targets that default to a specific ISA (instead of "from-abi"), +# the 64-bit -march option is required to override it, like for +# "mipsisa32r2el-*-*". +set abis { o32 -32 elf32btsmip n32 "-n32 -march=mips3" elf32btsmipn32 n64 "-64 -march=mips3" elf64btsmip } +foreach { abi flag emul } $abis { + mips_export_class_test $abi $flag $emul +} diff --git a/ld/testsuite/ld-mips-elf/mips-32-export-class.rd b/ld/testsuite/ld-mips-elf/mips-32-export-class.rd new file mode 100644 index 0000000..e1f8229 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/mips-32-export-class.rd @@ -0,0 +1,12 @@ +Relocation section '\.rel\.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries: + * Offset * Info * Type * Sym\. *Value * Sym\. * Name +00000000 00000000 R_MIPS_NONE * +12340000 00000003 R_MIPS_REL32 * +12340010 00000003 R_MIPS_REL32 * +12340020 00000003 R_MIPS_REL32 * +12340040 00000003 R_MIPS_REL32 * +12340050 00000003 R_MIPS_REL32 * +12340060 00000003 R_MIPS_REL32 * +12340070 00000003 R_MIPS_REL32 * +12340080 00000003 R_MIPS_REL32 * +12340090 00000003 R_MIPS_REL32 * diff --git a/ld/testsuite/ld-mips-elf/mips-32-export-class.xd b/ld/testsuite/ld-mips-elf/mips-32-export-class.xd new file mode 100644 index 0000000..400cddd --- /dev/null +++ b/ld/testsuite/ld-mips-elf/mips-32-export-class.xd @@ -0,0 +1,11 @@ +Hex dump of section '\.data': + 0x12340000 123400a0 00000000 00000000 00000000 .* + 0x12340010 123400a0 00000000 00000000 00000000 .* + 0x12340020 123400a0 00000000 00000000 00000000 .* + 0x12340030 00000000 00000000 00000000 00000000 .* + 0x12340040 123400a0 00000000 00000000 00000000 .* + 0x12340050 123400a0 00000000 00000000 00000000 .* + 0x12340060 123400a0 00000000 00000000 00000000 .* + 0x12340070 123400a0 00000000 00000000 00000000 .* + 0x12340080 123400a0 00000000 00000000 00000000 .* + 0x12340090 123400a0 00000000 00000000 00000000 .* diff --git a/ld/testsuite/ld-mips-elf/mips-64-export-class.rd b/ld/testsuite/ld-mips-elf/mips-64-export-class.rd new file mode 100644 index 0000000..b501ff7 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/mips-64-export-class.rd @@ -0,0 +1,32 @@ +Relocation section '\.rel\.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries: + * Offset * Info * Type * Sym\. *Value * Sym\. * Name +000000000000 000000000000 R_MIPS_NONE * + Type2: R_MIPS_NONE * + Type3: R_MIPS_NONE * +000012340000 000000001203 R_MIPS_REL32 * + Type2: R_MIPS_64 * + Type3: R_MIPS_NONE * +000012340010 000000001203 R_MIPS_REL32 * + Type2: R_MIPS_64 * + Type3: R_MIPS_NONE * +000012340020 000000001203 R_MIPS_REL32 * + Type2: R_MIPS_64 * + Type3: R_MIPS_NONE * +000012340040 000000001203 R_MIPS_REL32 * + Type2: R_MIPS_64 * + Type3: R_MIPS_NONE * +000012340050 000000001203 R_MIPS_REL32 * + Type2: R_MIPS_64 * + Type3: R_MIPS_NONE * +000012340060 000000001203 R_MIPS_REL32 * + Type2: R_MIPS_64 * + Type3: R_MIPS_NONE * +000012340070 000000001203 R_MIPS_REL32 * + Type2: R_MIPS_64 * + Type3: R_MIPS_NONE * +000012340080 000000001203 R_MIPS_REL32 * + Type2: R_MIPS_64 * + Type3: R_MIPS_NONE * +000012340090 000000001203 R_MIPS_REL32 * + Type2: R_MIPS_64 * + Type3: R_MIPS_NONE * diff --git a/ld/testsuite/ld-mips-elf/mips-64-export-class.xd b/ld/testsuite/ld-mips-elf/mips-64-export-class.xd new file mode 100644 index 0000000..d0388ad --- /dev/null +++ b/ld/testsuite/ld-mips-elf/mips-64-export-class.xd @@ -0,0 +1,11 @@ +Hex dump of section '\.data': + 0x12340000 00000000 123400a0 00000000 00000000 .* + 0x12340010 00000000 123400a0 00000000 00000000 .* + 0x12340020 00000000 123400a0 00000000 00000000 .* + 0x12340030 00000000 00000000 00000000 00000000 .* + 0x12340040 00000000 123400a0 00000000 00000000 .* + 0x12340050 00000000 123400a0 00000000 00000000 .* + 0x12340060 00000000 123400a0 00000000 00000000 .* + 0x12340070 00000000 123400a0 00000000 00000000 .* + 0x12340080 00000000 123400a0 00000000 00000000 .* + 0x12340090 00000000 123400a0 00000000 00000000 .* diff --git a/ld/testsuite/ld-powerpc/export-class.exp b/ld/testsuite/ld-powerpc/export-class.exp new file mode 100644 index 0000000..c1106bf --- /dev/null +++ b/ld/testsuite/ld-powerpc/export-class.exp @@ -0,0 +1,106 @@ +# Expect script for symbol export classes, PowerPC variation. +# +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. +# + +# +# Written by Maciej W. Rozycki <macro@codesourcery.com> +# + +# Exclude non-Linux targets; feel free to include your favorite one +# if you like. +if { ![istarget powerpc*-*-linux*] } { + return +} + +proc supports_ppc64 { } { + global ld + + catch "exec $ld --help | grep emulations" tmp + if [string match "*elf64ppc*" $tmp] then { + return 1 + } else { + return 0 + } +} + +proc powerpc_export_class_test { abi emul } { + + set testname "PowerPC $abi symbol export class test" + + set AFLAGS "-a$abi -be" + set LDFLAGS "-m$emul" + + # Build an auxiliary shared object with conflicting versioned symbol + # definitions. + run_ld_link_tests [list \ + [list \ + "$testname (auxiliary shared object)" \ + "$LDFLAGS -shared -version-script ../ld-elf/export-class-lib.ver" \ + "$AFLAGS" \ + { ../ld-elf/export-class-lib.s } \ + {} \ + "powerpc-$abi-export-class-lib.so" \ + ] \ + ] + + # Build a static object that pulls symbol definitions. It has to come + # first before the auxiliary shared object and other static objects on + # the linker's command line and hence we need to build it separately. + run_ld_link_tests [list \ + [list \ + "$testname (initial static object)" \ + "$LDFLAGS -r" \ + "$AFLAGS" \ + { ../ld-elf/export-class-ref.s } \ + {} \ + "powerpc-$abi-export-class-ref-r.o" \ + ] \ + ] + + # Build static objects that satisfy symbol dependencies and preempt + # shared-object symbol definitions, and link all the objects built into + # the final shared object. The command-line order of objects linked is + # important to make sure the linker correctly preempts versioned symbols + # from the auxiliary shared object and is as follows: ref, lib, dep, def. + # Get a dump to make sure symbol dependencies are resolved internally. + run_ld_link_tests [list \ + [list \ + "$testname (final shared object)" \ + "$LDFLAGS -shared -Tdata=0x12340000 tmpdir/powerpc-$abi-export-class-ref-r.o tmpdir/powerpc-$abi-export-class-lib.so" \ + "$AFLAGS" \ + { ../ld-elf/export-class-dep.s ../ld-elf/export-class-def.s } \ + [list \ + [list readelf -r powerpc-$abi-export-class.rd] \ + [list readelf "-x .data" powerpc-$abi-export-class.xd] \ + ] \ + "powerpc-$abi-export-class.so" \ + ] \ + ] +} + +if { [supports_ppc64] } { + set abis { 32 elf32ppclinux 64 elf64ppc } +} else { + set abis { 32 elf32ppclinux } +} +foreach { abi emul } $abis { + powerpc_export_class_test $abi $emul +} diff --git a/ld/testsuite/ld-powerpc/powerpc-32-export-class.rd b/ld/testsuite/ld-powerpc/powerpc-32-export-class.rd new file mode 100644 index 0000000..1c64b40 --- /dev/null +++ b/ld/testsuite/ld-powerpc/powerpc-32-export-class.rd @@ -0,0 +1,11 @@ +Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries: + * Offset * Info * Type * Sym\. *Value * Sym\. * Name * \+ * Addend +12340000 00000016 R_PPC_RELATIVE * 123400a0 +12340010 00000016 R_PPC_RELATIVE * 123400a0 +12340020 00000016 R_PPC_RELATIVE * 123400a0 +12340040 00000016 R_PPC_RELATIVE * 123400a0 +12340050 00000016 R_PPC_RELATIVE * 123400a0 +12340060 00000016 R_PPC_RELATIVE * 123400a0 +12340070 00000016 R_PPC_RELATIVE * 123400a0 +12340080 00000016 R_PPC_RELATIVE * 123400a0 +12340090 00000016 R_PPC_RELATIVE * 123400a0 diff --git a/ld/testsuite/ld-powerpc/powerpc-32-export-class.xd b/ld/testsuite/ld-powerpc/powerpc-32-export-class.xd new file mode 100644 index 0000000..36a589f --- /dev/null +++ b/ld/testsuite/ld-powerpc/powerpc-32-export-class.xd @@ -0,0 +1,11 @@ +Hex dump of section '\.data': + 0x12340000 00000000 00000000 00000000 00000000 .* + 0x12340010 00000000 00000000 00000000 00000000 .* + 0x12340020 00000000 00000000 00000000 00000000 .* + 0x12340030 00000000 00000000 00000000 00000000 .* + 0x12340040 00000000 00000000 00000000 00000000 .* + 0x12340050 00000000 00000000 00000000 00000000 .* + 0x12340060 00000000 00000000 00000000 00000000 .* + 0x12340070 00000000 00000000 00000000 00000000 .* + 0x12340080 00000000 00000000 00000000 00000000 .* + 0x12340090 00000000 00000000 00000000 00000000 .* diff --git a/ld/testsuite/ld-powerpc/powerpc-64-export-class.rd b/ld/testsuite/ld-powerpc/powerpc-64-export-class.rd new file mode 100644 index 0000000..c7ff641 --- /dev/null +++ b/ld/testsuite/ld-powerpc/powerpc-64-export-class.rd @@ -0,0 +1,11 @@ +Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries: + * Offset * Info * Type * Sym\. *Value * Sym\. * Name * \+ * Addend +000012340000 000000000016 R_PPC64_RELATIVE * 123400a0 +000012340010 000000000016 R_PPC64_RELATIVE * 123400a0 +000012340020 000000000016 R_PPC64_RELATIVE * 123400a0 +000012340040 000000000016 R_PPC64_RELATIVE * 123400a0 +000012340050 000000000016 R_PPC64_RELATIVE * 123400a0 +000012340060 000000000016 R_PPC64_RELATIVE * 123400a0 +000012340070 000000000016 R_PPC64_RELATIVE * 123400a0 +000012340080 000000000016 R_PPC64_RELATIVE * 123400a0 +000012340090 000000000016 R_PPC64_RELATIVE * 123400a0 diff --git a/ld/testsuite/ld-powerpc/powerpc-64-export-class.xd b/ld/testsuite/ld-powerpc/powerpc-64-export-class.xd new file mode 100644 index 0000000..d0388ad --- /dev/null +++ b/ld/testsuite/ld-powerpc/powerpc-64-export-class.xd @@ -0,0 +1,11 @@ +Hex dump of section '\.data': + 0x12340000 00000000 123400a0 00000000 00000000 .* + 0x12340010 00000000 123400a0 00000000 00000000 .* + 0x12340020 00000000 123400a0 00000000 00000000 .* + 0x12340030 00000000 00000000 00000000 00000000 .* + 0x12340040 00000000 123400a0 00000000 00000000 .* + 0x12340050 00000000 123400a0 00000000 00000000 .* + 0x12340060 00000000 123400a0 00000000 00000000 .* + 0x12340070 00000000 123400a0 00000000 00000000 .* + 0x12340080 00000000 123400a0 00000000 00000000 .* + 0x12340090 00000000 123400a0 00000000 00000000 .* diff --git a/ld/testsuite/ld-x86-64/export-class.exp b/ld/testsuite/ld-x86-64/export-class.exp new file mode 100644 index 0000000..af75b77 --- /dev/null +++ b/ld/testsuite/ld-x86-64/export-class.exp @@ -0,0 +1,93 @@ +# Expect script for symbol export classes, x86-64 variation. +# +# Copyright 2012 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. +# + +# +# Written by Maciej W. Rozycki <macro@codesourcery.com> +# + +# Exclude non-Linux targets; feel free to include your favorite one +# if you like. +if { ![istarget x86_64*-*-linux*] } { + return +} + +proc x86_64_export_class_test { abi flag emul } { + + set testname "x86-64 $abi symbol export class test" + + set dump [string map {32 ../ld-i386/i386 x32 x86-64-x32 64 x86-64-64} $abi] + + set AFLAGS "$flag" + set LDFLAGS "-m$emul" + + # Build an auxiliary shared object with conflicting versioned symbol + # definitions. + run_ld_link_tests [list \ + [list \ + "$testname (auxiliary shared object)" \ + "$LDFLAGS -shared -version-script ../ld-elf/export-class-lib.ver" \ + "$AFLAGS" \ + { ../ld-elf/export-class-lib.s } \ + {} \ + "x86-64-$abi-export-class-lib.so" \ + ] \ + ] + + # Build a static object that pulls symbol definitions. It has to come + # first before the auxiliary shared object and other static objects on + # the linker's command line and hence we need to build it separately. + run_ld_link_tests [list \ + [list \ + "$testname (initial static object)" \ + "$LDFLAGS -r" \ + "$AFLAGS" \ + { ../ld-elf/export-class-ref.s } \ + {} \ + "x86-64-$abi-export-class-ref-r.o" \ + ] \ + ] + + # Build static objects that satisfy symbol dependencies and preempt + # shared-object symbol definitions, and link all the objects built into + # the final shared object. The command-line order of objects linked is + # important to make sure the linker correctly preempts versioned symbols + # from the auxiliary shared object and is as follows: ref, lib, dep, def. + # Get a dump to make sure symbol dependencies are resolved internally. + run_ld_link_tests [list \ + [list \ + "$testname (final shared object)" \ + "$LDFLAGS -shared -Tdata=0x12340000 tmpdir/x86-64-$abi-export-class-ref-r.o tmpdir/x86-64-$abi-export-class-lib.so" \ + "$AFLAGS" \ + { ../ld-elf/export-class-dep.s ../ld-elf/export-class-def.s } \ + [list \ + [list readelf -r $dump-export-class.rd] \ + [list readelf "-x .data" ../ld-i386/i386-export-class.xd] \ + ] \ + "x86-64-$abi-export-class.so" \ + ] \ + ] +} + +set abis { 32 --32 elf_i386 x32 --x32 elf32_x86_64 64 --64 elf_x86_64 } +foreach { abi flag emul } $abis { + x86_64_export_class_test $abi $flag $emul +} diff --git a/ld/testsuite/ld-x86-64/x86-64-64-export-class.rd b/ld/testsuite/ld-x86-64/x86-64-64-export-class.rd new file mode 100644 index 0000000..308e307 --- /dev/null +++ b/ld/testsuite/ld-x86-64/x86-64-64-export-class.rd @@ -0,0 +1,11 @@ +Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries: + * Offset * Info * Type * Sym\. *Value * Sym\. * Name * \+ * Addend +000012340010 000000000008 R_X86_64_RELATIVE 123400a0 +000012340020 000000000008 R_X86_64_RELATIVE 123400a0 +000012340060 000000000008 R_X86_64_RELATIVE 123400a0 +000012340070 000000000008 R_X86_64_RELATIVE 123400a0 +000012340080 000000000008 R_X86_64_RELATIVE 123400a0 +000012340090 000000000008 R_X86_64_RELATIVE 123400a0 +000012340000 [0-9a-f]+00000001 R_X86_64_64 00000000123400a0 protected_baz \+ 0 +000012340040 [0-9a-f]+00000001 R_X86_64_64 00000000123400a0 protected_foo \+ 0 +000012340050 [0-9a-f]+00000001 R_X86_64_64 00000000123400a0 protected_bar \+ 0 diff --git a/ld/testsuite/ld-x86-64/x86-64-x32-export-class.rd b/ld/testsuite/ld-x86-64/x86-64-x32-export-class.rd new file mode 100644 index 0000000..4ea93ba --- /dev/null +++ b/ld/testsuite/ld-x86-64/x86-64-x32-export-class.rd @@ -0,0 +1,11 @@ +Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains [0-9]+ entries: + * Offset * Info * Type * Sym\. *Value * Sym\. * Name * \+ * Addend +12340010 00000008 R_X86_64_RELATIVE 123400a0 +12340020 00000008 R_X86_64_RELATIVE 123400a0 +12340060 00000008 R_X86_64_RELATIVE 123400a0 +12340070 00000008 R_X86_64_RELATIVE 123400a0 +12340080 00000008 R_X86_64_RELATIVE 123400a0 +12340090 00000008 R_X86_64_RELATIVE 123400a0 +12340000 [0-9a-f]+0a R_X86_64_32 123400a0 protected_baz \+ 0 +12340040 [0-9a-f]+0a R_X86_64_32 123400a0 protected_foo \+ 0 +12340050 [0-9a-f]+0a R_X86_64_32 123400a0 protected_bar \+ 0 |