1# Expect script for symbol export classes, MIPS variation.
2#
3# Copyright (C) 2012-2021 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 mips*-*-linux*] } {
30    return
31}
32
33proc mips_export_class_test { abi flag emul } {
34
35    set testname "MIPS $abi symbol export class test"
36
37    set dump [string map {o32 32 n32 32 n64 64} $abi]
38
39    set AFLAGS "$flag -EB"
40    set LDFLAGS "-m$emul"
41
42    # Build an auxiliary shared object with conflicting versioned symbol
43    # definitions.
44    run_ld_link_tests [list \
45	[list \
46	    "$testname (auxiliary shared object)" \
47	    "$LDFLAGS -shared -version-script ../ld-elf/export-class-lib.ver" "" \
48	    "$AFLAGS" \
49	    { ../ld-elf/export-class-lib.s } \
50	    {} \
51	    "mips-$abi-export-class-lib.so" \
52	] \
53    ]
54
55    # Build a static object that pulls symbol definitions.  It has to come
56    # first before the auxiliary shared object and other static objects on
57    # the linker's command line and hence we need to build it separately.
58    run_ld_link_tests [list \
59	[list \
60	    "$testname (initial static object)" \
61	    "$LDFLAGS -r" "" \
62	    "$AFLAGS" \
63	    { ../ld-elf/export-class-ref.s } \
64	    {} \
65	    "mips-$abi-export-class-ref-r.o" \
66	] \
67    ]
68
69    # Build static objects that satisfy symbol dependencies and preempt
70    # shared-object symbol definitions, and link all the objects built into
71    # the final shared object.  The command-line order of objects linked is
72    # important to make sure the linker correctly preempts versioned symbols
73    # from the auxiliary shared object and is as follows: ref, lib, dep, def.
74    # Get a dump to make sure symbol dependencies are resolved internally.
75    run_ld_link_tests [list \
76	[list \
77	    "$testname (final shared object)" \
78	    "$LDFLAGS -shared -Tdata=0x12340000 tmpdir/mips-$abi-export-class-ref-r.o tmpdir/mips-$abi-export-class-lib.so" "" \
79	    "$AFLAGS" \
80	    { ../ld-elf/export-class-dep.s ../ld-elf/export-class-def.s } \
81	    [list \
82		[list readelf -r mips-$dump-export-class.rd] \
83		[list readelf "-x .data" mips-$dump-export-class.xd] \
84	    ] \
85	    "mips-$abi-export-class.so" \
86	] \
87    ]
88}
89
90# For targets that default to a specific ISA (instead of "from-abi"),
91# the 64-bit -march option is required to override it, like for
92# "mipsisa32r2el-*-*".
93set abis { o32 -32 elf32btsmip n32 "-n32 -march=mips3" elf32btsmipn32 n64 "-64 -march=mips3" elf64btsmip }
94foreach { abi flag emul } $abis {
95    mips_export_class_test $abi $flag $emul
96}
97