mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-21 04:42:53 +08:00
d981640286
Many of the ld tests are not run for cross builds, in some cases because the test needs to run a newly linked executable, and in others simply because it was easier to write the test for native only. Even when a test needs to run, it's good to compile and link to exercise the linker. So that's what this patch does. I've also rid us of the old ld_link procedure with all the HOSTING_CRT0 etc. setup. It's much simpler to just link with $CC. This does mean that a cross build with cross-compiler installed but no cross C-library will give lots of failures. If that turns out to be too annoying, I guess we can write a tcl procedure to detect it and not run all the extra tests. * Makefile.am (bootstrap): Delete rule. (ld-partial, ld1, ld1-full, ld2, ld3): Likewise. (HOSTING_CRT0, HOSTING_SCRT0): Don't define. (HOSTING_LIBS, HOSTING_SLIBS, HOSTING_EMU): Likewise. * configure.ac (HOSTING_CRT0, HOSTING_SCRT0): Don't define. (HOSTING_LIBS, HOSTING_SLIBS): Likewise. * configure.host (HOSTING_CRT0, HOSTING_LIBS): Don't define. * Makefile.in: Regenerate. * configure: Regenerate. * testsuite/config/default.exp (get_link_files): Delete. (HOSTING_CRT0, HOSTING_SCRT0, HOSTING_LIBS, HOSTING_SLIBS): Don't define. (ld_simple_link): Delete. * testsuite/lib/ld-lib.exp (default_ld_link): Delete (default_ld_simple_link): Rename to default_ld_link. (ld_simple_link_defsyms): Rename to ld_link_defsyms. (run_ld_link_tests): Use ld_link, not ld_simple_link. (run_cc_link_tests): Likewise. (run_ld_link_exec_tests): Use $CC or $CXX to link, not $ld. Don't run exe when not native, and return unsupported. * testsuite/ld-bootstrap/bootstrap.exp: Create gccld1 etc. dirs. Link ld1 etc. using $CC. * testsuite/ld-cdtest/cdtest.exp: Link cdtest using $CC. * testsuite/ld-checks/checks.exp: Use ld_link, not ld_simple_link. * testsuite/ld-cygwin/exe-export.exp: Likewise. * testsuite/ld-elf/binutils.exp: Likewise. * testsuite/ld-elf/eh-group.exp: Likewise. * testsuite/ld-elf/exclude.exp: Likewise. * testsuite/ld-elf/frame.exp: Likewise. * testsuite/ld-elf/sec-to-seg.exp: Likewise. * testsuite/ld-elf/tls_common.exp: Likewise. * testsuite/ld-elfcomm/elfcomm.exp: Likewise. * testsuite/ld-fastcall/fastcall.exp: Likewise. * testsuite/ld-gc/gc.exp: Likewise. * testsuite/ld-ifunc/binutils.exp: Likewise. * testsuite/ld-mep/mep.exp: Likewise. * testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise. * testsuite/ld-mn10300/mn10300.exp: Likewise. * testsuite/ld-nios2/nios2.exp: Likewise. * testsuite/ld-pe/pe-compile.exp: Likewise. * testsuite/ld-pe/pe-run.exp: Likewise. * testsuite/ld-pe/pe-run2.exp: Likewise. * testsuite/ld-plugin/plugin.exp: Likewise. * testsuite/ld-scripts/align.exp: Likewise. * testsuite/ld-scripts/alignof.exp: Likewise. * testsuite/ld-scripts/assert.exp: Likewise. * testsuite/ld-scripts/defined.exp: Likewise. * testsuite/ld-scripts/extern.exp: Likewise. * testsuite/ld-scripts/log2.exp: Likewise. * testsuite/ld-scripts/map-address.exp: Likewise. * testsuite/ld-scripts/phdrs.exp: Likewise. * testsuite/ld-scripts/phdrs2.exp: Likewise. * testsuite/ld-scripts/script.exp: Likewise. * testsuite/ld-scripts/section-flags.exp: Likewise. * testsuite/ld-scripts/sizeof.exp: Likewise. * testsuite/ld-scripts/sysroot-prefix.exp: Likewise. * testsuite/ld-scripts/weak.exp: Likewise. * testsuite/ld-selective/selective.exp: Likewise. * testsuite/ld-sh/sh.exp: Likewise. * testsuite/ld-sh/sh64/relax.exp: Likewise. * testsuite/ld-sh/sh64/relfail.exp: Likewise. * testsuite/ld-srec/srec.exp: Likewise. * testsuite/ld-tic6x/tic6x.exp: Likewise. * testsuite/ld-undefined/weak-undef.exp: Likewise. * testsuite/ld-versados/versados.exp: Likewise. * testsuite/ld-x86-64/dwarfreloc.exp: Likewise. * testsuite/ld-xtensa/coalesce.exp: Likewise. * testsuite/ld-xtensa/diff_overflow.exp: Likewise. * testsuite/ld-xtensa/lcall.exp: Likewise. * testsuite/ld-elf/audit.exp: Run non-native too. * testsuite/ld-elf/compress.exp: Likewise. Replace ld options with gcc -Wl, options. * testsuite/ld-elf/dwarf.exp: Run non-native too. Use ld_link, not ld_simple_link. Add -Wl,--no-as-needed to some tests. * testsuite/ld-elf/elf.exp: Run non-native too. Formatting. * testsuite/ld-elf/indirect.exp: Run non-native too. Add -Wl,--no-as-needed to most tests. * testsuite/ld-elf/shared.exp: Run non-native too. Use braces to simplify quoting. Set run_tests using [list] rather than brace assignment to expand $extralibs. Add -Wl,--no-as-needed to many test. Prefix ld options with -Wl,. (mix_pic_and_non_pic): Don't run exe if not native. * testsuite/ld-elf/wrap.exp: Run non-native too. Add -Wl,--no-as-needed and prefix ld options with -Wl,. * testsuite/ld-elfvers/vers.exp: Run non-native too. Use ld_link, not ld_simple_link. * testsuite/ld-elfvsb/elfvsb.exp: Likewise. (visibility_test): Don't run exe if not native. * testsuite/ld-elfweak/elfweak.exp: Run non-native too. Use ld_link, not ld_simple_link. (build_exec): Don't run exe if not native. * testsuite/ld-ifunc/ifunc.exp: Run non-native too. Use ld_link, not ld_simple_link. Link using $CC. Add -Wl,--no-as-needed to some tests and prefix ld options with -Wl,. Expect GNU for hppa-linux even when no ifuncs. Delete cleanup. * testsuite/ld-pie/pie.exp: Run non-native too. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-shared/shared.exp: Likewise. Use ld_link, not ld_simple_link. (shared_test): Don't run exe if not native. * testsuite/ld-size/size.exp: Run non-native too. Add -Wl,--no-as-needed to some tests. Prefix ld options with -Wl,. * testsuite/ld-unique/unique.exp: Run non-native too. Use ld_link, not ld_simple_link. Link using $CC. Add -Wl,--no-as-needed to some tests and prefix ld options with -Wl,. Expect GNU for hppa-linux even when no unique syms. Delete cleanup. * testsuite/ld-x86-64/tls.exp: Add -Wl,--no-as-needed to some tests and prefix ld options with -Wl,. * testsuite/ld-x86-64/x86-64.exp: Use ld_link, not ld_simple_link. Add -Wl,--no-as-needed to some tests. Prefix ld options with -Wl,.
392 lines
16 KiB
Plaintext
392 lines
16 KiB
Plaintext
# Expect script for ld-plugin tests
|
|
# Copyright (C) 2010-2017 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.
|
|
|
|
# These tests require the plugin API to be configured in.
|
|
if ![check_plugin_api_available] {
|
|
return
|
|
}
|
|
|
|
# And a compiler to be available.
|
|
set can_compile 1
|
|
set failure_kind "unresolved"
|
|
if { [which $CC] == 0 } {
|
|
# Don't fail immediately,
|
|
set can_compile 0
|
|
set failure_kind "unsupported"
|
|
}
|
|
|
|
pass "plugin API enabled"
|
|
|
|
global base_dir
|
|
|
|
# Look for the name we can dlopen in the test plugin's libtool control script.
|
|
set plugin_name [file_contents "$base_dir/libldtestplug.la"]
|
|
set plugin_name [regsub "'.*" [regsub ".*dlname='" "$plugin_name" ""] ""]
|
|
# Even though the API supports plugins it does not mean that the
|
|
# linker was configured with --enable-plugins. Check for that here.
|
|
if { $plugin_name == "" } {
|
|
verbose "The linker is not configured to support plugins"
|
|
return
|
|
}
|
|
verbose "plugin name is '$plugin_name'"
|
|
|
|
set plugin2_name [file_contents "$base_dir/libldtestplug2.la"]
|
|
set plugin2_name [regsub "'.*" [regsub ".*dlname='" "$plugin2_name" ""] ""]
|
|
verbose "plugin2 name is '$plugin2_name'"
|
|
|
|
set plugin3_name [file_contents "$base_dir/libldtestplug3.la"]
|
|
set plugin3_name [regsub "'.*" [regsub ".*dlname='" "$plugin3_name" ""] ""]
|
|
verbose "plugin3 name is '$plugin3_name'"
|
|
|
|
set plugin4_name [file_contents "$base_dir/libldtestplug4.la"]
|
|
set plugin4_name [regsub "'.*" [regsub ".*dlname='" "$plugin4_name" ""] ""]
|
|
verbose "plugin4 name is '$plugin4_name'"
|
|
|
|
# Use libtool to find full path to plugin rather than worrying
|
|
# about run paths or anything like that.
|
|
catch "exec $base_dir/libtool --config" lt_config
|
|
verbose "Full lt config: $lt_config" 3
|
|
# Look for "objdir=.libs"
|
|
regexp -line "^objdir=.*$" "$lt_config" lt_objdir
|
|
verbose "lt_objdir line is '$lt_objdir'" 3
|
|
set lt_objdir [regsub "objdir=" "$lt_objdir" ""]
|
|
set plugin_path "$base_dir/$lt_objdir/$plugin_name"
|
|
set plugin2_path "$base_dir/$lt_objdir/$plugin2_name"
|
|
set plugin3_path "$base_dir/$lt_objdir/$plugin3_name"
|
|
set plugin4_path "$base_dir/$lt_objdir/$plugin4_name"
|
|
verbose "Full plugin path $plugin_path" 2
|
|
verbose "Full plugin2 path $plugin2_path" 2
|
|
verbose "Full plugin3 path $plugin3_path" 2
|
|
verbose "Full plugin4 path $plugin4_path" 2
|
|
|
|
set regclm "-plugin-opt registerclaimfile"
|
|
set regas "-plugin-opt registerallsymbolsread"
|
|
set regassilent "-plugin-opt registerallsymbolsreadsilent"
|
|
set regcln "-plugin-opt registercleanup"
|
|
|
|
if { [istarget m681*-*-*] || [istarget m68hc1*-*-*] || [istarget m9s12x*-*-*] } {
|
|
# otherwise get FAILS due to _.frame
|
|
set CFLAGS "$CFLAGS -fomit-frame-pointer"
|
|
}
|
|
# In order to define symbols in plugin options in the list of tests below,
|
|
# we need to know if the platform prepends an underscore to C symbols,
|
|
# which we find out by compiling the test objects now. If there is any
|
|
# error compiling, we defer reporting it until after the list of tests has
|
|
# been initialised, so that we can use the names in the list to report;
|
|
# otherwise, we scan one of the files with 'nm' and look for a known symbol
|
|
# in the output to see if it is prefixed or not.
|
|
set failed_compile 0
|
|
set _ ""
|
|
set plugin_nm_output ""
|
|
if { $can_compile && \
|
|
(![ld_compile "$CC $CFLAGS" $srcdir/$subdir/main.c tmpdir/main.o] \
|
|
|| ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/func.c tmpdir/func.o] \
|
|
|| ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/text.c tmpdir/text.o] \
|
|
|| ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/pr20070a.c tmpdir/pr20070a.o] \
|
|
|| ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/dummy.s tmpdir/dummy.o] \
|
|
|| ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/pr17973.s tmpdir/pr17973.o]) } {
|
|
# Defer fail until we have list of tests set.
|
|
set failed_compile 1
|
|
}
|
|
|
|
set dotsym 0
|
|
if { $can_compile && !$failed_compile } {
|
|
# Find out if symbols have prefix on this platform before setting tests.
|
|
catch "exec $NM tmpdir/func.o" plugin_nm_output
|
|
if { [regexp "_func" "$plugin_nm_output"] } {
|
|
set _ "_"
|
|
}
|
|
if { [regexp "\\.func" "$plugin_nm_output"] } {
|
|
set dotsym 1
|
|
}
|
|
}
|
|
|
|
set testobjfiles "tmpdir/main.o tmpdir/func.o tmpdir/text.o"
|
|
set testobjfiles_notext "tmpdir/main.o tmpdir/func.o"
|
|
set testsrcfiles "tmpdir/main.o $srcdir/$subdir/func.c tmpdir/text.o"
|
|
set testsrcfiles_notext "tmpdir/main.o $srcdir/$subdir/func.c"
|
|
# Rather than having libs we just define dummy values for anything
|
|
# we may need to link a target exe; we aren't going to run it anyway.
|
|
set libs "[ld_link_defsyms] --defsym ${_}printf=${_}main --defsym ${_}puts=${_}main"
|
|
if { $dotsym } {
|
|
append libs " --defsym .printf=.main --defsym .puts=.main"
|
|
}
|
|
|
|
set plugin_tests [list \
|
|
[list "load plugin" "-plugin $plugin_path \
|
|
$testobjfiles $libs" "" "" "" {{ld plugin-1.d}} "main.x" ] \
|
|
[list "fail plugin onload" "-plugin $plugin_path -plugin-opt failonload \
|
|
$testobjfiles $libs" "" "" "" {{ld plugin-2.d}} "main.x" ] \
|
|
[list "fail plugin allsymbolsread" "-plugin $plugin_path $regas \
|
|
-plugin-opt failallsymbolsread \
|
|
$testobjfiles $libs" "" "" "" {{ld plugin-3.d}} "main.x" ] \
|
|
[list "fail plugin cleanup" "-plugin $plugin_path -plugin-opt failcleanup \
|
|
$regcln \
|
|
$testobjfiles $libs" "" "" "" {{ld plugin-4.d}} "main.x" ] \
|
|
[list "plugin all hooks" "-plugin $plugin_path $regclm $regas $regcln \
|
|
$testobjfiles $libs" "" "" "" {{ld plugin-5.d}} "main.x" ] \
|
|
[list "plugin claimfile lost symbol" "-plugin $plugin_path $regclm \
|
|
$regas $regcln -plugin-opt claim:tmpdir/func.o \
|
|
$testobjfiles $libs" "" "" "" {{ld plugin-6.d}} "main.x" ] \
|
|
[list "plugin claimfile replace symbol" "-plugin $plugin_path $regclm \
|
|
$regas $regcln -plugin-opt claim:tmpdir/func.o \
|
|
-plugin-opt sym:${_}func::0:0:0 \
|
|
$testobjfiles $libs" "" "" "" {{ld plugin-7.d}} "main.x" ] \
|
|
[list "plugin claimfile resolve symbol" "-plugin $plugin_path $regclm \
|
|
$regas $regcln -plugin-opt claim:tmpdir/func.o \
|
|
-plugin-opt sym:${_}func::0:0:0 \
|
|
-plugin-opt sym:${_}func2::0:0:0 \
|
|
-plugin-opt dumpresolutions \
|
|
$testobjfiles $libs" "" "" "" {{ld plugin-8.d}} "main.x" ] \
|
|
[list "plugin claimfile replace file" "-plugin $plugin_path $regclm \
|
|
$regas $regcln -plugin-opt claim:tmpdir/func.o \
|
|
-plugin-opt sym:${_}func::0:0:0 \
|
|
-plugin-opt sym:${_}func2::0:0:0 \
|
|
-plugin-opt dumpresolutions \
|
|
-plugin-opt add:tmpdir/func.o \
|
|
$testobjfiles $libs" "" "" "" {{ld plugin-9.d}} "main.x" ] \
|
|
[list "load plugin with source" "-plugin $plugin_path $regclm \
|
|
-plugin-opt claim:$srcdir/$subdir/func.c \
|
|
$testsrcfiles $libs" "" "" "" {{ld plugin-13.d}} "main.x" ] \
|
|
[list "plugin claimfile lost symbol with source" \
|
|
"-plugin $plugin_path $regclm $regas $regcln \
|
|
-plugin-opt claim:$srcdir/$subdir/func.c \
|
|
$testsrcfiles $libs" "" "" "" {{ld plugin-14.d}} "main.x" ] \
|
|
[list "plugin claimfile replace symbol with source" \
|
|
"-plugin $plugin_path $regclm $regas $regcln \
|
|
-plugin-opt claim:$srcdir/$subdir/func.c \
|
|
-plugin-opt sym:${_}func::0:0:0 \
|
|
$testsrcfiles $libs" "" "" "" {{ld plugin-15.d}} "main.x" ] \
|
|
[list "plugin claimfile resolve symbol with source" \
|
|
"-plugin $plugin_path $regclm $regas $regcln \
|
|
-plugin-opt claim:$srcdir/$subdir/func.c \
|
|
-plugin-opt sym:${_}func::0:0:0 \
|
|
-plugin-opt sym:${_}func2::0:0:0 \
|
|
-plugin-opt dumpresolutions \
|
|
$testsrcfiles $libs" "" "" "" {{ld plugin-16.d}} "main.x" ] \
|
|
[list "plugin claimfile replace file with source" \
|
|
"-plugin $plugin_path $regclm $regas $regcln \
|
|
-plugin-opt claim:$srcdir/$subdir/func.c \
|
|
-plugin-opt sym:${_}func::0:0:0 \
|
|
-plugin-opt sym:${_}func2::0:0:0 \
|
|
-plugin-opt dumpresolutions \
|
|
-plugin-opt add:tmpdir/func.o \
|
|
$testsrcfiles $libs" "" "" "" {{ld plugin-17.d}} "main.x" ] \
|
|
[list "load plugin with source not claimed" "-plugin $plugin_path $regclm \
|
|
$testsrcfiles $libs" "" "" "" {{ld plugin-26.d}} "main.x" ] \
|
|
[list "plugin fatal error" "-plugin $plugin2_path -plugin-opt fatal \
|
|
$testobjfiles $libs" "" "" "" {{ld plugin-27.d}} "main.x" ] \
|
|
[list "plugin error" "-plugin $plugin2_path -plugin-opt error \
|
|
$testobjfiles $libs" "" "" "" {{ld plugin-28.d}} "main.x" ] \
|
|
[list "plugin warning" "-plugin $plugin2_path -plugin-opt warning \
|
|
$testobjfiles $libs" "" "" "" {{ld plugin-29.d}} "main.x" ] \
|
|
]
|
|
|
|
if [check_shared_lib_support] {
|
|
lappend plugin_tests [list "PR ld/17973" "-plugin $plugin2_path -shared $regassilent \
|
|
-plugin-opt add:tmpdir/pr17973.o \
|
|
tmpdir/dummy.o" "" "" "" {{readelf -sW pr17973.d}} "main.x" ]
|
|
}
|
|
|
|
|
|
set plugin_lib_tests [list \
|
|
[list "plugin ignore lib" "-plugin $plugin_path $regclm \
|
|
$regas $regcln -plugin-opt claim:tmpdir/func.o \
|
|
-plugin-opt sym:${_}func::0:0:0 \
|
|
-plugin-opt sym:${_}func2::0:0:0 \
|
|
-plugin-opt dumpresolutions \
|
|
-plugin-opt add:tmpdir/func.o \
|
|
$testobjfiles_notext -Ltmpdir -ltext $libs" "" "" "" {{ld plugin-10.d}} "main.x" ] \
|
|
[list "plugin claimfile replace lib" "-plugin $plugin_path $regclm \
|
|
$regas $regcln -plugin-opt claim:tmpdir/func.o \
|
|
-plugin-opt sym:${_}func::0:0:0 \
|
|
-plugin-opt sym:${_}func2::0:0:0 \
|
|
-plugin-opt dumpresolutions \
|
|
-plugin-opt add:tmpdir/func.o \
|
|
-plugin-opt claim:tmpdir/libtext.a \
|
|
-plugin-opt sym:${_}text::0:0:0 \
|
|
-plugin-opt add:tmpdir/text.o \
|
|
$testobjfiles_notext -Ltmpdir -ltext $libs" "" "" "" {{ld plugin-11.d}} "main.x" ] \
|
|
[list "plugin ignore lib with source" \
|
|
"-plugin $plugin_path $regclm $regas $regcln \
|
|
-plugin-opt claim:$srcdir/$subdir/func.c \
|
|
-plugin-opt sym:${_}func::0:0:0 \
|
|
-plugin-opt sym:${_}func2::0:0:0 \
|
|
-plugin-opt dumpresolutions \
|
|
-plugin-opt add:tmpdir/func.o \
|
|
$testsrcfiles_notext -Ltmpdir -ltext $libs" "" "" "" {{ld plugin-18.d}} "main.x" ] \
|
|
[list "plugin claimfile replace lib with source" \
|
|
"-plugin $plugin_path $regclm $regas $regcln \
|
|
-plugin-opt claim:$srcdir/$subdir/func.c \
|
|
-plugin-opt sym:${_}func::0:0:0 \
|
|
-plugin-opt sym:${_}func2::0:0:0 \
|
|
-plugin-opt dumpresolutions \
|
|
-plugin-opt add:tmpdir/func.o \
|
|
-plugin-opt claim:tmpdir/libtext.a \
|
|
-plugin-opt sym:${_}text::0:0:0 \
|
|
-plugin-opt add:tmpdir/text.o \
|
|
$testsrcfiles_notext -Ltmpdir -ltext $libs" "" "" "" {{ld plugin-19.d}} "main.x" ] \
|
|
[list "plugin with empty archive" \
|
|
"-plugin $plugin_path $regclm \
|
|
-plugin-opt read:8 \
|
|
$testobjfiles tmpdir/libempty.a $libs" "" "" "" {{ld plugin-30.d}} "main.x" ] \
|
|
]
|
|
|
|
set plugin_extra_elf_tests [list \
|
|
[list "plugin set symbol visibility" "-plugin $plugin_path $regclm \
|
|
$regas $regcln -plugin-opt claim:tmpdir/func.o \
|
|
-plugin-opt sym:${_}func::0:0:0 \
|
|
-plugin-opt sym:${_}func1::0:1:0 \
|
|
-plugin-opt sym:${_}func2::0:2:0 \
|
|
-plugin-opt sym:${_}func3::0:3:0 \
|
|
-plugin-opt dumpresolutions \
|
|
-plugin-opt add:tmpdir/func.o \
|
|
-plugin-opt add:tmpdir/func1p.o \
|
|
-plugin-opt add:tmpdir/func2i.o \
|
|
-plugin-opt add:tmpdir/func3h.o \
|
|
$testobjfiles $libs --verbose=2" "" "" "" {{ld plugin-12.d} \
|
|
{readelf -s plugin-vis-1.d}} "main.x" ] \
|
|
[list "plugin set symbol visibility with source" \
|
|
"-plugin $plugin_path $regclm $regas $regcln \
|
|
-plugin-opt claim:$srcdir/$subdir/func.c \
|
|
-plugin-opt sym:${_}func::0:0:0 \
|
|
-plugin-opt sym:${_}func1::0:1:0 \
|
|
-plugin-opt sym:${_}func2::0:2:0 \
|
|
-plugin-opt sym:${_}func3::0:3:0 \
|
|
-plugin-opt dumpresolutions \
|
|
-plugin-opt add:tmpdir/func.o \
|
|
-plugin-opt add:tmpdir/func1p.o \
|
|
-plugin-opt add:tmpdir/func2i.o \
|
|
-plugin-opt add:tmpdir/func3h.o \
|
|
$testsrcfiles $libs --verbose=2" "" "" "" {{ld plugin-12.d} \
|
|
{readelf -s plugin-vis-1.d}} "main.x" ] \
|
|
]
|
|
|
|
if { !$can_compile || $failed_compile } {
|
|
foreach testitem $plugin_tests {
|
|
$failure_kind [lindex $testitem 0]
|
|
}
|
|
if { [is_elf_format] } {
|
|
foreach testitem $plugin_extra_elf_tests {
|
|
$failure_kind [lindex $testitem 0]
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
run_ld_link_tests $plugin_tests
|
|
|
|
if { [is_elf_format] \
|
|
&& [ld_compile "$CC $CFLAGS" $srcdir/$subdir/func1p.c tmpdir/func1p.o] \
|
|
&& [ld_compile "$CC $CFLAGS" $srcdir/$subdir/func2i.c tmpdir/func2i.o] \
|
|
&& [ld_compile "$CC $CFLAGS" $srcdir/$subdir/func3h.c tmpdir/func3h.o] } {
|
|
run_ld_link_tests $plugin_extra_elf_tests
|
|
}
|
|
|
|
if {![ar_simple_create $ar "" "tmpdir/libtext.a" "tmpdir/text.o"] || \
|
|
![ar_simple_create $ar "" "tmpdir/libempty.a" ""]} {
|
|
foreach testitem $plugin_lib_tests {
|
|
unresolved [lindex $testitem 0]
|
|
}
|
|
} else {
|
|
run_ld_link_tests $plugin_lib_tests
|
|
}
|
|
|
|
set plugin_src_tests [list \
|
|
[list "plugin 2 with source lib" \
|
|
"-plugin $plugin2_path $regclm $regas $regcln \
|
|
-plugin-opt dumpresolutions \
|
|
tmpdir/main.o -Ltmpdir -ltext -lfunc $libs" "" "" "" {{ld plugin-20.d}} "main.x" ] \
|
|
[list "load plugin 2 with source" \
|
|
"-plugin $plugin2_path $regclm $regas $regcln \
|
|
-plugin-opt dumpresolutions \
|
|
$testsrcfiles $libs" "" "" "" {{ld plugin-21.d}} "main.x" ] \
|
|
[list "load plugin 2 with source and -r" \
|
|
"-r -plugin $plugin2_path $regclm $regas $regcln \
|
|
-plugin-opt dumpresolutions \
|
|
$testsrcfiles $libs" "" "" "" {{ld plugin-24.d}} "main.x" ] \
|
|
[list "plugin 3 with source lib" \
|
|
"-plugin $plugin3_path $regclm $regas $regcln \
|
|
-plugin-opt dumpresolutions \
|
|
tmpdir/main.o -Ltmpdir -ltext -lfunc $libs" "" "" "" {{ld plugin-22.d}} "main.x" ] \
|
|
[list "load plugin 3 with source" \
|
|
"-plugin $plugin3_path $regclm $regas $regcln \
|
|
-plugin-opt dumpresolutions \
|
|
$testsrcfiles $libs" "" "" "" {{ld plugin-23.d}} "main.x" ] \
|
|
[list "load plugin 3 with source and -r" \
|
|
"-r -plugin $plugin3_path $regclm $regas $regcln \
|
|
-plugin-opt dumpresolutions \
|
|
$testsrcfiles $libs" "" "" "" {{ld plugin-25.d}} "main.x" ] \
|
|
]
|
|
|
|
# Check if nm --plugin works.
|
|
set testname "nm --plugin"
|
|
set nm_plugin "$NM --plugin $plugin2_path $srcdir/$subdir/func.c"
|
|
catch "exec $nm_plugin" plugin_nm_output
|
|
send_log "$nm_plugin\n"
|
|
send_log "$plugin_nm_output\n"
|
|
if { [regexp "0+ T func" "$plugin_nm_output"] &&
|
|
[regexp "0+ T _func" "$plugin_nm_output"] } {
|
|
pass $testname
|
|
} else {
|
|
fail $testname
|
|
}
|
|
|
|
# Check if ar --plugin works.
|
|
file delete tmpdir/libfunc.a
|
|
if [ar_simple_create $ar "--plugin $plugin2_path" "tmpdir/libfunc.a" \
|
|
"tmpdir/main.o $srcdir/$subdir/func.c"] {
|
|
set testname "ar --plugin"
|
|
set nm_plugin "$NM -s --plugin $plugin2_path tmpdir/libfunc.a"
|
|
catch "exec $nm_plugin" plugin_nm_output
|
|
send_log "$nm_plugin\n"
|
|
send_log "$plugin_nm_output\n"
|
|
if { [regexp "func in func.c" "$plugin_nm_output"] &&
|
|
[regexp "_func in func.c" "$plugin_nm_output"] } {
|
|
pass $testname
|
|
run_ld_link_tests $plugin_src_tests
|
|
} else {
|
|
fail $testname
|
|
}
|
|
} else {
|
|
foreach testitem $plugin_src_tests {
|
|
unresolved [lindex $testitem 0]
|
|
}
|
|
}
|
|
|
|
file delete tmpdir/libpr20070.a
|
|
if [ar_simple_create $ar "--plugin $plugin4_path" "tmpdir/libpr20070.a" \
|
|
"$srcdir/$subdir/pr20070b.c"] {
|
|
run_ld_link_tests [list \
|
|
[list \
|
|
"PR ld/20070" \
|
|
"-Bstatic -plugin $plugin4_path $regclm \
|
|
$regas $regcln \
|
|
-plugin-opt claim:$srcdir/$subdir/pr20070b.c \
|
|
-plugin-opt claim:tmpdir/libpr20070.a \
|
|
-plugin-opt dumpresolutions \
|
|
tmpdir/pr20070a.o tmpdir/text.o tmpdir/libpr20070.a $libs" \
|
|
"" "" "" {{ld pr20070.d}} "pr20070.x" \
|
|
] \
|
|
]
|
|
} else {
|
|
unresolved "PR ld/20070"
|
|
}
|