summaryrefslogtreecommitdiff
path: root/exec/hostarch.c
diff options
context:
space:
mode:
Diffstat (limited to 'exec/hostarch.c')
-rw-r--r--exec/hostarch.c61
1 files changed, 57 insertions, 4 deletions
diff --git a/exec/hostarch.c b/exec/hostarch.c
index 38a38a00..d8466969 100644
--- a/exec/hostarch.c
+++ b/exec/hostarch.c
@@ -1,6 +1,6 @@
/* Determine the BFD and ELF architecture and machine flavor
from a Mach host port. Used by the exec and core servers.
- Copyright (C) 1992, 1993, 1995 Free Software Foundation, Inc.
+ Copyright (C) 1992, 1993, 1995, 1996 Free Software Foundation, Inc.
Written by Roland McGrath.
This file is part of the GNU Hurd.
@@ -19,17 +19,68 @@ You should have received a copy of the GNU General Public License
along with the GNU Hurd; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
#include <mach.h>
#include <hurd/hurd_types.h>
#include <errno.h>
-#include <bfd.h>
#include <elf.h>
error_t
+mach_host_elf_machine (host_t host,
+ Elf32_Half *e_machine)
+{
+ error_t err;
+ struct host_basic_info hostinfo;
+ mach_msg_type_number_t hostinfocnt = HOST_BASIC_INFO_COUNT;
+
+ err = host_info (host, HOST_BASIC_INFO,
+ (natural_t *) &hostinfo, &hostinfocnt);
+ if (err)
+ return err;
+
+ switch (hostinfo.cpu_type)
+ {
+ default:
+ *e_machine = EM_NONE;
+ break;
+
+ case CPU_TYPE_MC68020:
+ case CPU_TYPE_MC68030:
+ case CPU_TYPE_MC68040:
+ *e_machine = EM_68K;
+ break;
+
+ case CPU_TYPE_I860:
+ *e_machine = EM_860;
+ break;
+
+ case CPU_TYPE_MIPS:
+ *e_machine = EM_MIPS;
+ break;
+
+ case CPU_TYPE_MC88000:
+ *e_machine = EM_88K;
+ break;
+
+ case CPU_TYPE_SPARC:
+ *e_machine = EM_SPARC;
+ break;
+
+ case CPU_TYPE_I386:
+ *e_machine = EM_386;
+ break;
+ }
+
+ return 0;
+}
+
+#ifdef BFD
+#include <bfd.h>
+
+error_t
bfd_mach_host_arch_mach (host_t host,
enum bfd_architecture *arch,
- long int *machine,
- Elf32_Half *e_machine)
+ long int *machine)
{
error_t err;
struct host_basic_info hostinfo;
@@ -117,3 +168,5 @@ bfd_mach_host_arch_mach (host_t host,
return 0;
}
+
+#endif /* BFD */