blob: 6ef4c13ed477efd9b06b8d611fc38366a997321c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
# 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 GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# Please email any bugs, comments, and/or additions to this file to:
# gcc-bugs@gcc.gnu.org
# This file defines a proc for determining the file format in use by the
# target. This is useful for tests that are only supported by certain file
# formats. This procedure is defined in a separate file so that it can be
# included by other expect library files.
proc gcc_target_object_format { } {
global gcc_target_object_format_saved
global tool
if [info exists gcc_target_object_format_saved] {
verbose "gcc_target_object_format returning saved $gcc_target_object_format_saved" 2
} elseif { [istarget *-*-darwin*] } {
# Darwin doesn't necessarily have objdump, so hand-code it.
set gcc_target_object_format_saved mach-o
} elseif { [istarget hppa*-*-hpux*] } {
# HP-UX doesn't necessarily have objdump, so hand-code it.
if { [istarget hppa*64*-*-hpux*] } {
set gcc_target_object_format_saved elf
} else {
set gcc_target_object_format_saved som
}
} elseif { [istarget *-*-aix*] } {
# AIX doesn't necessarily have objdump, so hand-code it.
set gcc_target_object_format_saved coff
} elseif { [istarget *-*-amdhsa*] } {
# AMD GCN uses LLVM objdump which is not CLI-compatible
set gcc_target_object_format_saved elf
} else {
set objdump_name [find_binutils_prog objdump]
set open_file [open objfmtst.c w]
puts $open_file "void foo(void) { }"
close $open_file
${tool}_target_compile objfmtst.c objfmtst.o object ""
file delete objfmtst.c
set output [remote_exec host "$objdump_name" "--file-headers objfmtst.o"]
set output [lindex $output 1]
file delete objfmtst.o
if ![ regexp "file format (.*)arch" $output dummy objformat ] {
verbose "Could not parse objdump output" 2
set gcc_target_object_format_saved unknown
} else {
switch -regexp $objformat {
elf {
set gcc_target_object_format_saved elf
}
ecoff {
set gcc_target_object_format_saved ecoff
}
coff {
set gcc_target_object_format_saved coff
}
a\.out {
set gcc_target_object_format_saved a.out
}
pe {
set gcc_target_object_format_saved pe
}
som {
set gcc_target_object_format_saved som
}
default {
verbose "Unknown file format: $objformat" 3
set gcc_target_object_format_saved unknown
}
}
verbose "gcc_target_object_format returning $gcc_target_object_format_saved" 2
}
}
return $gcc_target_object_format_saved
}
|