1# Expect script for symbol export classes, PowerPC variation.
2#
3# Copyright (C) 2012-2016 Free Software Foundation, Inc.
4#
5# This file is part of the GNU Binutils.
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20# MA 02110-1301, USA.
21#
22
23#
24# Written by Maciej W. Rozycki <macro@codesourcery.com>
25#
26
27# Exclude non-Linux targets; feel free to include your favorite one
28# if you like.
29if { ![istarget powerpc*-*-linux*] } {
30    return
31}
32
33proc powerpc_export_class_test { abi endian emul } {
34
35    set testname "PowerPC $abi $endian symbol export class test"
36
37    set AFLAGS "-a$abi -$endian"
38    set LDFLAGS "-m$emul"
39
40    # Build an auxiliary shared object with conflicting versioned symbol
41    # definitions.
42    run_ld_link_tests [list \
43	[list \
44	    "$testname (auxiliary shared object)" \
45	    "$LDFLAGS -shared -version-script ../ld-elf/export-class-lib.ver" "" \
46	    "$AFLAGS" \
47	    { ../ld-elf/export-class-lib.s } \
48	    {} \
49	    "powerpc-$abi-export-class-lib.so" \
50	] \
51    ]
52
53    # Build a static object that pulls symbol definitions.  It has to come
54    # first before the auxiliary shared object and other static objects on
55    # the linker's command line and hence we need to build it separately.
56    run_ld_link_tests [list \
57	[list \
58	    "$testname (initial static object)" \
59	    "$LDFLAGS -r" "" \
60	    "$AFLAGS" \
61	    { ../ld-elf/export-class-ref.s } \
62	    {} \
63	    "powerpc-$abi-export-class-ref-r.o" \
64	] \
65    ]
66
67    # Build static objects that satisfy symbol dependencies and preempt
68    # shared-object symbol definitions, and link all the objects built into
69    # the final shared object.  The command-line order of objects linked is
70    # important to make sure the linker correctly preempts versioned symbols
71    # from the auxiliary shared object and is as follows: ref, lib, dep, def.
72    # Get a dump to make sure symbol dependencies are resolved internally.
73    run_ld_link_tests [list \
74	[list \
75	    "$testname (final shared object)" \
76	    "$LDFLAGS -shared -Tdata=0x12340000 tmpdir/powerpc-$abi-export-class-ref-r.o tmpdir/powerpc-$abi-export-class-lib.so" "" \
77	    "$AFLAGS" \
78	    { ../ld-elf/export-class-dep.s ../ld-elf/export-class-def.s } \
79	    [list \
80		[list readelf -r powerpc-$abi-export-class.rd] \
81		[list readelf "-x .data" powerpc-$abi-export-class.xd] \
82	    ] \
83	    "powerpc-$abi-export-class.so" \
84	] \
85    ]
86}
87
88set abis { 32 be elf32ppclinux 32 le elf32lppclinux 64 be elf64ppc 64 le elf64lppc }
89
90global ld
91catch "exec $ld --help | grep emulations" ldemul
92
93foreach { abi endian emul } $abis {
94    if { [string first $emul $ldemul] != -1 } then {
95	powerpc_export_class_test $abi $endian $emul
96    }
97}
98