Use config.bfd to determine the default architecture and byte order.

Flush all BYTE_ORDER_DEFAULT macros from mips. Can rely on BFD's value.
This commit is contained in:
Andrew Cagney 2000-06-08 04:00:56 +00:00
parent e28d556f6b
commit 1ba607adba
10 changed files with 492 additions and 345 deletions

View File

@ -1,3 +1,21 @@
Wed Jun 7 18:27:51 2000 Andrew Cagney <cagney@b1.cygnus.com>
* configure.in (DEFAULT_BFD_ARCH, DEFAULT_BFD_VEC): Use config.bfd
to determine the default architecture / target.
* acconfig (DEFAULT_BFD_ARCH, DEFAULT_BFD_VEC): Add.
* configure, config.in: Regenerate.
* arch-utils.c (set_endian): Better separate multi-arch and non-
multi-arch cases.
(set_endian_from_file): Call internal_error when multi-arch.
(initialize_current_architecture): Rewrite logic selecting a byte
order. Use DEFAULT_BFD_ARCH DEFAULT_BFD_VEC.
(version.h): Include.
* config/mips/tm-mips.h, config/mips/tm-bigmips64.h,
config/mips/tm-bigmips.h: Delete definition of
TARGET_BYTE_ORDER_DEFAULT.
Thu Jun 8 11:41:41 2000 Andrew Cagney <cagney@b1.cygnus.com>
* infrun.c (follow_inferior_fork): Bad merge from below. Compare

View File

@ -107,6 +107,16 @@ Turns out that ``1998-2000'' isn't considered valid :-(
http://sourceware.cygnus.com/ml/gdb-patches/2000-05/msg00467.html
--
Find something better than DEFAULT_BFD_ARCH, DEFAULT_BFD_VEC to
determine the default isa/byte-order.
--
Rely on BFD_BIG_ENDIAN and BFD_LITTLE_ENDIAN instead of host dependant
BIG_ENDIAN and LITTLE_ENDIAN.
--
Code Cleanups: General

View File

@ -115,3 +115,9 @@
/* Define if gnu-regex.c included with GDB should be used. */
#undef USE_INCLUDED_REGEX
/* BFD's default architecture. */
#undef DEFAULT_BFD_ARCH
/* BFD's default target vector. */
#undef DEFAULT_BFD_VEC

View File

@ -41,6 +41,8 @@
#include "symfile.h" /* for overlay functions */
#endif
#include "version.h"
#include "floatformat.h"
/* Convenience macro for allocting typesafe memory. */
@ -246,6 +248,9 @@ generic_register_convertible_not (num)
#ifndef TARGET_BYTE_ORDER_DEFAULT
#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN /* arbitrary */
#endif
/* ``target_byte_order'' is only used when non- multi-arch.
Multi-arch targets obtain the current byte order using
TARGET_BYTE_ORDER which is controlled by gdbarch.*. */
int target_byte_order = TARGET_BYTE_ORDER_DEFAULT;
int target_byte_order_auto = 1;
@ -287,7 +292,6 @@ set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
}
else if (set_endian_string == endian_little)
{
target_byte_order = LITTLE_ENDIAN;
target_byte_order_auto = 0;
if (GDB_MULTI_ARCH)
{
@ -296,10 +300,13 @@ set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
info.byte_order = LITTLE_ENDIAN;
gdbarch_update (info);
}
else
{
target_byte_order = LITTLE_ENDIAN;
}
}
else if (set_endian_string == endian_big)
{
target_byte_order = BIG_ENDIAN;
target_byte_order_auto = 0;
if (GDB_MULTI_ARCH)
{
@ -308,6 +315,10 @@ set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
info.byte_order = BIG_ENDIAN;
gdbarch_update (info);
}
else
{
target_byte_order = BIG_ENDIAN;
}
}
else
internal_error ("set_endian: bad value");
@ -319,6 +330,8 @@ set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
static void
set_endian_from_file (bfd *abfd)
{
if (GDB_MULTI_ARCH)
internal_error ("set_endian_from_file: not for multi-arch");
if (TARGET_BYTE_ORDER_SELECTABLE_P)
{
int want;
@ -547,32 +560,93 @@ set_gdbarch_from_file (abfd)
architecture'' command so that it specifies a list of valid
architectures. */
#ifdef DEFAULT_BFD_ARCH
extern const bfd_arch_info_type DEFAULT_BFD_ARCH;
static const bfd_arch_info_type *default_bfd_arch = &DEFAULT_BFD_ARCH;
#else
static const bfd_arch_info_type *default_bfd_arch
#endif
#ifdef DEFAULT_BFD_VEC
extern const bfd_target DEFAULT_BFD_VEC;
static const bfd_target *default_bfd_vec = &DEFAULT_BFD_VEC;
#else
static const bfd_target *default_bfd_vec;
#endif
void
initialize_current_architecture (void)
{
const char **arches = gdbarch_printable_names ();
const char *chosen = arches[0];
if (GDB_MULTI_ARCH)
/* determine a default architecture and byte order. */
struct gdbarch_info info;
memset (&info, 0, sizeof (info));
/* Find a default architecture. */
if (info.bfd_arch_info == NULL
&& default_bfd_arch != NULL)
info.bfd_arch_info = default_bfd_arch;
if (info.bfd_arch_info == NULL)
{
/* Choose the architecture by taking the first one
alphabetically. */
const char *chosen = arches[0];
const char **arch;
struct gdbarch_info info;
for (arch = arches; *arch != NULL; arch++)
{
/* Choose the first architecture alphabetically. */
if (strcmp (*arch, chosen) < 0)
chosen = *arch;
}
if (chosen == NULL)
internal_error ("initialize_current_architecture: No arch");
memset (&info, 0, sizeof info);
info.bfd_arch_info = bfd_scan_arch (chosen);
if (info.bfd_arch_info == NULL)
internal_error ("initialize_current_architecture: Arch not found");
}
/* take several guesses at a byte order. */
/* NB: can't use TARGET_BYTE_ORDER_DEFAULT as its definition is
forced above. */
if (info.byte_order == 0
&& default_bfd_vec != NULL)
{
/* Extract BFD's default vector's byte order. */
switch (default_bfd_vec->byteorder)
{
case BFD_ENDIAN_BIG:
info.byte_order = BIG_ENDIAN;
break;
case BFD_ENDIAN_LITTLE:
info.byte_order = LITTLE_ENDIAN;
break;
default:
break;
}
}
if (info.byte_order == 0)
{
/* look for ``*el-*'' in the target name. */
const char *chp;
chp = strchr (target_name, '-');
if (chp != NULL
&& chp - 2 >= target_name
&& strncmp (chp - 2, "el", 2) == 0)
info.byte_order = LITTLE_ENDIAN;
}
if (info.byte_order == 0)
{
/* Wire it to big-endian!!! */
info.byte_order = BIG_ENDIAN;
}
if (GDB_MULTI_ARCH)
{
gdbarch_update (info);
}
/* Create the ``set architecture'' command prepending ``auto''. */
/* Create the ``set architecture'' command appending ``auto'' to the
list of architectures. */
{
struct cmd_list_element *c;
/* Append ``auto''. */

View File

@ -135,6 +135,12 @@
/* Define if gnu-regex.c included with GDB should be used. */
#undef USE_INCLUDED_REGEX
/* BFD's default architecture. */
#undef DEFAULT_BFD_ARCH
/* BFD's default target vector. */
#undef DEFAULT_BFD_VEC
/* Define if you have the __argz_count function. */
#undef HAVE___ARGZ_COUNT

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1990 Free Software Foundation, Inc.
/* Copyright (C) 1990, 2000 Free Software Foundation, Inc.
This file is part of GDB.
@ -17,6 +17,4 @@
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN
#include "mips/tm-mips.h"

View File

@ -1,5 +1,5 @@
/* Target machine parameters for MIPS r4000
Copyright 1994 Free Software Foundation, Inc.
Copyright 1994, 2000 Free Software Foundation, Inc.
Contributed by Ian Lance Taylor (ian@cygnus.com)
This file is part of GDB.
@ -19,6 +19,4 @@
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN
#include "mips/tm-mips64.h"

View File

@ -33,10 +33,6 @@ struct value;
#include "coff/sym.h" /* Needed for PDR below. */
#include "coff/symconst.h"
#if !defined (TARGET_BYTE_ORDER_DEFAULT)
#define TARGET_BYTE_ORDER_DEFAULT LITTLE_ENDIAN
#endif
#if !defined (GDB_TARGET_IS_MIPS64)
#define GDB_TARGET_IS_MIPS64 0
#endif

682
gdb/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -71,9 +71,22 @@ changequote(,)dnl
. ${srcdir}/configure.tgt
targ=${target} ; . ${srcdir}/../bfd/config.bfd
dnl
changequote([,])dnl
dnl use BFD to determine the default architecture and byte order
dnl (bfd_vec->byteorder provides the latter).
targ=${target}
. ${srcdir}/../bfd/config.bfd
if test x"${targ_archs}" != x ; then
AC_DEFINE_UNQUOTED(DEFAULT_BFD_ARCH, ${targ_archs})
fi
if test x"${targ_defvec}" != x ; then
AC_DEFINE_UNQUOTED(DEFAULT_BFD_VEC, ${targ_defvec})
fi
AC_PROG_AWK
AC_PROG_INSTALL
AC_CHECK_TOOL(AR, ar)