diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3201f1450e..40c10a8ba1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,21 @@ +Sun Dec 13 09:52:51 1998 Andrew Cagney + + * defs.h (TARGET_PRINT_INSN_INFO, TARGET_PRINT_INSN): Define. + (TARGET_ARCHITECTURE, TARGET_ARCHITECTURE_AUTO): Define. + (TARGET_BYTE_ORDER_AUTO): Define. + (TARGET_BYTE_ORDER_SELECTABLE_P): Provide default. Replaces + TARGET_BYTE_ORDER_SELECTABLE. Handle compat issues. + (BITS_BIG_ENDIAN): Simplify. + (TARGET_FLOAT_FORMAT): Ditto. + (TARGET_DOUBLE_FORMAT): + + * remote-e7000.c, sh-tdep.c, printcmd.c, gdbtk-cmds.c, + remote-sim.c, remote-rdi.c, sparc-tdep.c: Update. + + * config/powerpc/tm-ppcle-eabi.h, config/rs6000/tm-rs6000.h, + config/powerpc/tm-ppc-eabi.h, config/mn10300/tm-mn10300.h: + Convert. + Sat Dec 12 09:28:13 1998 Andrew Cagney * frame.h (struct frame_info): Add CORE_ADDR *saved_regs and diff --git a/gdb/config/mn10300/tm-mn10300.h b/gdb/config/mn10300/tm-mn10300.h index 769924c1df..b77232345b 100644 --- a/gdb/config/mn10300/tm-mn10300.h +++ b/gdb/config/mn10300/tm-mn10300.h @@ -20,7 +20,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* The mn10300 is little endian. */ -#define TARGET_BYTE_ORDER LITTLE_ENDIAN +#define TARGET_BYTE_ORDER_DEFAULT LITTLE_ENDIAN /* All registers are 32bits (phew!). */ #define REGISTER_SIZE 4 diff --git a/gdb/config/powerpc/tm-ppcle-eabi.h b/gdb/config/powerpc/tm-ppcle-eabi.h index 309dd6f935..355195d8a0 100644 --- a/gdb/config/powerpc/tm-ppcle-eabi.h +++ b/gdb/config/powerpc/tm-ppcle-eabi.h @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Use normal ppc-eabi definitions */ #include "powerpc/tm-ppc-eabi.h" -#undef TARGET_BYTE_ORDER -#define TARGET_BYTE_ORDER LITTLE_ENDIAN +#undef TARGET_BYTE_ORDER_DEFAULT +#define TARGET_BYTE_ORDER_DEFAULT LITTLE_ENDIAN #endif /* TM_PPCLE_EABI_H */ diff --git a/gdb/defs.h b/gdb/defs.h index 831a083377..1c3e804b1e 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -780,15 +780,35 @@ extern void free (); /* Target-system-dependent parameters for GDB. */ +/* TARGET_BYTE_ORDER_SELECTABLE_P determines if the target endianness + is selectable at runtime. The user can use the `set endian' + command to change it. TARGET_BYTE_ORDER_AUTO is nonzero when + target_byte_order should be auto-detected (from the program image + say). */ + +#ifndef TARGET_BYTE_ORDER_SELECTABLE_P +/* compat - Catch old targets that define TARGET_BYTE_ORDER_SLECTABLE + when they should have defined TARGET_BYTE_ORDER_SELECTABLE_P 1 */ #ifdef TARGET_BYTE_ORDER_SELECTABLE -/* The target endianness is selectable at runtime. Define - TARGET_BYTE_ORDER to be a variable. The user can use the `set - endian' command to change it. */ -#undef TARGET_BYTE_ORDER -#define TARGET_BYTE_ORDER target_byte_order +#define TARGET_BYTE_ORDER_SELECTABLE_P 1 +#else +#define TARGET_BYTE_ORDER_SELECTABLE_P 0 +#endif +#endif + extern int target_byte_order; -/* Nonzero when target_byte_order auto-detected */ +#ifdef TARGET_BYTE_ORDER_SELECTABLE +/* compat - Catch old targets that define TARGET_BYTE_ORDER_SELECTABLE + and expect defs.h to re-define TARGET_BYTE_ORDER. */ +#undef TARGET_BYTE_ORDER +#endif +#ifndef TARGET_BYTE_ORDER +#define TARGET_BYTE_ORDER (target_byte_order + 0) +#endif + extern int target_byte_order_auto; +#ifndef TARGET_BYTE_ORDER_AUTO +#define TARGET_BYTE_ORDER_AUTO (target_byte_order_auto + 0) #endif extern void set_endian_from_file PARAMS ((bfd *)); @@ -796,6 +816,8 @@ extern void set_endian_from_file PARAMS ((bfd *)); /* The target architecture can be set at run-time. */ extern int target_architecture_auto; extern const bfd_arch_info_type *target_architecture; +#define TARGET_ARCHITECTURE_AUTO (target_architecture_auto + 0) +#define TARGET_ARCHITECTURE (target_architecture + 0) extern void set_architecture_from_file PARAMS ((bfd *)); /* Notify target of a change to the selected architecture. Zero return status indicates that the target did not like the change. */ @@ -864,22 +886,8 @@ extern void set_architecture_from_arch_mach PARAMS ((enum bfd_architecture arch, from byte/word byte order. */ #if !defined (BITS_BIG_ENDIAN) -#ifndef TARGET_BYTE_ORDER_SELECTABLE - -#if TARGET_BYTE_ORDER == BIG_ENDIAN -#define BITS_BIG_ENDIAN 1 -#endif /* Big endian. */ - -#if TARGET_BYTE_ORDER == LITTLE_ENDIAN -#define BITS_BIG_ENDIAN 0 -#endif /* Little endian. */ - -#else /* defined (TARGET_BYTE_ORDER_SELECTABLE) */ - #define BITS_BIG_ENDIAN (TARGET_BYTE_ORDER == BIG_ENDIAN) - -#endif /* defined (TARGET_BYTE_ORDER_SELECTABLE) */ -#endif /* BITS_BIG_ENDIAN not defined. */ +#endif /* In findvar.c. */ @@ -929,33 +937,15 @@ extern const struct floatformat floatformat_unknown; #define HOST_LONG_DOUBLE_FORMAT &floatformat_unknown #endif -#ifndef TARGET_BYTE_ORDER_SELECTABLE -# if TARGET_BYTE_ORDER == BIG_ENDIAN -# ifndef TARGET_FLOAT_FORMAT -# define TARGET_FLOAT_FORMAT &floatformat_ieee_single_big -# endif -# ifndef TARGET_DOUBLE_FORMAT -# define TARGET_DOUBLE_FORMAT &floatformat_ieee_double_big -# endif -# else /* LITTLE_ENDIAN */ -# ifndef TARGET_FLOAT_FORMAT -# define TARGET_FLOAT_FORMAT &floatformat_ieee_single_little -# endif -# ifndef TARGET_DOUBLE_FORMAT -# define TARGET_DOUBLE_FORMAT &floatformat_ieee_double_little -# endif -# endif -#else /* TARGET_BYTE_ORDER_SELECTABLE */ -# ifndef TARGET_FLOAT_FORMAT -# define TARGET_FLOAT_FORMAT (target_byte_order == BIG_ENDIAN \ - ? &floatformat_ieee_single_big \ - : &floatformat_ieee_single_little) -# endif -# ifndef TARGET_DOUBLE_FORMAT -# define TARGET_DOUBLE_FORMAT (target_byte_order == BIG_ENDIAN \ - ? &floatformat_ieee_double_big \ - : &floatformat_ieee_double_little) -# endif +#ifndef TARGET_FLOAT_FORMAT +#define TARGET_FLOAT_FORMAT (target_byte_order == BIG_ENDIAN \ + ? &floatformat_ieee_single_big \ + : &floatformat_ieee_single_little) +#endif +#ifndef TARGET_DOUBLE_FORMAT +#define TARGET_DOUBLE_FORMAT (target_byte_order == BIG_ENDIAN \ + ? &floatformat_ieee_double_big \ + : &floatformat_ieee_double_little) #endif #ifndef TARGET_LONG_DOUBLE_FORMAT @@ -1036,6 +1026,12 @@ extern void dis_asm_print_address PARAMS ((bfd_vma addr, extern int (*tm_print_insn) PARAMS ((bfd_vma, disassemble_info*)); extern disassemble_info tm_print_insn_info; +#ifndef TARGET_PRINT_INSN +#define TARGET_PRINT_INSN(vma, info) (*tm_print_insn) (vma, info) +#endif +#ifndef TARGET_PRINT_INSN_INFO +#define TARGET_PRINT_INSN_INFO (&tm_print_insn_info) +#endif /* Hooks for alternate command interfaces. */ diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 922a7e01d5..ebaf4f94a4 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +Sun Dec 13 10:27:59 1998 Andrew Cagney + + * gdbint.texinfo: Document TARGET_BYTE_ORDER_DEFAULT and + TARGET_BYTE_ORDER_SELECTABLE_P. + Thu Dec 10 16:07:09 1998 Andrew Cagney * gdbint.texinfo (FRAME_FIND_SAVED_REGS): Document. diff --git a/gdb/gdbtk-cmds.c b/gdb/gdbtk-cmds.c index 7001d062f6..fbf7458bb5 100644 --- a/gdb/gdbtk-cmds.c +++ b/gdb/gdbtk-cmds.c @@ -2081,7 +2081,7 @@ gdb_disassemble (clientData, interp, objc, objv) di_initialized = 1; } - di.mach = tm_print_insn_info.mach; + di.mach = TM_PRINT_INSN_INFO->mach; if (TARGET_BYTE_ORDER == BIG_ENDIAN) di.endian = BFD_ENDIAN_BIG; else diff --git a/gdb/printcmd.c b/gdb/printcmd.c index ecde3eb5ab..bbc4ba00c0 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -2283,20 +2283,16 @@ print_insn (memaddr, stream) CORE_ADDR memaddr; GDB_FILE *stream; { - /* If there's no disassembler, something is very wrong. */ - if (tm_print_insn == NULL) - abort (); - if (TARGET_BYTE_ORDER == BIG_ENDIAN) - tm_print_insn_info.endian = BFD_ENDIAN_BIG; + TARGET_PRINT_INSN_INFO->endian = BFD_ENDIAN_BIG; else - tm_print_insn_info.endian = BFD_ENDIAN_LITTLE; + TARGET_PRINT_INSN_INFO->endian = BFD_ENDIAN_LITTLE; - if (target_architecture != NULL) - tm_print_insn_info.mach = target_architecture->mach; + if (TARGET_ARCHITECTURE != NULL) + TARGET_PRINT_INSN_INFO->mach = TARGET_ARCHITECTURE->mach; /* else: should set .mach=0 but some disassemblers don't grok this */ - return (*tm_print_insn) (memaddr, &tm_print_insn_info); + return TARGET_PRINT_INSN (memaddr, TARGET_PRINT_INSN_INFO); } diff --git a/gdb/remote-e7000.c b/gdb/remote-e7000.c index 20cf774c1b..b252084943 100644 --- a/gdb/remote-e7000.c +++ b/gdb/remote-e7000.c @@ -1,5 +1,5 @@ /* Remote debugging interface for Hitachi E7000 ICE, for GDB - Copyright 1993, 1994, 1996 Free Software Foundation, Inc. + Copyright 1993, 1994, 1996, 1997, 1998 Free Software Foundation, Inc. Contributed by Cygnus Support. Written by Steve Chamberlain for Cygnus Support. @@ -48,6 +48,7 @@ #include #include + #if 1 #define HARD_BREAKPOINTS /* Now handled by set option. */ #define BC_BREAKPOINTS use_hard_breakpoints @@ -381,7 +382,7 @@ e7000_create_inferior (execfile, args, env) error ("Can't pass arguments to remote E7000DEBUG process"); if (execfile == 0 || exec_bfd == 0) - error ("No exec file specified"); + error ("No executable file specified"); entry_pt = (int) bfd_get_start_address (exec_bfd); @@ -920,21 +921,19 @@ e7000_fetch_registers () #ifdef GDB_TARGET_IS_SH wanted = want; - if (target_architecture->arch == bfd_arch_sh) - switch (target_architecture->mach) + if (TARGET_ARCHITECTURE->arch == bfd_arch_sh) + switch (TARGET_ARCHITECTURE->mach) { case bfd_mach_sh3: case bfd_mach_sh3e: - /* start-sanitize-sh4 */ case bfd_mach_sh4: - /* end-sanitize-sh4 */ wanted = want_sh3; } #else if (h8300smode) wanted = want_h8300s; else - wanted = want_h8300h); + wanted = want_h8300h; #endif fetch_regs_from_dump (gch, wanted); @@ -1576,7 +1575,7 @@ e7000_load (args, from_tty) perror_with_name (filename); return; } - old_chain = make_cleanup (bfd_close, pbfd); + old_chain = make_cleanup ((make_cleanup_func) bfd_close, pbfd); if (!bfd_check_format (pbfd, bfd_object)) error ("\"%s\" is not an object file: %s", filename, @@ -1710,8 +1709,6 @@ e7000_mourn_inferior () #define MAX_E7000DEBUG_BREAKPOINTS MAX_BREAKPOINTS #endif -extern int memory_breakpoint_size; - /* Since we can change to soft breakpoints dynamically, we must define more than enough. Was breakaddr[MAX_E7000DEBUG_BREAKPOINTS]. */ static CORE_ADDR breakaddr[MAX_BREAKPOINTS] = {0}; @@ -2077,21 +2074,19 @@ e7000_wait (pid, status) #ifdef GDB_TARGET_IS_SH wanted_nopc = want_nopc; - if (target_architecture->arch == bfd_arch_sh) - switch (target_architecture->mach) + if (TARGET_ARCHITECTURE->arch == bfd_arch_sh) + switch (TARGET_ARCHITECTURE->mach) { case bfd_mach_sh3: case bfd_mach_sh3e: - /* start-sanitize-sh4 */ case bfd_mach_sh4: - /* end-sanitize-sh4 */ wanted_nopc = want_sh3_nopc; } #else if (h8300smode) wanted_nopc = want_nopc_h8300s; else - wanted_nopc = want_nopc_h8300h); + wanted_nopc = want_nopc_h8300h; #endif fetch_regs_from_dump (gch, wanted_nopc); @@ -2163,59 +2158,61 @@ e7000_stop () /* Define the target subroutine names. */ -struct target_ops e7000_ops = +struct target_ops e7000_ops ; +static void init_e7000_ops(void) { - "e7000", - "Remote Hitachi e7000 target", - "Use a remote Hitachi e7000 ICE connected by a serial line,\n\ + e7000_ops.to_shortname = "e7000"; + e7000_ops.to_longname = "Remote Hitachi e7000 target"; + e7000_ops.to_doc = "Use a remote Hitachi e7000 ICE connected by a serial line;\n\ or a network connection.\n\ Arguments are the name of the device for the serial line,\n\ the speed to connect at in bits per second.\n\ eg\n\ target e7000 /dev/ttya 9600\n\ -target e7000 foobar", - e7000_open, /* to_open */ - e7000_close, /* to_close */ - 0, /* to_attach */ - e7000_detach, /* to_detach */ - e7000_resume, /* to_resume */ - e7000_wait, /* to_wait */ - e7000_fetch_register, /* to_fetch_registers */ - e7000_store_register, /* to_store_registers */ - e7000_prepare_to_store, /* to_prepare_to_store */ - e7000_xfer_inferior_memory, /* to_xfer_memory */ - e7000_files_info, /* to_files_info */ - e7000_insert_breakpoint, /* to_insert_breakpoint */ - e7000_remove_breakpoint, /* to_remove_breakpoint */ - 0, /* to_terminal_init */ - 0, /* to_terminal_inferior */ - 0, /* to_terminal_ours_for_output */ - 0, /* to_terminal_ours */ - 0, /* to_terminal_info */ - e7000_kill, /* to_kill */ - e7000_load, /* to_load */ - 0, /* to_lookup_symbol */ - e7000_create_inferior, /* to_create_inferior */ - e7000_mourn_inferior, /* to_mourn_inferior */ - 0, /* to_can_run */ - 0, /* to_notice_signals */ - 0, /* to_thread_alive */ - e7000_stop, /* to_stop */ - process_stratum, /* to_stratum */ - 0, /* next (unused) */ - 1, /* to_has_all_memory */ - 1, /* to_has_memory */ - 1, /* to_has_stack */ - 1, /* to_has_registers */ - 1, /* to_has_execution */ - 0, /* to_sections */ - 0, /* to_sections_end */ - OPS_MAGIC, /* Always the last thing */ +target e7000 foobar" ; + e7000_ops.to_open = e7000_open; + e7000_ops.to_close = e7000_close; + e7000_ops.to_attach = 0; + e7000_ops.to_detach = e7000_detach; + e7000_ops.to_resume = e7000_resume; + e7000_ops.to_wait = e7000_wait; + e7000_ops.to_fetch_registers = e7000_fetch_register; + e7000_ops.to_store_registers = e7000_store_register; + e7000_ops.to_prepare_to_store = e7000_prepare_to_store; + e7000_ops.to_xfer_memory = e7000_xfer_inferior_memory; + e7000_ops.to_files_info = e7000_files_info; + e7000_ops.to_insert_breakpoint = e7000_insert_breakpoint; + e7000_ops.to_remove_breakpoint = e7000_remove_breakpoint; + e7000_ops.to_terminal_init = 0; + e7000_ops.to_terminal_inferior = 0; + e7000_ops.to_terminal_ours_for_output = 0; + e7000_ops.to_terminal_ours = 0; + e7000_ops.to_terminal_info = 0; + e7000_ops.to_kill = e7000_kill; + e7000_ops.to_load = e7000_load; + e7000_ops.to_lookup_symbol = 0; + e7000_ops.to_create_inferior = e7000_create_inferior; + e7000_ops.to_mourn_inferior = e7000_mourn_inferior; + e7000_ops.to_can_run = 0; + e7000_ops.to_notice_signals = 0; + e7000_ops.to_thread_alive = 0; + e7000_ops.to_stop = e7000_stop; + e7000_ops.to_stratum = process_stratum; + e7000_ops.DONT_USE = 0; + e7000_ops.to_has_all_memory = 1; + e7000_ops.to_has_memory = 1; + e7000_ops.to_has_stack = 1; + e7000_ops.to_has_registers = 1; + e7000_ops.to_has_execution = 1; + e7000_ops.to_sections = 0; + e7000_ops.to_sections_end = 0; + e7000_ops.to_magic = OPS_MAGIC; }; void _initialize_remote_e7000 () { + init_e7000_ops() ; add_target (&e7000_ops); add_com ("e7000", class_obscure, e7000_command, diff --git a/gdb/remote-rdi.c b/gdb/remote-rdi.c index 3cd3ea12ed..7b6511e1e7 100644 --- a/gdb/remote-rdi.c +++ b/gdb/remote-rdi.c @@ -223,7 +223,7 @@ device is attached to the remote system (e.g. /dev/ttya)."); if (rslt != adp_ok) error ("Could not open device \"%s\"", name); - gdb_config.bytesex = 2 | (target_byte_order == BIG_ENDIAN ? 1 : 0); + gdb_config.bytesex = 2 | (TARGET_BYTE_ORDER == BIG_ENDIAN ? 1 : 0); gdb_config.fpe = 1; gdb_config.rditype = 2; gdb_config.heartbeat_on = 1; diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index aaa225230f..0c805447b5 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -528,8 +528,8 @@ gdbsim_open (args, from_tty) strcpy (arg_buf, "gdbsim"); /* 7 */ /* Specify the byte order for the target when it is both selectable and explicitly specified by the user (not auto detected). */ -#ifdef TARGET_BYTE_ORDER_SELECTABLE - if (!target_byte_order_auto) + if (TARGET_BYTE_ORDER_SELECTABLE_P + && !TARGET_BYTE_ORDER_AUTO) { switch (TARGET_BYTE_ORDER) { @@ -543,13 +543,12 @@ gdbsim_open (args, from_tty) fatal ("Value of TARGET_BYTE_ORDER unknown"); } } -#endif /* Specify the architecture of the target when it has been explicitly specified */ - if (!target_architecture_auto) + if (!TARGET_ARCHITECTURE_AUTO) { strcat (arg_buf, " --architecture="); - strcat (arg_buf, target_architecture->printable_name); + strcat (arg_buf, TARGET_ARCHITECTURE->printable_name); } /* finally, any explicit args */ if (args) diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index 55fef8995c..226ca2fe5a 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -626,8 +626,8 @@ sh_show_regs (args, from_tty) int from_tty; { int cpu; - if (target_architecture->arch == bfd_arch_sh) - cpu = target_architecture->mach; + if (TARGET_ARCHITECTURE->arch == bfd_arch_sh) + cpu = TARGET_ARCHITECTURE->mach; else cpu = 0; /* FIXME: sh4 has more registers */ diff --git a/gdb/top.c b/gdb/top.c index 9447484076..80e02b0fc8 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -3200,14 +3200,22 @@ dont_repeat_command (ignored, from_tty) /* Functions to manipulate the endianness of the target. */ #ifdef TARGET_BYTE_ORDER_SELECTABLE +/* compat - Catch old targets that expect a selectable byte-order to + default to BIG_ENDIAN */ #ifndef TARGET_BYTE_ORDER_DEFAULT #define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN #endif +#endif +#ifndef TARGET_BYTE_ORDER_DEFAULT +/* compat - Catch old non byte-order selectable targets that do not + define TARGET_BYTE_ORDER_DEFAULT and instead expect + TARGET_BYTE_ORDER to be used as the default. For targets that + defined neither TARGET_BYTE_ORDER nor TARGET_BYTE_ORDER_DEFAULT the + below will get a strange compiler warning. */ +#define TARGET_BYTE_ORDER_DEFAULT TARGET_BYTE_ORDER +#endif int target_byte_order = TARGET_BYTE_ORDER_DEFAULT; int target_byte_order_auto = 1; -#else -static int target_byte_order_auto = 0; -#endif /* Called if the user enters ``set endian'' without an argument. */ static void @@ -3225,13 +3233,16 @@ set_endian_big (args, from_tty) char *args; int from_tty; { -#ifdef TARGET_BYTE_ORDER_SELECTABLE - target_byte_order = BIG_ENDIAN; - target_byte_order_auto = 0; -#else - printf_unfiltered ("Byte order is not selectable."); - show_endian (args, from_tty); -#endif + if (TARGET_BYTE_ORDER_SELECTABLE_P) + { + target_byte_order = BIG_ENDIAN; + target_byte_order_auto = 0; + } + else + { + printf_unfiltered ("Byte order is not selectable."); + show_endian (args, from_tty); + } } /* Called by ``set endian little''. */ @@ -3240,13 +3251,16 @@ set_endian_little (args, from_tty) char *args; int from_tty; { -#ifdef TARGET_BYTE_ORDER_SELECTABLE - target_byte_order = LITTLE_ENDIAN; - target_byte_order_auto = 0; -#else - printf_unfiltered ("Byte order is not selectable."); - show_endian (args, from_tty); -#endif + if (TARGET_BYTE_ORDER_SELECTABLE_P) + { + target_byte_order = LITTLE_ENDIAN; + target_byte_order_auto = 0; + } + else + { + printf_unfiltered ("Byte order is not selectable."); + show_endian (args, from_tty); + } } /* Called by ``set endian auto''. */ @@ -3255,12 +3269,15 @@ set_endian_auto (args, from_tty) char *args; int from_tty; { -#ifdef TARGET_BYTE_ORDER_SELECTABLE - target_byte_order_auto = 1; -#else - printf_unfiltered ("Byte order is not selectable."); - show_endian (args, from_tty); -#endif + if (TARGET_BYTE_ORDER_SELECTABLE_P) + { + target_byte_order_auto = 1; + } + else + { + printf_unfiltered ("Byte order is not selectable."); + show_endian (args, from_tty); + } } /* Called by ``show endian''. */ @@ -3269,11 +3286,11 @@ show_endian (args, from_tty) char *args; int from_tty; { - const char *msg = - (target_byte_order_auto + char *msg = + (TARGET_BYTE_ORDER_AUTO ? "The target endianness is set automatically (currently %s endian)\n" : "The target is assumed to be %s endian\n"); - printf_unfiltered ((char *) msg, TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little"); + printf_unfiltered (msg, (TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little")); } /* Set the endianness from a BFD. */ @@ -3281,30 +3298,30 @@ void set_endian_from_file (abfd) bfd *abfd; { -#ifdef TARGET_BYTE_ORDER_SELECTABLE - int want; - - if (bfd_big_endian (abfd)) - want = BIG_ENDIAN; + if (TARGET_BYTE_ORDER_SELECTABLE_P) + { + int want; + + if (bfd_big_endian (abfd)) + want = BIG_ENDIAN; + else + want = LITTLE_ENDIAN; + if (TARGET_BYTE_ORDER_AUTO) + target_byte_order = want; + else if (TARGET_BYTE_ORDER != want) + warning ("%s endian file does not match %s endian target.", + want == BIG_ENDIAN ? "big" : "little", + TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little"); + } else - want = LITTLE_ENDIAN; - if (target_byte_order_auto) - target_byte_order = want; - else if (target_byte_order != want) - warning ("%s endian file does not match %s endian target.", - want == BIG_ENDIAN ? "big" : "little", - TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little"); - -#else /* ! defined (TARGET_BYTE_ORDER_SELECTABLE) */ - - if (bfd_big_endian (abfd) - ? TARGET_BYTE_ORDER != BIG_ENDIAN - : TARGET_BYTE_ORDER == BIG_ENDIAN) - warning ("%s endian file does not match %s endian target.", - bfd_big_endian (abfd) ? "big" : "little", - TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little"); - -#endif /* ! defined (TARGET_BYTE_ORDER_SELECTABLE) */ + { + if (bfd_big_endian (abfd) + ? TARGET_BYTE_ORDER != BIG_ENDIAN + : TARGET_BYTE_ORDER == BIG_ENDIAN) + warning ("%s endian file does not match %s endian target.", + bfd_big_endian (abfd) ? "big" : "little", + TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little"); + } } /* Functions to manipulate the architecture of the target */