bfd/
[external/binutils.git] / ld / testsuite / ld-elf / binutils.exp
1 # Expect script for binutils tests
2 #   Copyright 2006 Free Software Foundation, Inc.
3 #
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
17 #
18 # Written by H.J. Lu (hongjiu.lu@intel.com)
19 #
20
21 # Make sure that binutils can correctly handle ld output in ELF.
22
23 # This test can only be run on ELF platforms.
24 if ![is_elf_format] {
25     return
26 }
27
28 proc strip_test { ld_options test } {
29     global as
30     global ld
31     global READELF
32     global strip
33     global srcdir
34     global subdir
35
36     if { ![ld_assemble $as $srcdir/$subdir/$test.s tmpdir/$test.o ] } {
37         unresolved "$ld_options"
38         return
39     }
40
41     if { ![ld_simple_link $ld tmpdir/$test "$ld_options tmpdir/$test.o"] } {
42         unresolved "$ld_options"
43         return
44     }
45
46     send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.exp\n"
47     catch "exec $READELF -l --wide tmpdir/$test > tmpdir/$test.exp" got
48     if ![string match "" $got] then {
49         send_log "$got\n"
50         unresolved "$ld_options"
51         return
52     }
53
54     send_log "$strip tmpdir/$test\n"
55     catch "exec $strip tmpdir/$test" got
56     if ![string match "" $got] then {
57         send_log "$got\n"
58         unresolved "$ld_options"
59         return
60     }
61
62     send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.out\n"
63     catch "exec $READELF -l --wide tmpdir/$test > tmpdir/$test.out" got
64     if ![string match "" $got] then {
65         send_log "$got\n"
66         unresolved "$ld_options"
67         return
68     }
69
70     if { [catch {exec cmp tmpdir/$test.exp tmpdir/$test.out}] } then {
71         send_log "tmpdir/$test.exp tmpdir/$test.out differ.\n"
72         fail "$ld_options"
73         return
74     }
75
76     pass "$ld_options"
77 }
78
79 strip_test "-z max-page-size=0x200000" maxpage1
80 strip_test "-z max-page-size=0x200000 -z common-page-size=0x100000" maxpage1