OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.18.50/] [ld/] [testsuite/] [ld-cygwin/] [exe-export.exp] - Diff between revs 38 and 156

Only display areas with differences | Details | Blame | View Log

Rev 38 Rev 156
# Expect script for export table in executables tests
# Expect script for export table in executables tests
#   Copyright 2003, 2007
#   Copyright 2003, 2007
#   Free Software Foundation, Inc.
#   Free Software Foundation, Inc.
#
#
# This file is part of the GNU Binutils.
# This file is part of the GNU Binutils.
#
#
# This program is free software; you can redistribute it and/or modify
# 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
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
# MA 02110-1301, USA.
# MA 02110-1301, USA.
#
#
# Written by Fabrizio Gennari 
# Written by Fabrizio Gennari 
# Based on auto-import.exp  by Ralf.Habacker@freenet.de
# Based on auto-import.exp  by Ralf.Habacker@freenet.de
#
#
# This test can only be run on a cygwin platforms.
# This test can only be run on a cygwin platforms.
if {![istarget *-pc-cygwin]} {
if {![istarget *-pc-cygwin]} {
    verbose "Not a cygwin target."
    verbose "Not a cygwin target."
    return
    return
}
}
# No compiler, no test.
# No compiler, no test.
if { [which $CC] == 0 } {
if { [which $CC] == 0 } {
    untested "Exe export test (no compiler available)"
    untested "Exe export test (no compiler available)"
    return
    return
}
}
proc run_dlltool { lib_file def_file } {
proc run_dlltool { lib_file def_file } {
    global dlltool
    global dlltool
    global base_dir
    global base_dir
    global as
    global as
    if ![info exists dlltool] then {
    if ![info exists dlltool] then {
        set dlltool [findfile $base_dir/../binutils/dlltool]
        set dlltool [findfile $base_dir/../binutils/dlltool]
    }
    }
    if { [which $dlltool] == 0 } then {
    if { [which $dlltool] == 0 } then {
        verbose "$dlltool does not exist"
        verbose "$dlltool does not exist"
        return 0
        return 0
    }
    }
    verbose "$dlltool --as $as -l $lib_file -d $def_file"
    verbose "$dlltool --as $as -l $lib_file -d $def_file"
    catch "exec $dlltool --as $as -l $lib_file -d $def_file" dlltool_output
    catch "exec $dlltool --as $as -l $lib_file -d $def_file" dlltool_output
    #remove empty lines
    #remove empty lines
    regsub -all "\n+" $dlltool_output "" dlltool_output
    regsub -all "\n+" $dlltool_output "" dlltool_output
    if [string match "" $dlltool_output] then {
    if [string match "" $dlltool_output] then {
        return 1
        return 1
    }
    }
    verbose -log "$dlltool_output"
    verbose -log "$dlltool_output"
    return 0
    return 0
}
}
# ld_special_link
# ld_special_link
#       A copy of ld_simple_link (from ld-lib.exp) with extra
#       A copy of ld_simple_link (from ld-lib.exp) with extra
#       code to strip warnings about creating libraries.
#       code to strip warnings about creating libraries.
#
#
proc ld_special_link { ld target objects } {
proc ld_special_link { ld target objects } {
    global host_triplet
    global host_triplet
    global link_output
    global link_output
    if { [which $ld] == 0 } then {
    if { [which $ld] == 0 } then {
        verbose "$ld does not exist"
        verbose "$ld does not exist"
        return 0
        return 0
    }
    }
    if [is_endian_output_format $objects] then {
    if [is_endian_output_format $objects] then {
        set flags [big_or_little_endian]
        set flags [big_or_little_endian]
    } else {
    } else {
        set flags ""
        set flags ""
    }
    }
    verbose -log "$ld $flags -o $target $objects"
    verbose -log "$ld $flags -o $target $objects"
    catch "exec $ld $flags -o $target $objects" link_output
    catch "exec $ld $flags -o $target $objects" link_output
    set exec_output [prune_warnings $link_output]
    set exec_output [prune_warnings $link_output]
    # We don't care if we get a warning about a non-existent start
    # We don't care if we get a warning about a non-existent start
    # symbol, since the default linker script might use ENTRY.
    # symbol, since the default linker script might use ENTRY.
    regsub -all "(^|\n)(\[^\n\]*: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
    regsub -all "(^|\n)(\[^\n\]*: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
    # We don't care if we get a message about creating a library file.
    # We don't care if we get a message about creating a library file.
    regsub -all "(^|\n)(Creating library file\[^\n\]*\n?)" $exec_output "\\1" exec_output
    regsub -all "(^|\n)(Creating library file\[^\n\]*\n?)" $exec_output "\\1" exec_output
    if [string match "" $exec_output] then {
    if [string match "" $exec_output] then {
        return 1
        return 1
    }
    }
    verbose -log "$exec_output"
    verbose -log "$exec_output"
    return 0
    return 0
}
}
set tmpdir tmpdir
set tmpdir tmpdir
# Set some libs needed for cygwin.
# Set some libs needed for cygwin.
set MYLDFLAGS "-Wl,--out-implib,$tmpdir/testexe.lib -nostartfiles -nostdlib"
set MYLDFLAGS "-Wl,--out-implib,$tmpdir/testexe.lib -nostartfiles -nostdlib"
# Build an export library for testdll
# Build an export library for testdll
if ![run_dlltool $tmpdir/testdll.lib $srcdir/$subdir/testdll.def] {
if ![run_dlltool $tmpdir/testdll.lib $srcdir/$subdir/testdll.def] {
    fail "building an export library for the shared lib"
    fail "building an export library for the shared lib"
    return
    return
}
}
# Compile the executable.
# Compile the executable.
if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/testexe.c $tmpdir/testexe.o] {
if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/testexe.c $tmpdir/testexe.o] {
    fail "compiling executable"
    fail "compiling executable"
    return
    return
}
}
if ![ld_special_link "$CC $LDFLAGS $MYLDFLAGS -e _testexe_main@16" $tmpdir/testexe.exe "$tmpdir/testexe.o $srcdir/$subdir/testexe.def $tmpdir/testdll.lib"] {
if ![ld_special_link "$CC $LDFLAGS $MYLDFLAGS -e _testexe_main@16" $tmpdir/testexe.exe "$tmpdir/testexe.o $srcdir/$subdir/testexe.def $tmpdir/testdll.lib"] {
    fail "linking executable"
    fail "linking executable"
    return
    return
}
}
# Compile the dll.
# Compile the dll.
if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/testdll.c $tmpdir/testdll.o] {
if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/testdll.c $tmpdir/testdll.o] {
    fail "compiling shared lib"
    fail "compiling shared lib"
    return
    return
}
}
if ![ld_special_link "$CC $LDFLAGS -nostartfiles -nostdlib -e _testdll_main@12" $tmpdir/testdll.dll "$tmpdir/testdll.o $srcdir/$subdir/testdll.def $tmpdir/testexe.lib"] {
if ![ld_special_link "$CC $LDFLAGS -nostartfiles -nostdlib -e _testdll_main@12" $tmpdir/testdll.dll "$tmpdir/testdll.o $srcdir/$subdir/testdll.def $tmpdir/testexe.lib"] {
    fail "linking shared lib"
    fail "linking shared lib"
    return
    return
}
}
# This is as far as we can go with a cross-compiler
# This is as far as we can go with a cross-compiler
if ![isnative] then {
if ![isnative] then {
    verbose "Not running natively, so cannot execute binary"
    verbose "Not running natively, so cannot execute binary"
    pass "Compile and link and executable with an export table"
    pass "Compile and link and executable with an export table"
    return
    return
}
}
verbose -log "executing $tmpdir/testexe.exe"
verbose -log "executing $tmpdir/testexe.exe"
catch "exec $tmpdir/testexe.exe" prog_output
catch "exec $tmpdir/testexe.exe" prog_output
set expected ""
set expected ""
if [string match $expected $prog_output] then {
if [string match $expected $prog_output] then {
    pass "export table in executable"
    pass "export table in executable"
} else {
} else {
    verbose $prog_output
    verbose $prog_output
    fail "Output does not match expected string $expected"
    fail "Output does not match expected string $expected"
}
}
 
 

powered by: WebSVN 2.1.0

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