1 |
306 |
jeremybenn |
# Copyright (C) 1999, 2007 Free Software Foundation, Inc.
|
2 |
|
|
|
3 |
|
|
# This program is free software; you can redistribute it and/or modify
|
4 |
|
|
# it under the terms of the GNU General Public License as published by
|
5 |
|
|
# the Free Software Foundation; either version 3 of the License, or
|
6 |
|
|
# (at your option) any later version.
|
7 |
|
|
#
|
8 |
|
|
# This program is distributed in the hope that it will be useful,
|
9 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11 |
|
|
# GNU General Public License for more details.
|
12 |
|
|
#
|
13 |
|
|
# You should have received a copy of the GNU General Public License
|
14 |
|
|
# along with GCC; see the file COPYING3. If not see
|
15 |
|
|
# .
|
16 |
|
|
|
17 |
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
18 |
|
|
# gcc-bugs@gcc.gnu.org
|
19 |
|
|
|
20 |
|
|
# This file defines a proc for determining the file format in use by the
|
21 |
|
|
# target. This is useful for tests that are only supported by certain file
|
22 |
|
|
# formats. This procedure is defined in a separate file so that it can be
|
23 |
|
|
# included by other expect library files.
|
24 |
|
|
|
25 |
|
|
proc gcc_target_object_format { } {
|
26 |
|
|
global gcc_target_object_format_saved
|
27 |
|
|
global target_triplet
|
28 |
|
|
global tool
|
29 |
|
|
|
30 |
|
|
if [info exists gcc_target_object_format_saved] {
|
31 |
|
|
verbose "gcc_target_object_format returning saved $gcc_target_object_format_saved" 2
|
32 |
|
|
} elseif { [string match "*-*-darwin*" $target_triplet] } {
|
33 |
|
|
# Darwin doesn't necessarily have objdump, so hand-code it.
|
34 |
|
|
set gcc_target_object_format_saved mach-o
|
35 |
|
|
} elseif { [string match "hppa*-*-hpux*" $target_triplet] } {
|
36 |
|
|
# HP-UX doesn't necessarily have objdump, so hand-code it.
|
37 |
|
|
if { [string match "hppa*64*-*-hpux*" $target_triplet] } {
|
38 |
|
|
set gcc_target_object_format_saved elf
|
39 |
|
|
} else {
|
40 |
|
|
set gcc_target_object_format_saved som
|
41 |
|
|
}
|
42 |
|
|
} else {
|
43 |
|
|
set objdump_name [find_binutils_prog objdump]
|
44 |
|
|
set open_file [open objfmtst.c w]
|
45 |
|
|
puts $open_file "void foo(void) { }"
|
46 |
|
|
close $open_file
|
47 |
|
|
|
48 |
|
|
${tool}_target_compile objfmtst.c objfmtst.o object ""
|
49 |
|
|
file delete objfmtst.c
|
50 |
|
|
|
51 |
|
|
set output [remote_exec host "$objdump_name" "--file-headers objfmtst.o"]
|
52 |
|
|
set output [lindex $output 1]
|
53 |
|
|
|
54 |
|
|
file delete objfmtst.o
|
55 |
|
|
|
56 |
|
|
if ![ regexp "file format (.*)arch" $output dummy objformat ] {
|
57 |
|
|
verbose "Could not parse objdump output" 2
|
58 |
|
|
set gcc_target_object_format_saved unknown
|
59 |
|
|
} else {
|
60 |
|
|
switch -regexp $objformat {
|
61 |
|
|
elf {
|
62 |
|
|
set gcc_target_object_format_saved elf
|
63 |
|
|
}
|
64 |
|
|
ecoff {
|
65 |
|
|
set gcc_target_object_format_saved ecoff
|
66 |
|
|
}
|
67 |
|
|
coff {
|
68 |
|
|
set gcc_target_object_format_saved coff
|
69 |
|
|
}
|
70 |
|
|
a\.out {
|
71 |
|
|
set gcc_target_object_format_saved a.out
|
72 |
|
|
}
|
73 |
|
|
pe {
|
74 |
|
|
set gcc_target_object_format_saved pe
|
75 |
|
|
}
|
76 |
|
|
som {
|
77 |
|
|
set gcc_target_object_format_saved som
|
78 |
|
|
}
|
79 |
|
|
default {
|
80 |
|
|
verbose "Unknown file format: $objformat" 3
|
81 |
|
|
set gcc_target_object_format_saved unknown
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
verbose "gcc_target_object_format returning $gcc_target_object_format_saved" 2
|
86 |
|
|
}
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
return $gcc_target_object_format_saved
|
90 |
|
|
}
|