OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [ld/] [testsuite/] [ld-plugin/] [plugin.exp] - Blame information for rev 94

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 94 khays
# Expect script for ld-plugin tests
2
#   Copyright 2010
3
#   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
# These tests require the plugin API to be configured in.
23
if ![check_plugin_api_available] {
24
    return
25
}
26
 
27
# And a compiler to be available.
28
set can_compile 1
29
set failure_kind "unresolved"
30
if { [which $CC] == 0 } {
31
  # Don't fail immediately,
32
  set can_compile 0
33
  set failure_kind "unsupported"
34
}
35
 
36
pass "plugin API enabled"
37
 
38
global base_dir
39
 
40
# Look for the name we can dlopen in the test plugin's libtool control script.
41
set plugin_name [file_contents "$base_dir/libldtestplug.la"]
42
set plugin_name [regsub "'.*" [regsub ".*dlname='" "$plugin_name" ""] ""]
43
verbose "plugin name is '$plugin_name'"
44
 
45
# Use libtool to find full path to plugin rather than worrying
46
# about run paths or anything like that.
47
catch "exec $base_dir/libtool --config" lt_config
48
verbose "Full lt config: $lt_config" 3
49
# Look for "objdir=.libs"
50
regexp -line "^objdir=.*$" "$lt_config" lt_objdir
51
verbose "lt_objdir line is '$lt_objdir'" 3
52
set lt_objdir [regsub "objdir=" "$lt_objdir" ""]
53
set plugin_path "$base_dir/$lt_objdir/$plugin_name"
54
verbose "Full plugin path $plugin_path" 2
55
 
56
set regclm "-plugin-opt registerclaimfile"
57
set regas "-plugin-opt registerallsymbolsread"
58
set regcln "-plugin-opt registercleanup"
59
 
60
# In order to define symbols in plugin options in the list of tests below,
61
# we need to know if the platform prepends an underscore to C symbols,
62
# which we find out by compiling the test objects now.  If there is any
63
# error compiling, we defer reporting it until after the list of tests has
64
# been initialised, so that we can use the names in the list to report;
65
# otherwise, we scan one of the files with 'nm' and look for a known symbol
66
# in the output to see if it is prefixed or not.
67
set failed_compile 0
68
set _ ""
69
set plugin_nm_output ""
70
if { $can_compile && \
71
        (![ld_compile "$CC $CFLAGS" $srcdir/$subdir/main.c tmpdir/main.o] \
72
        || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/func.c tmpdir/func.o] \
73
        || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/text.c tmpdir/text.o]) } {
74
    # Defer fail until we have list of tests set.
75
    set failed_compile 1
76
}
77
 
78
if { $can_compile && !$failed_compile } {
79
    # Find out if symbols have prefix on this platform before setting tests.
80
    catch "exec $NM tmpdir/func.o" plugin_nm_output
81
    if { [regexp "_func" "$plugin_nm_output"] } {
82
        set _ "_"
83
    }
84
}
85
 
86
set testobjfiles "tmpdir/main.o tmpdir/func.o tmpdir/text.o"
87
set testobjfiles_notext "tmpdir/main.o tmpdir/func.o"
88
# Rather than having libs we just define dummy values for anything
89
# we may need to link a target exe; we aren't going to run it anyway.
90
set libs "[ld_simple_link_defsyms] --defsym ${_}printf=${_}main --defsym ${_}puts=${_}main"
91
 
92
set plugin_tests [list \
93
    [list "load plugin" "-plugin $plugin_path \
94
    $testobjfiles $libs" "" "" {{ld plugin-1.d}} "main.x" ] \
95
    [list "fail plugin onload" "-plugin $plugin_path -plugin-opt failonload \
96
    $testobjfiles $libs" "" "" {{ld plugin-2.d}} "main.x" ] \
97
    [list "fail plugin allsymbolsread" "-plugin $plugin_path $regas \
98
                        -plugin-opt failallsymbolsread \
99
    $testobjfiles $libs" "" "" {{ld plugin-3.d}} "main.x" ] \
100
    [list "fail plugin cleanup" "-plugin $plugin_path -plugin-opt failcleanup \
101
                        $regcln \
102
    $testobjfiles $libs" "" "" {{ld plugin-4.d}} "main.x" ] \
103
    [list "plugin all hooks" "-plugin $plugin_path $regclm $regas $regcln \
104
    $testobjfiles $libs" "" "" {{ld plugin-5.d}} "main.x" ] \
105
    [list "plugin claimfile lost symbol" "-plugin $plugin_path $regclm \
106
                        $regas $regcln -plugin-opt claim:tmpdir/func.o \
107
    $testobjfiles $libs" "" "" {{ld plugin-6.d}} "main.x" ] \
108
    [list "plugin claimfile replace symbol" "-plugin $plugin_path $regclm \
109
                        $regas $regcln -plugin-opt claim:tmpdir/func.o \
110
                        -plugin-opt sym:${_}func::0:0:0 \
111
    $testobjfiles $libs" "" "" {{ld plugin-7.d}} "main.x" ] \
112
    [list "plugin claimfile resolve symbol" "-plugin $plugin_path $regclm \
113
                        $regas $regcln -plugin-opt claim:tmpdir/func.o \
114
                        -plugin-opt sym:${_}func::0:0:0 \
115
                        -plugin-opt sym:${_}func2::0:0:0 \
116
                        -plugin-opt dumpresolutions \
117
    $testobjfiles $libs" "" "" {{ld plugin-8.d}} "main.x" ] \
118
    [list "plugin claimfile replace file" "-plugin $plugin_path $regclm \
119
                        $regas $regcln -plugin-opt claim:tmpdir/func.o \
120
                        -plugin-opt sym:${_}func::0:0:0 \
121
                        -plugin-opt sym:${_}func2::0:0:0 \
122
                        -plugin-opt dumpresolutions \
123
                        -plugin-opt add:tmpdir/func.o \
124
    $testobjfiles $libs" "" "" {{ld plugin-9.d}} "main.x" ] \
125
]
126
 
127
set plugin_lib_tests [list \
128
    [list "plugin ignore lib" "-plugin $plugin_path $regclm \
129
                        $regas $regcln -plugin-opt claim:tmpdir/func.o \
130
                        -plugin-opt sym:${_}func::0:0:0 \
131
                        -plugin-opt sym:${_}func2::0:0:0 \
132
                        -plugin-opt dumpresolutions \
133
                        -plugin-opt add:tmpdir/func.o \
134
    $testobjfiles_notext -Ltmpdir -ltext $libs" "" "" {{ld plugin-10.d}} "main.x" ] \
135
    [list "plugin claimfile replace lib" "-plugin $plugin_path $regclm \
136
                        $regas $regcln -plugin-opt claim:tmpdir/func.o \
137
                        -plugin-opt sym:${_}func::0:0:0 \
138
                        -plugin-opt sym:${_}func2::0:0:0 \
139
                        -plugin-opt dumpresolutions \
140
                        -plugin-opt add:tmpdir/func.o \
141
                        -plugin-opt claim:tmpdir/libtext.a \
142
                        -plugin-opt sym:${_}text::0:0:0 \
143
                        -plugin-opt add:tmpdir/text.o \
144
    $testobjfiles_notext -Ltmpdir -ltext $libs" "" "" {{ld plugin-11.d}} "main.x" ] \
145
]
146
 
147
set plugin_extra_elf_tests [list \
148
    [list "plugin set symbol visibility" "-plugin $plugin_path $regclm \
149
                        $regas $regcln -plugin-opt claim:tmpdir/func.o \
150
                        -plugin-opt sym:${_}func::0:0:0 \
151
                        -plugin-opt sym:${_}func1::0:1:0 \
152
                        -plugin-opt sym:${_}func2::0:2:0 \
153
                        -plugin-opt sym:${_}func3::0:3:0 \
154
                        -plugin-opt dumpresolutions \
155
                        -plugin-opt add:tmpdir/func.o \
156
    $testobjfiles $libs --verbose=2" "" "" {{ld plugin-12.d}} "main.x" ] \
157
]
158
 
159
if { !$can_compile || $failed_compile } {
160
    foreach testitem $plugin_tests {
161
        $failure_kind [lindex $testitem 0]
162
    }
163
    if { [is_elf_format] } {
164
        foreach testitem $plugin_extra_elf_tests {
165
            $failure_kind [lindex $testitem 0]
166
        }
167
    }
168
    return
169
}
170
 
171
run_ld_link_tests $plugin_tests
172
 
173
if { [is_elf_format] } {
174
    run_ld_link_tests $plugin_extra_elf_tests
175
}
176
 
177
if ![ar_simple_create $ar "" "tmpdir/libtext.a" "tmpdir/text.o"] {
178
    foreach testitem $plugin_lib_tests {
179
        unresolved [lindex $testitem 0]
180
    }
181
} else {
182
    run_ld_link_tests $plugin_lib_tests
183
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.