From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27120 invoked by alias); 8 Aug 2012 12:21:27 -0000 Received: (qmail 27099 invoked by uid 22791); 8 Aug 2012 12:21:20 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 08 Aug 2012 12:20:58 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1Sz5Fx-0000Et-SB from Maciej_Rozycki@mentor.com for binutils@sourceware.org; Wed, 08 Aug 2012 05:20:57 -0700 Received: from SVR-IES-FEM-02.mgc.mentorg.com ([137.202.0.106]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Wed, 8 Aug 2012 05:20:57 -0700 Received: from [172.30.3.42] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.1.289.1; Wed, 8 Aug 2012 13:20:54 +0100 Date: Wed, 08 Aug 2012 16:18:00 -0000 From: "Maciej W. Rozycki" To: Subject: [PATCH 3/3] LD/test: Hidden/internal versioned symbol preemption bug Message-ID: User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00162.txt.bz2 Hi, This change adds a number of test cases to verify correct preemption of a versioned dynamic symbol with a protected, hidden and internal static symbol. This covers the bug fixed in this patch series and as an extra bonus also protected symbols that worked correctly already before this fix. Included here are two sets of tests -- a generic one used across all ELF targets known to support shared libraries and making basic checks and a platform specific one including tests that examine ARM, i386, MIPS, Power and x86-64 Linux targets in a greater detail. Maintainers of other targets are encouraged to copy and adjust the platform-specific test script as appropriate and add diagnostic dumps suitable for their platforms. The sources used are the same across all tests; I chose 16 bytes as the original data section alignment to yield good readability of addresses in raw section dumps on one hand and cross-platform compatibility on the other. That turned out insufficient for the hppa64-linux target that makes an odd arrangement of the .data section, where 16 null bytes are prepended via a location pointer adjustment made in the default linker script used, presumably for system specific purposes. As a result one of the generic tests failed. I have addressed this problem by further massaging the alignments and using 32 bytes for the static symbol definitions, taking advantage of the first of the input data sections being 48 bytes in size. As a result extra padding is applied in all cases, on hppa64-linux at the beginning as noted above, and on all the other targets at the end of the first input data section, causing the static symbol definitions to have a consistent address across all targets. I have refrained from cooking up a dedicated linker script instead for this purpose as I consider it too fragile and troublesome for long-term maintenance to collect all the target-specific peculiarities (e.g. the order of output sections, any special extra sections needed, special dynamic symbols, etc.) needed for a correct shared library to be made across all targets, while it's all have been already taken care of in the default script. The tests are run in all cases, not only natively, that has a value for targets that are seldom or never tested in a native configuration (though that does not check if the dynamic linker correctly interprets output produced). The test cases were run across Alan's favourite targets and caused no failures apart from this: i370-linux +FAIL: Symbol export class test (auxiliary shared object) i370-linux +FAIL: Symbol export class test (final shared object) that I am going to ignore. This is specifically caused by a bunch of assertion failures like this: .../i370-linux/ld/ld-new: BFD (GNU Binutils) 2.23.51.20120806 assertion fail .../bfd/elf32-i370.c:969 that is in i370_elf_finish_dynamic_sections annotated as: "XXX hack alert bogus This routine is mostly all junk and almost certainly does the wrong thing. Its here simply because it does just enough to allow glibc-2.1 ld.so to compile & link." and there is no maintainer listed for this platform so I have to conclude that this port is broken (this assertion triggers in many other places throughout the test suite too). OK to apply? 2012-08-08 Maciej W. Rozycki ld/testsuite/ * 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: Run the new tests. * ld-arm/arm-export-class.rd: New test. * ld-arm/arm-export-class.xd: New test. * ld-arm/export-class.exp: Run the new tests. * ld-i386/i386-export-class.rd: New test. * ld-i386/i386-export-class.xd: New test. * ld-i386/export-class.exp: Run the new tests. * 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: Run the new tests. * 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: Run the new tests. * 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: Run the new tests. Maciej binutils-bfd-preempt-indirect-test.diff Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-arm/arm-export-class.rd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-arm/arm-export-class.rd 2012-08-08 02:59:45.340882767 +0100 @@ -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 Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-arm/arm-export-class.xd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-arm/arm-export-class.xd 2012-08-08 03:00:11.990569988 +0100 @@ -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 .* Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-arm/export-class.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-arm/export-class.exp 2012-08-08 02:08:44.331784275 +0100 @@ -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 +# + +# 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" \ + ] \ +] Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class-def.s =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class-def.s 2012-08-08 02:14:02.120599365 +0100 @@ -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: Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class-dep.s =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class-dep.s 2012-08-08 02:34:47.791761106 +0100 @@ -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: Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class-lib.s =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class-lib.s 2012-08-08 02:08:44.331784275 +0100 @@ -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: Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class-lib.ver =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class-lib.ver 2012-08-08 02:08:44.331784275 +0100 @@ -0,0 +1 @@ +GCC_3.0 { global: *_foo; }; Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class-ref.s =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class-ref.s 2012-08-08 02:08:44.331784275 +0100 @@ -0,0 +1,7 @@ + .data + .balign 16 + .dc.a protected_baz + .balign 16 + .dc.a hidden_baz + .balign 16 + .dc.a internal_baz Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class.exp 2012-08-08 02:08:44.331784275 +0100 @@ -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 +# + +# 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" \ + ] \ +] Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class.sd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class.sd 2012-08-08 02:15:28.561806170 +0100 @@ -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 Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class.vd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-elf/export-class.vd 2012-08-08 02:08:44.331784275 +0100 @@ -0,0 +1 @@ +No version information found in this file\. Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-i386/export-class.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-i386/export-class.exp 2012-08-08 02:08:44.331784275 +0100 @@ -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 +# + +# 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" \ + ] \ +] Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-i386/i386-export-class.rd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-i386/i386-export-class.rd 2012-08-08 03:01:48.200536061 +0100 @@ -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 Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-i386/i386-export-class.xd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-i386/i386-export-class.xd 2012-08-08 03:02:12.591807261 +0100 @@ -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 .* Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class.exp 2012-08-08 02:08:44.351767697 +0100 @@ -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 +# + +# 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 +} Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/mips-32-export-class.rd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/mips-32-export-class.rd 2012-08-08 03:02:39.740882903 +0100 @@ -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 * Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/mips-32-export-class.xd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/mips-32-export-class.xd 2012-08-08 03:03:08.000569754 +0100 @@ -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 .* Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/mips-64-export-class.rd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/mips-64-export-class.rd 2012-08-08 03:03:36.210711303 +0100 @@ -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 * Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/mips-64-export-class.xd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/mips-64-export-class.xd 2012-08-08 03:04:02.881592150 +0100 @@ -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 .* Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-powerpc/export-class.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-powerpc/export-class.exp 2012-08-08 02:08:44.351767697 +0100 @@ -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 +# + +# 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 +} Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-powerpc/powerpc-32-export-class.rd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-powerpc/powerpc-32-export-class.rd 2012-08-08 03:04:24.951351359 +0100 @@ -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 Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-powerpc/powerpc-32-export-class.xd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-powerpc/powerpc-32-export-class.xd 2012-08-08 03:04:37.020552167 +0100 @@ -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 .* Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-powerpc/powerpc-64-export-class.rd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-powerpc/powerpc-64-export-class.rd 2012-08-08 03:04:52.441039185 +0100 @@ -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 Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-powerpc/powerpc-64-export-class.xd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-powerpc/powerpc-64-export-class.xd 2012-08-08 03:05:22.890935567 +0100 @@ -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 .* Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-x86-64/export-class.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-x86-64/export-class.exp 2012-08-08 02:08:44.351767697 +0100 @@ -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 +# + +# 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 +} Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-x86-64/x86-64-64-export-class.rd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-x86-64/x86-64-64-export-class.rd 2012-08-08 03:05:48.300882198 +0100 @@ -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 Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-x86-64/x86-64-x32-export-class.rd =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils-fsf-trunk-quilt/ld/testsuite/ld-x86-64/x86-64-x32-export-class.rd 2012-08-08 03:06:04.740867053 +0100 @@ -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