This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [14/15] Byte order routines - part 1


> this patch addresses the use of current_gdbarch to retrieve target
> byte order in core conversion routines deep in the call chain.  The
> following routines now take an explicit BYTE_ORDER parameter:
> 
> - extract_signed_integer/extract_unsigned_integer/
>   extract_long_unsigned_integer
> - store_signed_integer/store_unsigned_integer
> - read_memory_integer/read_memory_unsigned_integer/safe_read_memory_integer
> - write_memory_signed_integer/write_memory_unsigned_integer
> - get_target_memory_unsigned
> - decimal_to_string/decimal_from_string/decimal_from_integral/
>   decimal_from_floating/decimal_to_doublest
> - decimal_is_zero/decimal_binop/decimal_compare/decimal_convert
> 
> These take just a BYTE_ORDER instead of a gdbarch because that's all
> they need, and because in some call sites no architecture is available.

This patch also required slight adaptations for changes that happened
in the meantime.  Here's part 1 of the version I checked in.

Bye,
Ulrich

ChangeLog:

	* defs.h (extract_signed_integer, extract_unsigned_integer,
	extract_long_unsigned_integer, store_signed_integer,
	store_unsigned_integer): Add BYTE_ORDER parameter.
	* findvar.c (extract_signed_integer, extract_unsigned_integer,
	extract_long_unsigned_integer, store_signed_integer,
	store_unsigned_integer): Add BYTE_ORDER parameter.  Use it
	instead of current_gdbarch.

	* gdbcore.h (read_memory_integer, safe_read_memory_integer,
	read_memory_unsigned_integer, write_memory_signed_integer,
	write_memory_unsigned_integer): Add BYTE_ORDER parameter.
	* corefile.c (struct captured_read_memory_integer_arguments): Add
	BYTE_ORDER member.
	(safe_read_memory_integer): Add BYTE_ORDER parameter.  Store it into
	struct captured_read_memory_integer_arguments.
	(do_captured_read_memory_integer): Pass it to read_memory_integer.
	(read_memory_integer): Add BYTE_ORDER parameter.  Pass it to
	extract_signed_integer.
	(read_memory_unsigned_integer): Add BYTE_ORDER parameter.  Pass it to
	extract_unsigned_integer.
	(write_memory_signed_integer): Add BYTE_ORDER parameter.  Pass it
	to store_signed_integer.
	(write_memory_unsigned_integer): Add BYTE_ORDER parameter.  Pass it
	to store_unsigned_integer.

	* target.h (get_target_memory_unsigned): Add BYTE_ORDER parameter.
	* target.c (get_target_memory_unsigned): Add BYTE_ORDER parameter.
	Pass it to extract_unsigned_integer.


	Update calls to extract_signed_integer, extract_unsigned_integer,
	extract_long_unsigned_integer, store_signed_integer,
	store_unsigned_integer, read_memory_integer,
	read_memory_unsigned_integer, safe_read_memory_integer,
	write_memory_signed_integer, write_memory_unsigned_integer, and
	get_target_memory_unsigned to pass byte order:
	* ada-lang.c (ada_value_binop): Update.
	* ada-valprint.c (char_at): Update.
	* alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Update.
	* alpha-tdep.c (alpha_lds, alpha_sts, alpha_push_dummy_call,
	alpha_extract_return_value, alpha_read_insn,
	alpha_get_longjmp_target): Update.
	* amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Update.
	* amd64obsd-tdep.c (amd64obsd_supply_uthread,
	amd64obsd_collect_uthread, amd64obsd_trapframe_cache): Update.
	* amd64-tdep.c (amd64_push_dummy_call, amd64_analyze_prologue,
	amd64_frame_cache, amd64_sigtramp_frame_cache, fixup_riprel,
	amd64_displaced_step_fixup): Update.
	* arm-linux-tdep.c (arm_linux_sigreturn_init,
	arm_linux_rt_sigreturn_init, arm_linux_supply_gregset): Update.
	* arm-tdep.c (thumb_analyze_prologue, arm_skip_prologue,
	arm_scan_prologue, arm_push_dummy_call, thumb_get_next_pc,
	arm_get_next_pc, arm_extract_return_value, arm_store_return_value,
	arm_return_value): Update.
	* arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update.
	* auxv.c (default_auxv_parse): Update.
	* avr-tdep.c (avr_address_to_pointer, avr_pointer_to_address,
	avr_scan_prologue, avr_extract_return_value,
	avr_frame_prev_register, avr_push_dummy_call): Update.
	* bsd-uthread.c (bsd_uthread_check_magic, bsd_uthread_lookup_offset,
	bsd_uthread_wait, bsd_uthread_thread_alive,
	bsd_uthread_extra_thread_info): Update.
	* c-lang.c (c_printstr, print_wchar): Update.
	* cp-valprint.c (cp_print_class_member): Update.
	* cris-tdep.c (cris_sigcontext_addr, cris_sigtramp_frame_unwind_cache,
	cris_push_dummy_call, cris_scan_prologue, cris_store_return_value,
	cris_extract_return_value, find_step_target, dip_prefix,
	sixteen_bit_offset_branch_op, none_reg_mode_jump_op,
	move_mem_to_reg_movem_op, get_data_from_address): Update.
	* dwarf2expr.c (dwarf2_read_address, execute_stack_op): Update.
	* dwarf2-frame.c (execute_cfa_program): Update.
	* dwarf2loc.c (find_location_expression): Update.
	* dwarf2read.c (dwarf2_const_value): Update.
	* expprint.c (print_subexp_standard): Update.
	* findvar.c (unsigned_pointer_to_address, signed_pointer_to_address,
	unsigned_address_to_pointer, address_to_signed_pointer,
	read_var_value): Update.
	* frame.c (frame_unwind_register_signed,
	frame_unwind_register_unsigned, get_frame_memory_signed,
	get_frame_memory_unsigned): Update.
	* frame-unwind.c (frame_unwind_got_constant): Update.
	* frv-linux-tdep.c (frv_linux_pc_in_sigtramp,
	frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache):
	Update.
	* frv-tdep.c (frv_analyze_prologue, frv_skip_main_prologue,
	frv_extract_return_value, find_func_descr,
	frv_convert_from_func_ptr_addr, frv_push_dummy_call): Update.
	* f-valprint.c (f_val_print): Update.
	* gnu-v3-abi.c (gnuv3_decode_method_ptr, gnuv3_make_method_ptr):
	Update.
	* h8300-tdep.c (h8300_is_argument_spill, h8300_analyze_prologue,
	h8300_push_dummy_call, h8300_extract_return_value,
	h8300h_extract_return_value, h8300_store_return_value,
	h8300h_store_return_value): Update.
	* hppabsd-tdep.c (hppabsd_find_global_pointer): Update.
	* hppa-hpux-nat.c (hppa_hpux_fetch_register, hppa_hpux_store_register):
	Update.
	* hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline,
	hppa64_hpux_in_solib_call_trampoline,
	hppa_hpux_in_solib_return_trampoline, hppa_hpux_skip_trampoline_code,
	hppa_hpux_sigtramp_frame_unwind_cache,
	hppa_hpux_sigtramp_unwind_sniffer, hppa32_hpux_find_global_pointer,
	hppa64_hpux_find_global_pointer, hppa_hpux_search_pattern,
	hppa32_hpux_search_dummy_call_sequence,
	hppa64_hpux_search_dummy_call_sequence, hppa_hpux_supply_save_state,
	hppa_hpux_unwind_adjust_stub): Update.
	* hppa-linux-tdep.c (insns_match_pattern,
	hppa_linux_find_global_pointer): Update.
	* hppa-tdep.c (hppa_in_function_epilogue_p, hppa32_push_dummy_call,
	hppa64_convert_code_addr_to_fptr, hppa64_push_dummy_call,
	skip_prologue_hard_way, hppa_frame_cache, hppa_fallback_frame_cache,
	hppa_pseudo_register_read, hppa_frame_prev_register_helper,
	hppa_match_insns): Update.
	* hpux-thread.c (hpux_thread_fetch_registers): Update.
	* i386-tdep.c (i386bsd_sigcontext_addr): Update.
	* i386-cygwin-tdep.c (core_process_module_section): Update.
	* i386-darwin-nat.c (i386_darwin_sstep_at_sigreturn,
	amd64_darwin_sstep_at_sigreturn): Update.
	* i386-darwin-tdep.c (i386_darwin_sigcontext_addr,
	amd64_darwin_sigcontext_addr): Likewise.
	* i386-linux-nat.c (i386_linux_sigcontext_addr): Update.
	* i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Update.
	* i386-nto-tdep.c (i386nto_sigcontext_addr): Update.
	* i386obsd-nat.c (i386obsd_supply_pcb): Update.
	* i386obsd-tdep.c (i386obsd_supply_uthread, i386obsd_collect_uthread,
	i386obsd_trapframe_cache): Update.
	* i386-tdep.c (i386_displaced_step_fixup, i386_follow_jump,
	i386_analyze_frame_setup, i386_analyze_prologue,
	i386_skip_main_prologue, i386_frame_cache, i386_sigtramp_frame_cache,
	i386_get_longjmp_target, i386_push_dummy_call,
	i386_pe_skip_trampoline_code, i386_svr4_sigcontext_addr,
	i386_fetch_pointer_argument): Update.
	* i387-tdep.c (i387_supply_fsave): Update.
	* ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Update.
	* ia64-tdep.c (ia64_pseudo_register_read, ia64_pseudo_register_write,
	examine_prologue, ia64_frame_cache, ia64_frame_prev_register,
	ia64_sigtramp_frame_cache, ia64_sigtramp_frame_prev_register,
	ia64_access_reg, ia64_access_rse_reg, ia64_libunwind_frame_this_id,
	ia64_libunwind_frame_prev_register,
	ia64_libunwind_sigtramp_frame_this_id,
	ia64_libunwind_sigtramp_frame_prev_register, ia64_find_global_pointer,
	find_extant_func_descr, find_func_descr,
	ia64_convert_from_func_ptr_addr, ia64_push_dummy_call, ia64_dummy_id,
	ia64_unwind_pc): Update.
	* iq2000-tdep.c (iq2000_pointer_to_address, iq2000_address_to_pointer,
	iq2000_scan_prologue, iq2000_extract_return_value,
	iq2000_push_dummy_call): Update.
	* irix5nat.c (fill_gregset): Update.
	* jv-lang.c (evaluate_subexp_java): Update.
	* jv-valprint.c (java_value_print): Update.
	* lm32-tdep.c (lm32_analyze_prologue, lm32_push_dummy_call, 
	lm32_extract_return_value, lm32_store_return_value): Update.
	* m32c-tdep.c (m32c_push_dummy_call, m32c_return_value,
	m32c_skip_trampoline_code, m32c_m16c_address_to_pointer,
	m32c_m16c_pointer_to_address): Update.
	* m32r-tdep.c (m32r_store_return_value, decode_prologue,
	m32r_skip_prologue, m32r_push_dummy_call, m32r_extract_return_value):
	Update.
	* m68hc11-tdep.c (m68hc11_pseudo_register_read,
	m68hc11_pseudo_register_write, m68hc11_analyze_instruction,
	m68hc11_push_dummy_call): Update.
	* m68linux-tdep.c (m68k_linux_pc_in_sigtramp,
	m68k_linux_get_sigtramp_info, m68k_linux_sigtramp_frame_cache):
	Update.
	* m68k-tdep.c (m68k_push_dummy_call, m68k_analyze_frame_setup,
	m68k_analyze_register_saves, m68k_analyze_prologue, m68k_frame_cache,
	m68k_get_longjmp_target): Update.
	* m88k-tdep.c (m88k_fetch_instruction): Update.
	* mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_csr_write,
	mep_pseudo_cr32_write, mep_get_insn, mep_push_dummy_call): Update.
	* mi/mi-main.c (mi_cmd_data_write_memory): Update.
	* mips-linux-tdep.c (mips_linux_get_longjmp_target, supply_32bit_reg,
	mips64_linux_get_longjmp_target, mips64_fill_gregset,
	mips64_fill_fpregset, mips_linux_in_dynsym_stub): Update.
	* mipsnbdsd-tdep.c (mipsnbsd_get_longjmp_target): Update.
	* mips-tdep.c (mips_fetch_instruction, fetch_mips_16,
	mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call,
	mips_o32_push_dummy_call, mips_o64_push_dummy_call, 
	mips_single_step_through_delay, mips_skip_pic_trampoline_code,
	mips_integer_to_address): Update.
	* mn10300-tdep.c (mn10300_analyze_prologue, mn10300_push_dummy_call):
	Update.
	* monitor.c (monitor_supply_register, monitor_write_memory,
	monitor_read_memory_single): Update.
	* moxie-tdep.c (moxie_store_return_value, moxie_extract_return_value,
	moxie_analyze_prologue): Update.
	* mt-tdep.c (mt_return_value, mt_skip_prologue, mt_select_coprocessor,
	mt_pseudo_register_read, mt_pseudo_register_write, mt_registers_info,
	mt_push_dummy_call): Update.
	* objc-lang.c (read_objc_method, read_objc_methlist_nmethods,
	read_objc_methlist_method, read_objc_object, read_objc_super,
	read_objc_class, find_implementation_from_class): Update.
	* ppc64-linux-tdep.c (ppc64_desc_entry_point,
	ppc64_linux_convert_from_func_ptr_addr, ppc_linux_sigtramp_cache):
	Update.
	* ppcobsd-tdep.c (ppcobsd_sigtramp_frame_sniffer,
	ppcobsd_sigtramp_frame_cache): Update.
	* ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call,
	do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call,
	ppc64_sysv_abi_return_value): Update.
	* ppc-linux-nat.c (ppc_linux_auxv_parse): Update.
	* procfs.c (procfs_auxv_parse): Update.
	* p-valprint.c (pascal_val_print): Update.
	* regcache.c (regcache_raw_read_signed, regcache_raw_read_unsigned,
	regcache_raw_write_signed, regcache_raw_write_unsigned,
	regcache_cooked_read_signed, regcache_cooked_read_unsigned,
	regcache_cooked_write_signed, regcache_cooked_write_unsigned): Update.
	* remote-m32r-sdi.c (m32r_fetch_register): Update.
	* remote-mips.c (mips_wait, mips_fetch_registers, mips_xfer_memory):
	Update.
	* rs6000-aix-tdep.c (rs6000_push_dummy_call, rs6000_return_value,
	rs6000_convert_from_func_ptr_addr, branch_dest, 
	rs6000_software_single_step): Update.
	* rs6000-tdep.c (rs6000_in_function_epilogue_p,
	ppc_displaced_step_fixup, ppc_deal_with_atomic_sequence,
	bl_to_blrl_insn_p, rs6000_fetch_instruction, skip_prologue,
	rs6000_skip_main_prologue, rs6000_skip_trampoline_code,
	rs6000_frame_cache): Update.
	* s390-tdep.c (s390_pseudo_register_read, s390_pseudo_register_write,
	s390x_pseudo_register_read, s390x_pseudo_register_write, s390_load,
	s390_backchain_frame_unwind_cache, s390_sigtramp_frame_unwind_cache,
	extend_simple_arg, s390_push_dummy_call, s390_return_value): Update.
	* scm-exp.c (scm_lreadr): Update.
	* scm-lang.c (scm_get_field, scm_unpack): Update.
	* scm-valprint.c (scm_val_print): Update.
	* score-tdep.c (score_breakpoint_from_pc, score_push_dummy_call,
	score_fetch_inst): Update.
	* sh64-tdep.c (look_for_args_moves, sh64_skip_prologue_hard_way,
	sh64_analyze_prologue, sh64_push_dummy_call, sh64_extract_return_value,
	sh64_pseudo_register_read, sh64_pseudo_register_write,
	sh64_frame_prev_register): Update:
	* sh-tdep.c (sh_analyze_prologue, sh_push_dummy_call_fpu,
	sh_push_dummy_call_nofpu, sh_extract_return_value_nofpu,
	sh_store_return_value_nofpu, sh_in_function_epilogue_p): Update.
	* solib-darwin.c (darwin_load_image_infos): Update.
	* solib-frv.c (fetch_loadmap, lm_base, frv_current_sos, enable_break2,
	find_canonical_descriptor_in_load_object): Update.
	* solib-irix.c (extract_mips_address, fetch_lm_info, irix_current_sos,
	irix_open_symbol_file_object): Update.
	* solib-som.c (som_solib_create_inferior_hook, link_map_start,
	som_current_sos, som_open_symbol_file_object): Update.
	* solib-sunos.c (SOLIB_EXTRACT_ADDRESS, LM_ADDR, LM_NEXT, LM_NAME):
	Update.
	* solib-svr4.c (read_program_header, scan_dyntag_auxv,
	solib_svr4_r_ldsomap): Update.
	* sparc64-linux-tdep.c (sparc64_linux_step_trap): Update.
	* sparc64obsd-tdep.c (sparc64obsd_supply_uthread,
	sparc64obsd_collect_uthread): Update.
	* sparc64-tdep.c (sparc64_pseudo_register_read,
	sparc64_pseudo_register_write, sparc64_supply_gregset,
	sparc64_collect_gregset): Update.
	* sparc-linux-tdep.c (sparc32_linux_step_trap): Update.
	* sparcobsd-tdep.c (sparc32obsd_supply_uthread,
	sparc32obsd_collect_uthread): Update.
	* sparc-tdep.c (sparc_fetch_wcookie, sparc32_push_dummy_code,
	sparc32_store_arguments, sparc32_return_value, sparc_supply_rwindow,
	sparc_collect_rwindow): Update.
	* spu-linux-nat.c (parse_spufs_run): Update.
	* spu-tdep.c (spu_pseudo_register_read_spu,
	spu_pseudo_register_write_spu, spu_pointer_to_address,
	spu_analyze_prologue, spu_in_function_epilogue_p,
	spu_frame_unwind_cache, spu_push_dummy_call, spu_software_single_step,
	spu_get_longjmp_target, spu_get_overlay_table, spu_overlay_update_osect,
	info_spu_signal_command, info_spu_mailbox_list, info_spu_dma_cmdlist,
	info_spu_dma_command, info_spu_proxydma_command): Update.
	* stack.c (print_frame_nameless_args, frame_info): Update.
	* symfile.c (read_target_long_array, simple_read_overlay_table,
	simple_read_overlay_region_table): Update.
	* target.c (debug_print_register): Update.
	* tramp-frame.c (tramp_frame_start): Update.
	* v850-tdep.c (v850_analyze_prologue, v850_push_dummy_call,
	v850_extract_return_value, v850_store_return_value, 
	* valarith.c (value_binop, value_bit_index): Update.
	* valops.c (value_cast): Update.
	* valprint.c (val_print_type_code_int, val_print_string,
	read_string): Update.
	* value.c (unpack_long, unpack_double, unpack_field_as_long,
	modify_field, pack_long): Update.
	* vax-tdep.c (vax_store_arguments, vax_push_dummy_call,
	vax_skip_prologue): Update.
	* xstormy16-tdep.c (xstormy16_push_dummy_call,
	xstormy16_analyze_prologue, xstormy16_in_function_epilogue_p,
	xstormy16_resolve_jmp_table_entry, xstormy16_find_jmp_table_entry,
	xstormy16_pointer_to_address, xstormy16_address_to_pointer): Update.
	* xtensa-tdep.c (extract_call_winsize, xtensa_pseudo_register_read,
	xtensa_pseudo_register_write, xtensa_frame_cache,
	xtensa_push_dummy_call, call0_track_op, call0_frame_cache): Update.


	* dfp.h (decimal_to_string, decimal_from_string, decimal_from_integral,
	decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add
	BYTE_ORDER parameter.
	(decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT
	parameters.
	(decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters.
	(decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters.
	* dfp.c (match_endianness): Add BYTE_ORDER parameter.  Use it
	instead of current_gdbarch.
	(decimal_to_string, decimal_from_integral, decimal_from_floating,
	decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter.
	Pass it to match_endianness.
	(decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT
	parameters.  Pass them to match_endianness.
	(decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters.
	Pass them to match_endianness.
	(decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters.
	Pass them to match_endianness.
	* valarith.c (value_args_as_decimal): Add BYTE_ORDER_X and
	BYTE_ORDER_Y output parameters.
	(value_binop): Update call to value_args_as_decimal.

	Update calls to decimal_to_string, decimal_from_string,
	decimal_from_integral, decimal_from_floating, decimal_to_doublest,
	decimal_is_zero, decimal_binop, decimal_compare and decimal_convert
	to pass/receive byte order:
	* c-exp.y (parse_number): Update.
	* printcmd.c (printf_command): Update.
	* valarith.c (value_args_as_decimal, value_binop, value_logical_not,
	value_equal, value_less): Update.
	* valops.c (value_cast, value_one): Update.
	* valprint.c (print_decimal_floating): Update.
	* value.c (unpack_long, unpack_double): Update.
	* python/python-value.c (valpy_nonzero): Update.


	* ada-valprint.c (char_at): Add BYTE_ORDER parameter.
	(printstr): Update calls to char_at.
	(ada_val_print_array): Likewise.
	* valprint.c (read_string): Add BYTE_ORDER parameter.
	(val_print_string): Update call to read_string.
	* c-lang.c (c_get_string): Likewise.
	* charset.h (target_wide_charset): Add BYTE_ORDER parameter.
	* charset.c (target_wide_charset): Add BYTE_ORDER parameter.
	Use it instead of current_gdbarch.
	* printcmd.c (printf_command): Update calls to target_wide_charset.
	* c-lang.c (charset_for_string_type): Add BYTE_ORDER parameter.
	Pass to target_wide_charset.  Use it instead of current_gdbarch.
	(classify_type): Add BYTE_ORDER parameter.  Pass to
	charset_for_string_type.  Allow NULL encoding pointer.
	(print_wchar): Add BYTE_ORDER parameter.
	(c_emit_char): Update calls to classify_type and print_wchar.
	(c_printchar, c_printstr): Likewise.


	* gdbarch.sh (in_solib_return_trampoline): Convert to type "m".
	* gdbarch.c, gdbarch.h: Regenerate.
	* arch-utils.h (generic_in_solib_return_trampoline): Add GDBARCH
	parameter.
	* arch-utils.c (generic_in_solib_return_trampoline): Likewise.
	* hppa-hpux-tdep.c (hppa_hpux_in_solib_return_trampoline): Likewise.
	* rs6000-tdep.c (rs6000_in_solib_return_trampoline): Likewise.
	(rs6000_skip_trampoline_code): Update call.

	* alpha-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to
	dynamic_sigtramp_offset and pc_in_sigtramp callbacks.
	(alpha_read_insn): Add GDBARCH parameter.
	* alpha-tdep.c (alpha_lds, alpha_sts): Add GDBARCH parameter.
	(alpha_register_to_value): Pass architecture to alpha_sts.
	(alpha_extract_return_value): Likewise.
	(alpha_value_to_register): Pass architecture to alpha_lds.
	(alpha_store_return_value): Likewise.
	(alpha_read_insn): Add GDBARCH parameter.
	(alpha_skip_prologue): Pass architecture to alpha_read_insn.
	(alpha_heuristic_proc_start): Likewise.
	(alpha_heuristic_frame_unwind_cache): Likewise.
	(alpha_next_pc): Likewise.
	(alpha_sigtramp_frame_this_id): Pass architecture to
	tdep->dynamic_sigtramp_offset callback.
	(alpha_sigtramp_frame_sniffer): Pass architecture to
	tdep->pc_in_sigtramp callback.
	* alphafbsd-tdep.c (alphafbsd_pc_in_sigtramp): Add GDBARCH parameter.
	(alphafbsd_sigtramp_offset): Likewise.
	* alpha-linux-tdep.c (alpha_linux_sigtramp_offset_1): Add GDBARCH
	parameter.  Pass to alpha_read_insn.
	(alpha_linux_sigtramp_offset): Add GDBARCH parameter.  Pass to
	alpha_linux_sigtramp_offset_1.
	(alpha_linux_pc_in_sigtramp): Add GDBARCH parameter.  Pass to
	alpha_linux_sigtramp_offset.
	(alpha_linux_sigcontext_addr): Pass architecture to alpha_read_insn
	and alpha_linux_sigtramp_offset.
	* alphanbsd-tdep.c (alphanbsd_sigtramp_offset): Add GDBARCH parameter.
	(alphanbsd_pc_in_sigtramp): Add GDBARCH parameter.  Pass to
	alphanbsd_sigtramp_offset.
	* alphaobsd-tdep.c (alphaobsd_sigtramp_offset): Add GDBARCH parameter.
	(alphaobsd_pc_in_sigtramp): Add GDBARCH parameter.  Pass to
	alpha_read_insn.
	(alphaobsd_sigcontext_addr): Pass architecture to
	alphaobsd_sigtramp_offset.
	* alpha-osf1-tdep.c (alpha_osf1_pc_in_sigtramp): Add GDBARCH
	parameter.

	* amd64-tdep.c (amd64_analyze_prologue): Add GDBARCH parameter.
	(amd64_skip_prologue): Pass architecture to amd64_analyze_prologue.
	(amd64_frame_cache): Likewise.

	* arm-tdep.c (SWAP_SHORT, SWAP_INT): Remove.
	(thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue,
	thumb_get_next_pc, arm_get_next_pc): Do not use SWAP_ macros.
	* arm-wince-tdep.c: Include "frame.h".

	* avr-tdep.c (EXTRACT_INSN): Remove.
	(avr_scan_prologue): Add GDBARCH argument, inline EXTRACT_INSN.
	(avr_skip_prologue): Pass architecture to avr_scan_prologue.
	(avr_frame_unwind_cache): Likewise.

	* cris-tdep.c (struct instruction_environment): Add BYTE_ORDER member.
	(find_step_target): Initialize it.
	(get_data_from_address): Add BYTE_ORDER parameter.
	(bdap_prefix): Pass byte order to get_data_from_address.
	(handle_prefix_assign_mode_for_aritm_op): Likewise.
	(three_operand_add_sub_cmp_and_or_op): Likewise.
	(handle_inc_and_index_mode_for_aritm_op): Likewise.

	* frv-linux-tdep.c (frv_linux_pc_in_sigtramp): Add GDBARCH parameter.
	(frv_linux_sigcontext_reg_addr): Pass architecture to
	frv_linux_pc_in_sigtramp.
	(frv_linux_sigtramp_frame_sniffer): Likewise.

	* h8300-tdep.c (h8300_is_argument_spill): Add GDBARCH parameter.
	(h8300_analyze_prologue): Add GDBARCH parameter.  Pass to
	h8300_is_argument_spill.
	(h8300_frame_cache, h8300_skip_prologue): Pass architecture
	to h8300_analyze_prologue.

	* hppa-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to
	in_solib_call_trampoline callback.
	(hppa_in_solib_call_trampoline): Add GDBARCH parameter.
	* hppa-tdep.c (hppa64_convert_code_addr_to_fptr): Add GDBARCH
	parameter.
	(hppa64_push_dummy_call): Pass architecture to
	hppa64_convert_code_addr_to_fptr.
	(hppa_match_insns): Add GDBARCH parameter.
	(hppa_match_insns_relaxed): Add GDBARCH parameter.  Pass to
	hppa_match_insns.
	(hppa_skip_trampoline_code): Pass architecture to hppa_match_insns.
	(hppa_in_solib_call_trampoline): Add GDBARCH parameter.  Pass to
	hppa_match_insns_relaxed.
	(hppa_stub_unwind_sniffer): Pass architecture to
	tdep->in_solib_call_trampoline callback.
	* hppa-hpux-tdep.c (hppa_hpux_search_pattern): Add GDBARCH parameter.
	(hppa32_hpux_search_dummy_call_sequence): Pass architecture to
	hppa_hpux_search_pattern.
	* hppa-linux-tdep.c (insns_match_pattern): Add GDBARCH parameter.
	(hppa_linux_sigtramp_find_sigcontext): Add GDBARCH parameter.
	Pass to insns_match_pattern.
	(hppa_linux_sigtramp_frame_unwind_cache): Pass architecture to
	hppa_linux_sigtramp_find_sigcontext.
	(hppa_linux_sigtramp_frame_sniffer): Likewise.
	(hppa32_hpux_in_solib_call_trampoline): Add GDBARCH parameter.
	(hppa64_hpux_in_solib_call_trampoline): Likewise.

	* i386-tdep.c (i386_follow_jump): Add GDBARCH parameter.
	(i386_analyze_frame_setup): Add GDBARCH parameter.
	(i386_analyze_prologue): Add GDBARCH parameter.  Pass to
	i386_follow_jump and i386_analyze_frame_setup.
	(i386_skip_prologue): Pass architecture to i386_analyze_prologue
	and i386_follow_jump.
	(i386_frame_cache): Pass architecture to i386_analyze_prologue.
	(i386_pe_skip_trampoline_code): Add FRAME parameter.
	* i386-tdep.h (i386_pe_skip_trampoline_code): Add FRAME parameter.
	* i386-cygwin-tdep.c (i386_cygwin_skip_trampoline_code): Pass
	frame to i386_pe_skip_trampoline_code.

	* ia64-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter
	to sigcontext_register_address callback.
	* ia64-tdep.c (ia64_find_global_pointer): Add GDBARCH parameter.
	(ia64_find_unwind_table): Pass architecture to
	ia64_find_global_pointer.
	(find_extant_func_descr): Add GDBARCH parameter.
	(find_func_descr): Pass architecture to find_extant_func_descr
	and ia64_find_global_pointer.
	(ia64_sigtramp_frame_init_saved_regs): Pass architecture to
	tdep->sigcontext_register_address callback.
	* ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Add
	GDBARCH parameter.

	* iq2000-tdep.c (iq2000_scan_prologue): Add GDBARCH parameter.
	(iq2000_frame_cache): Pass architecture to iq2000_scan_prologue.

	* lm32-tdep.c (lm32_analyze_prologue): Add GDBARCH parameter.
	(lm32_skip_prologue, lm32_frame_cache): Pass architecture to
	lm32_analyze_prologue.

	* m32r-tdep.c (decode_prologue): Add GDBARCH parameter.
	(m32r_skip_prologue): Pass architecture to decode_prologue.

	* m68hc11-tdep.c (m68hc11_analyze_instruction): Add GDBARCH parameter.
	(m68hc11_scan_prologue): Pass architecture to
	m68hc11_analyze_instruction.

	* m68k-tdep.c (m68k_analyze_frame_setup): Add GDBARCH parameter.
	(m68k_analyze_prologue): Pass architecture to
	m68k_analyze_frame_setup.

	* m88k-tdep.c (m88k_fetch_instruction): Add BYTE_ORDER parameter.
	(m88k_analyze_prologue): Add GDBARCH parameter.  Pass byte order
	to m88k_fetch_instruction.
	(m88k_skip_prologue): Pass architecture to m88k_analyze_prologue.
	(m88k_frame_cache): Likewise.

	* mep-tdep.c (mep_get_insn): Add GDBARCH parameter.
	(mep_analyze_prologue): Pass architecture to mep_get_insn.

	* mips-tdep.c (mips_fetch_instruction): Add GDBARCH parameter.
	(mips32_next_pc): Pass architecture to mips_fetch_instruction.
	(deal_with_atomic_sequence): Likewise.
	(unpack_mips16): Add GDBARCH parameter, pass to mips_fetch_instruction.
	(mips16_scan_prologue): Likewise.
	(mips32_scan_prologue): Likewise.
	(mips16_in_function_epilogue_p): Likewise.
	(mips32_in_function_epilogue_p): Likewise.
	(mips_about_to_return): Likewise.
	(mips_insn16_frame_cache): Pass architecture to mips16_scan_prologue.
	(mips_insn32_frame_cache): Pass architecture to mips32_scan_prologue.
	(mips_skip_prologue): Pass architecture to mips16_scan_prologue
	and mips32_scan_prologue.
	(mips_in_function_epilogue_p): Pass architecture to
	mips16_in_function_epilogue_p and
	mips32_in_function_epilogue_p.
	(heuristic_proc_start): Pass architecture to mips_fetch_instruction
	and mips_about_to_return.
	(mips_skip_mips16_trampoline_code): Pass architecture to
	mips_fetch_instruction.
	(fetch_mips_16): Add GDBARCH parameter.
	(mips16_next_pc): Pass architecture to fetch_mips_16.
	(extended_mips16_next_pc): Pass architecture to unpack_mips16 and
	fetch_mips_16.

	* objc-lang.c (read_objc_method, read_objc_methlist_nmethods,
	read_objc_methlist_method, read_objc_object, read_objc_super,
	read_objc_class): Add GDBARCH parameter.
	(find_implementation_from_class): Add GDBARCH parameter, pass
	to read_objc_class, read_objc_methlist_nmethods, and
	read_objc_methlist_method.
	(find_implementation): Add GDBARCH parameter, pass to
	read_objc_object and find_implementation_from_class.
	(resolve_msgsend, resolve_msgsend_stret): Pass architecture
	to find_implementation.
	(resolve_msgsend_super, resolve_msgsend_super_stret): Pass
	architecture to read_objc_super and find_implementation_from_class.

	* ppc64-linux-tdep.c (ppc64_desc_entry_point): Add GDBARCH parameter.
	(ppc64_standard_linkage1_target, ppc64_standard_linkage2_target,
	ppc64_standard_linkage3_target): Pass architecture to
	ppc64_desc_entry_point.
	* rs6000-tdep.c (bl_to_blrl_insn_p): Add BYTE_ORDER parameter.
	(skip_prologue): Pass byte order to bl_to_blrl_insn_p.
	(rs6000_fetch_instruction): Add GDBARCH parameter.
	(rs6000_skip_stack_check): Add GDBARCH parameter, pass to
	rs6000_fetch_instruction.
	(skip_prologue): Pass architecture to rs6000_fetch_instruction.
	
	* remote-mips.c (mips_store_word): Return old_contents as host
	integer value instead of target bytes.

	* s390-tdep.c (struct s390_prologue_data): Add BYTE_ORDER member.
	(s390_analyze_prologue): Initialize it.
	(extend_simple_arg): Add GDBARCH parameter.
	(s390_push_dummy_call): Pass architecture to extend_simple_arg.

	* scm-lang.c (scm_get_field): Add BYTE_ORDER parameter.
	* scm-lang.h (scm_get_field): Add BYTE_ORDER parameter.
	(SCM_CAR, SCM_CDR): Pass SCM_BYTE_ORDER to scm_get_field.
	* scm-valprint.c (scm_scmval_print): Likewise.
	(scm_scmlist_print, scm_ipruk, scm_scmval_print): Define
	SCM_BYTE_ORDER.

	* sh64-tdep.c (look_for_args_moves): Add GDBARCH parameter.
	(sh64_skip_prologue_hard_way): Add GDBARCH parameter, pass to
	look_for_args_moves.
	(sh64_skip_prologue): Pass architecture to
	sh64_skip_prologue_hard_way.
	* sh-tdep.c (sh_analyze_prologue): Add GDBARCH parameter.
	(sh_skip_prologue): Pass architecture to sh_analyze_prologue.
	(sh_frame_cache): Likewise.

	* solib-irix.c (extract_mips_address): Add GDBARCH parameter.
	(fetch_lm_info, irix_current_sos, irix_open_symbol_file_object):
	Pass architecture to extract_mips_address.

	* sparc-tdep.h (sparc_fetch_wcookie): Add GDBARCH parameter.
	* sparc-tdep.c (sparc_fetch_wcookie): Add GDBARCH parameter.
	(sparc_supply_rwindow, sparc_collect_rwindow): Pass architecture
	to sparc_fetch_wcookie.
	(sparc32_frame_prev_register): Likewise.
	* sparc64-tdep.c (sparc64_frame_prev_register): Likewise.
	* sparc32nbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise.
	* sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise.

	* spu-tdep.c (spu_analyze_prologue): Add GDBARCH parameter.
	(spu_skip_prologue): Pass architecture to spu_analyze_prologue.
	(spu_virtual_frame_pointer): Likewise.
	(spu_frame_unwind_cache): Likewise.
	(info_spu_mailbox_list): Add BYTE_ORER parameter.
	(info_spu_mailbox_command): Pass byte order to info_spu_mailbox_list.
	(info_spu_dma_cmdlist): Add BYTE_ORER parameter.
	(info_spu_dma_command, info_spu_proxydma_command): Pass byte order
	to info_spu_dma_cmdlist.

	* symfile.c (read_target_long_array): Add GDBARCH parameter.
	(simple_read_overlay_table, simple_read_overlay_region_table,
	simple_overlay_update_1): Pass architecture to read_target_long_array.

	* v850-tdep.c (v850_analyze_prologue): Add GDBARCH parameter.
	(v850_frame_cache): Pass architecture to v850_analyze_prologue.

	* xstormy16-tdep.c (xstormy16_analyze_prologue): Add GDBARCH
	parameter.
	(xstormy16_skip_prologue, xstormy16_frame_cache): Pass architecture
	to xstormy16_analyze_prologue.
	(xstormy16_resolve_jmp_table_entry): Add GDBARCH parameter.
	(xstormy16_find_jmp_table_entry): Likewise.
	(xstormy16_skip_trampoline_code): Pass architecture to
	xstormy16_resolve_jmp_table_entry.
	(xstormy16_pointer_to_address): Likewise.
	(xstormy16_address_to_pointer): Pass architecture to
	xstormy16_find_jmp_table_entry.

	* xtensa-tdep.c (call0_track_op): Add GDBARCH parameter.
	(call0_analyze_prologue): Add GDBARCH parameter, pass to
	call0_track_op.
	(call0_frame_cache): Pass architecture to call0_analyze_prologue.
	(xtensa_skip_prologue): Likewise.




Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -7922,7 +7922,8 @@ ada_value_binop (struct value *arg1, str
 
   val = allocate_value (type1);
   store_unsigned_integer (value_contents_raw (val),
-                          TYPE_LENGTH (value_type (val)), v);
+                          TYPE_LENGTH (value_type (val)),
+			  gdbarch_byte_order (get_type_arch (type1)), v);
   return val;
 }
 
Index: gdb-head/gdb/ada-valprint.c
===================================================================
--- gdb-head.orig/gdb/ada-valprint.c
+++ gdb-head/gdb/ada-valprint.c
@@ -292,12 +292,13 @@ ada_emit_char (int c, struct type *type,
    or 2) of a character.  */
 
 static int
-char_at (const gdb_byte *string, int i, int type_len)
+char_at (const gdb_byte *string, int i, int type_len,
+	 enum bfd_endian byte_order)
 {
   if (type_len == 1)
     return string[i];
   else
-    return (int) extract_unsigned_integer (string + 2 * i, 2);
+    return (int) extract_unsigned_integer (string + 2 * i, 2, byte_order);
 }
 
 /* Wrapper around memcpy to make it legal argument to ui_file_put */
@@ -466,6 +467,7 @@ printstr (struct ui_file *stream, struct
 	  unsigned int length, int force_ellipses, int type_len,
 	  const struct value_print_options *options)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (elttype));
   unsigned int i;
   unsigned int things_printed = 0;
   int in_quotes = 0;
@@ -496,8 +498,8 @@ printstr (struct ui_file *stream, struct
       rep1 = i + 1;
       reps = 1;
       while (rep1 < length
-	     && char_at (string, rep1, type_len) == char_at (string, i,
-							     type_len))
+	     && char_at (string, rep1, type_len, byte_order)
+		== char_at (string, i, type_len, byte_order))
 	{
 	  rep1 += 1;
 	  reps += 1;
@@ -514,8 +516,8 @@ printstr (struct ui_file *stream, struct
 	      in_quotes = 0;
 	    }
 	  fputs_filtered ("'", stream);
-	  ada_emit_char (char_at (string, i, type_len), elttype, stream, '\'',
-			 type_len);
+	  ada_emit_char (char_at (string, i, type_len, byte_order),
+			 elttype, stream, '\'', type_len);
 	  fputs_filtered ("'", stream);
 	  fprintf_filtered (stream, _(" <repeats %u times>"), reps);
 	  i = rep1 - 1;
@@ -532,8 +534,8 @@ printstr (struct ui_file *stream, struct
 		fputs_filtered ("\"", stream);
 	      in_quotes = 1;
 	    }
-	  ada_emit_char (char_at (string, i, type_len), elttype, stream, '"',
-			 type_len);
+	  ada_emit_char (char_at (string, i, type_len, byte_order),
+			 elttype, stream, '"', type_len);
 	  things_printed += 1;
 	}
     }
@@ -610,6 +612,7 @@ ada_val_print_array (struct type *type, 
 		     CORE_ADDR address, struct ui_file *stream, int recurse,
 		     const struct value_print_options *options)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
   struct type *elttype = TYPE_TARGET_TYPE (type);
   unsigned int eltlen;
   unsigned int len;
@@ -641,7 +644,7 @@ ada_val_print_array (struct type *type, 
           for (temp_len = 0;
                (temp_len < len
                 && temp_len < options->print_max
-                && char_at (valaddr, temp_len, eltlen) != 0);
+                && char_at (valaddr, temp_len, eltlen, byte_order) != 0);
                temp_len += 1);
           len = temp_len;
         }
Index: gdb-head/gdb/alphafbsd-tdep.c
===================================================================
--- gdb-head.orig/gdb/alphafbsd-tdep.c
+++ gdb-head/gdb/alphafbsd-tdep.c
@@ -65,13 +65,14 @@ CORE_ADDR alphafbsd_sigtramp_start = 0x1
 CORE_ADDR alphafbsd_sigtramp_end = 0x11ffffe0;
 
 static int
-alphafbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
+alphafbsd_pc_in_sigtramp (struct gdbarch *gdbarch,
+			  CORE_ADDR pc, char *func_name)
 {
   return (pc >= alphafbsd_sigtramp_start && pc < alphafbsd_sigtramp_end);
 }
 
 static LONGEST
-alphafbsd_sigtramp_offset (CORE_ADDR pc)
+alphafbsd_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   return pc - alphafbsd_sigtramp_start;
 }
Index: gdb-head/gdb/alpha-linux-tdep.c
===================================================================
--- gdb-head.orig/gdb/alpha-linux-tdep.c
+++ gdb-head/gdb/alpha-linux-tdep.c
@@ -44,9 +44,9 @@
 */
 
 static long
-alpha_linux_sigtramp_offset_1 (CORE_ADDR pc)
+alpha_linux_sigtramp_offset_1 (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
-  switch (alpha_read_insn (pc))
+  switch (alpha_read_insn (gdbarch, pc))
     {
     case 0x47de0410:		/* bis $30,$30,$16 */
     case 0x47fe0410:		/* bis $31,$30,$16 */
@@ -66,7 +66,7 @@ alpha_linux_sigtramp_offset_1 (CORE_ADDR
 }
 
 static LONGEST
-alpha_linux_sigtramp_offset (CORE_ADDR pc)
+alpha_linux_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   long i, off;
 
@@ -74,7 +74,7 @@ alpha_linux_sigtramp_offset (CORE_ADDR p
     return -1;
 
   /* Guess where we might be in the sequence.  */
-  off = alpha_linux_sigtramp_offset_1 (pc);
+  off = alpha_linux_sigtramp_offset_1 (gdbarch, pc);
   if (off < 0)
     return -1;
 
@@ -84,7 +84,7 @@ alpha_linux_sigtramp_offset (CORE_ADDR p
     {
       if (i == off)
 	continue;
-      if (alpha_linux_sigtramp_offset_1 (pc + i) != i)
+      if (alpha_linux_sigtramp_offset_1 (gdbarch, pc + i) != i)
 	return -1;
     }
 
@@ -92,14 +92,16 @@ alpha_linux_sigtramp_offset (CORE_ADDR p
 }
 
 static int
-alpha_linux_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
+alpha_linux_pc_in_sigtramp (struct gdbarch *gdbarch,
+			    CORE_ADDR pc, char *func_name)
 {
-  return alpha_linux_sigtramp_offset (pc) >= 0;
+  return alpha_linux_sigtramp_offset (gdbarch, pc) >= 0;
 }
 
 static CORE_ADDR
 alpha_linux_sigcontext_addr (struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   CORE_ADDR pc;
   ULONGEST sp;
   long off;
@@ -107,7 +109,7 @@ alpha_linux_sigcontext_addr (struct fram
   pc = get_frame_pc (this_frame);
   sp = get_frame_register_unsigned (this_frame, ALPHA_SP_REGNUM);
 
-  off = alpha_linux_sigtramp_offset (pc);
+  off = alpha_linux_sigtramp_offset (gdbarch, pc);
   gdb_assert (off >= 0);
 
   /* __NR_rt_sigreturn has a couple of structures on the stack.  This is:
@@ -119,7 +121,7 @@ alpha_linux_sigcontext_addr (struct fram
 
 	offsetof (struct rt_sigframe, uc.uc_mcontext);
   */
-  if (alpha_read_insn (pc - off + 4) == 0x201f015f)
+  if (alpha_read_insn (gdbarch, pc - off + 4) == 0x201f015f)
     return sp + 176;
 
   /* __NR_sigreturn has the sigcontext structure at the top of the stack.  */
Index: gdb-head/gdb/alphanbsd-tdep.c
===================================================================
--- gdb-head.orig/gdb/alphanbsd-tdep.c
+++ gdb-head/gdb/alphanbsd-tdep.c
@@ -211,7 +211,7 @@ static const unsigned char sigtramp_retc
 #define RETCODE_SIZE		(RETCODE_NWORDS * 4)
 
 static LONGEST
-alphanbsd_sigtramp_offset (CORE_ADDR pc)
+alphanbsd_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   unsigned char ret[RETCODE_SIZE], w[4];
   LONGEST off;
@@ -241,10 +241,11 @@ alphanbsd_sigtramp_offset (CORE_ADDR pc)
 }
 
 static int
-alphanbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
+alphanbsd_pc_in_sigtramp (struct gdbarch *gdbarch,
+		 	  CORE_ADDR pc, char *func_name)
 {
   return (nbsd_pc_in_sigtramp (pc, func_name)
-	  || alphanbsd_sigtramp_offset (pc) >= 0);
+	  || alphanbsd_sigtramp_offset (gdbarch, pc) >= 0);
 }
 
 static CORE_ADDR
Index: gdb-head/gdb/alphaobsd-tdep.c
===================================================================
--- gdb-head.orig/gdb/alphaobsd-tdep.c
+++ gdb-head/gdb/alphaobsd-tdep.c
@@ -40,13 +40,14 @@
 static const int alphaobsd_page_size = 8192;
 
 static LONGEST
-alphaobsd_sigtramp_offset (CORE_ADDR pc)
+alphaobsd_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   return (pc & (alphaobsd_page_size - 1));
 }
 
 static int
-alphaobsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
+alphaobsd_pc_in_sigtramp (struct gdbarch *gdbarch,
+			  CORE_ADDR pc, char *name)
 {
   CORE_ADDR start_pc = (pc & ~(alphaobsd_page_size - 1));
   unsigned insn;
@@ -55,12 +56,12 @@ alphaobsd_pc_in_sigtramp (CORE_ADDR pc, 
     return 0;
 
   /* Check for "".  */
-  insn = alpha_read_insn (start_pc + 5 * ALPHA_INSN_SIZE);
+  insn = alpha_read_insn (gdbarch, start_pc + 5 * ALPHA_INSN_SIZE);
   if (insn != 0x201f0067)
     return 0;
 
   /* Check for "".  */
-  insn = alpha_read_insn (start_pc + 6 * ALPHA_INSN_SIZE);
+  insn = alpha_read_insn (gdbarch, start_pc + 6 * ALPHA_INSN_SIZE);
   if (insn != 0x00000083)
     return 0;
 
@@ -70,14 +71,15 @@ alphaobsd_pc_in_sigtramp (CORE_ADDR pc, 
 static CORE_ADDR
 alphaobsd_sigcontext_addr (struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   CORE_ADDR pc = get_frame_pc (this_frame);
 
-  if (alphaobsd_sigtramp_offset (pc) < 3 * ALPHA_INSN_SIZE)
+  if (alphaobsd_sigtramp_offset (gdbarch, pc) < 3 * ALPHA_INSN_SIZE)
     {
       /* On entry, a pointer the `struct sigcontext' is passed in %a2.  */
       return get_frame_register_unsigned (this_frame, ALPHA_A0_REGNUM + 2);
     }
-  else if (alphaobsd_sigtramp_offset (pc) < 4 * ALPHA_INSN_SIZE)
+  else if (alphaobsd_sigtramp_offset (gdbarch, pc) < 4 * ALPHA_INSN_SIZE)
     {
       /* It is stored on the stack Before calling the signal handler.  */
       CORE_ADDR sp;
Index: gdb-head/gdb/alpha-osf1-tdep.c
===================================================================
--- gdb-head.orig/gdb/alpha-osf1-tdep.c
+++ gdb-head/gdb/alpha-osf1-tdep.c
@@ -27,7 +27,8 @@
 #include "alpha-tdep.h"
 
 static int
-alpha_osf1_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
+alpha_osf1_pc_in_sigtramp (struct gdbarch *gdbarch,
+			   CORE_ADDR pc, char *func_name)
 {
   return (func_name != NULL && strcmp ("__sigtramp", func_name) == 0);
 }
@@ -35,13 +36,15 @@ alpha_osf1_pc_in_sigtramp (CORE_ADDR pc,
 static CORE_ADDR
 alpha_osf1_sigcontext_addr (struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct frame_info *next_frame = get_next_frame (this_frame);
   struct frame_id next_id = null_frame_id;
   
   if (next_frame != NULL)
     next_id = get_frame_id (next_frame);
 
-  return (read_memory_integer (next_id.stack_addr, 8));
+  return (read_memory_integer (next_id.stack_addr, 8, byte_order));
 }
 
 static void
Index: gdb-head/gdb/alpha-tdep.c
===================================================================
--- gdb-head.orig/gdb/alpha-tdep.c
+++ gdb-head/gdb/alpha-tdep.c
@@ -154,9 +154,10 @@ alpha_register_reggroup_p (struct gdbarc
    floating point and 32-bit integers.  */
 
 static void
-alpha_lds (void *out, const void *in)
+alpha_lds (struct gdbarch *gdbarch, void *out, const void *in)
 {
-  ULONGEST mem     = extract_unsigned_integer (in, 4);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  ULONGEST mem     = extract_unsigned_integer (in, 4, byte_order);
   ULONGEST frac    = (mem >>  0) & 0x7fffff;
   ULONGEST sign    = (mem >> 31) & 1;
   ULONGEST exp_msb = (mem >> 30) & 1;
@@ -176,20 +177,21 @@ alpha_lds (void *out, const void *in)
     }
 
   reg = (sign << 63) | (exp << 52) | (frac << 29);
-  store_unsigned_integer (out, 8, reg);
+  store_unsigned_integer (out, 8, byte_order, reg);
 }
 
 /* Similarly, this represents exactly the conversion performed by
    the STS instruction.  */
 
 static void
-alpha_sts (void *out, const void *in)
+alpha_sts (struct gdbarch *gdbarch, void *out, const void *in)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST reg, mem;
 
-  reg = extract_unsigned_integer (in, 8);
+  reg = extract_unsigned_integer (in, 8, byte_order);
   mem = ((reg >> 32) & 0xc0000000) | ((reg >> 29) & 0x3fffffff);
-  store_unsigned_integer (out, 4, mem);
+  store_unsigned_integer (out, 4, byte_order, mem);
 }
 
 /* The alpha needs a conversion between register and memory format if the
@@ -215,7 +217,7 @@ alpha_register_to_value (struct frame_in
   switch (TYPE_LENGTH (valtype))
     {
     case 4:
-      alpha_sts (out, in);
+      alpha_sts (get_frame_arch (frame), out, in);
       break;
     default:
       error (_("Cannot retrieve value from floating point register"));
@@ -231,7 +233,7 @@ alpha_value_to_register (struct frame_in
   switch (TYPE_LENGTH (valtype))
     {
     case 4:
-      alpha_lds (out, in);
+      alpha_lds (get_frame_arch (frame), out, in);
       break;
     default:
       error (_("Cannot store value in floating point register"));
@@ -258,6 +260,7 @@ alpha_push_dummy_call (struct gdbarch *g
 		       int nargs, struct value **args, CORE_ADDR sp,
 		       int struct_return, CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int i;
   int accumulate_size = struct_return ? 8 : 0;
   struct alpha_arg
@@ -408,7 +411,8 @@ alpha_push_dummy_call (struct gdbarch *g
       write_memory (sp + offset - sizeof(arg_reg_buffer), contents, len);
     }
   if (struct_return)
-    store_unsigned_integer (arg_reg_buffer, ALPHA_REGISTER_SIZE, struct_addr);
+    store_unsigned_integer (arg_reg_buffer, ALPHA_REGISTER_SIZE,
+			    byte_order, struct_addr);
 
   /* Load the argument registers.  */
   for (i = 0; i < required_arg_regs; i++)
@@ -432,6 +436,8 @@ static void
 alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
 			    gdb_byte *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int length = TYPE_LENGTH (valtype);
   gdb_byte raw_buffer[ALPHA_REGISTER_SIZE];
   ULONGEST l;
@@ -443,7 +449,7 @@ alpha_extract_return_value (struct type 
 	{
 	case 4:
 	  regcache_cooked_read (regcache, ALPHA_FP0_REGNUM, raw_buffer);
-	  alpha_sts (valbuf, raw_buffer);
+	  alpha_sts (gdbarch, valbuf, raw_buffer);
 	  break;
 
 	case 8:
@@ -486,7 +492,7 @@ alpha_extract_return_value (struct type 
     default:
       /* Assume everything else degenerates to an integer.  */
       regcache_cooked_read_unsigned (regcache, ALPHA_V0_REGNUM, &l);
-      store_unsigned_integer (valbuf, length, l);
+      store_unsigned_integer (valbuf, length, byte_order, l);
       break;
     }
 }
@@ -509,7 +515,7 @@ alpha_store_return_value (struct type *v
       switch (length)
 	{
 	case 4:
-	  alpha_lds (raw_buffer, valbuf);
+	  alpha_lds (gdbarch, raw_buffer, valbuf);
 	  regcache_cooked_write (regcache, ALPHA_FP0_REGNUM, raw_buffer);
 	  break;
 
@@ -634,15 +640,16 @@ alpha_after_prologue (CORE_ADDR pc)
 /* Read an instruction from memory at PC, looking through breakpoints.  */
 
 unsigned int
-alpha_read_insn (CORE_ADDR pc)
+alpha_read_insn (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[ALPHA_INSN_SIZE];
   int status;
 
   status = target_read_memory (pc, buf, sizeof (buf));
   if (status)
     memory_error (status, pc);
-  return extract_unsigned_integer (buf, sizeof (buf));
+  return extract_unsigned_integer (buf, sizeof (buf), byte_order);
 }
 
 /* To skip prologues, I use this predicate.  Returns either PC itself
@@ -686,7 +693,7 @@ alpha_skip_prologue (struct gdbarch *gdb
      or in the gcc frame.  */
   for (offset = 0; offset < 100; offset += ALPHA_INSN_SIZE)
     {
-      inst = alpha_read_insn (pc + offset);
+      inst = alpha_read_insn (gdbarch, pc + offset);
 
       if ((inst & 0xffff0000) == 0x27bb0000)	/* ldah $gp,n($t12) */
 	continue;
@@ -721,7 +728,9 @@ alpha_skip_prologue (struct gdbarch *gdb
 static int
 alpha_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR jb_addr;
   gdb_byte raw_buffer[ALPHA_REGISTER_SIZE];
 
@@ -731,7 +740,7 @@ alpha_get_longjmp_target (struct frame_i
 			  raw_buffer, tdep->jb_elt_size))
     return 0;
 
-  *pc = extract_unsigned_integer (raw_buffer, tdep->jb_elt_size);
+  *pc = extract_unsigned_integer (raw_buffer, tdep->jb_elt_size, byte_order);
   return 1;
 }
 
@@ -810,7 +819,7 @@ alpha_sigtramp_frame_this_id (struct fra
     {
       int offset;
       code_addr = get_frame_pc (this_frame);
-      offset = tdep->dynamic_sigtramp_offset (code_addr);
+      offset = tdep->dynamic_sigtramp_offset (gdbarch, code_addr);
       if (offset >= 0)
 	code_addr -= offset;
       else
@@ -876,7 +885,7 @@ alpha_sigtramp_frame_sniffer (const stru
 
   /* Otherwise we should be in a signal frame.  */
   find_pc_partial_function (pc, &name, NULL, NULL);
-  if (gdbarch_tdep (gdbarch)->pc_in_sigtramp (pc, name))
+  if (gdbarch_tdep (gdbarch)->pc_in_sigtramp (gdbarch, pc, name))
     return 1;
 
   return 0;
@@ -931,7 +940,7 @@ alpha_heuristic_proc_start (struct gdbar
      nops, since this usually indicates padding between functions.  */
   for (pc -= ALPHA_INSN_SIZE; pc >= fence; pc -= ALPHA_INSN_SIZE)
     {
-      unsigned int insn = alpha_read_insn (pc);
+      unsigned int insn = alpha_read_insn (gdbarch, pc);
       switch (insn)
 	{
 	case 0:			/* invalid insn */
@@ -1027,7 +1036,7 @@ alpha_heuristic_frame_unwind_cache (stru
 
       for (cur_pc = start_pc; cur_pc < limit_pc; cur_pc += ALPHA_INSN_SIZE)
 	{
-	  unsigned int word = alpha_read_insn (cur_pc);
+	  unsigned int word = alpha_read_insn (gdbarch, cur_pc);
 
 	  if ((word & 0xffff0000) == 0x23de0000)	/* lda $sp,n($sp) */
 	    {
@@ -1115,7 +1124,7 @@ alpha_heuristic_frame_unwind_cache (stru
 	{
 	  while (cur_pc < (limit_pc + 80) && cur_pc < (start_pc + 80))
 	    {
-	      unsigned int word = alpha_read_insn (cur_pc);
+	      unsigned int word = alpha_read_insn (gdbarch, cur_pc);
 
 	      if ((word & 0xfc1f0000) == 0xb41e0000)	/* stq reg,n($sp) */
 		{
@@ -1358,13 +1367,14 @@ fp_register_sign_bit (LONGEST reg)
 static CORE_ADDR
 alpha_next_pc (struct frame_info *frame, CORE_ADDR pc)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
   unsigned int insn;
   unsigned int op;
   int regno;
   int offset;
   LONGEST rav;
 
-  insn = alpha_read_insn (pc);
+  insn = alpha_read_insn (gdbarch, pc);
 
   /* Opcode is top 6 bits. */
   op = (insn >> 26) & 0x3f;
@@ -1401,7 +1411,7 @@ alpha_next_pc (struct frame_info *frame,
           case 0x33:              /* FBLE */
           case 0x32:              /* FBLT */
           case 0x35:              /* FBNE */
-            regno += gdbarch_fp0_regnum (get_frame_arch (frame));
+            regno += gdbarch_fp0_regnum (gdbarch);
 	}
       
       rav = get_frame_register_signed (frame, regno);
Index: gdb-head/gdb/alpha-tdep.h
===================================================================
--- gdb-head.orig/gdb/alpha-tdep.h
+++ gdb-head/gdb/alpha-tdep.h
@@ -76,7 +76,7 @@ struct gdbarch_tdep
   /* If PC is inside a dynamically-generated signal trampoline function
      (i.e. one copied onto the user stack at run-time), return how many
      bytes PC is beyond the start of that function.  Otherwise, return -1.  */
-  LONGEST (*dynamic_sigtramp_offset) (CORE_ADDR);
+  LONGEST (*dynamic_sigtramp_offset) (struct gdbarch *, CORE_ADDR);
 
   /* Translate a signal handler stack base address into the address of
      the sigcontext structure for that signal handler.  */
@@ -86,7 +86,7 @@ struct gdbarch_tdep
   /* NOTE: cagney/2004-04-30: Do not copy/clone this code.  Instead
      look at tramp-frame.h and other simplier per-architecture
      sigtramp unwinders.  */
-  int (*pc_in_sigtramp) (CORE_ADDR pc, char *name);
+  int (*pc_in_sigtramp) (struct gdbarch *gdbarch, CORE_ADDR pc, char *name);
 
   /* If TYPE will be returned in memory, return true.  */
   int (*return_in_memory) (struct type *type);
@@ -102,7 +102,7 @@ struct gdbarch_tdep
   size_t jb_elt_size;		/* And the size of each entry in the buf. */
 };
 
-extern unsigned int alpha_read_insn (CORE_ADDR pc);
+extern unsigned int alpha_read_insn (struct gdbarch *gdbarch, CORE_ADDR pc);
 extern int alpha_software_single_step (struct frame_info *frame);
 extern CORE_ADDR alpha_after_prologue (CORE_ADDR pc);
 
Index: gdb-head/gdb/amd64-linux-tdep.c
===================================================================
--- gdb-head.orig/gdb/amd64-linux-tdep.c
+++ gdb-head/gdb/amd64-linux-tdep.c
@@ -153,11 +153,13 @@ amd64_linux_sigtramp_p (struct frame_inf
 static CORE_ADDR
 amd64_linux_sigcontext_addr (struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR sp;
   gdb_byte buf[8];
 
   get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
-  sp = extract_unsigned_integer (buf, 8);
+  sp = extract_unsigned_integer (buf, 8, byte_order);
 
   /* The sigcontext structure is part of the user context.  A pointer
      to the user context is passed as the third argument to the signal
Index: gdb-head/gdb/amd64obsd-tdep.c
===================================================================
--- gdb-head.orig/gdb/amd64obsd-tdep.c
+++ gdb-head/gdb/amd64obsd-tdep.c
@@ -251,6 +251,8 @@ static void
 amd64obsd_supply_uthread (struct regcache *regcache,
 			  int regnum, CORE_ADDR addr)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR sp_addr = addr + AMD64OBSD_UTHREAD_RSP_OFFSET;
   CORE_ADDR sp = 0;
   gdb_byte buf[8];
@@ -263,12 +265,12 @@ amd64obsd_supply_uthread (struct regcach
       int offset;
 
       /* Fetch stack pointer from thread structure.  */
-      sp = read_memory_unsigned_integer (sp_addr, 8);
+      sp = read_memory_unsigned_integer (sp_addr, 8, byte_order);
 
       /* Adjust the stack pointer such that it looks as if we just
          returned from _thread_machdep_switch.  */
       offset = amd64obsd_uthread_reg_offset[AMD64_RIP_REGNUM] + 8;
-      store_unsigned_integer (buf, 8, sp + offset);
+      store_unsigned_integer (buf, 8, byte_order, sp + offset);
       regcache_raw_supply (regcache, AMD64_RSP_REGNUM, buf);
     }
 
@@ -280,7 +282,7 @@ amd64obsd_supply_uthread (struct regcach
 	  /* Fetch stack pointer from thread structure (if we didn't
              do so already).  */
 	  if (sp == 0)
-	    sp = read_memory_unsigned_integer (sp_addr, 8);
+	    sp = read_memory_unsigned_integer (sp_addr, 8, byte_order);
 
 	  /* Read the saved register from the stack frame.  */
 	  read_memory (sp + amd64obsd_uthread_reg_offset[i], buf, 8);
@@ -293,6 +295,8 @@ static void
 amd64obsd_collect_uthread (const struct regcache *regcache,
 			   int regnum, CORE_ADDR addr)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR sp_addr = addr + AMD64OBSD_UTHREAD_RSP_OFFSET;
   CORE_ADDR sp = 0;
   gdb_byte buf[8];
@@ -308,10 +312,10 @@ amd64obsd_collect_uthread (const struct 
          stored into the thread structure.  */
       offset = amd64obsd_uthread_reg_offset[AMD64_RIP_REGNUM] + 8;
       regcache_raw_collect (regcache, AMD64_RSP_REGNUM, buf);
-      sp = extract_unsigned_integer (buf, 8) - offset;
+      sp = extract_unsigned_integer (buf, 8, byte_order) - offset;
 
       /* Store the stack pointer.  */
-      write_memory_unsigned_integer (sp_addr, 8, sp);
+      write_memory_unsigned_integer (sp_addr, 8, byte_order, sp);
 
       /* The stack pointer was (potentially) modified.  Make sure we
          build a proper stack frame.  */
@@ -326,7 +330,7 @@ amd64obsd_collect_uthread (const struct 
 	  /* Fetch stack pointer from thread structure (if we didn't
              calculate it already).  */
 	  if (sp == 0)
-	    sp = read_memory_unsigned_integer (sp_addr, 8);
+	    sp = read_memory_unsigned_integer (sp_addr, 8, byte_order);
 
 	  /* Write the register into the stack frame.  */
 	  regcache_raw_collect (regcache, i, buf);
@@ -343,6 +347,8 @@ amd64obsd_collect_uthread (const struct 
 static struct trad_frame_cache *
 amd64obsd_trapframe_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct trad_frame_cache *cache;
   CORE_ADDR func, sp, addr;
   ULONGEST cs;
@@ -370,7 +376,7 @@ amd64obsd_trapframe_cache (struct frame_
 
   /* Read %cs from trap frame.  */
   addr += amd64obsd_tf_reg_offset[AMD64_CS_REGNUM];
-  cs = read_memory_unsigned_integer (addr, 8); 
+  cs = read_memory_unsigned_integer (addr, 8, byte_order);
   if ((cs & I386_SEL_RPL) == I386_SEL_UPL)
     {
       /* Trap from user space; terminate backtrace.  */
Index: gdb-head/gdb/amd64-tdep.c
===================================================================
--- gdb-head.orig/gdb/amd64-tdep.c
+++ gdb-head/gdb/amd64-tdep.c
@@ -677,6 +677,7 @@ amd64_push_dummy_call (struct gdbarch *g
 		       int nargs, struct value **args,	CORE_ADDR sp,
 		       int struct_return, CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[8];
 
   /* Pass arguments.  */
@@ -685,17 +686,17 @@ amd64_push_dummy_call (struct gdbarch *g
   /* Pass "hidden" argument".  */
   if (struct_return)
     {
-      store_unsigned_integer (buf, 8, struct_addr);
+      store_unsigned_integer (buf, 8, byte_order, struct_addr);
       regcache_cooked_write (regcache, AMD64_RDI_REGNUM, buf);
     }
 
   /* Store return address.  */
   sp -= 8;
-  store_unsigned_integer (buf, 8, bp_addr);
+  store_unsigned_integer (buf, 8, byte_order, bp_addr);
   write_memory (sp, buf, 8);
 
   /* Finally, update the stack pointer...  */
-  store_unsigned_integer (buf, 8, sp);
+  store_unsigned_integer (buf, 8, byte_order, sp);
   regcache_cooked_write (regcache, AMD64_RSP_REGNUM, buf);
 
   /* ...and fake a frame pointer.  */
@@ -1034,6 +1035,7 @@ static void
 fixup_riprel (struct gdbarch *gdbarch, struct displaced_step_closure *dsc,
 	      CORE_ADDR from, CORE_ADDR to, struct regcache *regs)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   const struct amd64_insn *insn_details = &dsc->insn_details;
   int modrm_offset = insn_details->modrm_offset;
   gdb_byte *insn = insn_details->raw_insn + modrm_offset;
@@ -1047,7 +1049,7 @@ fixup_riprel (struct gdbarch *gdbarch, s
   ++insn;
 
   /* Compute the rip-relative address.	*/
-  disp = extract_signed_integer (insn, sizeof (int32_t));
+  disp = extract_signed_integer (insn, sizeof (int32_t), byte_order);
   insn_length = amd64_insn_length (gdbarch, dsc->insn_buf, dsc->max_len, from);
   rip_base = from + insn_length;
 
@@ -1251,6 +1253,7 @@ amd64_displaced_step_fixup (struct gdbar
 			    CORE_ADDR from, CORE_ADDR to,
 			    struct regcache *regs)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   /* The offset we applied to the instruction's address.  */
   ULONGEST insn_offset = to - from;
   gdb_byte *insn = dsc->insn_buf;
@@ -1354,9 +1357,9 @@ amd64_displaced_step_fixup (struct gdbar
       const ULONGEST retaddr_len = 8;
 
       regcache_cooked_read_unsigned (regs, AMD64_RSP_REGNUM, &rsp);
-      retaddr = read_memory_unsigned_integer (rsp, retaddr_len);
+      retaddr = read_memory_unsigned_integer (rsp, retaddr_len, byte_order);
       retaddr = (retaddr - insn_offset) & 0xffffffffUL;
-      write_memory_unsigned_integer (rsp, retaddr_len, retaddr);
+      write_memory_unsigned_integer (rsp, retaddr_len, byte_order, retaddr);
 
       if (debug_displaced)
 	fprintf_unfiltered (gdb_stdlog,
@@ -1589,9 +1592,11 @@ amd64_analyze_stack_align (CORE_ADDR pc,
    to have no prologue and thus no valid frame pointer in %rbp.  */
 
 static CORE_ADDR
-amd64_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
+amd64_analyze_prologue (struct gdbarch *gdbarch,
+			CORE_ADDR pc, CORE_ADDR current_pc,
 			struct amd64_frame_cache *cache)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   static gdb_byte proto[3] = { 0x48, 0x89, 0xe5 }; /* movq %rsp, %rbp */
   gdb_byte buf[3];
   gdb_byte op;
@@ -1601,7 +1606,7 @@ amd64_analyze_prologue (CORE_ADDR pc, CO
 
   pc = amd64_analyze_stack_align (pc, current_pc, cache);
 
-  op = read_memory_unsigned_integer (pc, 1);
+  op = read_memory_unsigned_integer (pc, 1, byte_order);
 
   if (op == 0x55)		/* pushq %rbp */
     {
@@ -1636,7 +1641,8 @@ amd64_skip_prologue (struct gdbarch *gdb
   CORE_ADDR pc;
 
   amd64_init_frame_cache (&cache);
-  pc = amd64_analyze_prologue (start_pc, 0xffffffffffffffffLL, &cache);
+  pc = amd64_analyze_prologue (gdbarch, start_pc, 0xffffffffffffffffLL,
+			       &cache);
   if (cache.frameless_p)
     return start_pc;
 
@@ -1649,6 +1655,8 @@ amd64_skip_prologue (struct gdbarch *gdb
 static struct amd64_frame_cache *
 amd64_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct amd64_frame_cache *cache;
   gdb_byte buf[8];
   int i;
@@ -1661,13 +1669,14 @@ amd64_frame_cache (struct frame_info *th
 
   cache->pc = get_frame_func (this_frame);
   if (cache->pc != 0)
-    amd64_analyze_prologue (cache->pc, get_frame_pc (this_frame), cache);
+    amd64_analyze_prologue (gdbarch, cache->pc, get_frame_pc (this_frame),
+			    cache);
 
   if (cache->saved_sp_reg != -1)
     {
       /* Stack pointer has been saved.  */
       get_frame_register (this_frame, cache->saved_sp_reg, buf);
-      cache->saved_sp = extract_unsigned_integer(buf, 8);
+      cache->saved_sp = extract_unsigned_integer(buf, 8, byte_order);
     }
 
   if (cache->frameless_p)
@@ -1691,13 +1700,14 @@ amd64_frame_cache (struct frame_info *th
       else
 	{
 	  get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
-	  cache->base = extract_unsigned_integer (buf, 8) + cache->sp_offset;
+	  cache->base = extract_unsigned_integer (buf, 8, byte_order)
+			+ cache->sp_offset;
 	}
     }
   else
     {
       get_frame_register (this_frame, AMD64_RBP_REGNUM, buf);
-      cache->base = extract_unsigned_integer (buf, 8);
+      cache->base = extract_unsigned_integer (buf, 8, byte_order);
     }
 
   /* Now that we have the base address for the stack frame we can
@@ -1773,8 +1783,10 @@ static const struct frame_unwind amd64_f
 static struct amd64_frame_cache *
 amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct amd64_frame_cache *cache;
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
   CORE_ADDR addr;
   gdb_byte buf[8];
   int i;
@@ -1785,7 +1797,7 @@ amd64_sigtramp_frame_cache (struct frame
   cache = amd64_alloc_frame_cache ();
 
   get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
-  cache->base = extract_unsigned_integer (buf, 8) - 8;
+  cache->base = extract_unsigned_integer (buf, 8, byte_order) - 8;
 
   addr = tdep->sigcontext_addr (this_frame);
   gdb_assert (tdep->sc_reg_offset);
Index: gdb-head/gdb/arch-utils.c
===================================================================
--- gdb-head.orig/gdb/arch-utils.c
+++ gdb-head/gdb/arch-utils.c
@@ -118,7 +118,8 @@ generic_skip_solib_resolver (struct gdba
 }
 
 int
-generic_in_solib_return_trampoline (CORE_ADDR pc, char *name)
+generic_in_solib_return_trampoline (struct gdbarch *gdbarch,
+				    CORE_ADDR pc, char *name)
 {
   return 0;
 }
Index: gdb-head/gdb/arch-utils.h
===================================================================
--- gdb-head.orig/gdb/arch-utils.h
+++ gdb-head/gdb/arch-utils.h
@@ -92,7 +92,8 @@ extern CORE_ADDR generic_skip_trampoline
 extern CORE_ADDR generic_skip_solib_resolver (struct gdbarch *gdbarch,
 					      CORE_ADDR pc);
 
-extern int generic_in_solib_return_trampoline (CORE_ADDR pc, char *name);
+extern int generic_in_solib_return_trampoline (struct gdbarch *gdbarch,
+					       CORE_ADDR pc, char *name);
 
 extern int generic_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc);
 
Index: gdb-head/gdb/arm-linux-tdep.c
===================================================================
--- gdb-head.orig/gdb/arm-linux-tdep.c
+++ gdb-head/gdb/arm-linux-tdep.c
@@ -284,8 +284,10 @@ arm_linux_sigreturn_init (const struct t
 			  struct trad_frame_cache *this_cache,
 			  CORE_ADDR func)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR sp = get_frame_register_unsigned (this_frame, ARM_SP_REGNUM);
-  ULONGEST uc_flags = read_memory_unsigned_integer (sp, 4);
+  ULONGEST uc_flags = read_memory_unsigned_integer (sp, 4, byte_order);
 
   if (uc_flags == ARM_NEW_SIGFRAME_MAGIC)
     arm_linux_sigtramp_cache (this_frame, this_cache, func,
@@ -302,8 +304,10 @@ arm_linux_rt_sigreturn_init (const struc
 			  struct trad_frame_cache *this_cache,
 			  CORE_ADDR func)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR sp = get_frame_register_unsigned (this_frame, ARM_SP_REGNUM);
-  ULONGEST pinfo = read_memory_unsigned_integer (sp, 4);
+  ULONGEST pinfo = read_memory_unsigned_integer (sp, 4, byte_order);
 
   if (pinfo == sp + ARM_OLD_RT_SIGFRAME_SIGINFO)
     arm_linux_sigtramp_cache (this_frame, this_cache, func,
@@ -368,6 +372,8 @@ arm_linux_supply_gregset (const struct r
 			  struct regcache *regcache,
 			  int regnum, const void *gregs_buf, size_t len)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   const gdb_byte *gregs = gregs_buf;
   int regno;
   CORE_ADDR reg_pc;
@@ -392,9 +398,9 @@ arm_linux_supply_gregset (const struct r
     {
       reg_pc = extract_unsigned_integer (gregs
 					 + INT_REGISTER_SIZE * ARM_PC_REGNUM,
-					 INT_REGISTER_SIZE);
-      reg_pc = gdbarch_addr_bits_remove (get_regcache_arch (regcache), reg_pc);
-      store_unsigned_integer (pc_buf, INT_REGISTER_SIZE, reg_pc);
+					 INT_REGISTER_SIZE, byte_order);
+      reg_pc = gdbarch_addr_bits_remove (gdbarch, reg_pc);
+      store_unsigned_integer (pc_buf, INT_REGISTER_SIZE, byte_order, reg_pc);
       regcache_raw_supply (regcache, ARM_PC_REGNUM, pc_buf);
     }
 }
Index: gdb-head/gdb/arm-tdep.c
===================================================================
--- gdb-head.orig/gdb/arm-tdep.c
+++ gdb-head/gdb/arm-tdep.c
@@ -68,19 +68,6 @@ static int arm_debug;
 #define MSYMBOL_IS_SPECIAL(msym)				\
 	MSYMBOL_TARGET_FLAG_1 (msym)
 
-/* Macros for swapping shorts and ints. In the unlikely case that anybody else needs these,
-   move to a general header. (A better solution might be to define memory read routines that
-   know whether they are reading code or data.)  */
-
-#define SWAP_SHORT(x) \
-  ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8));
-
-#define SWAP_INT(x) \
-  (  ((x & 0xff000000) >> 24) \
-   | ((x & 0x00ff0000) >> 8)  \
-   | ((x & 0x0000ff00) << 8)  \
-   | ((x & 0x000000ff) << 24))
-
 /* Per-objfile data used for mapping symbols.  */
 static const struct objfile_data *arm_objfile_data_key;
 
@@ -387,6 +374,7 @@ thumb_analyze_prologue (struct gdbarch *
 			CORE_ADDR start, CORE_ADDR limit,
 			struct arm_prologue_cache *cache)
 {
+  enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
   int i;
   pv_t regs[16];
   struct pv_area *stack;
@@ -402,10 +390,7 @@ thumb_analyze_prologue (struct gdbarch *
     {
       unsigned short insn;
 
-      insn = read_memory_unsigned_integer (start, 2);
-
-      if (gdbarch_byte_order_for_code (gdbarch) != gdbarch_byte_order (gdbarch))
-	insn = SWAP_SHORT (insn);
+      insn = read_memory_unsigned_integer (start, 2, byte_order_for_code);
 
       if ((insn & 0xfe00) == 0xb400)		/* push { rlist } */
 	{
@@ -533,6 +518,7 @@ thumb_analyze_prologue (struct gdbarch *
 static CORE_ADDR
 arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
   unsigned long inst;
   CORE_ADDR skip_pc;
   CORE_ADDR func_addr, limit_pc;
@@ -571,10 +557,7 @@ arm_skip_prologue (struct gdbarch *gdbar
 
   for (skip_pc = pc; skip_pc < limit_pc; skip_pc += 4)
     {
-      inst = read_memory_unsigned_integer (skip_pc, 4);
-
-      if (gdbarch_byte_order_for_code (gdbarch) != gdbarch_byte_order (gdbarch))
-	inst = SWAP_INT (inst);
+      inst = read_memory_unsigned_integer (skip_pc, 4, byte_order_for_code);
 
       /* "mov ip, sp" is no longer a required part of the prologue.  */
       if (inst == 0xe1a0c00d)			/* mov ip, sp */
@@ -754,6 +737,8 @@ arm_scan_prologue (struct frame_info *th
 		   struct arm_prologue_cache *cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
   int regno;
   CORE_ADDR prologue_start, prologue_end, current_pc;
   CORE_ADDR prev_pc = get_frame_pc (this_frame);
@@ -827,7 +812,7 @@ arm_scan_prologue (struct frame_info *th
       LONGEST return_value;
 
       frame_loc = get_frame_register_unsigned (this_frame, ARM_FP_REGNUM);
-      if (!safe_read_memory_integer (frame_loc, 4, &return_value))
+      if (!safe_read_memory_integer (frame_loc, 4, byte_order, &return_value))
         return;
       else
         {
@@ -870,10 +855,8 @@ arm_scan_prologue (struct frame_info *th
        current_pc < prologue_end;
        current_pc += 4)
     {
-      unsigned int insn = read_memory_unsigned_integer (current_pc, 4);
-
-      if (gdbarch_byte_order_for_code (gdbarch) != gdbarch_byte_order (gdbarch))
-	insn = SWAP_INT (insn);
+      unsigned int insn
+	= read_memory_unsigned_integer (current_pc, 4, byte_order_for_code);
 
       if (insn == 0xe1a0c00d)		/* mov ip, sp */
 	{
@@ -1400,6 +1383,7 @@ arm_push_dummy_call (struct gdbarch *gdb
 		     struct value **args, CORE_ADDR sp, int struct_return,
 		     CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int argnum;
   int argreg;
   int nstack;
@@ -1481,11 +1465,12 @@ arm_push_dummy_call (struct gdbarch *gdb
 	  && target_type != NULL
 	  && TYPE_CODE_FUNC == TYPE_CODE (target_type))
 	{
-	  CORE_ADDR regval = extract_unsigned_integer (val, len);
+	  CORE_ADDR regval = extract_unsigned_integer (val, len, byte_order);
 	  if (arm_pc_is_thumb (regval))
 	    {
 	      val = alloca (len);
-	      store_unsigned_integer (val, len, MAKE_THUMB_ADDR (regval));
+	      store_unsigned_integer (val, len, byte_order,
+				      MAKE_THUMB_ADDR (regval));
 	    }
 	}
 
@@ -1500,8 +1485,9 @@ arm_push_dummy_call (struct gdbarch *gdb
 	    {
 	      /* The argument is being passed in a general purpose
 		 register.  */
-	      CORE_ADDR regval = extract_unsigned_integer (val, partial_len);
-	      if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
+	      CORE_ADDR regval
+		= extract_unsigned_integer (val, partial_len, byte_order);
+	      if (byte_order == BFD_ENDIAN_BIG)
 		regval <<= (INT_REGISTER_SIZE - partial_len) * 8;
 	      if (arm_debug)
 		fprintf_unfiltered (gdb_stdlog, "arg %d in %s = 0x%s\n",
@@ -1843,13 +1829,14 @@ static CORE_ADDR
 thumb_get_next_pc (struct frame_info *frame, CORE_ADDR pc)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
   unsigned long pc_val = ((unsigned long) pc) + 4;	/* PC after prefetch */
-  unsigned short inst1 = read_memory_unsigned_integer (pc, 2);
+  unsigned short inst1;
   CORE_ADDR nextpc = pc + 2;		/* default is next instruction */
   unsigned long offset;
 
-  if (gdbarch_byte_order_for_code (gdbarch) != gdbarch_byte_order (gdbarch))
-    inst1 = SWAP_SHORT (inst1);
+  inst1 = read_memory_unsigned_integer (pc, 2, byte_order_for_code);
 
   if ((inst1 & 0xff00) == 0xbd00)	/* pop {rlist, pc} */
     {
@@ -1859,7 +1846,7 @@ thumb_get_next_pc (struct frame_info *fr
          all of the other registers.  */
       offset = bitcount (bits (inst1, 0, 7)) * INT_REGISTER_SIZE;
       sp = get_frame_register_unsigned (frame, ARM_SP_REGNUM);
-      nextpc = (CORE_ADDR) read_memory_unsigned_integer (sp + offset, 4);
+      nextpc = read_memory_unsigned_integer (sp + offset, 4, byte_order);
       nextpc = gdbarch_addr_bits_remove (gdbarch, nextpc);
       if (nextpc == pc)
 	error (_("Infinite loop detected"));
@@ -1877,9 +1864,8 @@ thumb_get_next_pc (struct frame_info *fr
     }
   else if ((inst1 & 0xf800) == 0xf000)	/* long branch with link, and blx */
     {
-      unsigned short inst2 = read_memory_unsigned_integer (pc + 2, 2);
-      if (gdbarch_byte_order_for_code (gdbarch) != gdbarch_byte_order (gdbarch))
-	inst2 = SWAP_SHORT (inst2);
+      unsigned short inst2;
+      inst2 = read_memory_unsigned_integer (pc + 2, 2, byte_order_for_code);
       offset = (sbits (inst1, 0, 10) << 12) + (bits (inst2, 0, 10) << 1);
       nextpc = pc_val + offset;
       /* For BLX make sure to clear the low bits.  */
@@ -1905,6 +1891,8 @@ CORE_ADDR
 arm_get_next_pc (struct frame_info *frame, CORE_ADDR pc)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
   unsigned long pc_val;
   unsigned long this_instr;
   unsigned long status;
@@ -1914,10 +1902,7 @@ arm_get_next_pc (struct frame_info *fram
     return thumb_get_next_pc (frame, pc);
 
   pc_val = (unsigned long) pc;
-  this_instr = read_memory_unsigned_integer (pc, 4);
-
-  if (gdbarch_byte_order_for_code (gdbarch) != gdbarch_byte_order (gdbarch))
-    this_instr = SWAP_INT (this_instr);
+  this_instr = read_memory_unsigned_integer (pc, 4, byte_order_for_code);
 
   status = get_frame_register_unsigned (frame, ARM_PS_REGNUM);
   nextpc = (CORE_ADDR) (pc_val + 4);	/* Default case */
@@ -2098,7 +2083,7 @@ arm_get_next_pc (struct frame_info *fram
 			base -= offset;
 		    }
 		  nextpc = (CORE_ADDR) read_memory_integer ((CORE_ADDR) base,
-							    4);
+							    4, byte_order);
 
 		  nextpc = gdbarch_addr_bits_remove (gdbarch, nextpc);
 
@@ -2136,7 +2121,7 @@ arm_get_next_pc (struct frame_info *fram
 		    nextpc =
 		      (CORE_ADDR) read_memory_integer ((CORE_ADDR) (rn_val
 								  + offset),
-						       4);
+						       4, byte_order);
 		  }
 		  nextpc = gdbarch_addr_bits_remove
 			     (gdbarch, nextpc);
@@ -2309,6 +2294,7 @@ arm_extract_return_value (struct type *t
 			  gdb_byte *valbuf)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regs);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   if (TYPE_CODE_FLT == TYPE_CODE (type))
     {
@@ -2363,7 +2349,7 @@ arm_extract_return_value (struct type *t
 	  store_unsigned_integer (valbuf, 
 				  (len > INT_REGISTER_SIZE
 				   ? INT_REGISTER_SIZE : len),
-				  tmp);
+				  byte_order, tmp);
 	  len -= INT_REGISTER_SIZE;
 	  valbuf += INT_REGISTER_SIZE;
 	}
@@ -2498,6 +2484,7 @@ arm_store_return_value (struct type *typ
 			const gdb_byte *valbuf)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regs);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   if (TYPE_CODE (type) == TYPE_CODE_FLT)
     {
@@ -2541,7 +2528,7 @@ arm_store_return_value (struct type *typ
 	  bfd_byte tmpbuf[INT_REGISTER_SIZE];
 	  LONGEST val = unpack_long (type, valbuf);
 
-	  store_signed_integer (tmpbuf, INT_REGISTER_SIZE, val);
+	  store_signed_integer (tmpbuf, INT_REGISTER_SIZE, byte_order, val);
 	  regcache_cooked_write (regs, ARM_A1_REGNUM, tmpbuf);
 	}
       else
@@ -2612,9 +2599,11 @@ arm_return_value (struct gdbarch *gdbarc
 static int
 arm_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR jb_addr;
   char buf[INT_REGISTER_SIZE];
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
   
   jb_addr = get_frame_register_unsigned (frame, ARM_A1_REGNUM);
 
@@ -2622,7 +2611,7 @@ arm_get_longjmp_target (struct frame_inf
 			  INT_REGISTER_SIZE))
     return 0;
 
-  *pc = extract_unsigned_integer (buf, INT_REGISTER_SIZE);
+  *pc = extract_unsigned_integer (buf, INT_REGISTER_SIZE, byte_order);
   return 1;
 }
 
Index: gdb-head/gdb/arm-wince-tdep.c
===================================================================
--- gdb-head.orig/gdb/arm-wince-tdep.c
+++ gdb-head/gdb/arm-wince-tdep.c
@@ -24,6 +24,7 @@
 #include "target.h"
 #include "solib.h"
 #include "solib-target.h"
+#include "frame.h"
 
 #include "gdb_string.h"
 
@@ -39,6 +40,8 @@ static const char arm_wince_thumb_le_bre
 static CORE_ADDR
 arm_pe_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST indirect;
   struct minimal_symbol *indsym;
   char *symname;
@@ -50,11 +53,11 @@ arm_pe_skip_trampoline_code (struct fram
        .dw __imp_<func>  */
 
   if (pc == 0
-      || read_memory_unsigned_integer (pc + 0, 4) != 0xe59fc000
-      || read_memory_unsigned_integer (pc + 4, 4) != 0xe59cf000)
+      || read_memory_unsigned_integer (pc + 0, 4, byte_order) != 0xe59fc000
+      || read_memory_unsigned_integer (pc + 4, 4, byte_order) != 0xe59cf000)
     return 0;
 
-  indirect = read_memory_unsigned_integer (pc + 8, 4);
+  indirect = read_memory_unsigned_integer (pc + 8, 4, byte_order);
   if (indirect == 0)
     return 0;
 
@@ -66,7 +69,7 @@ arm_pe_skip_trampoline_code (struct fram
   if (symname == NULL || strncmp (symname, "__imp_", 6) != 0)
     return 0;
 
-  next_pc = read_memory_unsigned_integer (indirect, 4);
+  next_pc = read_memory_unsigned_integer (indirect, 4, byte_order);
   if (next_pc != 0)
     return next_pc;
 
Index: gdb-head/gdb/auxv.c
===================================================================
--- gdb-head.orig/gdb/auxv.c
+++ gdb-head/gdb/auxv.c
@@ -82,6 +82,7 @@ default_auxv_parse (struct target_ops *o
 {
   const int sizeof_auxv_field = gdbarch_ptr_bit (target_gdbarch)
 				/ TARGET_CHAR_BIT;
+  const enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   gdb_byte *ptr = *readptr;
 
   if (endptr == ptr)
@@ -90,9 +91,9 @@ default_auxv_parse (struct target_ops *o
   if (endptr - ptr < sizeof_auxv_field * 2)
     return -1;
 
-  *typep = extract_unsigned_integer (ptr, sizeof_auxv_field);
+  *typep = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
   ptr += sizeof_auxv_field;
-  *valp = extract_unsigned_integer (ptr, sizeof_auxv_field);
+  *valp = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
   ptr += sizeof_auxv_field;
 
   *readptr = ptr;
Index: gdb-head/gdb/avr-tdep.c
===================================================================
--- gdb-head.orig/gdb/avr-tdep.c
+++ gdb-head/gdb/avr-tdep.c
@@ -72,9 +72,6 @@
 #undef XMALLOC
 #define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
 
-#undef EXTRACT_INSN
-#define EXTRACT_INSN(addr) extract_unsigned_integer(addr,2)
-
 /* Constants: prefixed with AVR_ to avoid name space clashes */
 
 enum
@@ -282,17 +279,19 @@ static void
 avr_address_to_pointer (struct gdbarch *gdbarch,
 			struct type *type, gdb_byte *buf, CORE_ADDR addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   /* Is it a code address?  */
   if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC
       || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_METHOD)
     {
-      store_unsigned_integer (buf, TYPE_LENGTH (type),
+      store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order,
 			      avr_convert_iaddr_to_raw (addr >> 1));
     }
   else
     {
       /* Strip off any upper segment bits.  */
-      store_unsigned_integer (buf, TYPE_LENGTH (type),
+      store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order,
 			      avr_convert_saddr_to_raw (addr));
     }
 }
@@ -301,7 +300,9 @@ static CORE_ADDR
 avr_pointer_to_address (struct gdbarch *gdbarch,
 			struct type *type, const gdb_byte *buf)
 {
-  CORE_ADDR addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  CORE_ADDR addr
+    = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
 
   /* Is it a code address?  */
   if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC
@@ -423,9 +424,10 @@ avr_write_pc (struct regcache *regcache,
    types.  */
 
 static CORE_ADDR
-avr_scan_prologue (CORE_ADDR pc_beg, CORE_ADDR pc_end,
+avr_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR pc_beg, CORE_ADDR pc_end,
 		   struct avr_unwind_cache *info)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int i;
   unsigned short insn;
   int scan_stage = 0;
@@ -458,12 +460,12 @@ avr_scan_prologue (CORE_ADDR pc_beg, COR
 	0xcd, 0xbf		/* out __SP_L__,r28 */
       };
 
-      insn = EXTRACT_INSN (&prologue[vpc]);
+      insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
       /* ldi r28,lo8(<RAM_ADDR> - <LOCALS_SIZE>) */
       if ((insn & 0xf0f0) == 0xe0c0)
 	{
 	  locals = (insn & 0xf) | ((insn & 0x0f00) >> 4);
-	  insn = EXTRACT_INSN (&prologue[vpc + 2]);
+	  insn = extract_unsigned_integer (&prologue[vpc + 2], 2, byte_order);
 	  /* ldi r29,hi8(<RAM_ADDR> - <LOCALS_SIZE>) */
 	  if ((insn & 0xf0f0) == 0xe0d0)
 	    {
@@ -494,28 +496,28 @@ avr_scan_prologue (CORE_ADDR pc_beg, COR
       if (len < 10)
 	break;
 
-      insn = EXTRACT_INSN (&prologue[vpc]);
+      insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
       /* ldi r26,<LOCALS_SIZE> */
       if ((insn & 0xf0f0) != 0xe0a0)
 	break;
       loc_size = (insn & 0xf) | ((insn & 0x0f00) >> 4);
       pc_offset += 2;
 
-      insn = EXTRACT_INSN (&prologue[vpc + 2]);
+      insn = extract_unsigned_integer (&prologue[vpc + 2], 2, byte_order);
       /* ldi r27,<LOCALS_SIZE> / 256 */
       if ((insn & 0xf0f0) != 0xe0b0)
 	break;
       loc_size |= ((insn & 0xf) | ((insn & 0x0f00) >> 4)) << 8;
       pc_offset += 2;
 
-      insn = EXTRACT_INSN (&prologue[vpc + 4]);
+      insn = extract_unsigned_integer (&prologue[vpc + 4], 2, byte_order);
       /* ldi r30,pm_lo8(.L_foo_body) */
       if ((insn & 0xf0f0) != 0xe0e0)
 	break;
       body_addr = (insn & 0xf) | ((insn & 0x0f00) >> 4);
       pc_offset += 2;
 
-      insn = EXTRACT_INSN (&prologue[vpc + 6]);
+      insn = extract_unsigned_integer (&prologue[vpc + 6], 2, byte_order);
       /* ldi r31,pm_hi8(.L_foo_body) */
       if ((insn & 0xf0f0) != 0xe0f0)
 	break;
@@ -526,7 +528,7 @@ avr_scan_prologue (CORE_ADDR pc_beg, COR
       if (!msymbol)
 	break;
 
-      insn = EXTRACT_INSN (&prologue[vpc + 8]);
+      insn = extract_unsigned_integer (&prologue[vpc + 8], 2, byte_order);
       /* rjmp __prologue_saves__+RRR */
       if ((insn & 0xf000) == 0xc000)
         {
@@ -546,7 +548,8 @@ avr_scan_prologue (CORE_ADDR pc_beg, COR
         {
           /* Extract absolute PC address from JMP */
           i = (((insn & 0x1) | ((insn & 0x1f0) >> 3) << 16)
-            | (EXTRACT_INSN (&prologue[vpc + 10]) & 0xffff));
+	       | (extract_unsigned_integer (&prologue[vpc + 10], 2, byte_order)
+		  & 0xffff));
           /* Convert address to byte addressable mode */
           i *= 2;
 
@@ -630,7 +633,7 @@ avr_scan_prologue (CORE_ADDR pc_beg, COR
 
   for (; vpc < len; vpc += 2)
     {
-      insn = EXTRACT_INSN (&prologue[vpc]);
+      insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
       if ((insn & 0xfe0f) == 0x920f)	/* push rXX */
 	{
 	  /* Bits 4-9 contain a mask for registers R0-R32. */
@@ -699,14 +702,14 @@ avr_scan_prologue (CORE_ADDR pc_beg, COR
 	0xcd, 0xbf		/* out 0x3d,r28 ; SPL */
       };
 
-      insn = EXTRACT_INSN (&prologue[vpc]);
+      insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
       vpc += 2;
       if ((insn & 0xff30) == 0x9720)	/* sbiw r28,XXX */
 	locals_size = (insn & 0xf) | ((insn & 0xc0) >> 2);
       else if ((insn & 0xf0f0) == 0x50c0)	/* subi r28,lo8(XX) */
 	{
 	  locals_size = (insn & 0xf) | ((insn & 0xf00) >> 4);
-	  insn = EXTRACT_INSN (&prologue[vpc]);
+	  insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
 	  vpc += 2;
 	  locals_size += ((insn & 0xf) | ((insn & 0xf00) >> 4) << 8);
 	}
@@ -744,7 +747,7 @@ avr_scan_prologue (CORE_ADDR pc_beg, COR
 
   for (; vpc < len; vpc += 2)
     {
-      insn = EXTRACT_INSN (&prologue[vpc]);
+      insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
       if ((insn & 0xff00) == 0x0100)	/* movw rXX, rYY */
         continue;
       else if ((insn & 0xfc00) == 0x2c00) /* mov rXX, rYY */
@@ -776,7 +779,7 @@ avr_skip_prologue (struct gdbarch *gdbar
          prologue and possibly skip over moving arguments passed via registers
          to other registers.  */
 
-      prologue_end = avr_scan_prologue (func_addr, func_end, &info);
+      prologue_end = avr_scan_prologue (gdbarch, func_addr, func_end, &info);
 
       if (info.prologue_type == AVR_PROLOGUE_NONE)
         return pc;
@@ -817,13 +820,15 @@ static void
 avr_extract_return_value (struct type *type, struct regcache *regcache,
                           gdb_byte *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST r24, r25;
   ULONGEST c;
   int len;
   if (TYPE_LENGTH (type) == 1)
     {
       regcache_cooked_read_unsigned (regcache, 24, &c);
-      store_unsigned_integer (valbuf, 1, c);
+      store_unsigned_integer (valbuf, 1, byte_order, c);
     }
   else
     {
@@ -909,7 +914,8 @@ avr_frame_unwind_cache (struct frame_inf
   start_pc = get_frame_func (this_frame);
   current_pc = get_frame_pc (this_frame);
   if ((start_pc > 0) && (start_pc <= current_pc))
-    avr_scan_prologue (start_pc, current_pc, info);
+    avr_scan_prologue (get_frame_arch (this_frame),
+		       start_pc, current_pc, info);
 
   if ((info->prologue_type != AVR_PROLOGUE_NONE)
       && (info->prologue_type != AVR_PROLOGUE_MAIN))
@@ -1015,6 +1021,8 @@ static struct value *
 avr_frame_prev_register (struct frame_info *this_frame,
 			 void **this_prologue_cache, int regnum)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct avr_unwind_cache *info
     = avr_frame_unwind_cache (this_frame, this_prologue_cache);
 
@@ -1171,6 +1179,7 @@ avr_push_dummy_call (struct gdbarch *gdb
                      int nargs, struct value **args, CORE_ADDR sp,
                      int struct_return, CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int i;
   unsigned char buf[2];
   CORE_ADDR return_pc = avr_convert_iaddr_to_raw (bp_addr);
@@ -1209,7 +1218,7 @@ avr_push_dummy_call (struct gdbarch *gdb
           if (len & 1)
             regnum--;
 
-          val = extract_unsigned_integer (contents, len);
+          val = extract_unsigned_integer (contents, len, byte_order);
           for (j=0; j<len; j++)
             {
               regcache_cooked_write_unsigned (regcache, regnum--,
Index: gdb-head/gdb/bsd-uthread.c
===================================================================
--- gdb-head.orig/gdb/bsd-uthread.c
+++ gdb-head/gdb/bsd-uthread.c
@@ -93,7 +93,8 @@ bsd_uthread_set_collect_uthread (struct 
 static void
 bsd_uthread_check_magic (CORE_ADDR addr)
 {
-  ULONGEST magic = read_memory_unsigned_integer (addr, 4);
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+  ULONGEST magic = read_memory_unsigned_integer (addr, 4, byte_order);
 
   if (magic != BSD_UTHREAD_PTHREAD_MAGIC)
     error (_("Bad magic"));
@@ -136,13 +137,14 @@ bsd_uthread_lookup_address (const char *
 static int
 bsd_uthread_lookup_offset (const char *name, struct objfile *objfile)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   CORE_ADDR addr;
 
   addr = bsd_uthread_lookup_address (name, objfile);
   if (addr == 0)
     return 0;
 
-  return read_memory_unsigned_integer (addr, 4);
+  return read_memory_unsigned_integer (addr, 4, byte_order);
 }
 
 static CORE_ADDR
@@ -347,6 +349,7 @@ static ptid_t
 bsd_uthread_wait (struct target_ops *ops,
 		  ptid_t ptid, struct target_waitstatus *status, int options)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   CORE_ADDR addr;
   struct target_ops *beneath = find_target_beneath (ops);
 
@@ -372,7 +375,7 @@ bsd_uthread_wait (struct target_ops *ops
          been read from the wrong virtual memory image.  */
       if (target_read_memory (addr, buf, 4) == 0)
 	{
-	  ULONGEST magic = extract_unsigned_integer (buf, 4);
+	  ULONGEST magic = extract_unsigned_integer (buf, 4, byte_order);
 	  if (magic == BSD_UTHREAD_PTHREAD_MAGIC)
 	    ptid = ptid_build (ptid_get_pid (ptid), 0, addr);
 	}
@@ -404,6 +407,7 @@ bsd_uthread_resume (struct target_ops *o
 static int
 bsd_uthread_thread_alive (struct target_ops *ops, ptid_t ptid)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   struct target_ops *beneath = find_target_beneath (ops);
   CORE_ADDR addr = ptid_get_tid (inferior_ptid);
 
@@ -414,7 +418,7 @@ bsd_uthread_thread_alive (struct target_
 
       bsd_uthread_check_magic (addr);
 
-      state = read_memory_unsigned_integer (addr + offset, 4);
+      state = read_memory_unsigned_integer (addr + offset, 4, byte_order);
       if (state == BSD_UTHREAD_PS_DEAD)
 	return 0;
     }
@@ -480,6 +484,7 @@ static char *bsd_uthread_state[] =
 static char *
 bsd_uthread_extra_thread_info (struct thread_info *info)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   CORE_ADDR addr = ptid_get_tid (info->ptid);
 
   if (addr != 0)
@@ -487,7 +492,7 @@ bsd_uthread_extra_thread_info (struct th
       int offset = bsd_uthread_thread_state_offset;
       ULONGEST state;
 
-      state = read_memory_unsigned_integer (addr + offset, 4);
+      state = read_memory_unsigned_integer (addr + offset, 4, byte_order);
       if (state < ARRAY_SIZE (bsd_uthread_state))
 	return bsd_uthread_state[state];
     }
Index: gdb-head/gdb/c-exp.y
===================================================================
--- gdb-head.orig/gdb/c-exp.y
+++ gdb-head/gdb/c-exp.y
@@ -1181,7 +1181,8 @@ parse_number (char *p, int len, int pars
 	  p[len - 2] = '\0';
 	  putithere->typed_val_decfloat.type
 	    = parse_type->builtin_decfloat;
-	  decimal_from_string (putithere->typed_val_decfloat.val, 4, p);
+	  decimal_from_string (putithere->typed_val_decfloat.val, 4,
+			       gdbarch_byte_order (parse_gdbarch), p);
 	  p[len - 2] = 'd';
 	  return DECFLOAT;
 	}
@@ -1191,7 +1192,8 @@ parse_number (char *p, int len, int pars
 	  p[len - 2] = '\0';
 	  putithere->typed_val_decfloat.type
 	    = parse_type->builtin_decdouble;
-	  decimal_from_string (putithere->typed_val_decfloat.val, 8, p);
+	  decimal_from_string (putithere->typed_val_decfloat.val, 8,
+			       gdbarch_byte_order (parse_gdbarch), p);
 	  p[len - 2] = 'd';
 	  return DECFLOAT;
 	}
@@ -1201,7 +1203,8 @@ parse_number (char *p, int len, int pars
 	  p[len - 2] = '\0';
 	  putithere->typed_val_decfloat.type
 	    = parse_type->builtin_declong;
-	  decimal_from_string (putithere->typed_val_decfloat.val, 16, p);
+	  decimal_from_string (putithere->typed_val_decfloat.val, 16,
+			       gdbarch_byte_order (parse_gdbarch), p);
 	  p[len - 2] = 'd';
 	  return DECFLOAT;
 	}
Index: gdb-head/gdb/c-lang.c
===================================================================
--- gdb-head.orig/gdb/c-lang.c
+++ gdb-head/gdb/c-lang.c
@@ -42,23 +42,24 @@ extern void _initialize_c_language (void
    character set name.  */
 
 static const char *
-charset_for_string_type (enum c_string_type str_type)
+charset_for_string_type (enum c_string_type str_type,
+			 enum bfd_endian byte_order)
 {
   switch (str_type & ~C_CHAR)
     {
     case C_STRING:
       return target_charset ();
     case C_WIDE_STRING:
-      return target_wide_charset ();
+      return target_wide_charset (byte_order);
     case C_STRING_16:
       /* FIXME: UCS-2 is not always correct.  */
-      if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+      if (byte_order == BFD_ENDIAN_BIG)
 	return "UCS-2BE";
       else
 	return "UCS-2LE";
     case C_STRING_32:
       /* FIXME: UCS-4 is not always correct.  */
-      if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+      if (byte_order == BFD_ENDIAN_BIG)
 	return "UCS-4BE";
       else
 	return "UCS-4LE";
@@ -69,10 +70,11 @@ charset_for_string_type (enum c_string_t
 /* Classify ELTTYPE according to what kind of character it is.  Return
    the enum constant representing the character type.  Also set
    *ENCODING to the name of the character set to use when converting
-   characters of this type to the host character set.  */
+   characters of this type in target BYTE_ORDER to the host character set.  */
 
 static enum c_string_type
-classify_type (struct type *elttype, const char **encoding)
+classify_type (struct type *elttype, enum bfd_endian byte_order,
+	       const char **encoding)
 {
   struct type *saved_type;
   enum c_string_type result;
@@ -131,7 +133,9 @@ classify_type (struct type *elttype, con
   result = C_CHAR;
 
  done:
-  *encoding = charset_for_string_type (result);
+  if (encoding)
+    *encoding = charset_for_string_type (result, byte_order);
+
   return result;
 }
 
@@ -172,8 +176,8 @@ append_string_as_wide (const char *strin
 
 static void
 print_wchar (gdb_wint_t w, const gdb_byte *orig, int orig_len,
-	     int width, struct obstack *output, int quoter,
-	     int *need_escapep)
+	     int width, enum bfd_endian byte_order, struct obstack *output,
+	     int quoter, int *need_escapep)
 {
   int need_escape = *need_escapep;
   *need_escapep = 0;
@@ -219,7 +223,8 @@ print_wchar (gdb_wint_t w, const gdb_byt
 	    for (i = 0; i + width <= orig_len; i += width)
 	      {
 		char octal[30];
-		ULONGEST value = extract_unsigned_integer (&orig[i], width);
+		ULONGEST value;
+		value = extract_unsigned_integer (&orig[i], width, byte_order);
 		sprintf (octal, "\\%lo", (long) value);
 		append_string_as_wide (octal, output);
 	      }
@@ -246,6 +251,7 @@ print_wchar (gdb_wint_t w, const gdb_byt
 static void
 c_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
   struct obstack wchar_buf, output;
   struct cleanup *cleanups;
   const char *encoding;
@@ -253,7 +259,7 @@ c_emit_char (int c, struct type *type, s
   struct wchar_iterator *iter;
   int need_escape = 0;
 
-  classify_type (type, &encoding);
+  classify_type (type, byte_order, &encoding);
 
   buf = alloca (TYPE_LENGTH (type));
   pack_long (buf, type, c);
@@ -299,14 +305,14 @@ c_emit_char (int c, struct type *type, s
 	    {
 	      for (i = 0; i < num_chars; ++i)
 		print_wchar (chars[i], buf, buflen, TYPE_LENGTH (type),
-			     &wchar_buf, quoter, &need_escape);
+			     byte_order, &wchar_buf, quoter, &need_escape);
 	    }
 	}
 
       /* This handles the NUM_CHARS == 0 case as well.  */
       if (print_escape)
-	print_wchar (gdb_WEOF, buf, buflen, TYPE_LENGTH (type), &wchar_buf,
-		     quoter, &need_escape);
+	print_wchar (gdb_WEOF, buf, buflen, TYPE_LENGTH (type), byte_order,
+		     &wchar_buf, quoter, &need_escape);
     }
 
   /* The output in the host encoding.  */
@@ -328,9 +334,8 @@ void
 c_printchar (int c, struct type *type, struct ui_file *stream)
 {
   enum c_string_type str_type;
-  const char *encoding;
 
-  str_type = classify_type (type, &encoding);
+  str_type = classify_type (type, BFD_ENDIAN_UNKNOWN, NULL);
   switch (str_type)
     {
     case C_CHAR:
@@ -362,6 +367,7 @@ c_printstr (struct ui_file *stream, stru
 	    unsigned int length, int force_ellipses,
 	    const struct value_print_options *options)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
   unsigned int i;
   unsigned int things_printed = 0;
   int in_quotes = 0;
@@ -380,10 +386,11 @@ c_printstr (struct ui_file *stream, stru
      style.  */
   if (!force_ellipses
       && length > 0
-      && (extract_unsigned_integer (string + (length - 1) * width, width) == 0))
+      && (extract_unsigned_integer (string + (length - 1) * width,
+				    width, byte_order) == 0))
     length--;
 
-  str_type = classify_type (type, &encoding) & ~C_CHAR;
+  str_type = classify_type (type, byte_order, &encoding) & ~C_CHAR;
   switch (str_type)
     {
     case C_STRING:
@@ -411,7 +418,8 @@ c_printstr (struct ui_file *stream, stru
       for (i = 0; current_char; ++i)
 	{
 	  QUIT;
-	  current_char = extract_unsigned_integer (string + i * width, width);
+	  current_char = extract_unsigned_integer (string + i * width,
+						   width, byte_order);
 	}
       length = i;
     }
@@ -481,7 +489,7 @@ c_printstr (struct ui_file *stream, stru
 	      obstack_grow_wstr (&wchar_buf, LCST ("'"));
 	      need_escape = 0;
 	      print_wchar (current_char, orig_buf, orig_len, width,
-			   &wchar_buf, '\'', &need_escape);
+			   byte_order, &wchar_buf, '\'', &need_escape);
 	      obstack_grow_wstr (&wchar_buf, LCST ("'"));
 	      {
 		/* Painful gyrations.  */
@@ -514,7 +522,7 @@ c_printstr (struct ui_file *stream, stru
 	      while (reps-- > 0)
 		{
 		  print_wchar (current_char, orig_buf, orig_len, width,
-			       &wchar_buf, '"', &need_escape);
+			       byte_order, &wchar_buf, '"', &need_escape);
 		  ++things_printed;
 		}
 	    }
@@ -541,7 +549,7 @@ c_printstr (struct ui_file *stream, stru
 	      in_quotes = 1;
 	    }
 	  need_escape = 0;
-	  print_wchar (gdb_WEOF, buf, buflen, width, &wchar_buf,
+	  print_wchar (gdb_WEOF, buf, buflen, width, byte_order, &wchar_buf,
 		       '"', &need_escape);
 	  break;
 
@@ -555,7 +563,7 @@ c_printstr (struct ui_file *stream, stru
 	      in_quotes = 0;
 	    }
 	  obstack_grow_wstr (&wchar_buf, LCST (" <incomplete sequence "));
-	  print_wchar (gdb_WEOF, buf, buflen, width, &wchar_buf,
+	  print_wchar (gdb_WEOF, buf, buflen, width, byte_order, &wchar_buf,
 		       0, &need_escape);
 	  obstack_grow_wstr (&wchar_buf, LCST (">"));
 	  finished = 1;
@@ -612,6 +620,7 @@ c_get_string (struct value *value, gdb_b
   unsigned int fetchlimit;
   struct type *type = check_typedef (value_type (value));
   struct type *element_type = TYPE_TARGET_TYPE (type);
+  enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
 
   if (element_type == NULL)
     goto error;
@@ -659,7 +668,8 @@ c_get_string (struct value *value, gdb_b
 
       /* Look for a null character.  */
       for (i = 0; i < fetchlimit; i++)
-	if (extract_unsigned_integer (contents + i * width, width) == 0)
+	if (extract_unsigned_integer (contents + i * width, width,
+				      byte_order) == 0)
 	  break;
 
       /* I is now either the number of non-null characters, or FETCHLIMIT.  */
@@ -671,7 +681,7 @@ c_get_string (struct value *value, gdb_b
   else
     {
       err = read_string (value_as_address (value), -1, width, fetchlimit,
-			 buffer, length);
+			 byte_order, buffer, length);
       if (err)
 	{
 	  xfree (*buffer);
@@ -682,7 +692,8 @@ c_get_string (struct value *value, gdb_b
 
   /* If the last character is null, subtract it from LENGTH.  */
   if (*length > 0
-      && extract_unsigned_integer (*buffer + *length - width, width) == 0)
+      && extract_unsigned_integer (*buffer + *length - width, width,
+				   byte_order) == 0)
     *length -= width;
 
   *charset = target_charset ();
@@ -905,6 +916,7 @@ evaluate_subexp_c (struct type *expect_t
 	struct value *result;
 	enum c_string_type dest_type;
 	const char *dest_charset;
+	enum bfd_endian byte_order;
 
 	obstack_init (&output);
 	cleanup = make_cleanup_obstack_free (&output);
@@ -941,7 +953,8 @@ evaluate_subexp_c (struct type *expect_t
 	/* Ensure TYPE_LENGTH is valid for TYPE.  */
 	check_typedef (type);
 
-	dest_charset = charset_for_string_type (dest_type);
+	byte_order = gdbarch_byte_order (exp->gdbarch);
+	dest_charset = charset_for_string_type (dest_type, byte_order);
 
 	++*pos;
 	while (*pos < limit)
Index: gdb-head/gdb/corefile.c
===================================================================
--- gdb-head.orig/gdb/corefile.c
+++ gdb-head/gdb/corefile.c
@@ -246,6 +246,7 @@ struct captured_read_memory_integer_argu
 {
   CORE_ADDR memaddr;
   int len;
+  enum bfd_endian byte_order;
   LONGEST result;
 };
 
@@ -262,8 +263,9 @@ do_captured_read_memory_integer (void *d
   struct captured_read_memory_integer_arguments *args = (struct captured_read_memory_integer_arguments*) data;
   CORE_ADDR memaddr = args->memaddr;
   int len = args->len;
+  enum bfd_endian byte_order = args->byte_order;
 
-  args->result = read_memory_integer (memaddr, len);
+  args->result = read_memory_integer (memaddr, len, byte_order);
 
   return 1;
 }
@@ -273,12 +275,14 @@ do_captured_read_memory_integer (void *d
    if successful.  */
 
 int
-safe_read_memory_integer (CORE_ADDR memaddr, int len, LONGEST *return_value)
+safe_read_memory_integer (CORE_ADDR memaddr, int len, enum bfd_endian byte_order,
+			  LONGEST *return_value)
 {
   int status;
   struct captured_read_memory_integer_arguments args;
   args.memaddr = memaddr;
   args.len = len;
+  args.byte_order = byte_order;
 
   status = catch_errors (do_captured_read_memory_integer, &args,
                         "", RETURN_MASK_ALL);
@@ -289,21 +293,21 @@ safe_read_memory_integer (CORE_ADDR mema
 }
 
 LONGEST
-read_memory_integer (CORE_ADDR memaddr, int len)
+read_memory_integer (CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
 {
   gdb_byte buf[sizeof (LONGEST)];
 
   read_memory (memaddr, buf, len);
-  return extract_signed_integer (buf, len);
+  return extract_signed_integer (buf, len, byte_order);
 }
 
 ULONGEST
-read_memory_unsigned_integer (CORE_ADDR memaddr, int len)
+read_memory_unsigned_integer (CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
 {
   gdb_byte buf[sizeof (ULONGEST)];
 
   read_memory (memaddr, buf, len);
-  return extract_unsigned_integer (buf, len);
+  return extract_unsigned_integer (buf, len, byte_order);
 }
 
 void
@@ -353,19 +357,21 @@ write_memory (CORE_ADDR memaddr, const b
 
 /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer.  */
 void
-write_memory_unsigned_integer (CORE_ADDR addr, int len, ULONGEST value)
+write_memory_unsigned_integer (CORE_ADDR addr, int len, enum bfd_endian byte_order,
+			       ULONGEST value)
 {
   gdb_byte *buf = alloca (len);
-  store_unsigned_integer (buf, len, value);
+  store_unsigned_integer (buf, len, byte_order, value);
   write_memory (addr, buf, len);
 }
 
 /* Store VALUE at ADDR in the inferior as a LEN-byte signed integer.  */
 void
-write_memory_signed_integer (CORE_ADDR addr, int len, LONGEST value)
+write_memory_signed_integer (CORE_ADDR addr, int len, enum bfd_endian byte_order,
+			     LONGEST value)
 {
   gdb_byte *buf = alloca (len);
-  store_signed_integer (buf, len, value);
+  store_signed_integer (buf, len, byte_order, value);
   write_memory (addr, buf, len);
 }
 
Index: gdb-head/gdb/cp-valprint.c
===================================================================
--- gdb-head.orig/gdb/cp-valprint.c
+++ gdb-head/gdb/cp-valprint.c
@@ -564,13 +564,17 @@ void
 cp_print_class_member (const gdb_byte *valaddr, struct type *type,
 		       struct ui_file *stream, char *prefix)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
+
   /* VAL is a byte offset into the structure type DOMAIN.
      Find the name of the field for that offset and
      print it.  */
   struct type *domain = TYPE_DOMAIN_TYPE (type);
-  LONGEST val = extract_signed_integer (valaddr, TYPE_LENGTH (type));
+  LONGEST val;
   unsigned int fieldno;
 
+  val = extract_signed_integer (valaddr, TYPE_LENGTH (type), byte_order);
+
   /* Pointers to data members are usually byte offsets into an object.
      Because a data member can have offset zero, and a NULL pointer to
      member must be distinct from any valid non-NULL pointer to
Index: gdb-head/gdb/cris-tdep.c
===================================================================
--- gdb-head.orig/gdb/cris-tdep.c
+++ gdb-head/gdb/cris-tdep.c
@@ -259,13 +259,14 @@ cris_rt_sigtramp_start (struct frame_inf
 static CORE_ADDR
 cris_sigcontext_addr (struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR pc;
   CORE_ADDR sp;
   char buf[4];
 
-  get_frame_register (this_frame,
-		      gdbarch_sp_regnum (get_frame_arch (this_frame)), buf);
-  sp = extract_unsigned_integer (buf, 4);
+  get_frame_register (this_frame, gdbarch_sp_regnum (gdbarch), buf);
+  sp = extract_unsigned_integer (buf, 4, byte_order);
 
   /* Look for normal sigtramp frame first.  */
   pc = cris_sigtramp_start (this_frame);
@@ -321,6 +322,7 @@ cris_sigtramp_frame_unwind_cache (struct
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct cris_unwind_cache *info;
   CORE_ADDR pc;
   CORE_ADDR sp;
@@ -346,7 +348,7 @@ cris_sigtramp_frame_unwind_cache (struct
   info->leaf_function = 0;
 
   get_frame_register (this_frame, gdbarch_sp_regnum (gdbarch), buf);
-  info->base = extract_unsigned_integer (buf, 4);
+  info->base = extract_unsigned_integer (buf, 4, byte_order);
 
   addr = cris_sigcontext_addr (this_frame);
   
@@ -535,6 +537,7 @@ struct instruction_environment
   int   delay_slot_pc_active;
   int   xflag_found;
   int   disable_interrupt;
+  int   byte_order;
 } inst_env_type;
 
 /* Machine-dependencies in CRIS for opcodes.  */
@@ -862,6 +865,7 @@ cris_push_dummy_call (struct gdbarch *gd
 		      int nargs, struct value **args, CORE_ADDR sp,
 		      int struct_return, CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int stack_alloc;
   int stack_offset;
   int argreg;
@@ -952,7 +956,7 @@ cris_push_dummy_call (struct gdbarch *gd
 	  else
 	    {
 	      gdb_byte buf[4];
-	      store_unsigned_integer (buf, 4, sp);
+	      store_unsigned_integer (buf, 4, byte_order, sp);
 	      si = push_stack_item (si, buf, 4);
 	    }
         }
@@ -1085,6 +1089,8 @@ cris_scan_prologue (CORE_ADDR pc, struct
 		    struct cris_unwind_cache *info)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   /* Present instruction.  */
   unsigned short insn;
 
@@ -1126,12 +1132,12 @@ cris_scan_prologue (CORE_ADDR pc, struct
   /* Find the prologue instructions.  */
   while (pc > 0 && pc < limit)
     {
-      insn = read_memory_unsigned_integer (pc, 2);
+      insn = read_memory_unsigned_integer (pc, 2, byte_order);
       pc += 2;
       if (insn == 0xE1FC)
         {
           /* push <reg> 32 bit instruction */
-          insn_next = read_memory_unsigned_integer (pc, 2);
+          insn_next = read_memory_unsigned_integer (pc, 2, byte_order);
           pc += 2;
           regno = cris_get_operand2 (insn_next);
 	  if (info)
@@ -1195,7 +1201,7 @@ cris_scan_prologue (CORE_ADDR pc, struct
 	    {
 	      info->sp_offset += -cris_get_signed_offset (insn);
 	    }
-	  insn_next = read_memory_unsigned_integer (pc, 2);
+	  insn_next = read_memory_unsigned_integer (pc, 2, byte_order);
           pc += 2;
           if (cris_get_mode (insn_next) == PREFIX_ASSIGN_MODE
               && cris_get_opcode (insn_next) == 0x000F
@@ -1240,7 +1246,7 @@ cris_scan_prologue (CORE_ADDR pc, struct
                && (cris_get_signed_offset (insn) < 0))  
         {
           /* move.S rZ,[r8-U] (?) */
-          insn_next = read_memory_unsigned_integer (pc, 2);
+          insn_next = read_memory_unsigned_integer (pc, 2, byte_order);
           pc += 2;
           regno = cris_get_operand2 (insn_next);
           if ((regno >= 0 && regno < gdbarch_sp_regnum (gdbarch))
@@ -1264,7 +1270,7 @@ cris_scan_prologue (CORE_ADDR pc, struct
                && (cris_get_signed_offset (insn) > 0))  
         {
           /* move.S [r8+U],rZ (?) */
-	  insn_next = read_memory_unsigned_integer (pc, 2);
+	  insn_next = read_memory_unsigned_integer (pc, 2, byte_order);
           pc += 2;
           regno = cris_get_operand2 (insn_next);
           if ((regno >= 0 && regno < gdbarch_sp_regnum (gdbarch))
@@ -1703,21 +1709,23 @@ static void
 cris_store_return_value (struct type *type, struct regcache *regcache,
 			 const void *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST val;
   int len = TYPE_LENGTH (type);
   
   if (len <= 4)
     {
       /* Put the return value in R10.  */
-      val = extract_unsigned_integer (valbuf, len);
+      val = extract_unsigned_integer (valbuf, len, byte_order);
       regcache_cooked_write_unsigned (regcache, ARG1_REGNUM, val);
     }
   else if (len <= 8)
     {
       /* Put the return value in R10 and R11.  */
-      val = extract_unsigned_integer (valbuf, 4);
+      val = extract_unsigned_integer (valbuf, 4, byte_order);
       regcache_cooked_write_unsigned (regcache, ARG1_REGNUM, val);
-      val = extract_unsigned_integer ((char *)valbuf + 4, len - 4);
+      val = extract_unsigned_integer ((char *)valbuf + 4, len - 4, byte_order);
       regcache_cooked_write_unsigned (regcache, ARG2_REGNUM, val);
     }
   else
@@ -1872,6 +1880,8 @@ static void
 cris_extract_return_value (struct type *type, struct regcache *regcache,
 			   void *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST val;
   int len = TYPE_LENGTH (type);
   
@@ -1879,15 +1889,15 @@ cris_extract_return_value (struct type *
     {
       /* Get the return value from R10.  */
       regcache_cooked_read_unsigned (regcache, ARG1_REGNUM, &val);
-      store_unsigned_integer (valbuf, len, val);
+      store_unsigned_integer (valbuf, len, byte_order, val);
     }
   else if (len <= 8)
     {
       /* Get the return value from R10 and R11.  */
       regcache_cooked_read_unsigned (regcache, ARG1_REGNUM, &val);
-      store_unsigned_integer (valbuf, 4, val);
+      store_unsigned_integer (valbuf, 4, byte_order, val);
       regcache_cooked_read_unsigned (regcache, ARG2_REGNUM, &val);
-      store_unsigned_integer ((char *)valbuf + 4, len - 4, val);
+      store_unsigned_integer ((char *)valbuf + 4, len - 4, byte_order, val);
     }
   else
     error (_("cris_extract_return_value: type length too large"));
@@ -2054,6 +2064,7 @@ find_step_target (struct frame_info *fra
   int offset;
   unsigned short insn;
   struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   /* Create a local register image and set the initial state.  */
   for (i = 0; i < NUM_GENREGS; i++)
@@ -2074,13 +2085,14 @@ find_step_target (struct frame_info *fra
   inst_env->invalid = 0;
   inst_env->xflag_found = 0;
   inst_env->disable_interrupt = 0;
+  inst_env->byte_order = byte_order;
 
   /* Look for a step target.  */
   do
     {
       /* Read an instruction from the client.  */
       insn = read_memory_unsigned_integer
-	     (inst_env->reg[gdbarch_pc_regnum (gdbarch)], 2);
+	     (inst_env->reg[gdbarch_pc_regnum (gdbarch)], 2, byte_order);
 
       /* If the instruction is not in a delay slot the new content of the
          PC is [PC] + 2.  If the instruction is in a delay slot it is not
@@ -2209,7 +2221,8 @@ process_autoincrement (int size, unsigne
 /* Just a forward declaration.  */
 
 static unsigned long get_data_from_address (unsigned short *inst,
-					    CORE_ADDR address);
+					    CORE_ADDR address,
+					    enum bfd_endian byte_order);
 
 /* Calculates the prefix value for the general case of offset addressing 
    mode.  */
@@ -2235,7 +2248,8 @@ bdap_prefix (unsigned short inst, inst_e
 
   /* The offset is an indirection of the contents of the operand1 register.  */
   inst_env->prefix_value += 
-    get_data_from_address (&inst, inst_env->reg[cris_get_operand1 (inst)]);
+    get_data_from_address (&inst, inst_env->reg[cris_get_operand1 (inst)],
+			   inst_env->byte_order);
   
   if (cris_get_mode (inst) == AUTOINC_MODE)
     {
@@ -2301,7 +2315,8 @@ dip_prefix (unsigned short inst, inst_en
   /* The prefix value is one dereference of the contents of the operand1
      register.  */
   address = (CORE_ADDR) inst_env->reg[cris_get_operand1 (inst)];
-  inst_env->prefix_value = read_memory_unsigned_integer (address, 4);
+  inst_env->prefix_value
+    = read_memory_unsigned_integer (address, 4, inst_env->byte_order);
     
   /* Check if the mode is autoincrement.  */
   if (cris_get_mode (inst) == AUTOINC_MODE)
@@ -2368,7 +2383,7 @@ sixteen_bit_offset_branch_op (unsigned s
     }
 
   /* We have a branch, find out the offset for the branch.  */
-  offset = read_memory_integer (inst_env->reg[REG_PC], 2);
+  offset = read_memory_integer (inst_env->reg[REG_PC], 2, inst_env->byte_order);
 
   /* The instruction is one word longer than normal, so add one word
      to the PC.  */
@@ -2877,13 +2892,14 @@ none_reg_mode_jump_op (unsigned short in
           /* Get the new value for the the PC.  */
           newpc = 
             read_memory_unsigned_integer ((CORE_ADDR) inst_env->prefix_value,
-                                          4);
+                                          4, inst_env->byte_order);
         }
       else
         {
           /* Get the new value for the PC.  */
           address = (CORE_ADDR) inst_env->reg[cris_get_operand1 (inst)];
-          newpc = read_memory_unsigned_integer (address, 4);
+          newpc = read_memory_unsigned_integer (address,
+						4, inst_env->byte_order);
 
           /* Check if we should increment a register.  */
           if (cris_get_mode (inst) == AUTOINC_MODE)
@@ -3058,7 +3074,8 @@ move_mem_to_reg_movem_op (unsigned short
       if (cris_get_operand2 (inst) >= REG_PC)
         {
           inst_env->reg[REG_PC] = 
-            read_memory_unsigned_integer (inst_env->prefix_value, 4);
+            read_memory_unsigned_integer (inst_env->prefix_value,
+					  4, inst_env->byte_order);
         }
       /* The assign value is the value after the increment.  Normally, the   
          assign value is the value before the increment.  */
@@ -3082,7 +3099,7 @@ move_mem_to_reg_movem_op (unsigned short
             }
           inst_env->reg[REG_PC] =
             read_memory_unsigned_integer (inst_env->reg[cris_get_operand1 (inst)], 
-                                          4);
+                                          4, inst_env->byte_order);
         }
       /* The increment is not depending on the size, instead it's depending
          on the number of registers loaded from memory.  */
@@ -3396,7 +3413,7 @@ reg_mode_add_sub_cmp_and_or_move_op (uns
    extend instruction, the size field is changed in instruction.  */
 
 static unsigned long 
-get_data_from_address (unsigned short *inst, CORE_ADDR address)
+get_data_from_address (unsigned short *inst, CORE_ADDR address, enum bfd_endian byte_order)
 {
   int size = cris_get_size (*inst);
   unsigned long value;
@@ -3410,7 +3427,7 @@ get_data_from_address (unsigned short *i
   /* Is there a need for checking the size?  Size should contain the number of
      bytes to read.  */
   size = 1 << size;
-  value = read_memory_unsigned_integer (address, size);
+  value = read_memory_unsigned_integer (address, size, byte_order);
 
   /* Check if it's an extend, signed or zero instruction.  */
   if (cris_get_opcode (*inst) < 4)
@@ -3436,7 +3453,8 @@ handle_prefix_assign_mode_for_aritm_op (
       operand2 = inst_env->reg[REG_PC];
 
       /* Get the value of the third operand.  */
-      operand3 = get_data_from_address (&inst, inst_env->prefix_value);
+      operand3 = get_data_from_address (&inst, inst_env->prefix_value,
+					inst_env->byte_order);
 
       /* Calculate the PC value after the instruction, i.e. where the
          breakpoint should be.  The order of the udw_operands is vital.  */
@@ -3465,7 +3483,8 @@ three_operand_add_sub_cmp_and_or_op (uns
       operand2 = inst_env->reg[cris_get_operand2 (inst)];
 
       /* Get the value of the third operand.  */
-      operand3 = get_data_from_address (&inst, inst_env->prefix_value);
+      operand3 = get_data_from_address (&inst, inst_env->prefix_value,
+					inst_env->byte_order);
 
       /* Calculate the PC value after the instruction, i.e. where the
          breakpoint should be.  */
@@ -3528,7 +3547,7 @@ handle_inc_and_index_mode_for_aritm_op (
 
       /* Get the value of the third operand, i.e. the indirect operand.  */
       operand1 = inst_env->reg[cris_get_operand1 (inst)];
-      operand3 = get_data_from_address (&inst, operand1);
+      operand3 = get_data_from_address (&inst, operand1, inst_env->byte_order);
 
       /* Calculate the PC value after the instruction, i.e. where the
          breakpoint should be.  The order of the udw_operands is vital.  */
Index: gdb-head/gdb/c-valprint.c
===================================================================
--- gdb-head.orig/gdb/c-valprint.c
+++ gdb-head/gdb/c-valprint.c
@@ -153,6 +153,7 @@ c_val_print (struct type *type, const gd
 	     const struct value_print_options *options)
 {
   struct gdbarch *gdbarch = get_type_arch (type);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned int i = 0;	/* Number of characters printed */
   unsigned len;
   struct type *elttype, *unresolved_elttype;
@@ -190,7 +191,7 @@ c_val_print (struct type *type, const gd
 			&& temp_len < options->print_max
 			&& extract_unsigned_integer (valaddr + embedded_offset
 						     + temp_len * eltlen,
-						     eltlen) == 0);
+						     eltlen, byte_order) == 0);
 		       ++temp_len)
 		    ;
 		  len = temp_len;
Index: gdb-head/gdb/defs.h
===================================================================
--- gdb-head.orig/gdb/defs.h
+++ gdb-head/gdb/defs.h
@@ -1043,18 +1043,23 @@ enum { MAX_REGISTER_SIZE = 16 };
 
 /* In findvar.c.  */
 
-extern LONGEST extract_signed_integer (const gdb_byte *, int);
+extern LONGEST extract_signed_integer (const gdb_byte *, int,
+				       enum bfd_endian);
 
-extern ULONGEST extract_unsigned_integer (const gdb_byte *, int);
+extern ULONGEST extract_unsigned_integer (const gdb_byte *, int,
+					  enum bfd_endian);
 
-extern int extract_long_unsigned_integer (const gdb_byte *, int, LONGEST *);
+extern int extract_long_unsigned_integer (const gdb_byte *, int,
+					  enum bfd_endian, LONGEST *);
 
 extern CORE_ADDR extract_typed_address (const gdb_byte *buf,
 					struct type *type);
 
-extern void store_signed_integer (gdb_byte *, int, LONGEST);
+extern void store_signed_integer (gdb_byte *, int,
+				  enum bfd_endian, LONGEST);
 
-extern void store_unsigned_integer (gdb_byte *, int, ULONGEST);
+extern void store_unsigned_integer (gdb_byte *, int,
+				    enum bfd_endian, ULONGEST);
 
 extern void store_typed_address (gdb_byte *buf, struct type *type,
 				 CORE_ADDR addr);
Index: gdb-head/gdb/dfp.c
===================================================================
--- gdb-head.orig/gdb/dfp.c
+++ gdb-head/gdb/dfp.c
@@ -34,7 +34,8 @@
    They are stored in host byte order.  This routine does the conversion if
    the target byte order is different.  */
 static void
-match_endianness (const gdb_byte *from, int len, gdb_byte *to)
+match_endianness (const gdb_byte *from, int len, enum bfd_endian byte_order,
+		  gdb_byte *to)
 {
   int i;
 
@@ -44,7 +45,7 @@ match_endianness (const gdb_byte *from, 
 #define OPPOSITE_BYTE_ORDER BFD_ENDIAN_BIG
 #endif
 
-  if (gdbarch_byte_order (current_gdbarch) == OPPOSITE_BYTE_ORDER)
+  if (byte_order == OPPOSITE_BYTE_ORDER)
     for (i = 0; i < len; i++)
       to[i] = from[len - i - 1];
   else
@@ -141,11 +142,12 @@ decimal_to_number (const gdb_byte *from,
    of the decimal type, 4 bytes for decimal32, 8 bytes for decimal64 and
    16 bytes for decimal128.  */
 void
-decimal_to_string (const gdb_byte *decbytes, int len, char *s)
+decimal_to_string (const gdb_byte *decbytes, int len,
+		   enum bfd_endian byte_order, char *s)
 {
   gdb_byte dec[16];
 
-  match_endianness (decbytes, len, dec);
+  match_endianness (decbytes, len, byte_order, dec);
 
   switch (len)
     {
@@ -168,7 +170,8 @@ decimal_to_string (const gdb_byte *decby
    LEN is the length of the decimal type, 4 bytes for decimal32, 8 bytes for
    decimal64 and 16 bytes for decimal128.  */
 int
-decimal_from_string (gdb_byte *decbytes, int len, const char *string)
+decimal_from_string (gdb_byte *decbytes, int len, enum bfd_endian byte_order,
+		     const char *string)
 {
   decContext set;
   gdb_byte dec[16];
@@ -191,7 +194,7 @@ decimal_from_string (gdb_byte *decbytes,
 	break;
     }
 
-  match_endianness (dec, len, decbytes);
+  match_endianness (dec, len, byte_order, decbytes);
 
   /* Check for errors in the DFP operation.  */
   decimal_check_errors (&set);
@@ -202,7 +205,8 @@ decimal_from_string (gdb_byte *decbytes,
 /* Converts a value of an integral type to a decimal float of
    specified LEN bytes.  */
 void
-decimal_from_integral (struct value *from, gdb_byte *to, int len)
+decimal_from_integral (struct value *from,
+		       gdb_byte *to, int len, enum bfd_endian byte_order)
 {
   LONGEST l;
   gdb_byte dec[16];
@@ -223,7 +227,7 @@ decimal_from_integral (struct value *fro
     decNumberFromInt32 (&number, (int) l);
 
   decimal_from_number (&number, dec, len);
-  match_endianness (dec, len, to);
+  match_endianness (dec, len, byte_order, to);
 }
 
 /* Converts a value of a float type to a decimal float of
@@ -232,41 +236,46 @@ decimal_from_integral (struct value *fro
    This is an ugly way to do the conversion, but libdecnumber does
    not offer a direct way to do it.  */
 void
-decimal_from_floating (struct value *from, gdb_byte *to, int len)
+decimal_from_floating (struct value *from,
+		       gdb_byte *to, int len, enum bfd_endian byte_order)
 {
   char *buffer;
 
   buffer = xstrprintf ("%.30" DOUBLEST_PRINT_FORMAT, value_as_double (from));
 
-  decimal_from_string (to, len, buffer);
+  decimal_from_string (to, len, byte_order, buffer);
 
   xfree (buffer);
 }
 
 /* Converts a decimal float of LEN bytes to a double value.  */
 DOUBLEST
-decimal_to_doublest (const gdb_byte *from, int len)
+decimal_to_doublest (const gdb_byte *from, int len, enum bfd_endian byte_order)
 {
   char buffer[MAX_DECIMAL_STRING];
 
   /* This is an ugly way to do the conversion, but libdecnumber does
      not offer a direct way to do it.  */
-  decimal_to_string (from, len, buffer);
+  decimal_to_string (from, len, byte_order, buffer);
   return strtod (buffer, NULL);
 }
 
 /* Perform operation OP with operands X and Y with sizes LEN_X and LEN_Y
-   and store value in RESULT with size LEN_RESULT.  */
+   and byte orders BYTE_ORDER_X and BYTE_ORDER_Y, and store value in
+   RESULT with size LEN_RESULT and byte order BYTE_ORDER_RESULT.  */
 void
-decimal_binop (enum exp_opcode op, const gdb_byte *x, int len_x,
-	       const gdb_byte *y, int len_y, gdb_byte *result, int len_result)
+decimal_binop (enum exp_opcode op,
+	       const gdb_byte *x, int len_x, enum bfd_endian byte_order_x,
+	       const gdb_byte *y, int len_y, enum bfd_endian byte_order_y,
+	       gdb_byte *result, int len_result,
+	       enum bfd_endian byte_order_result)
 {
   decContext set;
   decNumber number1, number2, number3;
   gdb_byte dec1[16], dec2[16], dec3[16];
 
-  match_endianness (x, len_x, dec1);
-  match_endianness (y, len_y, dec2);
+  match_endianness (x, len_x, byte_order_x, dec1);
+  match_endianness (y, len_y, byte_order_y, dec2);
 
   decimal_to_number (dec1, len_x, &number1);
   decimal_to_number (dec2, len_y, &number2);
@@ -301,17 +310,17 @@ decimal_binop (enum exp_opcode op, const
 
   decimal_from_number (&number3, dec3, len_result);
 
-  match_endianness (dec3, len_result, result);
+  match_endianness (dec3, len_result, byte_order_result, result);
 }
 
 /* Returns true if X (which is LEN bytes wide) is the number zero.  */
 int
-decimal_is_zero (const gdb_byte *x, int len)
+decimal_is_zero (const gdb_byte *x, int len, enum bfd_endian byte_order)
 {
   decNumber number;
   gdb_byte dec[16];
 
-  match_endianness (x, len, dec);
+  match_endianness (x, len, byte_order, dec);
   decimal_to_number (dec, len, &number);
 
   return decNumberIsZero (&number);
@@ -321,15 +330,16 @@ decimal_is_zero (const gdb_byte *x, int 
    will be -1.  If they are equal, then the return value will be 0.  If X is
    greater than the Y then the return value will be 1.  */
 int
-decimal_compare (const gdb_byte *x, int len_x, const gdb_byte *y, int len_y)
+decimal_compare (const gdb_byte *x, int len_x, enum bfd_endian byte_order_x,
+		 const gdb_byte *y, int len_y, enum bfd_endian byte_order_y)
 {
   decNumber number1, number2, result;
   decContext set;
   gdb_byte dec1[16], dec2[16];
   int len_result;
 
-  match_endianness (x, len_x, dec1);
-  match_endianness (y, len_y, dec2);
+  match_endianness (x, len_x, byte_order_x, dec1);
+  match_endianness (y, len_y, byte_order_y, dec2);
 
   decimal_to_number (dec1, len_x, &number1);
   decimal_to_number (dec2, len_y, &number2);
@@ -356,16 +366,17 @@ decimal_compare (const gdb_byte *x, int 
 /* Convert a decimal value from a decimal type with LEN_FROM bytes to a
    decimal type with LEN_TO bytes.  */
 void
-decimal_convert (const gdb_byte *from, int len_from, gdb_byte *to,
-		 int len_to)
+decimal_convert (const gdb_byte *from, int len_from,
+		 enum bfd_endian byte_order_from, gdb_byte *to, int len_to,
+		 enum bfd_endian byte_order_to)
 {
   decNumber number;
   gdb_byte dec[16];
 
-  match_endianness (from, len_from, dec);
+  match_endianness (from, len_from, byte_order_from, dec);
 
   decimal_to_number (dec, len_from, &number);
   decimal_from_number (&number, dec, len_to);
 
-  match_endianness (dec, len_to, to);
+  match_endianness (dec, len_to, byte_order_to, to);
 }
Index: gdb-head/gdb/dfp.h
===================================================================
--- gdb-head.orig/gdb/dfp.h
+++ gdb-head/gdb/dfp.h
@@ -29,16 +29,22 @@
  * (value comes from libdecnumber's DECIMAL128_String constant).  */
 #define MAX_DECIMAL_STRING  43
 
-extern void decimal_to_string (const gdb_byte *, int, char *);
-extern int decimal_from_string (gdb_byte *, int, const char *);
-extern void decimal_from_integral (struct value *from, gdb_byte *to, int len);
-extern void decimal_from_floating (struct value *from, gdb_byte *to, int len);
-extern DOUBLEST decimal_to_doublest (const gdb_byte *from, int len);
-extern void decimal_binop (enum exp_opcode, const gdb_byte *, int,
-			   const gdb_byte *, int, gdb_byte *, int);
-extern int decimal_is_zero (const gdb_byte *x, int len);
-extern int decimal_compare (const gdb_byte *x, int len_x, const gdb_byte *y, int len_y);
-extern void decimal_convert (const gdb_byte *from, int len_from, gdb_byte *to,
-			     int len_to);
+extern void decimal_to_string (const gdb_byte *, int, enum bfd_endian, char *);
+extern int decimal_from_string (gdb_byte *, int, enum bfd_endian, const char *);
+extern void decimal_from_integral (struct value *from, gdb_byte *to,
+				   int len, enum bfd_endian byte_order);
+extern void decimal_from_floating (struct value *from, gdb_byte *to,
+				   int len, enum bfd_endian byte_order);
+extern DOUBLEST decimal_to_doublest (const gdb_byte *from, int len,
+				     enum bfd_endian byte_order);
+extern void decimal_binop (enum exp_opcode,
+			   const gdb_byte *, int, enum bfd_endian,
+			   const gdb_byte *, int, enum bfd_endian,
+			   gdb_byte *, int, enum bfd_endian);
+extern int decimal_is_zero (const gdb_byte *, int, enum bfd_endian);
+extern int decimal_compare (const gdb_byte *, int, enum bfd_endian,
+			    const gdb_byte *, int, enum bfd_endian);
+extern void decimal_convert (const gdb_byte *, int, enum bfd_endian,
+			     gdb_byte *, int, enum bfd_endian);
 
 #endif
Index: gdb-head/gdb/dwarf2expr.c
===================================================================
--- gdb-head.orig/gdb/dwarf2expr.c
+++ gdb-head/gdb/dwarf2expr.c
@@ -207,6 +207,7 @@ CORE_ADDR
 dwarf2_read_address (struct gdbarch *gdbarch, gdb_byte *buf,
 		     gdb_byte *buf_end, int addr_size)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR result;
 
   if (buf_end - buf < addr_size)
@@ -227,7 +228,7 @@ dwarf2_read_address (struct gdbarch *gdb
     return gdbarch_integer_to_address
 	     (gdbarch, unsigned_address_type (gdbarch, addr_size), buf);
 
-  return extract_unsigned_integer (buf, addr_size);
+  return extract_unsigned_integer (buf, addr_size, byte_order);
 }
 
 /* Return the type of an address of size ADDR_SIZE,
@@ -277,6 +278,8 @@ static void
 execute_stack_op (struct dwarf_expr_context *ctx,
 		  gdb_byte *op_ptr, gdb_byte *op_end)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (ctx->gdbarch);
+
   ctx->in_reg = 0;
   ctx->initialized = 1;  /* Default is initialized.  */
 
@@ -336,35 +339,35 @@ execute_stack_op (struct dwarf_expr_cont
 	  break;
 
 	case DW_OP_const1u:
-	  result = extract_unsigned_integer (op_ptr, 1);
+	  result = extract_unsigned_integer (op_ptr, 1, byte_order);
 	  op_ptr += 1;
 	  break;
 	case DW_OP_const1s:
-	  result = extract_signed_integer (op_ptr, 1);
+	  result = extract_signed_integer (op_ptr, 1, byte_order);
 	  op_ptr += 1;
 	  break;
 	case DW_OP_const2u:
-	  result = extract_unsigned_integer (op_ptr, 2);
+	  result = extract_unsigned_integer (op_ptr, 2, byte_order);
 	  op_ptr += 2;
 	  break;
 	case DW_OP_const2s:
-	  result = extract_signed_integer (op_ptr, 2);
+	  result = extract_signed_integer (op_ptr, 2, byte_order);
 	  op_ptr += 2;
 	  break;
 	case DW_OP_const4u:
-	  result = extract_unsigned_integer (op_ptr, 4);
+	  result = extract_unsigned_integer (op_ptr, 4, byte_order);
 	  op_ptr += 4;
 	  break;
 	case DW_OP_const4s:
-	  result = extract_signed_integer (op_ptr, 4);
+	  result = extract_signed_integer (op_ptr, 4, byte_order);
 	  op_ptr += 4;
 	  break;
 	case DW_OP_const8u:
-	  result = extract_unsigned_integer (op_ptr, 8);
+	  result = extract_unsigned_integer (op_ptr, 8, byte_order);
 	  op_ptr += 8;
 	  break;
 	case DW_OP_const8s:
-	  result = extract_signed_integer (op_ptr, 8);
+	  result = extract_signed_integer (op_ptr, 8, byte_order);
 	  op_ptr += 8;
 	  break;
 	case DW_OP_constu:
@@ -712,13 +715,13 @@ execute_stack_op (struct dwarf_expr_cont
 	  break;
 
 	case DW_OP_skip:
-	  offset = extract_signed_integer (op_ptr, 2);
+	  offset = extract_signed_integer (op_ptr, 2, byte_order);
 	  op_ptr += 2;
 	  op_ptr += offset;
 	  goto no_push;
 
 	case DW_OP_bra:
-	  offset = extract_signed_integer (op_ptr, 2);
+	  offset = extract_signed_integer (op_ptr, 2, byte_order);
 	  op_ptr += 2;
 	  if (dwarf_expr_fetch (ctx, 0) != 0)
 	    op_ptr += offset;
Index: gdb-head/gdb/dwarf2-frame.c
===================================================================
--- gdb-head.orig/gdb/dwarf2-frame.c
+++ gdb-head/gdb/dwarf2-frame.c
@@ -379,6 +379,7 @@ execute_cfa_program (struct dwarf2_fde *
   CORE_ADDR pc = get_frame_pc (this_frame);
   int bytes_read;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   while (insn_ptr < insn_end && fs->pc <= pc)
     {
@@ -418,17 +419,17 @@ execute_cfa_program (struct dwarf2_fde *
 	      break;
 
 	    case DW_CFA_advance_loc1:
-	      utmp = extract_unsigned_integer (insn_ptr, 1);
+	      utmp = extract_unsigned_integer (insn_ptr, 1, byte_order);
 	      fs->pc += utmp * fs->code_align;
 	      insn_ptr++;
 	      break;
 	    case DW_CFA_advance_loc2:
-	      utmp = extract_unsigned_integer (insn_ptr, 2);
+	      utmp = extract_unsigned_integer (insn_ptr, 2, byte_order);
 	      fs->pc += utmp * fs->code_align;
 	      insn_ptr += 2;
 	      break;
 	    case DW_CFA_advance_loc4:
-	      utmp = extract_unsigned_integer (insn_ptr, 4);
+	      utmp = extract_unsigned_integer (insn_ptr, 4, byte_order);
 	      fs->pc += utmp * fs->code_align;
 	      insn_ptr += 4;
 	      break;
Index: gdb-head/gdb/dwarf2loc.c
===================================================================
--- gdb-head.orig/gdb/dwarf2loc.c
+++ gdb-head/gdb/dwarf2loc.c
@@ -57,6 +57,7 @@ find_location_expression (struct dwarf2_
   int length;
   struct objfile *objfile = dwarf2_per_cu_objfile (baton->per_cu);
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned int addr_size = dwarf2_per_cu_addr_size (baton->per_cu);
   CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
   /* Adjust base_address for relocatable objects.  */
@@ -89,7 +90,7 @@ find_location_expression (struct dwarf2_
       low += base_address;
       high += base_address;
 
-      length = extract_unsigned_integer (loc_ptr, 2);
+      length = extract_unsigned_integer (loc_ptr, 2, byte_order);
       loc_ptr += 2;
 
       if (pc >= low && pc < high)
Index: gdb-head/gdb/dwarf2read.c
===================================================================
--- gdb-head.orig/gdb/dwarf2read.c
+++ gdb-head/gdb/dwarf2read.c
@@ -8076,6 +8076,8 @@ dwarf2_const_value (struct attribute *at
 {
   struct objfile *objfile = cu->objfile;
   struct comp_unit_head *cu_header = &cu->header;
+  enum bfd_endian byte_order = bfd_big_endian (objfile->obfd) ?
+				BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
   struct dwarf_block *blk;
 
   switch (attr->form)
@@ -8091,7 +8093,7 @@ dwarf2_const_value (struct attribute *at
       /* NOTE: cagney/2003-05-09: In-lined store_address call with
          it's body - store_unsigned_integer.  */
       store_unsigned_integer (SYMBOL_VALUE_BYTES (sym), cu_header->addr_size,
-			      DW_ADDR (attr));
+			      DW_ADDR (attr), byte_order);
       SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
       break;
     case DW_FORM_string:
Index: gdb-head/gdb/findvar.c
===================================================================
--- gdb-head.orig/gdb/findvar.c
+++ gdb-head/gdb/findvar.c
@@ -48,7 +48,8 @@ you lose
 #endif
 
 LONGEST
-extract_signed_integer (const gdb_byte *addr, int len)
+extract_signed_integer (const gdb_byte *addr, int len,
+			enum bfd_endian byte_order)
 {
   LONGEST retval;
   const unsigned char *p;
@@ -62,7 +63,7 @@ That operation is not available on integ
 
   /* Start at the most significant end of the integer, and work towards
      the least significant.  */
-  if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+  if (byte_order == BFD_ENDIAN_BIG)
     {
       p = startaddr;
       /* Do the sign extension once at the start.  */
@@ -82,7 +83,8 @@ That operation is not available on integ
 }
 
 ULONGEST
-extract_unsigned_integer (const gdb_byte *addr, int len)
+extract_unsigned_integer (const gdb_byte *addr, int len,
+			  enum bfd_endian byte_order)
 {
   ULONGEST retval;
   const unsigned char *p;
@@ -97,7 +99,7 @@ That operation is not available on integ
   /* Start at the most significant end of the integer, and work towards
      the least significant.  */
   retval = 0;
-  if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+  if (byte_order == BFD_ENDIAN_BIG)
     {
       for (p = startaddr; p < endaddr; ++p)
 	retval = (retval << 8) | *p;
@@ -117,14 +119,14 @@ That operation is not available on integ
 
 int
 extract_long_unsigned_integer (const gdb_byte *addr, int orig_len,
-			       LONGEST *pval)
+			       enum bfd_endian byte_order, LONGEST *pval)
 {
   const gdb_byte *p;
   const gdb_byte *first_addr;
   int len;
 
   len = orig_len;
-  if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+  if (byte_order == BFD_ENDIAN_BIG)
     {
       for (p = addr;
 	   len > (int) sizeof (LONGEST) && p < addr + orig_len;
@@ -154,7 +156,8 @@ extract_long_unsigned_integer (const gdb
   if (len <= (int) sizeof (LONGEST))
     {
       *pval = (LONGEST) extract_unsigned_integer (first_addr,
-						  sizeof (LONGEST));
+						  sizeof (LONGEST),
+						  byte_order);
       return 1;
     }
 
@@ -178,7 +181,8 @@ extract_typed_address (const gdb_byte *b
 
 
 void
-store_signed_integer (gdb_byte *addr, int len, LONGEST val)
+store_signed_integer (gdb_byte *addr, int len,
+		      enum bfd_endian byte_order, LONGEST val)
 {
   gdb_byte *p;
   gdb_byte *startaddr = addr;
@@ -186,7 +190,7 @@ store_signed_integer (gdb_byte *addr, in
 
   /* Start at the least significant end of the integer, and work towards
      the most significant.  */
-  if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+  if (byte_order == BFD_ENDIAN_BIG)
     {
       for (p = endaddr - 1; p >= startaddr; --p)
 	{
@@ -205,7 +209,8 @@ store_signed_integer (gdb_byte *addr, in
 }
 
 void
-store_unsigned_integer (gdb_byte *addr, int len, ULONGEST val)
+store_unsigned_integer (gdb_byte *addr, int len,
+			enum bfd_endian byte_order, ULONGEST val)
 {
   unsigned char *p;
   unsigned char *startaddr = (unsigned char *) addr;
@@ -213,7 +218,7 @@ store_unsigned_integer (gdb_byte *addr, 
 
   /* Start at the least significant end of the integer, and work towards
      the most significant.  */
-  if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+  if (byte_order == BFD_ENDIAN_BIG)
     {
       for (p = endaddr - 1; p >= startaddr; --p)
 	{
@@ -312,14 +317,16 @@ CORE_ADDR
 unsigned_pointer_to_address (struct gdbarch *gdbarch,
 			     struct type *type, const gdb_byte *buf)
 {
-  return extract_unsigned_integer (buf, TYPE_LENGTH (type));
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  return extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
 }
 
 CORE_ADDR
 signed_pointer_to_address (struct gdbarch *gdbarch,
 			   struct type *type, const gdb_byte *buf)
 {
-  return extract_signed_integer (buf, TYPE_LENGTH (type));
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  return extract_signed_integer (buf, TYPE_LENGTH (type), byte_order);
 }
 
 /* Given an address, store it as a pointer of type TYPE in target
@@ -328,14 +335,16 @@ void
 unsigned_address_to_pointer (struct gdbarch *gdbarch, struct type *type,
 			     gdb_byte *buf, CORE_ADDR addr)
 {
-  store_unsigned_integer (buf, TYPE_LENGTH (type), addr);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr);
 }
 
 void
 address_to_signed_pointer (struct gdbarch *gdbarch, struct type *type,
 			   gdb_byte *buf, CORE_ADDR addr)
 {
-  store_signed_integer (buf, TYPE_LENGTH (type), addr);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  store_signed_integer (buf, TYPE_LENGTH (type), byte_order, addr);
 }
 
 /* Will calling read_var_value or locate_var_value on SYM end
@@ -415,6 +424,7 @@ read_var_value (struct symbol *var, stru
     case LOC_CONST:
       /* Put the constant back in target format.  */
       store_signed_integer (value_contents_raw (v), len,
+			    gdbarch_byte_order (get_type_arch (type)),
 			    (LONGEST) SYMBOL_VALUE (var));
       VALUE_LVAL (v) = not_lval;
       return v;
Index: gdb-head/gdb/frame.c
===================================================================
--- gdb-head.orig/gdb/frame.c
+++ gdb-head/gdb/frame.c
@@ -810,10 +810,12 @@ get_frame_register_value (struct frame_i
 LONGEST
 frame_unwind_register_signed (struct frame_info *frame, int regnum)
 {
+  struct gdbarch *gdbarch = frame_unwind_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  int size = register_size (gdbarch, regnum);
   gdb_byte buf[MAX_REGISTER_SIZE];
   frame_unwind_register (frame, regnum, buf);
-  return extract_signed_integer (buf, register_size (frame_unwind_arch (frame),
-						     regnum));
+  return extract_signed_integer (buf, size, byte_order);
 }
 
 LONGEST
@@ -825,10 +827,12 @@ get_frame_register_signed (struct frame_
 ULONGEST
 frame_unwind_register_unsigned (struct frame_info *frame, int regnum)
 {
+  struct gdbarch *gdbarch = frame_unwind_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  int size = register_size (gdbarch, regnum);
   gdb_byte buf[MAX_REGISTER_SIZE];
   frame_unwind_register (frame, regnum, buf);
-  return extract_unsigned_integer (buf, register_size (frame_unwind_arch (frame),
-						       regnum));
+  return extract_unsigned_integer (buf, size, byte_order);
 }
 
 ULONGEST
@@ -1874,14 +1878,18 @@ LONGEST
 get_frame_memory_signed (struct frame_info *this_frame, CORE_ADDR addr,
 			 int len)
 {
-  return read_memory_integer (addr, len);
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  return read_memory_integer (addr, len, byte_order);
 }
 
 ULONGEST
 get_frame_memory_unsigned (struct frame_info *this_frame, CORE_ADDR addr,
 			   int len)
 {
-  return read_memory_unsigned_integer (addr, len);
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  return read_memory_unsigned_integer (addr, len, byte_order);
 }
 
 int
Index: gdb-head/gdb/frame-unwind.c
===================================================================
--- gdb-head.orig/gdb/frame-unwind.c
+++ gdb-head/gdb/frame-unwind.c
@@ -165,11 +165,12 @@ frame_unwind_got_constant (struct frame_
 			   ULONGEST val)
 {
   struct gdbarch *gdbarch = frame_unwind_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct value *reg_val;
 
   reg_val = value_zero (register_type (gdbarch, regnum), not_lval);
   store_unsigned_integer (value_contents_writeable (reg_val),
-			  register_size (gdbarch, regnum), val);
+			  register_size (gdbarch, regnum), byte_order, val);
   return reg_val;
 }
 
Index: gdb-head/gdb/frv-linux-tdep.c
===================================================================
--- gdb-head.orig/gdb/frv-linux-tdep.c
+++ gdb-head/gdb/frv-linux-tdep.c
@@ -41,8 +41,9 @@ enum {
 };
 
 static int
-frv_linux_pc_in_sigtramp (CORE_ADDR pc, char *name)
+frv_linux_pc_in_sigtramp (struct gdbarch *gdbarch, CORE_ADDR pc, char *name)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   char buf[frv_instr_size];
   LONGEST instr;
   int retval = 0;
@@ -50,7 +51,7 @@ frv_linux_pc_in_sigtramp (CORE_ADDR pc, 
   if (target_read_memory (pc, buf, sizeof buf) != 0)
     return 0;
 
-  instr = extract_unsigned_integer (buf, sizeof buf);
+  instr = extract_unsigned_integer (buf, sizeof buf, byte_order);
 
   if (instr == 0x8efc0077)	/* setlos #__NR_sigreturn, gr7 */
     retval = NORMAL_SIGTRAMP;
@@ -61,7 +62,7 @@ frv_linux_pc_in_sigtramp (CORE_ADDR pc, 
 
   if (target_read_memory (pc + frv_instr_size, buf, sizeof buf) != 0)
     return 0;
-  instr = extract_unsigned_integer (buf, sizeof buf);
+  instr = extract_unsigned_integer (buf, sizeof buf, byte_order);
   if (instr != 0xc0700000)	/* tira	gr0, 0 */
     return 0;
 
@@ -168,6 +169,8 @@ static LONGEST
 frv_linux_sigcontext_reg_addr (struct frame_info *this_frame, int regno,
                                CORE_ADDR *sc_addr_cache_ptr)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR sc_addr;
 
   if (sc_addr_cache_ptr && *sc_addr_cache_ptr)
@@ -181,10 +184,10 @@ frv_linux_sigcontext_reg_addr (struct fr
       int tramp_type;
 
       pc = get_frame_pc (this_frame);
-      tramp_type = frv_linux_pc_in_sigtramp (pc, 0);
+      tramp_type = frv_linux_pc_in_sigtramp (gdbarch, pc, 0);
 
       get_frame_register (this_frame, sp_regnum, buf);
-      sp = extract_unsigned_integer (buf, sizeof buf);
+      sp = extract_unsigned_integer (buf, sizeof buf, byte_order);
 
       if (tramp_type == NORMAL_SIGTRAMP)
 	{
@@ -206,7 +209,7 @@ frv_linux_sigcontext_reg_addr (struct fr
 	      warning (_("Can't read realtime sigtramp frame."));
 	      return 0;
 	    }
-	  sc_addr = extract_unsigned_integer (buf, sizeof buf);
+	  sc_addr = extract_unsigned_integer (buf, sizeof buf, byte_order);
  	  sc_addr += 24;
 	}
       else
@@ -255,8 +258,10 @@ frv_linux_sigcontext_reg_addr (struct fr
 static struct trad_frame_cache *
 frv_linux_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct trad_frame_cache *cache;
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
   CORE_ADDR addr;
   char buf[4];
   int regnum;
@@ -273,8 +278,8 @@ frv_linux_sigtramp_frame_cache (struct f
      signal trampoline and not the current PC within that
      trampoline.  */
   get_frame_register (this_frame, sp_regnum, buf);
-  this_id = frame_id_build (extract_unsigned_integer (buf, sizeof buf),
-			    get_frame_pc (this_frame));
+  addr = extract_unsigned_integer (buf, sizeof buf, byte_order);
+  this_id = frame_id_build (addr, get_frame_pc (this_frame));
   trad_frame_set_id (cache, this_id);
 
   for (regnum = 0; regnum < frv_num_regs; regnum++)
@@ -313,11 +318,12 @@ frv_linux_sigtramp_frame_sniffer (const 
 				  struct frame_info *this_frame,
 				  void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   CORE_ADDR pc = get_frame_pc (this_frame);
   char *name;
 
   find_pc_partial_function (pc, &name, NULL, NULL);
-  if (frv_linux_pc_in_sigtramp (pc, name))
+  if (frv_linux_pc_in_sigtramp (gdbarch, pc, name))
     return 1;
 
   return 0;
Index: gdb-head/gdb/frv-tdep.c
===================================================================
--- gdb-head.orig/gdb/frv-tdep.c
+++ gdb-head/gdb/frv-tdep.c
@@ -514,6 +514,8 @@ frv_analyze_prologue (struct gdbarch *gd
 		      struct frame_info *this_frame,
                       struct frv_unwind_cache *info)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   /* When writing out instruction bitpatterns, we use the following
      letters to label instruction fields:
      P - The parallel bit.  We don't use this.
@@ -595,7 +597,7 @@ frv_analyze_prologue (struct gdbarch *gd
 
       if (target_read_memory (pc, buf, sizeof buf) != 0)
 	break;
-      op = extract_signed_integer (buf, sizeof buf);
+      op = extract_signed_integer (buf, sizeof buf, byte_order);
 
       next_pc = pc + 4;
 
@@ -1007,13 +1009,14 @@ frv_skip_prologue (struct gdbarch *gdbar
 static CORE_ADDR
 frv_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[4];
   unsigned long op;
   CORE_ADDR orig_pc = pc;
 
   if (target_read_memory (pc, buf, 4))
     return pc;
-  op = extract_unsigned_integer (buf, 4);
+  op = extract_unsigned_integer (buf, 4, byte_order);
 
   /* In PIC code, GR15 may be loaded from some offset off of FP prior
      to the call instruction.
@@ -1041,7 +1044,7 @@ frv_skip_main_prologue (struct gdbarch *
       pc += 4;
       if (target_read_memory (pc, buf, 4))
 	return orig_pc;
-      op = extract_unsigned_integer (buf, 4);
+      op = extract_unsigned_integer (buf, 4, byte_order);
     }
 
   /* The format of an FRV CALL instruction is as follows:
@@ -1106,21 +1109,23 @@ static void
 frv_extract_return_value (struct type *type, struct regcache *regcache,
                           gdb_byte *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int len = TYPE_LENGTH (type);
 
   if (len <= 4)
     {
       ULONGEST gpr8_val;
       regcache_cooked_read_unsigned (regcache, 8, &gpr8_val);
-      store_unsigned_integer (valbuf, len, gpr8_val);
+      store_unsigned_integer (valbuf, len, byte_order, gpr8_val);
     }
   else if (len == 8)
     {
       ULONGEST regval;
       regcache_cooked_read_unsigned (regcache, 8, &regval);
-      store_unsigned_integer (valbuf, 4, regval);
+      store_unsigned_integer (valbuf, 4, byte_order, regval);
       regcache_cooked_read_unsigned (regcache, 9, &regval);
-      store_unsigned_integer ((bfd_byte *) valbuf + 4, 4, regval);
+      store_unsigned_integer ((bfd_byte *) valbuf + 4, 4, byte_order, regval);
     }
   else
     internal_error (__FILE__, __LINE__, _("Illegal return value length: %d"), len);
@@ -1136,6 +1141,7 @@ frv_frame_align (struct gdbarch *gdbarch
 static CORE_ADDR
 find_func_descr (struct gdbarch *gdbarch, CORE_ADDR entry_point)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR descr;
   char valbuf[4];
   CORE_ADDR start_addr;
@@ -1155,9 +1161,9 @@ find_func_descr (struct gdbarch *gdbarch
      the stack.  */
 
   descr = value_as_long (value_allocate_space_in_inferior (8));
-  store_unsigned_integer (valbuf, 4, entry_point);
+  store_unsigned_integer (valbuf, 4, byte_order, entry_point);
   write_memory (descr, valbuf, 4);
-  store_unsigned_integer (valbuf, 4,
+  store_unsigned_integer (valbuf, 4, byte_order,
                           frv_fdpic_find_global_pointer (entry_point));
   write_memory (descr + 4, valbuf, 4);
   return descr;
@@ -1167,11 +1173,12 @@ static CORE_ADDR
 frv_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
                                 struct target_ops *targ)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR entry_point;
   CORE_ADDR got_address;
 
-  entry_point = get_target_memory_unsigned (targ, addr, 4);
-  got_address = get_target_memory_unsigned (targ, addr + 4, 4);
+  entry_point = get_target_memory_unsigned (targ, addr, 4, byte_order);
+  got_address = get_target_memory_unsigned (targ, addr + 4, 4, byte_order);
 
   if (got_address == frv_fdpic_find_global_pointer (entry_point))
     return entry_point;
@@ -1185,6 +1192,7 @@ frv_push_dummy_call (struct gdbarch *gdb
                      int nargs, struct value **args, CORE_ADDR sp,
 		     int struct_return, CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int argreg;
   int argnum;
   char *val;
@@ -1232,7 +1240,8 @@ frv_push_dummy_call (struct gdbarch *gdb
 
       if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
 	{
-	  store_unsigned_integer (valbuf, 4, value_address (arg));
+	  store_unsigned_integer (valbuf, 4, byte_order,
+				  value_address (arg));
 	  typecode = TYPE_CODE_PTR;
 	  len = 4;
 	  val = valbuf;
@@ -1244,11 +1253,10 @@ frv_push_dummy_call (struct gdbarch *gdb
 	{
 	  /* The FDPIC ABI requires function descriptors to be passed instead
 	     of entry points.  */
-	  store_unsigned_integer
-	    (valbuf, 4,
-	     find_func_descr (gdbarch,
-	                      extract_unsigned_integer (value_contents (arg),
-			                                4)));
+	  CORE_ADDR addr = extract_unsigned_integer
+			     (value_contents (arg), 4, byte_order);
+	  addr = find_func_descr (gdbarch, addr);
+	  store_unsigned_integer (valbuf, 4, byte_order, addr);
 	  typecode = TYPE_CODE_PTR;
 	  len = 4;
 	  val = valbuf;
@@ -1264,7 +1272,7 @@ frv_push_dummy_call (struct gdbarch *gdb
 
 	  if (argreg < 14)
 	    {
-	      regval = extract_unsigned_integer (val, partial_len);
+	      regval = extract_unsigned_integer (val, partial_len, byte_order);
 #if 0
 	      printf("  Argnum %d data %x -> reg %d\n",
 		     argnum, (int) regval, argreg);
Index: gdb-head/gdb/f-valprint.c
===================================================================
--- gdb-head.orig/gdb/f-valprint.c
+++ gdb-head/gdb/f-valprint.c
@@ -246,6 +246,7 @@ f_val_print (struct type *type, const gd
 	     const struct value_print_options *options)
 {
   struct gdbarch *gdbarch = get_type_arch (type);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned int i = 0;	/* Number of characters printed */
   struct type *elttype;
   LONGEST val;
@@ -409,8 +410,8 @@ f_val_print (struct type *type, const gd
 	}
       else
 	{
-	  val = extract_unsigned_integer (valaddr, TYPE_LENGTH (type));
-
+	  val = extract_unsigned_integer (valaddr,
+					  TYPE_LENGTH (type), byte_order);
 	  if (val == 0)
 	    fprintf_filtered (stream, ".FALSE.");
 	  else if (val == 1)
Index: gdb-head/gdb/gdbarch.c
===================================================================
--- gdb-head.orig/gdb/gdbarch.c
+++ gdb-head/gdb/gdbarch.c
@@ -347,7 +347,7 @@ struct gdbarch startup_gdbarch =
   0,  /* print_insn */
   0,  /* skip_trampoline_code */
   generic_skip_solib_resolver,  /* skip_solib_resolver */
-  0,  /* in_solib_return_trampoline */
+  generic_in_solib_return_trampoline,  /* in_solib_return_trampoline */
   generic_in_function_epilogue_p,  /* in_function_epilogue_p */
   0,  /* elf_make_msymbol_special */
   0,  /* coff_make_msymbol_special */
@@ -2682,7 +2682,7 @@ gdbarch_in_solib_return_trampoline (stru
   gdb_assert (gdbarch->in_solib_return_trampoline != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_in_solib_return_trampoline called\n");
-  return gdbarch->in_solib_return_trampoline (pc, name);
+  return gdbarch->in_solib_return_trampoline (gdbarch, pc, name);
 }
 
 void
Index: gdb-head/gdb/gdbarch.h
===================================================================
--- gdb-head.orig/gdb/gdbarch.h
+++ gdb-head/gdb/gdbarch.h
@@ -563,7 +563,7 @@ extern void set_gdbarch_skip_solib_resol
 
 /* Some systems also have trampoline code for returning from shared libs. */
 
-typedef int (gdbarch_in_solib_return_trampoline_ftype) (CORE_ADDR pc, char *name);
+typedef int (gdbarch_in_solib_return_trampoline_ftype) (struct gdbarch *gdbarch, CORE_ADDR pc, char *name);
 extern int gdbarch_in_solib_return_trampoline (struct gdbarch *gdbarch, CORE_ADDR pc, char *name);
 extern void set_gdbarch_in_solib_return_trampoline (struct gdbarch *gdbarch, gdbarch_in_solib_return_trampoline_ftype *in_solib_return_trampoline);
 
Index: gdb-head/gdb/gdbarch.sh
===================================================================
--- gdb-head.orig/gdb/gdbarch.sh
+++ gdb-head/gdb/gdbarch.sh
@@ -563,7 +563,7 @@ f:CORE_ADDR:skip_trampoline_code:struct 
 # a step-resume breakpoint to get us past the dynamic linker.
 m:CORE_ADDR:skip_solib_resolver:CORE_ADDR pc:pc::generic_skip_solib_resolver::0
 # Some systems also have trampoline code for returning from shared libs.
-f:int:in_solib_return_trampoline:CORE_ADDR pc, char *name:pc, name::generic_in_solib_return_trampoline::0
+m:int:in_solib_return_trampoline:CORE_ADDR pc, char *name:pc, name::generic_in_solib_return_trampoline::0
 
 # A target might have problems with watchpoints as soon as the stack
 # frame of the current function has been destroyed.  This mostly happens
Index: gdb-head/gdb/gdbcore.h
===================================================================
--- gdb-head.orig/gdb/gdbcore.h
+++ gdb-head/gdb/gdbcore.h
@@ -50,13 +50,16 @@ extern void read_memory (CORE_ADDR memad
 /* Read an integer from debugged memory, given address and number of
    bytes.  */
 
-extern LONGEST read_memory_integer (CORE_ADDR memaddr, int len);
-extern int safe_read_memory_integer (CORE_ADDR memaddr, int len, LONGEST *return_value);
+extern LONGEST read_memory_integer (CORE_ADDR memaddr,
+				    int len, enum bfd_endian byte_order);
+extern int safe_read_memory_integer (CORE_ADDR memaddr, int len,
+				     enum bfd_endian byte_order, LONGEST *return_value);
 
 /* Read an unsigned integer from debugged memory, given address and
    number of bytes.  */
 
-extern ULONGEST read_memory_unsigned_integer (CORE_ADDR memaddr, int len);
+extern ULONGEST read_memory_unsigned_integer (CORE_ADDR memaddr,
+					      int len, enum bfd_endian byte_order);
 
 /* Read a null-terminated string from the debuggee's memory, given address,
  * a buffer into which to place the string, and the maximum available space */
@@ -77,10 +80,12 @@ extern void write_memory (CORE_ADDR mema
 
 /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer.  */
 extern void write_memory_unsigned_integer (CORE_ADDR addr, int len,
-                                           ULONGEST value);
+                                           enum bfd_endian byte_order,
+					   ULONGEST value);
 
 /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer.  */
 extern void write_memory_signed_integer (CORE_ADDR addr, int len,
+                                         enum bfd_endian byte_order,
                                          LONGEST value);
 
 /* Hook for `exec_file_command' command to call.  */
Index: gdb-head/gdb/gnu-v3-abi.c
===================================================================
--- gdb-head.orig/gdb/gnu-v3-abi.c
+++ gdb-head/gdb/gnu-v3-abi.c
@@ -514,6 +514,7 @@ gnuv3_decode_method_ptr (struct gdbarch 
 {
   struct type *funcptr_type = builtin_type (gdbarch)->builtin_func_ptr;
   struct type *offset_type = vtable_ptrdiff_type (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR ptr_value;
   LONGEST voffset, adjustment;
   int vbit;
@@ -525,9 +526,11 @@ gnuv3_decode_method_ptr (struct gdbarch 
      yet know which case we have, so we extract the value under both
      interpretations and choose the right one later on.  */
   ptr_value = extract_typed_address (contents, funcptr_type);
-  voffset = extract_signed_integer (contents, TYPE_LENGTH (funcptr_type));
+  voffset = extract_signed_integer (contents,
+				    TYPE_LENGTH (funcptr_type), byte_order);
   contents += TYPE_LENGTH (funcptr_type);
-  adjustment = extract_signed_integer (contents, TYPE_LENGTH (offset_type));
+  adjustment = extract_signed_integer (contents,
+				       TYPE_LENGTH (offset_type), byte_order);
 
   if (!gdbarch_vbit_in_delta (gdbarch))
     {
@@ -632,6 +635,7 @@ gnuv3_make_method_ptr (struct type *type
   struct type *domain_type = check_typedef (TYPE_DOMAIN_TYPE (type));
   struct gdbarch *gdbarch = get_type_arch (domain_type);
   int size = TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   /* FIXME drow/2006-12-24: The adjustment of "this" is currently
      always zero, since the method pointer is of the correct type.
@@ -644,13 +648,13 @@ gnuv3_make_method_ptr (struct type *type
 
   if (!gdbarch_vbit_in_delta (gdbarch))
     {
-      store_unsigned_integer (contents, size, value | is_virtual);
-      store_unsigned_integer (contents + size, size, 0);
+      store_unsigned_integer (contents, size, byte_order, value | is_virtual);
+      store_unsigned_integer (contents + size, size, byte_order, 0);
     }
   else
     {
-      store_unsigned_integer (contents, size, value);
-      store_unsigned_integer (contents + size, size, is_virtual);
+      store_unsigned_integer (contents, size, byte_order, value);
+      store_unsigned_integer (contents + size, size, byte_order, is_virtual);
     }
 }
 
Index: gdb-head/gdb/h8300-tdep.c
===================================================================
--- gdb-head.orig/gdb/h8300-tdep.c
+++ gdb-head/gdb/h8300-tdep.c
@@ -178,9 +178,10 @@ h8300_init_frame_cache (struct gdbarch *
    is used, it could be a byte, word or long move to registers r3-r5.  */
 
 static int
-h8300_is_argument_spill (CORE_ADDR pc)
+h8300_is_argument_spill (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
-  int w = read_memory_unsigned_integer (pc, 2);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  int w = read_memory_unsigned_integer (pc, 2, byte_order);
 
   if ((IS_MOVB_RnRm (w) || IS_MOVW_RnRm (w) || IS_MOVL_RnRm (w))
       && (w & 0x70) <= 0x20	/* Rs is R0, R1 or R2 */
@@ -190,14 +191,16 @@ h8300_is_argument_spill (CORE_ADDR pc)
   if (IS_MOVB_Rn16_SP (w)
       && 8 <= (w & 0xf) && (w & 0xf) <= 10)	/* Rs is R0L, R1L, or R2L  */
     {
-      if (read_memory_integer (pc + 2, 2) < 0)	/* ... and d:16 is negative.  */
+      /* ... and d:16 is negative.  */
+      if (read_memory_integer (pc + 2, 2, byte_order) < 0)
 	return 4;
     }
   else if (IS_MOVB_EXT (w))
     {
-      if (IS_MOVB_Rn24_SP (read_memory_unsigned_integer (pc + 2, 2)))
+      if (IS_MOVB_Rn24_SP (read_memory_unsigned_integer (pc + 2,
+							 2, byte_order)))
 	{
-	  LONGEST disp = read_memory_integer (pc + 4, 4);
+	  LONGEST disp = read_memory_integer (pc + 4, 4, byte_order);
 
 	  /* ... and d:24 is negative.  */
 	  if (disp < 0 && disp > 0xffffff)
@@ -208,14 +211,15 @@ h8300_is_argument_spill (CORE_ADDR pc)
 	   && (w & 0xf) <= 2)	/* Rs is R0, R1, or R2 */
     {
       /* ... and d:16 is negative.  */
-      if (read_memory_integer (pc + 2, 2) < 0)
+      if (read_memory_integer (pc + 2, 2, byte_order) < 0)
 	return 4;
     }
   else if (IS_MOVW_EXT (w))
     {
-      if (IS_MOVW_Rn24_SP (read_memory_unsigned_integer (pc + 2, 2)))
+      if (IS_MOVW_Rn24_SP (read_memory_unsigned_integer (pc + 2,
+							 2, byte_order)))
 	{
-	  LONGEST disp = read_memory_integer (pc + 4, 4);
+	  LONGEST disp = read_memory_integer (pc + 4, 4, byte_order);
 
 	  /* ... and d:24 is negative.  */
 	  if (disp < 0 && disp > 0xffffff)
@@ -224,22 +228,22 @@ h8300_is_argument_spill (CORE_ADDR pc)
     }
   else if (IS_MOVL_PRE (w))
     {
-      int w2 = read_memory_integer (pc + 2, 2);
+      int w2 = read_memory_integer (pc + 2, 2, byte_order);
 
       if (IS_MOVL_Rn16_SP (w2)
 	  && (w2 & 0xf) <= 2)	/* Rs is ER0, ER1, or ER2 */
 	{
 	  /* ... and d:16 is negative.  */
-	  if (read_memory_integer (pc + 4, 2) < 0)
+	  if (read_memory_integer (pc + 4, 2, byte_order) < 0)
 	    return 6;
 	}
       else if (IS_MOVL_EXT (w2))
 	{
-	  int w3 = read_memory_integer (pc + 4, 2);
+	  int w3 = read_memory_integer (pc + 4, 2, byte_order);
 
-	  if (IS_MOVL_Rn24_SP (read_memory_integer (pc + 4, 2)))
+	  if (IS_MOVL_Rn24_SP (read_memory_integer (pc + 4, 2, byte_order)))
 	    {
-	      LONGEST disp = read_memory_integer (pc + 6, 4);
+	      LONGEST disp = read_memory_integer (pc + 6, 4, byte_order);
 
 	      /* ... and d:24 is negative.  */
 	      if (disp < 0 && disp > 0xffffff)
@@ -287,9 +291,11 @@ h8300_is_argument_spill (CORE_ADDR pc)
    */
 
 static CORE_ADDR
-h8300_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
+h8300_analyze_prologue (struct gdbarch *gdbarch,
+			CORE_ADDR pc, CORE_ADDR current_pc,
 			struct h8300_frame_cache *cache)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned int op;
   int regno, i, spill_size;
 
@@ -298,7 +304,7 @@ h8300_analyze_prologue (CORE_ADDR pc, CO
   if (pc >= current_pc)
     return current_pc;
 
-  op = read_memory_unsigned_integer (pc, 4);
+  op = read_memory_unsigned_integer (pc, 4, byte_order);
 
   if (IS_PUSHFP_MOVESPFP (op))
     {
@@ -312,7 +318,7 @@ h8300_analyze_prologue (CORE_ADDR pc, CO
       pc += 4;
       if (pc >= current_pc)
         return current_pc;
-      op = read_memory_unsigned_integer (pc, 2);
+      op = read_memory_unsigned_integer (pc, 2, byte_order);
       if (IS_MOV_SP_FP (op))
 	{
 	  cache->uses_fp = 1;
@@ -322,7 +328,7 @@ h8300_analyze_prologue (CORE_ADDR pc, CO
 
   while (pc < current_pc)
     {
-      op = read_memory_unsigned_integer (pc, 2);
+      op = read_memory_unsigned_integer (pc, 2, byte_order);
       if (IS_SUB2_SP (op))
 	{
 	  cache->sp_offset += 2;
@@ -335,12 +341,12 @@ h8300_analyze_prologue (CORE_ADDR pc, CO
 	}
       else if (IS_ADD_IMM_SP (op))
 	{
-	  cache->sp_offset += -read_memory_integer (pc + 2, 2);
+	  cache->sp_offset += -read_memory_integer (pc + 2, 2, byte_order);
 	  pc += 4;
 	}
       else if (IS_SUB_IMM_SP (op))
 	{
-	  cache->sp_offset += read_memory_integer (pc + 2, 2);
+	  cache->sp_offset += read_memory_integer (pc + 2, 2, byte_order);
 	  pc += 4;
 	}
       else if (IS_SUBL4_SP (op))
@@ -350,9 +356,9 @@ h8300_analyze_prologue (CORE_ADDR pc, CO
 	}
       else if (IS_MOV_IMM_Rn (op))
         {
-	  int offset = read_memory_integer (pc + 2, 2);
+	  int offset = read_memory_integer (pc + 2, 2, byte_order);
 	  regno = op & 0x000f;
-	  op = read_memory_unsigned_integer (pc + 4, 2);
+	  op = read_memory_unsigned_integer (pc + 4, 2, byte_order);
 	  if (IS_ADD_RnSP (op) && (op & 0x00f0) == regno)
 	    {
 	      cache->sp_offset -= offset;
@@ -375,7 +381,7 @@ h8300_analyze_prologue (CORE_ADDR pc, CO
 	}
       else if (op == 0x0100)
 	{
-	  op = read_memory_unsigned_integer (pc + 2, 2);
+	  op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
 	  if (IS_PUSH (op))
 	    {
 	      regno = op & 0x000f;
@@ -389,7 +395,7 @@ h8300_analyze_prologue (CORE_ADDR pc, CO
       else if ((op & 0xffcf) == 0x0100)
 	{
 	  int op1;
-	  op1 = read_memory_unsigned_integer (pc + 2, 2);
+	  op1 = read_memory_unsigned_integer (pc + 2, 2, byte_order);
 	  if (IS_PUSH (op1))
 	    {
 	      /* Since the prefix is 0x01x0, this is not a simple pushm but a
@@ -413,7 +419,7 @@ h8300_analyze_prologue (CORE_ADDR pc, CO
   /* Check for spilling an argument register to the stack frame.
      This could also be an initializing store from non-prologue code,
      but I don't think there's any harm in skipping that.  */
-  while ((spill_size = h8300_is_argument_spill (pc)) > 0
+  while ((spill_size = h8300_is_argument_spill (gdbarch, pc)) > 0
          && pc + spill_size <= current_pc)
     pc += spill_size;
 
@@ -451,7 +457,7 @@ h8300_frame_cache (struct frame_info *th
   cache->pc = get_frame_func (this_frame);
   current_pc = get_frame_pc (this_frame);
   if (cache->pc != 0)
-    h8300_analyze_prologue (cache->pc, current_pc, cache);
+    h8300_analyze_prologue (gdbarch, cache->pc, current_pc, cache);
 
   if (!cache->uses_fp)
     {
@@ -558,7 +564,7 @@ h8300_skip_prologue (struct gdbarch *gdb
 
       /* No useable line symbol.  Use prologue parsing method.  */
       h8300_init_frame_cache (gdbarch, &cache);
-      return h8300_analyze_prologue (func_addr, func_end, &cache);
+      return h8300_analyze_prologue (gdbarch, func_addr, func_end, &cache);
     }
 
   /* No function symbol -- just return the PC.  */
@@ -635,6 +641,7 @@ h8300_push_dummy_call (struct gdbarch *g
 		       int nargs, struct value **args, CORE_ADDR sp,
 		       int struct_return, CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int stack_alloc = 0, stack_offset = 0;
   int wordsize = BINWORD (gdbarch);
   int reg = E_ARG0_REGNUM;
@@ -698,8 +705,9 @@ h8300_push_dummy_call (struct gdbarch *g
 
 	      for (offset = 0; offset < padded_len; offset += wordsize)
 		{
-		  ULONGEST word = extract_unsigned_integer (padded + offset,
-							    wordsize);
+		  ULONGEST word
+		    = extract_unsigned_integer (padded + offset,
+						wordsize, byte_order);
 		  regcache_cooked_write_unsigned (regcache, reg++, word);
 		}
 	    }
@@ -718,7 +726,7 @@ h8300_push_dummy_call (struct gdbarch *g
 
   /* Store return address.  */
   sp -= wordsize;
-  write_memory_unsigned_integer (sp, wordsize, bp_addr);
+  write_memory_unsigned_integer (sp, wordsize, byte_order, bp_addr);
 
   /* Update stack pointer.  */
   regcache_cooked_write_unsigned (regcache, E_SP_REGNUM, sp);
@@ -736,6 +744,8 @@ static void
 h8300_extract_return_value (struct type *type, struct regcache *regcache,
 			    void *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int len = TYPE_LENGTH (type);
   ULONGEST c, addr;
 
@@ -744,20 +754,20 @@ h8300_extract_return_value (struct type 
     case 1:
     case 2:
       regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
-      store_unsigned_integer (valbuf, len, c);
+      store_unsigned_integer (valbuf, len, byte_order, c);
       break;
     case 4:			/* Needs two registers on plain H8/300 */
       regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
-      store_unsigned_integer (valbuf, 2, c);
+      store_unsigned_integer (valbuf, 2, byte_order, c);
       regcache_cooked_read_unsigned (regcache, E_RET1_REGNUM, &c);
-      store_unsigned_integer ((void *) ((char *) valbuf + 2), 2, c);
+      store_unsigned_integer ((void *)((char *) valbuf + 2), 2, byte_order, c);
       break;
     case 8:			/* long long is now 8 bytes.  */
       if (TYPE_CODE (type) == TYPE_CODE_INT)
 	{
 	  regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &addr);
-	  c = read_memory_unsigned_integer ((CORE_ADDR) addr, len);
-	  store_unsigned_integer (valbuf, len, c);
+	  c = read_memory_unsigned_integer ((CORE_ADDR) addr, len, byte_order);
+	  store_unsigned_integer (valbuf, len, byte_order, c);
 	}
       else
 	{
@@ -771,6 +781,8 @@ static void
 h8300h_extract_return_value (struct type *type, struct regcache *regcache,
 			     void *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int len = TYPE_LENGTH (type);
   ULONGEST c, addr;
 
@@ -780,15 +792,16 @@ h8300h_extract_return_value (struct type
     case 2:
     case 4:
       regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
-      store_unsigned_integer (valbuf, len, c);
+      store_unsigned_integer (valbuf, len, byte_order, c);
       break;
     case 8:			/* long long is now 8 bytes.  */
       if (TYPE_CODE (type) == TYPE_CODE_INT)
 	{
 	  regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
-	  store_unsigned_integer (valbuf, 4, c);
+	  store_unsigned_integer (valbuf, 4, byte_order, c);
 	  regcache_cooked_read_unsigned (regcache, E_RET1_REGNUM, &c);
-	  store_unsigned_integer ((void *) ((char *) valbuf + 4), 4, c);
+	  store_unsigned_integer ((void *) ((char *) valbuf + 4), 4,
+				  byte_order, c);
 	}
       else
 	{
@@ -835,6 +848,8 @@ static void
 h8300_store_return_value (struct type *type, struct regcache *regcache,
 			  const void *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int len = TYPE_LENGTH (type);
   ULONGEST val;
 
@@ -842,11 +857,11 @@ h8300_store_return_value (struct type *t
     {
     case 1:
     case 2:			/* short... */
-      val = extract_unsigned_integer (valbuf, len);
+      val = extract_unsigned_integer (valbuf, len, byte_order);
       regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, val);
       break;
     case 4:			/* long, float */
-      val = extract_unsigned_integer (valbuf, len);
+      val = extract_unsigned_integer (valbuf, len, byte_order);
       regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM,
 				      (val >> 16) & 0xffff);
       regcache_cooked_write_unsigned (regcache, E_RET1_REGNUM, val & 0xffff);
@@ -862,6 +877,8 @@ static void
 h8300h_store_return_value (struct type *type, struct regcache *regcache,
 			   const void *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int len = TYPE_LENGTH (type);
   ULONGEST val;
 
@@ -870,11 +887,11 @@ h8300h_store_return_value (struct type *
     case 1:
     case 2:
     case 4:			/* long, float */
-      val = extract_unsigned_integer (valbuf, len);
+      val = extract_unsigned_integer (valbuf, len, byte_order);
       regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, val);
       break;
     case 8:
-      val = extract_unsigned_integer (valbuf, len);
+      val = extract_unsigned_integer (valbuf, len, byte_order);
       regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM,
 				      (val >> 32) & 0xffffffff);
       regcache_cooked_write_unsigned (regcache, E_RET1_REGNUM,
Index: gdb-head/gdb/hppabsd-tdep.c
===================================================================
--- gdb-head.orig/gdb/hppabsd-tdep.c
+++ gdb-head/gdb/hppabsd-tdep.c
@@ -32,6 +32,7 @@
 static CORE_ADDR
 hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR faddr = value_as_address (function);
   struct obj_section *faddr_sec;
   gdb_byte buf[4];
@@ -41,7 +42,7 @@ hppabsd_find_global_pointer (struct gdba
   if (faddr & 2)
     {
       if (target_read_memory ((faddr & ~3) + 4, buf, sizeof buf) == 0)
-	return extract_unsigned_integer (buf, sizeof buf);
+	return extract_unsigned_integer (buf, sizeof buf, byte_order);
     }
 
   /* If the address is in the .plt section, then the real function
@@ -74,7 +75,7 @@ hppabsd_find_global_pointer (struct gdba
 	      if (target_read_memory (addr, buf, sizeof buf) != 0)
 		break;
 
-	      tag = extract_signed_integer (buf, sizeof buf);
+	      tag = extract_signed_integer (buf, sizeof buf, byte_order);
 	      if (tag == DT_PLTGOT)
 		{
 		  CORE_ADDR pltgot;
@@ -84,7 +85,8 @@ hppabsd_find_global_pointer (struct gdba
 
 		  /* The NetBSD/OpenBSD ld.so doesn't relocate DT_PLTGOT, so
 		     we have to do it ourselves.  */
-		  pltgot = extract_unsigned_integer (buf, sizeof buf);
+		  pltgot = extract_unsigned_integer (buf, sizeof buf,
+						     byte_order);
 		  pltgot += ANOFFSET (sec->objfile->section_offsets,
 				      SECT_OFF_TEXT (sec->objfile));
 
Index: gdb-head/gdb/hppa-hpux-nat.c
===================================================================
--- gdb-head.orig/gdb/hppa-hpux-nat.c
+++ gdb-head/gdb/hppa-hpux-nat.c
@@ -88,6 +88,7 @@ static void
 hppa_hpux_fetch_register (struct regcache *regcache, int regnum)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR addr;
   size_t size;
   PTRACE_TYPE_RET *buf;
@@ -135,8 +136,9 @@ hppa_hpux_fetch_register (struct regcach
      `struct save_state', even for 64-bit code.  */
   if (regnum == HPPA_FLAGS_REGNUM && size == 8)
     {
-      ULONGEST flags = extract_unsigned_integer ((gdb_byte *)buf, 4);
-      store_unsigned_integer ((gdb_byte *)buf, 8, flags);
+      ULONGEST flags;
+      flags = extract_unsigned_integer ((gdb_byte *)buf, 4, byte_order);
+      store_unsigned_integer ((gdb_byte *)buf, 8, byte_order, flags);
     }
 
   regcache_raw_supply (regcache, regnum, buf);
@@ -161,6 +163,7 @@ static void
 hppa_hpux_store_register (struct regcache *regcache, int regnum)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR addr;
   size_t size;
   PTRACE_TYPE_RET *buf;
@@ -181,8 +184,9 @@ hppa_hpux_store_register (struct regcach
      `struct save_state', even for 64-bit code.  */
   if (regnum == HPPA_FLAGS_REGNUM && size == 8)
     {
-      ULONGEST flags = extract_unsigned_integer ((gdb_byte *)buf, 8);
-      store_unsigned_integer ((gdb_byte *)buf, 4, flags);
+      ULONGEST flags;
+      flags = extract_unsigned_integer ((gdb_byte *)buf, 8, byte_order);
+      store_unsigned_integer ((gdb_byte *)buf, 4, byte_order, flags);
       size = 4;
     }
 
Index: gdb-head/gdb/hppa-hpux-tdep.c
===================================================================
--- gdb-head.orig/gdb/hppa-hpux-tdep.c
+++ gdb-head/gdb/hppa-hpux-tdep.c
@@ -86,8 +86,10 @@ in_opd_section (CORE_ADDR pc)
    just shared library trampolines (import, export).  */
 
 static int
-hppa32_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
+hppa32_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch,
+				      CORE_ADDR pc, char *name)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct minimal_symbol *minsym;
   struct unwind_table_entry *u;
 
@@ -133,7 +135,7 @@ hppa32_hpux_in_solib_call_trampoline (CO
 	{
 	  unsigned long insn;
 
-	  insn = read_memory_integer (addr, 4);
+	  insn = read_memory_integer (addr, 4, byte_order);
 
 	  /* Does it look like a bl?  If so then it's the call path, if
 	     we find a bv or be first, then we're on the return path.  */
@@ -154,8 +156,11 @@ hppa32_hpux_in_solib_call_trampoline (CO
 }
 
 static int
-hppa64_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
+hppa64_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch,
+				      CORE_ADDR pc, char *name)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   /* PA64 has a completely different stub/trampoline scheme.  Is it
      better?  Maybe.  It's certainly harder to determine with any
      certainty that we are in a stub because we can not refer to the
@@ -188,7 +193,7 @@ hppa64_hpux_in_solib_call_trampoline (CO
 
   /* We might be in a stub.  Peek at the instructions.  Stubs are 3
      instructions long. */
-  insn = read_memory_integer (pc, 4);
+  insn = read_memory_integer (pc, 4, byte_order);
 
   /* Find out where we think we are within the stub.  */
   if ((insn & 0xffffc00e) == 0x53610000)
@@ -201,17 +206,17 @@ hppa64_hpux_in_solib_call_trampoline (CO
     return 0;
 
   /* Now verify each insn in the range looks like a stub instruction.  */
-  insn = read_memory_integer (addr, 4);
+  insn = read_memory_integer (addr, 4, byte_order);
   if ((insn & 0xffffc00e) != 0x53610000)
     return 0;
 	
   /* Now verify each insn in the range looks like a stub instruction.  */
-  insn = read_memory_integer (addr + 4, 4);
+  insn = read_memory_integer (addr + 4, 4, byte_order);
   if ((insn & 0xffffffff) != 0xe820d000)
     return 0;
     
   /* Now verify each insn in the range looks like a stub instruction.  */
-  insn = read_memory_integer (addr + 8, 4);
+  insn = read_memory_integer (addr + 8, 4, byte_order);
   if ((insn & 0xffffc00e) != 0x537b0000)
     return 0;
 
@@ -225,8 +230,10 @@ hppa64_hpux_in_solib_call_trampoline (CO
    just shared library trampolines (import, export).  */
 
 static int
-hppa_hpux_in_solib_return_trampoline (CORE_ADDR pc, char *name)
+hppa_hpux_in_solib_return_trampoline (struct gdbarch *gdbarch,
+				      CORE_ADDR pc, char *name)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct unwind_table_entry *u;
 
   /* Get the unwind descriptor corresponding to PC, return zero
@@ -259,7 +266,7 @@ hppa_hpux_in_solib_return_trampoline (CO
 	{
 	  unsigned long insn;
 
-	  insn = read_memory_integer (addr, 4);
+	  insn = read_memory_integer (addr, 4, byte_order);
 
 	  /* Does it look like a bl?  If so then it's the call path, if
 	     we find a bv or be first, then we're on the return path.  */
@@ -301,6 +308,8 @@ static CORE_ADDR
 hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  int word_size = gdbarch_ptr_bit (gdbarch) / 8;
   long orig_pc = pc;
   long prev_inst, curr_inst, loc;
   struct minimal_symbol *msym;
@@ -316,14 +325,12 @@ hppa_hpux_skip_trampoline_code (struct f
          the PLT entry for this function, not the address of the function
          itself.  Bit 31 has meaning too, but only for MPE.  */
       if (pc & 0x2)
-	pc = (CORE_ADDR) read_memory_integer
-			   (pc & ~0x3, gdbarch_ptr_bit (gdbarch) / 8);
+	pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, word_size, byte_order);
     }
   if (pc == hppa_symbol_address("$$dyncall_external"))
     {
       pc = (CORE_ADDR) get_frame_register_unsigned (frame, 22);
-      pc = (CORE_ADDR) read_memory_integer
-			 (pc & ~0x3, gdbarch_ptr_bit (gdbarch) / 8);
+      pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, word_size, byte_order);
     }
   else if (pc == hppa_symbol_address("_sr4export"))
     pc = (CORE_ADDR) get_frame_register_unsigned (frame, 22);
@@ -420,7 +427,7 @@ hppa_hpux_skip_trampoline_code (struct f
 	}
 
       prev_inst = curr_inst;
-      curr_inst = read_memory_integer (loc, 4);
+      curr_inst = read_memory_integer (loc, 4, byte_order);
 
       /* Does it look like a branch external using %r1?  Then it's the
          branch from the stub to the actual function.  */
@@ -504,7 +511,7 @@ hppa_hpux_skip_trampoline_code (struct f
 	    {
 	      CORE_ADDR sp;
 	      sp = get_frame_register_unsigned (frame, HPPA_SP_REGNUM);
-	      return read_memory_integer (sp - 8, 4) & ~0x3;
+	      return read_memory_integer (sp - 8, 4, byte_order) & ~0x3;
 	    }
 	  else
 	    {
@@ -520,7 +527,7 @@ hppa_hpux_skip_trampoline_code (struct f
 	{
 	  return (read_memory_integer
 		  (get_frame_register_unsigned (frame, HPPA_SP_REGNUM) - 24,
-		   gdbarch_ptr_bit (gdbarch) / 8)) & ~0x3;
+		   word_size, byte_order)) & ~0x3;
 	}
 
       /* What about be,n 0(sr0,%rp)?  It's just another way we return to
@@ -533,7 +540,7 @@ hppa_hpux_skip_trampoline_code (struct f
 	     mtsp %r1,%sr0 if we want to do sanity checking.  */
 	  return (read_memory_integer
 		  (get_frame_register_unsigned (frame, HPPA_SP_REGNUM) - 24,
-		   gdbarch_ptr_bit (gdbarch) / 8)) & ~0x3;
+		   word_size, byte_order)) & ~0x3;
 	}
 
       /* Haven't found the branch yet, but we're still in the stub.
@@ -618,6 +625,7 @@ hppa_hpux_sigtramp_frame_unwind_cache (s
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct hppa_hpux_sigtramp_unwind_cache *info;
   unsigned int flag;
   CORE_ADDR sp, scptr, off;
@@ -642,7 +650,8 @@ hppa_hpux_sigtramp_frame_unwind_cache (s
   /* See /usr/include/machine/save_state.h for the structure of the save_state_t
      structure. */
   
-  flag = read_memory_unsigned_integer(scptr + HPPA_HPUX_SS_FLAGS_OFFSET, 4);
+  flag = read_memory_unsigned_integer (scptr + HPPA_HPUX_SS_FLAGS_OFFSET,
+				       4, byte_order);
 
   if (!(flag & HPPA_HPUX_SS_WIDEREGS))
     {
@@ -707,6 +716,8 @@ hppa_hpux_sigtramp_unwind_sniffer (const
                                    struct frame_info *this_frame,
                                    void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct unwind_table_entry *u;
   CORE_ADDR pc = get_frame_pc (this_frame);
 
@@ -723,7 +734,7 @@ hppa_hpux_sigtramp_unwind_sniffer (const
 				     buf, sizeof buf))
 	return 0;
 
-      insn = extract_unsigned_integer (buf, sizeof buf);
+      insn = extract_unsigned_integer (buf, sizeof buf, byte_order);
       if ((insn & 0xffe0e000) == 0xe8400000)
 	u = find_unwind_entry(u->region_start + hppa_extract_17 (insn) + 8);
     }
@@ -746,6 +757,7 @@ static CORE_ADDR
 hppa32_hpux_find_global_pointer (struct gdbarch *gdbarch,
 				 struct value *function)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR faddr;
   
   faddr = value_as_address (function);
@@ -760,7 +772,7 @@ hppa32_hpux_find_global_pointer (struct 
 
       status = target_read_memory (faddr + 4, buf, sizeof (buf));
       if (status == 0)
-	return extract_unsigned_integer (buf, sizeof (buf));
+	return extract_unsigned_integer (buf, sizeof (buf), byte_order);
     }
 
   return gdbarch_tdep (gdbarch)->solib_get_got_by_pc (faddr);
@@ -770,6 +782,7 @@ static CORE_ADDR
 hppa64_hpux_find_global_pointer (struct gdbarch *gdbarch,
 				 struct value *function)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR faddr;
   char buf[32];
 
@@ -778,7 +791,7 @@ hppa64_hpux_find_global_pointer (struct 
   if (in_opd_section (faddr))
     {
       target_read_memory (faddr, buf, sizeof (buf));
-      return extract_unsigned_integer (&buf[24], 8);
+      return extract_unsigned_integer (&buf[24], 8, byte_order);
     }
   else
     {
@@ -793,9 +806,11 @@ static unsigned int ldsid_pattern[] = {
 };
 
 static CORE_ADDR
-hppa_hpux_search_pattern (CORE_ADDR start, CORE_ADDR end, 
+hppa_hpux_search_pattern (struct gdbarch *gdbarch,
+			  CORE_ADDR start, CORE_ADDR end,
 			  unsigned int *patterns, int count)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int num_insns = (end - start + HPPA_INSN_SIZE) / HPPA_INSN_SIZE;
   unsigned int *insns;
   gdb_byte *buf;
@@ -806,7 +821,7 @@ hppa_hpux_search_pattern (CORE_ADDR star
 
   read_memory (start, buf, num_insns * HPPA_INSN_SIZE);
   for (i = 0; i < num_insns; i++, buf += HPPA_INSN_SIZE)
-    insns[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE);
+    insns[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE, byte_order);
 
   for (offset = 0; offset <= num_insns - count; offset++)
     {
@@ -829,6 +844,7 @@ static CORE_ADDR
 hppa32_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
 					int *argreg)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct objfile *obj;
   struct obj_section *sec;
   struct hppa_objfile_private *priv;
@@ -861,7 +877,8 @@ hppa32_hpux_search_dummy_call_sequence (
   u = find_unwind_entry (rp);
   if (u && u->stub_unwind.stub_type == EXPORT)
     {
-      addr = hppa_hpux_search_pattern (u->region_start, u->region_end, 
+      addr = hppa_hpux_search_pattern (gdbarch,
+				       u->region_start, u->region_end,
 				       ldsid_pattern, 
 				       ARRAY_SIZE (ldsid_pattern));
       if (addr)
@@ -879,7 +896,8 @@ hppa32_hpux_search_dummy_call_sequence (
 	  u = &priv->unwind_info->table[i];
 	  if (u->stub_unwind.stub_type == EXPORT)
 	    {
-	      addr = hppa_hpux_search_pattern (u->region_start, u->region_end, 
+	      addr = hppa_hpux_search_pattern (gdbarch,
+					       u->region_start, u->region_end,
 					       ldsid_pattern, 
 					       ARRAY_SIZE (ldsid_pattern));
 	      if (addr)
@@ -902,7 +920,7 @@ hppa32_hpux_search_dummy_call_sequence (
       find_pc_partial_function (addr, NULL, &start, &end);
       if (start != 0 && end != 0)
         {
-	  addr = hppa_hpux_search_pattern (start, end, ldsid_pattern,
+	  addr = hppa_hpux_search_pattern (gdbarch, start, end, ldsid_pattern,
 					   ARRAY_SIZE (ldsid_pattern));
 	  if (addr)
 	    goto found_pattern;
@@ -914,7 +932,7 @@ hppa32_hpux_search_dummy_call_sequence (
 
 found_pattern:
   target_read_memory (addr, buf, sizeof (buf));
-  insn = extract_unsigned_integer (buf, sizeof (buf));
+  insn = extract_unsigned_integer (buf, sizeof (buf), byte_order);
   priv->dummy_call_sequence_addr = addr;
   priv->dummy_call_sequence_reg = (insn >> 21) & 0x1f;
 
@@ -926,6 +944,7 @@ static CORE_ADDR
 hppa64_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
 					int *argreg)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct objfile *obj;
   struct obj_section *sec;
   struct hppa_objfile_private *priv;
@@ -973,7 +992,8 @@ hppa64_hpux_search_dummy_call_sequence (
 	    {
 	      unsigned int insn;
 
-	      insn = extract_unsigned_integer (buf + offset, HPPA_INSN_SIZE);
+	      insn = extract_unsigned_integer (buf + offset,
+					       HPPA_INSN_SIZE, byte_order);
 	      if (insn == 0xe840d002) /* bve,n (rp) */
 	        {
 		  addr = (end - sizeof (buf)) + offset;
@@ -1324,18 +1344,20 @@ hppa_hpux_supply_save_state (const struc
 			     struct regcache *regcache,
 			     int regnum, const void *regs, size_t len)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   const char *proc_info = regs;
   const char *save_state = proc_info + 8;
   ULONGEST flags;
 
-  flags = extract_unsigned_integer (save_state + HPPA_HPUX_SS_FLAGS_OFFSET, 4);
+  flags = extract_unsigned_integer (save_state + HPPA_HPUX_SS_FLAGS_OFFSET,
+				    4, byte_order);
   if (regnum == -1 || regnum == HPPA_FLAGS_REGNUM)
     {
-      struct gdbarch *arch = get_regcache_arch (regcache);
-      size_t size = register_size (arch, HPPA_FLAGS_REGNUM);
+      size_t size = register_size (gdbarch, HPPA_FLAGS_REGNUM);
       char buf[8];
 
-      store_unsigned_integer (buf, size, flags);
+      store_unsigned_integer (buf, size, byte_order, flags);
       regcache_raw_supply (regcache, HPPA_FLAGS_REGNUM, buf);
     }
 
@@ -1431,6 +1453,8 @@ hppa_hpux_unwind_adjust_stub (struct fra
 			      struct trad_frame_saved_reg *saved_regs)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  int word_size = gdbarch_ptr_bit (gdbarch) / 8;
   struct value *pcoq_head_val;
   ULONGEST pcoq_head;
   CORE_ADDR stubpc;
@@ -1440,19 +1464,19 @@ hppa_hpux_unwind_adjust_stub (struct fra
 				                HPPA_PCOQ_HEAD_REGNUM);
   pcoq_head =
     extract_unsigned_integer (value_contents_all (pcoq_head_val),
-			      register_size (gdbarch, HPPA_PCOQ_HEAD_REGNUM));
+			      register_size (gdbarch, HPPA_PCOQ_HEAD_REGNUM),
+			      byte_order);
 
   u = find_unwind_entry (pcoq_head);
   if (u && u->stub_unwind.stub_type == EXPORT)
     {
-      stubpc = read_memory_integer (base - 24, gdbarch_ptr_bit (gdbarch) / 8);
+      stubpc = read_memory_integer (base - 24, word_size, byte_order);
       trad_frame_set_value (saved_regs, HPPA_PCOQ_HEAD_REGNUM, stubpc);
     }
   else if (hppa_symbol_address ("__gcc_plt_call") 
            == get_pc_function_start (pcoq_head))
     {
-      stubpc = read_memory_integer
-		 (base - 8, gdbarch_ptr_bit (gdbarch) / 8);
+      stubpc = read_memory_integer (base - 8, word_size, byte_order);
       trad_frame_set_value (saved_regs, HPPA_PCOQ_HEAD_REGNUM, stubpc);
     }
 }
Index: gdb-head/gdb/hppa-linux-tdep.c
===================================================================
--- gdb-head.orig/gdb/hppa-linux-tdep.c
+++ gdb-head/gdb/hppa-linux-tdep.c
@@ -87,10 +87,11 @@ static struct insn_pattern hppa_sigtramp
    When the match is successful, fill INSN[i] with what PATTERN[i]
    matched.  */
 static int
-insns_match_pattern (CORE_ADDR pc,
+insns_match_pattern (struct gdbarch *gdbarch, CORE_ADDR pc,
                      struct insn_pattern *pattern,
                      unsigned int *insn)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int i;
   CORE_ADDR npc = pc;
 
@@ -99,7 +100,7 @@ insns_match_pattern (CORE_ADDR pc,
       char buf[4];
 
       target_read_memory (npc, buf, 4);
-      insn[i] = extract_unsigned_integer (buf, 4);
+      insn[i] = extract_unsigned_integer (buf, 4, byte_order);
       if ((insn[i] & pattern[i].mask) == pattern[i].data)
         npc += 4;
       else
@@ -130,7 +131,7 @@ insns_match_pattern (CORE_ADDR pc,
    Note that with a 2.4 64-bit kernel, the signal context is not properly
    passed back to userspace so the unwind will not work correctly.  */
 static CORE_ADDR
-hppa_linux_sigtramp_find_sigcontext (CORE_ADDR pc)
+hppa_linux_sigtramp_find_sigcontext (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   unsigned int dummy[HPPA_MAX_INSN_PATTERN_LEN];
   int offs = 0;
@@ -154,7 +155,8 @@ hppa_linux_sigtramp_find_sigcontext (COR
 
   for (try = 0; try < ARRAY_SIZE (pcoffs); try++)
     {
-      if (insns_match_pattern (sp + pcoffs[try], hppa_sigtramp, dummy))
+      if (insns_match_pattern (gdbarch, sp + pcoffs[try],
+			       hppa_sigtramp, dummy))
 	{
           offs = sfoffs[try];
 	  break;
@@ -163,7 +165,7 @@ hppa_linux_sigtramp_find_sigcontext (COR
 
   if (offs == 0)
     {
-      if (insns_match_pattern (pc, hppa_sigtramp, dummy))
+      if (insns_match_pattern (gdbarch, pc, hppa_sigtramp, dummy))
 	{
 	  /* sigaltstack case: we have no way of knowing which offset to 
 	     use in this case; default to new kernel handling. If this is
@@ -209,7 +211,7 @@ hppa_linux_sigtramp_frame_unwind_cache (
   info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
   pc = get_frame_pc (this_frame);
-  scptr = hppa_linux_sigtramp_find_sigcontext (pc);
+  scptr = hppa_linux_sigtramp_find_sigcontext (gdbarch, pc);
 
   /* structure of struct sigcontext:
    
@@ -299,9 +301,10 @@ hppa_linux_sigtramp_frame_sniffer (const
 				   struct frame_info *this_frame,
 				   void **this_prologue_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   CORE_ADDR pc = get_frame_pc (this_frame);
 
-  if (hppa_linux_sigtramp_find_sigcontext (pc))
+  if (hppa_linux_sigtramp_find_sigcontext (gdbarch, pc))
     return 1;
 
   return 0;
@@ -328,6 +331,7 @@ static const struct frame_unwind hppa_li
 static CORE_ADDR
 hppa_linux_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct obj_section *faddr_sect;
   CORE_ADDR faddr;
   
@@ -343,7 +347,7 @@ hppa_linux_find_global_pointer (struct g
 
       status = target_read_memory (faddr + 4, buf, sizeof (buf));
       if (status == 0)
-	return extract_unsigned_integer (buf, sizeof (buf));
+	return extract_unsigned_integer (buf, sizeof (buf), byte_order);
     }
 
   /* If the address is in the plt section, then the real function hasn't 
@@ -379,7 +383,7 @@ hppa_linux_find_global_pointer (struct g
 	      status = target_read_memory (addr, buf, sizeof (buf));
 	      if (status != 0)
 		break;
-	      tag = extract_signed_integer (buf, sizeof (buf));
+	      tag = extract_signed_integer (buf, sizeof (buf), byte_order);
 
 	      if (tag == DT_PLTGOT)
 		{
@@ -388,8 +392,8 @@ hppa_linux_find_global_pointer (struct g
 		  status = target_read_memory (addr + 4, buf, sizeof (buf));
 		  if (status != 0)
 		    break;
-		  global_pointer = extract_unsigned_integer (buf, sizeof (buf));
-
+		  global_pointer = extract_unsigned_integer (buf, sizeof (buf),
+							     byte_order);
 		  /* The payoff... */
 		  return global_pointer;
 		}
Index: gdb-head/gdb/hppa-tdep.c
===================================================================
--- gdb-head.orig/gdb/hppa-tdep.c
+++ gdb-head/gdb/hppa-tdep.c
@@ -540,6 +540,7 @@ find_unwind_entry (CORE_ADDR pc)
 static int
 hppa_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned long status;
   unsigned int inst;
   char buf[4];
@@ -549,7 +550,7 @@ hppa_in_function_epilogue_p (struct gdba
   if (status != 0)
     return 0;
 
-  inst = extract_unsigned_integer (buf, 4);
+  inst = extract_unsigned_integer (buf, 4, byte_order);
 
   /* The most common way to perform a stack adjustment ldo X(sp),sp 
      We are destroying a stack frame if the offset is negative.  */
@@ -690,6 +691,8 @@ hppa32_push_dummy_call (struct gdbarch *
 			int nargs, struct value **args, CORE_ADDR sp,
 			int struct_return, CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   /* Stack base address at which any pass-by-reference parameters are
      stored.  */
   CORE_ADDR struct_end = 0;
@@ -737,7 +740,8 @@ hppa32_push_dummy_call (struct gdbarch *
 	      if (write_pass)
 		write_memory (struct_end - struct_ptr, value_contents (arg),
 			      TYPE_LENGTH (type));
-	      store_unsigned_integer (param_val, 4, struct_end - struct_ptr);
+	      store_unsigned_integer (param_val, 4, byte_order,
+				      struct_end - struct_ptr);
 	    }
 	  else if (TYPE_CODE (type) == TYPE_CODE_INT
 		   || TYPE_CODE (type) == TYPE_CODE_ENUM)
@@ -745,7 +749,7 @@ hppa32_push_dummy_call (struct gdbarch *
 	      /* Integer value store, right aligned.  "unpack_long"
 		 takes care of any sign-extension problems.  */
 	      param_len = align_up (TYPE_LENGTH (type), 4);
-	      store_unsigned_integer (param_val, param_len,
+	      store_unsigned_integer (param_val, param_len, byte_order,
 				      unpack_long (type,
 						   value_contents (arg)));
 	    }
@@ -898,8 +902,9 @@ hppa64_floating_p (const struct type *ty
    function descriptor and return its address instead.  If CODE is not a
    function entry address, then just return it unchanged.  */
 static CORE_ADDR
-hppa64_convert_code_addr_to_fptr (CORE_ADDR code)
+hppa64_convert_code_addr_to_fptr (struct gdbarch *gdbarch, CORE_ADDR code)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct obj_section *sec, *opd;
 
   sec = find_pc_section (code);
@@ -930,7 +935,7 @@ hppa64_convert_code_addr_to_fptr (CORE_A
 
 	  if (target_read_memory (addr, tmp, sizeof (tmp)))
 	      break;
-	  opdaddr = extract_unsigned_integer (tmp, sizeof (tmp));
+	  opdaddr = extract_unsigned_integer (tmp, sizeof (tmp), byte_order);
 
 	  if (opdaddr == code)
 	    return addr - 16;
@@ -947,6 +952,7 @@ hppa64_push_dummy_call (struct gdbarch *
 			int struct_return, CORE_ADDR struct_addr)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int i, offset = 0;
   CORE_ADDR gp;
 
@@ -1044,8 +1050,9 @@ hppa64_push_dummy_call (struct gdbarch *
 	  ULONGEST codeptr, fptr;
 
 	  codeptr = unpack_long (type, value_contents (arg));
-	  fptr = hppa64_convert_code_addr_to_fptr (codeptr);
-	  store_unsigned_integer (fptrbuf, TYPE_LENGTH (type), fptr);
+	  fptr = hppa64_convert_code_addr_to_fptr (gdbarch, codeptr);
+	  store_unsigned_integer (fptrbuf, TYPE_LENGTH (type), byte_order,
+				  fptr);
 	  valbuf = fptrbuf;
 	}
       else
@@ -1476,6 +1483,7 @@ static CORE_ADDR
 skip_prologue_hard_way (struct gdbarch *gdbarch, CORE_ADDR pc,
 			int stop_before_branch)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   char buf[4];
   CORE_ADDR orig_pc = pc;
   unsigned long inst, stack_remaining, save_gr, save_fr, save_rp, save_sp;
@@ -1557,7 +1565,7 @@ restart:
       old_stack_remaining = stack_remaining;
 
       status = target_read_memory (pc, buf, 4);
-      inst = extract_unsigned_integer (buf, 4);
+      inst = extract_unsigned_integer (buf, 4, byte_order);
 
       /* Yow! */
       if (status != 0)
@@ -1608,7 +1616,7 @@ restart:
 	    {
 	      pc += 4;
 	      status = target_read_memory (pc, buf, 4);
-	      inst = extract_unsigned_integer (buf, 4);
+	      inst = extract_unsigned_integer (buf, 4, byte_order);
 	      if (status != 0)
 		return pc;
 	      reg_num = inst_saves_gr (inst);
@@ -1621,7 +1629,7 @@ restart:
       save_fr &= ~(1 << reg_num);
 
       status = target_read_memory (pc + 4, buf, 4);
-      next_inst = extract_unsigned_integer (buf, 4);
+      next_inst = extract_unsigned_integer (buf, 4, byte_order);
 
       /* Yow! */
       if (status != 0)
@@ -1652,13 +1660,13 @@ restart:
 	    {
 	      pc += 8;
 	      status = target_read_memory (pc, buf, 4);
-	      inst = extract_unsigned_integer (buf, 4);
+	      inst = extract_unsigned_integer (buf, 4, byte_order);
 	      if (status != 0)
 		return pc;
 	      if ((inst & 0xfc000000) != 0x34000000)
 		break;
 	      status = target_read_memory (pc + 4, buf, 4);
-	      next_inst = extract_unsigned_integer (buf, 4);
+	      next_inst = extract_unsigned_integer (buf, 4, byte_order);
 	      if (status != 0)
 		return pc;
 	      reg_num = inst_saves_fr (next_inst);
@@ -1816,6 +1824,8 @@ static struct hppa_frame_cache *
 hppa_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  int word_size = gdbarch_ptr_bit (gdbarch) / 8;
   struct hppa_frame_cache *cache;
   long saved_gr_mask;
   long saved_fr_mask;
@@ -1940,7 +1950,7 @@ hppa_frame_cache (struct frame_info *thi
 	    return (*this_cache);
 	  }
 
-	inst = extract_unsigned_integer (buf4, sizeof buf4);
+	inst = extract_unsigned_integer (buf4, sizeof buf4, byte_order);
 
 	/* Note the interesting effects of this instruction.  */
 	frame_size += prologue_inst_adjust_sp (inst);
@@ -2109,8 +2119,7 @@ hppa_frame_cache (struct frame_info *thi
             /* Both we're expecting the SP to be saved and the SP has been
 	       saved.  The entry SP value is saved at this frame's SP
 	       address.  */
-            cache->base = read_memory_integer
-			    (this_sp, gdbarch_ptr_bit (gdbarch) / 8);
+            cache->base = read_memory_integer (this_sp, word_size, byte_order);
 
 	    if (hppa_debug)
 	      fprintf_unfiltered (gdb_stdlog, " (base=%s) [saved]",
@@ -2265,6 +2274,8 @@ static const struct frame_unwind hppa_fr
 static struct hppa_frame_cache *
 hppa_fallback_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct hppa_frame_cache *cache;
   unsigned int frame_size = 0;
   int found_rp = 0;
@@ -2289,7 +2300,7 @@ hppa_fallback_frame_cache (struct frame_
 	{
 	  unsigned int insn;
 
-	  insn = read_memory_unsigned_integer (pc, 4);
+	  insn = read_memory_unsigned_integer (pc, 4, byte_order);
 	  frame_size += prologue_inst_adjust_sp (insn);
 
 	  /* There are limited ways to store the return pointer into the
@@ -2444,7 +2455,7 @@ hppa_stub_unwind_sniffer (const struct f
 
   if (pc == 0
       || (tdep->in_solib_call_trampoline != NULL
-	  && tdep->in_solib_call_trampoline (pc, NULL))
+	  && tdep->in_solib_call_trampoline (gdbarch, pc, NULL))
       || gdbarch_in_solib_return_trampoline (gdbarch, pc, NULL))
     return 1;
   return 0;
@@ -2690,12 +2701,13 @@ static void
 hppa_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
 			   int regnum, gdb_byte *buf)
 {
+    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
     ULONGEST tmp;
 
     regcache_raw_read_unsigned (regcache, regnum, &tmp);
     if (regnum == HPPA_PCOQ_HEAD_REGNUM || regnum == HPPA_PCOQ_TAIL_REGNUM)
       tmp &= ~0x3;
-    store_unsigned_integer (buf, sizeof tmp, tmp);
+    store_unsigned_integer (buf, sizeof tmp, byte_order, tmp);
 }
 
 static CORE_ADDR
@@ -2710,6 +2722,7 @@ hppa_frame_prev_register_helper (struct 
 				 int regnum)
 {
   struct gdbarch *arch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (arch);
 
   if (regnum == HPPA_PCOQ_TAIL_REGNUM)
     {
@@ -2719,7 +2732,8 @@ hppa_frame_prev_register_helper (struct 
         trad_frame_get_prev_register (this_frame, saved_regs,
                                       HPPA_PCOQ_HEAD_REGNUM);
 
-      pc = extract_unsigned_integer (value_contents_all (pcoq_val), size);
+      pc = extract_unsigned_integer (value_contents_all (pcoq_val),
+				     size, byte_order);
       return frame_unwind_got_constant (this_frame, regnum, pc + 4);
     }
 
@@ -2817,9 +2831,10 @@ static struct insn_pattern hppa_sigtramp
    matched.  */
 
 static int
-hppa_match_insns (CORE_ADDR pc, struct insn_pattern *pattern,
-		  unsigned int *insn)
+hppa_match_insns (struct gdbarch *gdbarch, CORE_ADDR pc,
+		  struct insn_pattern *pattern, unsigned int *insn)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR npc = pc;
   int i;
 
@@ -2828,7 +2843,7 @@ hppa_match_insns (CORE_ADDR pc, struct i
       gdb_byte buf[HPPA_INSN_SIZE];
 
       target_read_memory (npc, buf, HPPA_INSN_SIZE);
-      insn[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE);
+      insn[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE, byte_order);
       if ((insn[i] & pattern[i].mask) == pattern[i].data)
         npc += 4;
       else
@@ -2843,8 +2858,8 @@ hppa_match_insns (CORE_ADDR pc, struct i
    instruction scheme.  */
 
 static int
-hppa_match_insns_relaxed (CORE_ADDR pc, struct insn_pattern *pattern,
-			  unsigned int *insn)
+hppa_match_insns_relaxed (struct gdbarch *gdbarch, CORE_ADDR pc,
+			  struct insn_pattern *pattern, unsigned int *insn)
 {
   int offset, len = 0;
 
@@ -2852,7 +2867,8 @@ hppa_match_insns_relaxed (CORE_ADDR pc, 
     len++;
 
   for (offset = 0; offset < len; offset++)
-    if (hppa_match_insns (pc - offset * HPPA_INSN_SIZE, pattern, insn))
+    if (hppa_match_insns (gdbarch, pc - offset * HPPA_INSN_SIZE,
+			  pattern, insn))
       return 1;
 
   return 0;
@@ -2871,7 +2887,8 @@ hppa_in_dyncall (CORE_ADDR pc)
 }
 
 int
-hppa_in_solib_call_trampoline (CORE_ADDR pc, char *name)
+hppa_in_solib_call_trampoline (struct gdbarch *gdbarch,
+			       CORE_ADDR pc, char *name)
 {
   unsigned int insn[HPPA_MAX_INSN_PATTERN_LEN];
   struct unwind_table_entry *u;
@@ -2887,10 +2904,12 @@ hppa_in_solib_call_trampoline (CORE_ADDR
   if (u != NULL)
     return 0;
 
-  return (hppa_match_insns_relaxed (pc, hppa_import_stub, insn)
-	  || hppa_match_insns_relaxed (pc, hppa_import_pic_stub, insn)
-	  || hppa_match_insns_relaxed (pc, hppa_long_branch_stub, insn)
-	  || hppa_match_insns_relaxed (pc, hppa_long_branch_pic_stub, insn));
+  return
+    (hppa_match_insns_relaxed (gdbarch, pc, hppa_import_stub, insn)
+     || hppa_match_insns_relaxed (gdbarch, pc, hppa_import_pic_stub, insn)
+     || hppa_match_insns_relaxed (gdbarch, pc, hppa_long_branch_stub, insn)
+     || hppa_match_insns_relaxed (gdbarch, pc,
+				  hppa_long_branch_pic_stub, insn));
 }
 
 /* This code skips several kind of "trampolines" used on PA-RISC
@@ -2917,8 +2936,8 @@ hppa_skip_trampoline_code (struct frame_
       return pc;
     }
 
-  dp_rel = hppa_match_insns (pc, hppa_import_stub, insn);
-  if (dp_rel || hppa_match_insns (pc, hppa_import_pic_stub, insn))
+  dp_rel = hppa_match_insns (gdbarch, pc, hppa_import_stub, insn);
+  if (dp_rel || hppa_match_insns (gdbarch, pc, hppa_import_pic_stub, insn))
     {
       /* Extract the target address from the addil/ldw sequence.  */
       pc = hppa_extract_21 (insn[0]) + hppa_extract_14 (insn[1]);
@@ -2940,7 +2959,7 @@ hppa_skip_trampoline_code (struct frame_
       if (in_plt_section (pc, NULL))
 	{
 	  /* Sanity check: are we pointing to the PLT stub?  */
-  	  if (!hppa_match_insns (pc, hppa_plt_stub, insn))
+  	  if (!hppa_match_insns (gdbarch, pc, hppa_plt_stub, insn))
 	    {
 	      warning (_("Cannot resolve PLT stub at %s."),
 		       paddress (gdbarch, pc));
Index: gdb-head/gdb/hppa-tdep.h
===================================================================
--- gdb-head.orig/gdb/hppa-tdep.h
+++ gdb-head/gdb/hppa-tdep.h
@@ -93,7 +93,8 @@ struct gdbarch_tdep
      trampoline code in the ".plt", or equivalent, section.
      IN_SOLIB_CALL_TRAMPOLINE evaluates to nonzero if we are currently
      stopped in one of these.  */
-  int (*in_solib_call_trampoline) (CORE_ADDR pc, char *name);
+  int (*in_solib_call_trampoline) (struct gdbarch *gdbarch,
+				   CORE_ADDR pc, char *name);
 
   /* For targets that support multiple spaces, we may have additional stubs
      in the return path.  These stubs are internal to the ABI, and users are
@@ -241,7 +242,8 @@ extern struct minimal_symbol *
 extern struct hppa_objfile_private *
 hppa_init_objfile_priv_data (struct objfile *objfile);
 
-extern int hppa_in_solib_call_trampoline (CORE_ADDR pc, char *name);
+extern int hppa_in_solib_call_trampoline (struct gdbarch *gdbarch,
+					  CORE_ADDR pc, char *name);
 extern CORE_ADDR hppa_skip_trampoline_code (struct frame_info *, CORE_ADDR pc);
 
 #endif  /* hppa-tdep.h */
Index: gdb-head/gdb/hpux-thread.c
===================================================================
--- gdb-head.orig/gdb/hpux-thread.c
+++ gdb-head/gdb/hpux-thread.c
@@ -243,6 +243,7 @@ hpux_thread_fetch_registers (struct targ
 			     struct regcache *regcache, int regno)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   cma__t_int_tcb tcb, *tcb_ptr;
   struct cleanup *old_chain;
   int i;
@@ -291,7 +292,7 @@ hpux_thread_fetch_registers (struct targ
 	    /* Flags must be 0 to avoid bogus value for SS_INSYSCALL */
 	    memset (buf, '\000', register_size (gdbarch, regno));
 	  else if (regno == HPPA_SP_REGNUM)
-	    store_unsigned_integer (buf, sizeof sp, sp);
+	    store_unsigned_integer (buf, sizeof sp, byte_order, sp);
 	  else if (regno == HPPA_PCOQ_HEAD_REGNUM)
 	    read_memory (sp - 20, buf, register_size (gdbarch, regno));
 	  else
Index: gdb-head/gdb/i386bsd-tdep.c
===================================================================
--- gdb-head.orig/gdb/i386bsd-tdep.c
+++ gdb-head/gdb/i386bsd-tdep.c
@@ -37,13 +37,15 @@
 static CORE_ADDR
 i386bsd_sigcontext_addr (struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[4];
   CORE_ADDR sp;
 
   get_frame_register (this_frame, I386_ESP_REGNUM, buf);
-  sp = extract_unsigned_integer (buf, 4);
+  sp = extract_unsigned_integer (buf, 4, byte_order);
 
-  return read_memory_unsigned_integer (sp + 8, 4);
+  return read_memory_unsigned_integer (sp + 8, 4, byte_order);
 }
 
 
Index: gdb-head/gdb/i386-cygwin-tdep.c
===================================================================
--- gdb-head.orig/gdb/i386-cygwin-tdep.c
+++ gdb-head/gdb/i386-cygwin-tdep.c
@@ -122,6 +122,7 @@ static void
 core_process_module_section (bfd *abfd, asection *sect, void *obj)
 {
   struct cpms_data *data = obj;
+  enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch);
 
   char *module_name;
   size_t module_name_size;
@@ -147,10 +148,10 @@ core_process_module_section (bfd *abfd, 
   /* A DWORD (data_type) followed by struct windows_core_module_info.  */
 
   base_addr =
-    extract_unsigned_integer (buf + 4, 4);
+    extract_unsigned_integer (buf + 4, 4, byte_order);
 
   module_name_size =
-    extract_unsigned_integer (buf + 8, 4);
+    extract_unsigned_integer (buf + 8, 4, byte_order);
 
   module_name = buf + 12;
   if (module_name - buf + module_name_size > bfd_get_section_size (sect))
@@ -201,7 +202,7 @@ windows_core_xfer_shared_libraries (stru
 static CORE_ADDR
 i386_cygwin_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 {
-  return i386_pe_skip_trampoline_code (pc, NULL);
+  return i386_pe_skip_trampoline_code (frame, pc, NULL);
 }
 
 static void
Index: gdb-head/gdb/i386-linux-nat.c
===================================================================
--- gdb-head.orig/gdb/i386-linux-nat.c
+++ gdb-head/gdb/i386-linux-nat.c
@@ -757,13 +757,15 @@ i386_linux_resume (struct target_ops *op
   if (step)
     {
       struct regcache *regcache = get_thread_regcache (pid_to_ptid (pid));
+      struct gdbarch *gdbarch = get_regcache_arch (regcache);
+      enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
       ULONGEST pc;
       gdb_byte buf[LINUX_SYSCALL_LEN];
 
       request = PTRACE_SINGLESTEP;
 
-      regcache_cooked_read_unsigned
-	(regcache, gdbarch_pc_regnum (get_regcache_arch (regcache)), &pc);
+      regcache_cooked_read_unsigned (regcache,
+				     gdbarch_pc_regnum (gdbarch), &pc);
 
       /* Returning from a signal trampoline is done by calling a
          special system call (sigreturn or rt_sigreturn, see
@@ -789,7 +791,7 @@ i386_linux_resume (struct target_ops *op
 
 	      regcache_cooked_read_unsigned (regcache, I386_ESP_REGNUM, &sp);
 	      if (syscall == SYS_rt_sigreturn)
-		addr = read_memory_integer (sp + 8, 4) + 20;
+		addr = read_memory_integer (sp + 8, 4, byte_order) + 20;
 	      else
 		addr = sp;
 
Index: gdb-head/gdb/i386-linux-tdep.c
===================================================================
--- gdb-head.orig/gdb/i386-linux-tdep.c
+++ gdb-head/gdb/i386-linux-tdep.c
@@ -290,12 +290,14 @@ i386_linux_dwarf_signal_frame_p (struct 
 static CORE_ADDR
 i386_linux_sigcontext_addr (struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR pc;
   CORE_ADDR sp;
   gdb_byte buf[4];
 
   get_frame_register (this_frame, I386_ESP_REGNUM, buf);
-  sp = extract_unsigned_integer (buf, 4);
+  sp = extract_unsigned_integer (buf, 4, byte_order);
 
   pc = i386_linux_sigtramp_start (this_frame);
   if (pc)
@@ -320,7 +322,7 @@ i386_linux_sigcontext_addr (struct frame
 	 pointer to the user context is passed as the third argument
 	 to the signal handler.  */
       read_memory (sp + 8, buf, 4);
-      ucontext_addr = extract_unsigned_integer (buf, 4);
+      ucontext_addr = extract_unsigned_integer (buf, 4, byte_order);
       return ucontext_addr + I386_LINUX_UCONTEXT_SIGCONTEXT_OFFSET;
     }
 
Index: gdb-head/gdb/i386nbsd-tdep.c
===================================================================
--- gdb-head.orig/gdb/i386nbsd-tdep.c
+++ gdb-head/gdb/i386nbsd-tdep.c
@@ -234,6 +234,7 @@ i386nbsd_sigtramp_cache_init (const stru
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM);
   CORE_ADDR base;
   int *reg_offset;
@@ -246,7 +247,7 @@ i386nbsd_sigtramp_cache_init (const stru
       num_regs = ARRAY_SIZE (i386nbsd_sc_reg_offset);
 
       /* Read in the sigcontext address */
-      base = read_memory_unsigned_integer (sp + 8, 4);
+      base = read_memory_unsigned_integer (sp + 8, 4, byte_order);
     }
   else
     {
@@ -254,7 +255,7 @@ i386nbsd_sigtramp_cache_init (const stru
       num_regs = ARRAY_SIZE (i386nbsd_mc_reg_offset);
 
       /* Read in the ucontext address */
-      base = read_memory_unsigned_integer (sp + 8, 4);
+      base = read_memory_unsigned_integer (sp + 8, 4, byte_order);
       /* offsetof(ucontext_t, uc_mcontext) == 36 */
       base += 36;
     }
Index: gdb-head/gdb/i386-nto-tdep.c
===================================================================
--- gdb-head.orig/gdb/i386-nto-tdep.c
+++ gdb-head/gdb/i386-nto-tdep.c
@@ -293,12 +293,14 @@ i386nto_sigtramp_p (struct frame_info *t
 static CORE_ADDR
 i386nto_sigcontext_addr (struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   char buf[4];
   CORE_ADDR ptrctx;
 
   /* We store __ucontext_t addr in EDI register.  */
   get_frame_register (this_frame, I386_EDI_REGNUM, buf);
-  ptrctx = extract_unsigned_integer (buf, 4);
+  ptrctx = extract_unsigned_integer (buf, 4, byte_order);
   ptrctx += 24 /* Context pointer is at this offset.  */;
 
   return ptrctx;
Index: gdb-head/gdb/i386obsd-nat.c
===================================================================
--- gdb-head.orig/gdb/i386obsd-nat.c
+++ gdb-head/gdb/i386obsd-nat.c
@@ -35,6 +35,8 @@
 static int
 i386obsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct switchframe sf;
 
   /* The following is true for OpenBSD 3.6:
@@ -76,8 +78,8 @@ i386obsd_supply_pcb (struct regcache *re
     {
       /* No, the pcb must have been last updated by savectx().  */
       pcb->pcb_esp = pcb->pcb_ebp;
-      pcb->pcb_ebp = read_memory_integer(pcb->pcb_esp, 4);
-      sf.sf_eip = read_memory_integer(pcb->pcb_esp + 4, 4);
+      pcb->pcb_ebp = read_memory_integer(pcb->pcb_esp, 4, byte_order);
+      sf.sf_eip = read_memory_integer(pcb->pcb_esp + 4, 4, byte_order);
       regcache_raw_supply (regcache, I386_EIP_REGNUM, &sf.sf_eip);
     }
 
Index: gdb-head/gdb/i386obsd-tdep.c
===================================================================
--- gdb-head.orig/gdb/i386obsd-tdep.c
+++ gdb-head/gdb/i386obsd-tdep.c
@@ -228,6 +228,8 @@ static void
 i386obsd_supply_uthread (struct regcache *regcache,
 			 int regnum, CORE_ADDR addr)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR sp_addr = addr + I386OBSD_UTHREAD_ESP_OFFSET;
   CORE_ADDR sp = 0;
   gdb_byte buf[4];
@@ -240,12 +242,12 @@ i386obsd_supply_uthread (struct regcache
       int offset;
 
       /* Fetch stack pointer from thread structure.  */
-      sp = read_memory_unsigned_integer (sp_addr, 4);
+      sp = read_memory_unsigned_integer (sp_addr, 4, byte_order);
 
       /* Adjust the stack pointer such that it looks as if we just
          returned from _thread_machdep_switch.  */
       offset = i386obsd_uthread_reg_offset[I386_EIP_REGNUM] + 4;
-      store_unsigned_integer (buf, 4, sp + offset);
+      store_unsigned_integer (buf, 4, byte_order, sp + offset);
       regcache_raw_supply (regcache, I386_ESP_REGNUM, buf);
     }
 
@@ -257,7 +259,7 @@ i386obsd_supply_uthread (struct regcache
 	  /* Fetch stack pointer from thread structure (if we didn't
              do so already).  */
 	  if (sp == 0)
-	    sp = read_memory_unsigned_integer (sp_addr, 4);
+	    sp = read_memory_unsigned_integer (sp_addr, 4, byte_order);
 
 	  /* Read the saved register from the stack frame.  */
 	  read_memory (sp + i386obsd_uthread_reg_offset[i], buf, 4);
@@ -270,6 +272,8 @@ static void
 i386obsd_collect_uthread (const struct regcache *regcache,
 			  int regnum, CORE_ADDR addr)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR sp_addr = addr + I386OBSD_UTHREAD_ESP_OFFSET;
   CORE_ADDR sp = 0;
   gdb_byte buf[4];
@@ -285,10 +289,10 @@ i386obsd_collect_uthread (const struct r
          stored into the thread structure.  */
       offset = i386obsd_uthread_reg_offset[I386_EIP_REGNUM] + 4;
       regcache_raw_collect (regcache, I386_ESP_REGNUM, buf);
-      sp = extract_unsigned_integer (buf, 4) - offset;
+      sp = extract_unsigned_integer (buf, 4, byte_order) - offset;
 
       /* Store the stack pointer.  */
-      write_memory_unsigned_integer (sp_addr, 4, sp);
+      write_memory_unsigned_integer (sp_addr, 4, byte_order, sp);
 
       /* The stack pointer was (potentially) modified.  Make sure we
          build a proper stack frame.  */
@@ -303,7 +307,7 @@ i386obsd_collect_uthread (const struct r
 	  /* Fetch stack pointer from thread structure (if we didn't
              calculate it already).  */
 	  if (sp == 0)
-	    sp = read_memory_unsigned_integer (sp_addr, 4);
+	    sp = read_memory_unsigned_integer (sp_addr, 4, byte_order);
 
 	  /* Write the register into the stack frame.  */
 	  regcache_raw_collect (regcache, i, buf);
@@ -339,6 +343,8 @@ static int i386obsd_tf_reg_offset[] =
 static struct trad_frame_cache *
 i386obsd_trapframe_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct trad_frame_cache *cache;
   CORE_ADDR func, sp, addr;
   ULONGEST cs;
@@ -366,7 +372,7 @@ i386obsd_trapframe_cache (struct frame_i
 
   /* Read %cs from trap frame.  */
   addr += i386obsd_tf_reg_offset[I386_CS_REGNUM];
-  cs = read_memory_unsigned_integer (addr, 4); 
+  cs = read_memory_unsigned_integer (addr, 4, byte_order);
   if ((cs & I386_SEL_RPL) == I386_SEL_UPL)
     {
       /* Trap from user space; terminate backtrace.  */
Index: gdb-head/gdb/i386-tdep.c
===================================================================
--- gdb-head.orig/gdb/i386-tdep.c
+++ gdb-head/gdb/i386-tdep.c
@@ -414,6 +414,8 @@ i386_displaced_step_fixup (struct gdbarc
                            CORE_ADDR from, CORE_ADDR to,
                            struct regcache *regs)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   /* The offset we applied to the instruction's address.
      This could well be negative (when viewed as a signed 32-bit
      value), but ULONGEST won't reflect that, so take care when
@@ -521,9 +523,9 @@ i386_displaced_step_fixup (struct gdbarc
       const ULONGEST retaddr_len = 4;
 
       regcache_cooked_read_unsigned (regs, I386_ESP_REGNUM, &esp);
-      retaddr = read_memory_unsigned_integer (esp, retaddr_len);
+      retaddr = read_memory_unsigned_integer (esp, byte_order, retaddr_len);
       retaddr = (retaddr - insn_offset) & 0xffffffffUL;
-      write_memory_unsigned_integer (esp, retaddr_len, retaddr);
+      write_memory_unsigned_integer (esp, retaddr_len, byte_order, retaddr);
 
       if (debug_displaced)
         fprintf_unfiltered (gdb_stdlog,
@@ -595,8 +597,9 @@ i386_alloc_frame_cache (void)
    target.  Otherwise, return PC.  */
 
 static CORE_ADDR
-i386_follow_jump (CORE_ADDR pc)
+i386_follow_jump (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte op;
   long delta = 0;
   int data16 = 0;
@@ -605,7 +608,7 @@ i386_follow_jump (CORE_ADDR pc)
   if (op == 0x66)
     {
       data16 = 1;
-      op = read_memory_unsigned_integer (pc + 1, 1);
+      op = read_memory_unsigned_integer (pc + 1, 1, byte_order);
     }
 
   switch (op)
@@ -614,7 +617,7 @@ i386_follow_jump (CORE_ADDR pc)
       /* Relative jump: if data16 == 0, disp32, else disp16.  */
       if (data16)
 	{
-	  delta = read_memory_integer (pc + 2, 2);
+	  delta = read_memory_integer (pc + 2, 2, byte_order);
 
 	  /* Include the size of the jmp instruction (including the
              0x66 prefix).  */
@@ -622,7 +625,7 @@ i386_follow_jump (CORE_ADDR pc)
 	}
       else
 	{
-	  delta = read_memory_integer (pc + 1, 4);
+	  delta = read_memory_integer (pc + 1, 4, byte_order);
 
 	  /* Include the size of the jmp instruction.  */
 	  delta += 5;
@@ -630,7 +633,7 @@ i386_follow_jump (CORE_ADDR pc)
       break;
     case 0xeb:
       /* Relative jump, disp8 (ignore data16).  */
-      delta = read_memory_integer (pc + data16 + 1, 1);
+      delta = read_memory_integer (pc + data16 + 1, 1, byte_order);
 
       delta += data16 + 2;
       break;
@@ -1006,9 +1009,11 @@ i386_skip_noop (CORE_ADDR pc)
    whichever is smaller.  If we don't recognize the code, return PC.  */
 
 static CORE_ADDR
-i386_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR limit,
+i386_analyze_frame_setup (struct gdbarch *gdbarch,
+			  CORE_ADDR pc, CORE_ADDR limit,
 			  struct i386_frame_cache *cache)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct i386_insn *insn;
   gdb_byte op;
   int skip = 0;
@@ -1057,11 +1062,13 @@ i386_analyze_frame_setup (CORE_ADDR pc, 
       switch (op)
 	{
 	case 0x8b:
-	  if (read_memory_unsigned_integer (pc + skip + 1, 1) != 0xec)
+	  if (read_memory_unsigned_integer (pc + skip + 1, 1, byte_order)
+	      != 0xec)
 	    return pc;
 	  break;
 	case 0x89:
-	  if (read_memory_unsigned_integer (pc + skip + 1, 1) != 0xe5)
+	  if (read_memory_unsigned_integer (pc + skip + 1, 1, byte_order)
+	      != 0xe5)
 	    return pc;
 	  break;
 	default:
@@ -1089,24 +1096,24 @@ i386_analyze_frame_setup (CORE_ADDR pc, 
       if (op == 0x83)
 	{
 	  /* `subl' with 8-bit immediate.  */
-	  if (read_memory_unsigned_integer (pc + 1, 1) != 0xec)
+	  if (read_memory_unsigned_integer (pc + 1, 1, byte_order) != 0xec)
 	    /* Some instruction starting with 0x83 other than `subl'.  */
 	    return pc;
 
 	  /* `subl' with signed 8-bit immediate (though it wouldn't
 	     make sense to be negative).  */
-	  cache->locals = read_memory_integer (pc + 2, 1);
+	  cache->locals = read_memory_integer (pc + 2, 1, byte_order);
 	  return pc + 3;
 	}
       else if (op == 0x81)
 	{
 	  /* Maybe it is `subl' with a 32-bit immediate.  */
-	  if (read_memory_unsigned_integer (pc + 1, 1) != 0xec)
+	  if (read_memory_unsigned_integer (pc + 1, 1, byte_order) != 0xec)
 	    /* Some instruction starting with 0x81 other than `subl'.  */
 	    return pc;
 
 	  /* It is `subl' with a 32-bit immediate.  */
-	  cache->locals = read_memory_integer (pc + 2, 4);
+	  cache->locals = read_memory_integer (pc + 2, 4, byte_order);
 	  return pc + 6;
 	}
       else
@@ -1117,7 +1124,7 @@ i386_analyze_frame_setup (CORE_ADDR pc, 
     }
   else if (op == 0xc8)		/* enter */
     {
-      cache->locals = read_memory_unsigned_integer (pc + 1, 2);
+      cache->locals = read_memory_unsigned_integer (pc + 1, 2, byte_order);
       return pc + 4;
     }
 
@@ -1182,15 +1189,16 @@ i386_analyze_register_saves (CORE_ADDR p
    instruction will be a branch back to the start.  */
 
 static CORE_ADDR
-i386_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
+i386_analyze_prologue (struct gdbarch *gdbarch,
+		       CORE_ADDR pc, CORE_ADDR current_pc,
 		       struct i386_frame_cache *cache)
 {
   pc = i386_skip_noop (pc);
-  pc = i386_follow_jump (pc);
+  pc = i386_follow_jump (gdbarch, pc);
   pc = i386_analyze_struct_return (pc, current_pc, cache);
   pc = i386_skip_probe (pc);
   pc = i386_analyze_stack_align (pc, current_pc, cache);
-  pc = i386_analyze_frame_setup (pc, current_pc, cache);
+  pc = i386_analyze_frame_setup (gdbarch, pc, current_pc, cache);
   return i386_analyze_register_saves (pc, current_pc, cache);
 }
 
@@ -1199,6 +1207,8 @@ i386_analyze_prologue (CORE_ADDR pc, COR
 static CORE_ADDR
 i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   static gdb_byte pic_pat[6] =
   {
     0xe8, 0, 0, 0, 0,		/* call 0x0 */
@@ -1210,7 +1220,7 @@ i386_skip_prologue (struct gdbarch *gdba
   int i;
 
   cache.locals = -1;
-  pc = i386_analyze_prologue (start_pc, 0xffffffff, &cache);
+  pc = i386_analyze_prologue (gdbarch, start_pc, 0xffffffff, &cache);
   if (cache.locals < 0)
     return start_pc;
 
@@ -1243,7 +1253,7 @@ i386_skip_prologue (struct gdbarch *gdba
 
       if (op == 0x89)		/* movl %ebx, x(%ebp) */
 	{
-	  op = read_memory_unsigned_integer (pc + delta + 1, 1);
+	  op = read_memory_unsigned_integer (pc + delta + 1, 1, byte_order);
 
 	  if (op == 0x5d)	/* One byte offset from %ebp.  */
 	    delta += 3;
@@ -1257,7 +1267,8 @@ i386_skip_prologue (struct gdbarch *gdba
 
       /* addl y,%ebx */
       if (delta > 0 && op == 0x81
-	  && read_memory_unsigned_integer (pc + delta + 1, 1) == 0xc3)
+	  && read_memory_unsigned_integer (pc + delta + 1, 1, byte_order)
+	     == 0xc3)
 	{
 	  pc += delta + 6;
 	}
@@ -1266,8 +1277,8 @@ i386_skip_prologue (struct gdbarch *gdba
   /* If the function starts with a branch (to startup code at the end)
      the last instruction should bring us back to the first
      instruction of the real code.  */
-  if (i386_follow_jump (start_pc) != start_pc)
-    pc = i386_follow_jump (pc);
+  if (i386_follow_jump (gdbarch, start_pc) != start_pc)
+    pc = i386_follow_jump (gdbarch, pc);
 
   return pc;
 }
@@ -1278,6 +1289,7 @@ i386_skip_prologue (struct gdbarch *gdba
 CORE_ADDR
 i386_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte op;
 
   target_read_memory (pc, &op, 1);
@@ -1290,8 +1302,9 @@ i386_skip_main_prologue (struct gdbarch 
 	  /* Make sure address is computed correctly as a 32bit
 	     integer even if CORE_ADDR is 64 bit wide.  */
  	  struct minimal_symbol *s;
- 	  CORE_ADDR call_dest = pc + 5 + extract_signed_integer (buf, 4);
+ 	  CORE_ADDR call_dest;
 
+	  call_dest = pc + 5 + extract_signed_integer (buf, 4, byte_order);
 	  call_dest = call_dest & 0xffffffffU;
  	  s = lookup_minimal_symbol_by_pc (call_dest);
  	  if (s != NULL
@@ -1321,6 +1334,8 @@ i386_unwind_pc (struct gdbarch *gdbarch,
 static struct i386_frame_cache *
 i386_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct i386_frame_cache *cache;
   gdb_byte buf[4];
   int i;
@@ -1341,7 +1356,7 @@ i386_frame_cache (struct frame_info *thi
      in progress when the signal occurred.  */
 
   get_frame_register (this_frame, I386_EBP_REGNUM, buf);
-  cache->base = extract_unsigned_integer (buf, 4);
+  cache->base = extract_unsigned_integer (buf, 4, byte_order);
   if (cache->base == 0)
     return cache;
 
@@ -1350,13 +1365,14 @@ i386_frame_cache (struct frame_info *thi
 
   cache->pc = get_frame_func (this_frame);
   if (cache->pc != 0)
-    i386_analyze_prologue (cache->pc, get_frame_pc (this_frame), cache);
+    i386_analyze_prologue (gdbarch, cache->pc, get_frame_pc (this_frame),
+			   cache);
 
   if (cache->saved_sp_reg != -1)
     {
       /* Saved stack pointer has been saved.  */
       get_frame_register (this_frame, cache->saved_sp_reg, buf);
-      cache->saved_sp = extract_unsigned_integer(buf, 4);
+      cache->saved_sp = extract_unsigned_integer (buf, 4, byte_order);
     }
 
   if (cache->locals < 0)
@@ -1381,7 +1397,8 @@ i386_frame_cache (struct frame_info *thi
       else
 	{
 	  get_frame_register (this_frame, I386_ESP_REGNUM, buf);
-	  cache->base = extract_unsigned_integer (buf, 4) + cache->sp_offset;
+	  cache->base = extract_unsigned_integer (buf, 4, byte_order)
+			+ cache->sp_offset;
 	}
     }
 
@@ -1477,8 +1494,10 @@ static const struct frame_unwind i386_fr
 static struct i386_frame_cache *
 i386_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct i386_frame_cache *cache;
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
   CORE_ADDR addr;
   gdb_byte buf[4];
 
@@ -1488,7 +1507,7 @@ i386_sigtramp_frame_cache (struct frame_
   cache = i386_alloc_frame_cache ();
 
   get_frame_register (this_frame, I386_ESP_REGNUM, buf);
-  cache->base = extract_unsigned_integer (buf, 4) - 4;
+  cache->base = extract_unsigned_integer (buf, 4, byte_order) - 4;
 
   addr = tdep->sigcontext_addr (this_frame);
   if (tdep->sc_reg_offset)
@@ -1612,6 +1631,7 @@ i386_get_longjmp_target (struct frame_in
   gdb_byte buf[4];
   CORE_ADDR sp, jb_addr;
   struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int jb_pc_offset = gdbarch_tdep (gdbarch)->jb_pc_offset;
 
   /* If JB_PC_OFFSET is -1, we have no way to find out where the
@@ -1620,15 +1640,15 @@ i386_get_longjmp_target (struct frame_in
     return 0;
 
   get_frame_register (frame, I386_ESP_REGNUM, buf);
-  sp = extract_unsigned_integer (buf, 4);
+  sp = extract_unsigned_integer (buf, 4, byte_order);
   if (target_read_memory (sp + 4, buf, 4))
     return 0;
 
-  jb_addr = extract_unsigned_integer (buf, 4);
+  jb_addr = extract_unsigned_integer (buf, 4, byte_order);
   if (target_read_memory (jb_addr + jb_pc_offset, buf, 4))
     return 0;
 
-  *pc = extract_unsigned_integer (buf, 4);
+  *pc = extract_unsigned_integer (buf, 4, byte_order);
   return 1;
 }
 
@@ -1667,6 +1687,7 @@ i386_push_dummy_call (struct gdbarch *gd
 		      struct value **args, CORE_ADDR sp, int struct_return,
 		      CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[4];
   int i;
   int write_pass;
@@ -1686,7 +1707,7 @@ i386_push_dummy_call (struct gdbarch *gd
 	  if (write_pass)
 	    {
 	      /* Push value address.  */
-	      store_unsigned_integer (buf, 4, struct_addr);
+	      store_unsigned_integer (buf, 4, byte_order, struct_addr);
 	      write_memory (sp, buf, 4);
 	      args_space_used += 4;
 	    }
@@ -1735,11 +1756,11 @@ i386_push_dummy_call (struct gdbarch *gd
 
   /* Store return address.  */
   sp -= 4;
-  store_unsigned_integer (buf, 4, bp_addr);
+  store_unsigned_integer (buf, 4, byte_order, bp_addr);
   write_memory (sp, buf, 4);
 
   /* Finally, update the stack pointer...  */
-  store_unsigned_integer (buf, 4, sp);
+  store_unsigned_integer (buf, 4, byte_order, sp);
   regcache_cooked_write (regcache, I386_ESP_REGNUM, buf);
 
   /* ...and fake a frame pointer.  */
@@ -2500,11 +2521,17 @@ i386_regset_from_core_section (struct gd
 /* Stuff for WIN32 PE style DLL's but is pretty generic really.  */
 
 CORE_ADDR
-i386_pe_skip_trampoline_code (CORE_ADDR pc, char *name)
+i386_pe_skip_trampoline_code (struct frame_info *frame,
+			      CORE_ADDR pc, char *name)
 {
-  if (pc && read_memory_unsigned_integer (pc, 2) == 0x25ff) /* jmp *(dest) */
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
+  /* jmp *(dest) */
+  if (pc && read_memory_unsigned_integer (pc, 2, byte_order) == 0x25ff)
     {
-      unsigned long indirect = read_memory_unsigned_integer (pc + 2, 4);
+      unsigned long indirect =
+	read_memory_unsigned_integer (pc + 2, 4, byte_order);
       struct minimal_symbol *indsym =
 	indirect ? lookup_minimal_symbol_by_pc (indirect) : 0;
       char *symname = indsym ? SYMBOL_LINKAGE_NAME (indsym) : 0;
@@ -2513,7 +2540,8 @@ i386_pe_skip_trampoline_code (CORE_ADDR 
 	{
 	  if (strncmp (symname, "__imp_", 6) == 0
 	      || strncmp (symname, "_imp_", 5) == 0)
-	    return name ? 1 : read_memory_unsigned_integer (indirect, 4);
+	    return name ? 1 :
+		   read_memory_unsigned_integer (indirect, 4, byte_order);
 	}
     }
   return 0;			/* Not a trampoline.  */
@@ -2581,13 +2609,15 @@ i386_svr4_sigtramp_p (struct frame_info 
 static CORE_ADDR
 i386_svr4_sigcontext_addr (struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[4];
   CORE_ADDR sp;
 
   get_frame_register (this_frame, I386_ESP_REGNUM, buf);
-  sp = extract_unsigned_integer (buf, 4);
+  sp = extract_unsigned_integer (buf, 4, byte_order);
 
-  return read_memory_unsigned_integer (sp + 8, 4);
+  return read_memory_unsigned_integer (sp + 8, 4, byte_order);
 }
 
 
@@ -2704,8 +2734,10 @@ static CORE_ADDR
 i386_fetch_pointer_argument (struct frame_info *frame, int argi, 
 			     struct type *type)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR sp = get_frame_register_unsigned  (frame, I386_ESP_REGNUM);
-  return read_memory_unsigned_integer (sp + (4 * (argi + 1)), 4);
+  return read_memory_unsigned_integer (sp + (4 * (argi + 1)), 4, byte_order);
 }
 
 static void
Index: gdb-head/gdb/i386-tdep.h
===================================================================
--- gdb-head.orig/gdb/i386-tdep.h
+++ gdb-head/gdb/i386-tdep.h
@@ -178,7 +178,8 @@ extern struct type *i387_ext_type (struc
 #define I386_MAX_INSN_LEN (16)
 
 /* Functions exported from i386-tdep.c.  */
-extern CORE_ADDR i386_pe_skip_trampoline_code (CORE_ADDR pc, char *name);
+extern CORE_ADDR i386_pe_skip_trampoline_code (struct frame_info *frame,
+					       CORE_ADDR pc, char *name);
 extern CORE_ADDR i386_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc);
 
 /* Return whether the THIS_FRAME corresponds to a sigtramp routine.  */
Index: gdb-head/gdb/i387-tdep.c
===================================================================
--- gdb-head.orig/gdb/i387-tdep.c
+++ gdb-head/gdb/i387-tdep.c
@@ -389,7 +389,9 @@ static int fsave_offset[] =
 void
 i387_supply_fsave (struct regcache *regcache, int regnum, const void *fsave)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache));
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   const gdb_byte *regs = fsave;
   int i;
 
@@ -429,7 +431,7 @@ i387_supply_fsave (struct regcache *regc
     {
       gdb_byte buf[4];
 
-      store_unsigned_integer (buf, 4, 0x1f80);
+      store_unsigned_integer (buf, 4, byte_order, 0x1f80);
       regcache_raw_supply (regcache, I387_MXCSR_REGNUM (tdep), buf);
     }
 }
Index: gdb-head/gdb/ia64-linux-tdep.c
===================================================================
--- gdb-head.orig/gdb/ia64-linux-tdep.c
+++ gdb-head/gdb/ia64-linux-tdep.c
@@ -50,14 +50,16 @@ ia64_linux_pc_in_sigtramp (CORE_ADDR pc)
    sigcontext structure. */
 
 static CORE_ADDR
-ia64_linux_sigcontext_register_address (CORE_ADDR sp, int regno)
+ia64_linux_sigcontext_register_address (struct gdbarch *gdbarch,
+					CORE_ADDR sp, int regno)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   char buf[8];
   CORE_ADDR sigcontext_addr = 0;
 
   /* The address of the sigcontext area is found at offset 16 in the sigframe.  */
   read_memory (sp + 16, buf, 8);
-  sigcontext_addr = extract_unsigned_integer (buf, 8);
+  sigcontext_addr = extract_unsigned_integer (buf, 8, byte_order);
 
   if (IA64_GR0_REGNUM <= regno && regno <= IA64_GR31_REGNUM)
     return sigcontext_addr + 200 + 8 * (regno - IA64_GR0_REGNUM);
Index: gdb-head/gdb/ia64-tdep.c
===================================================================
--- gdb-head.orig/gdb/ia64-tdep.c
+++ gdb-head/gdb/ia64-tdep.c
@@ -123,7 +123,8 @@ static gdbarch_register_type_ftype ia64_
 static gdbarch_breakpoint_from_pc_ftype ia64_breakpoint_from_pc;
 static gdbarch_skip_prologue_ftype ia64_skip_prologue;
 static struct type *is_float_or_hfa_type (struct type *t);
-static CORE_ADDR ia64_find_global_pointer (CORE_ADDR faddr);
+static CORE_ADDR ia64_find_global_pointer (struct gdbarch *gdbarch,
+					   CORE_ADDR faddr);
 
 #define NUM_IA64_RAW_REGS 462
 
@@ -824,6 +825,8 @@ static void
 ia64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
                            int regnum, gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   if (regnum >= V32_REGNUM && regnum <= V127_REGNUM)
     {
 #ifdef HAVE_LIBUNWIND_IA64_H
@@ -849,11 +852,13 @@ ia64_pseudo_register_read (struct gdbarc
 	  if ((cfm & 0x7f) > regnum - V32_REGNUM) 
 	    {
 	      ULONGEST reg_addr = rse_address_add (bsp, (regnum - V32_REGNUM));
-	      reg = read_memory_integer ((CORE_ADDR)reg_addr, 8);
-	      store_unsigned_integer (buf, register_size (gdbarch, regnum), reg);
+	      reg = read_memory_integer ((CORE_ADDR)reg_addr, 8, byte_order);
+	      store_unsigned_integer (buf, register_size (gdbarch, regnum),
+				      byte_order, reg);
 	    }
 	  else
-	    store_unsigned_integer (buf, register_size (gdbarch, regnum), 0);
+	    store_unsigned_integer (buf, register_size (gdbarch, regnum),
+				    byte_order, 0);
 	}
     }
   else if (IA64_NAT0_REGNUM <= regnum && regnum <= IA64_NAT31_REGNUM)
@@ -862,7 +867,8 @@ ia64_pseudo_register_read (struct gdbarc
       ULONGEST unat;
       regcache_cooked_read_unsigned (regcache, IA64_UNAT_REGNUM, &unat);
       unatN_val = (unat & (1LL << (regnum - IA64_NAT0_REGNUM))) != 0;
-      store_unsigned_integer (buf, register_size (gdbarch, regnum), unatN_val);
+      store_unsigned_integer (buf, register_size (gdbarch, regnum),
+			      byte_order, unatN_val);
     }
   else if (IA64_NAT32_REGNUM <= regnum && regnum <= IA64_NAT127_REGNUM)
     {
@@ -892,12 +898,13 @@ ia64_pseudo_register_read (struct gdbarc
 	  if (nat_addr >= bsp)
 	    regcache_cooked_read_unsigned (regcache, IA64_RNAT_REGNUM, &nat_collection);
 	  else
-	    nat_collection = read_memory_integer (nat_addr, 8);
+	    nat_collection = read_memory_integer (nat_addr, 8, byte_order);
 	  nat_bit = (gr_addr >> 3) & 0x3f;
 	  natN_val = (nat_collection >> nat_bit) & 1;
 	}
       
-      store_unsigned_integer (buf, register_size (gdbarch, regnum), natN_val);
+      store_unsigned_integer (buf, register_size (gdbarch, regnum),
+			      byte_order, natN_val);
     }
   else if (regnum == VBOF_REGNUM)
     {
@@ -912,7 +919,8 @@ ia64_pseudo_register_read (struct gdbarc
       /* The bsp points at the end of the register frame so we
 	 subtract the size of frame from it to get beginning of frame.  */
       vbsp = rse_address_add (bsp, -(cfm & 0x7f));
-      store_unsigned_integer (buf, register_size (gdbarch, regnum), vbsp);
+      store_unsigned_integer (buf, register_size (gdbarch, regnum),
+			      byte_order, vbsp);
     }
   else if (VP0_REGNUM <= regnum && regnum <= VP63_REGNUM)
     {
@@ -934,7 +942,8 @@ ia64_pseudo_register_read (struct gdbarc
 	         + ((regnum - VP16_REGNUM) + rrb_pr) % 48;
 	}
       prN_val = (pr & (1LL << (regnum - VP0_REGNUM))) != 0;
-      store_unsigned_integer (buf, register_size (gdbarch, regnum), prN_val);
+      store_unsigned_integer (buf, register_size (gdbarch, regnum),
+			      byte_order, prN_val);
     }
   else
     memset (buf, 0, register_size (gdbarch, regnum));
@@ -944,6 +953,8 @@ static void
 ia64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
 			    int regnum, const gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   if (regnum >= V32_REGNUM && regnum <= V127_REGNUM)
     {
       ULONGEST bsp;
@@ -964,7 +975,8 @@ ia64_pseudo_register_write (struct gdbar
     {
       ULONGEST unatN_val, unat, unatN_mask;
       regcache_cooked_read_unsigned (regcache, IA64_UNAT_REGNUM, &unat);
-      unatN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum)); 
+      unatN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum),
+					    byte_order);
       unatN_mask = (1LL << (regnum - IA64_NAT0_REGNUM));
       if (unatN_val == 0)
 	unat &= ~unatN_mask;
@@ -988,7 +1000,8 @@ ia64_pseudo_register_write (struct gdbar
       if ((cfm & 0x7f) > regnum - V32_REGNUM) 
 	gr_addr = rse_address_add (bsp, (regnum - V32_REGNUM));
       
-      natN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum)); 
+      natN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum),
+					   byte_order);
 
       if (gr_addr != 0 && (natN_val == 0 || natN_val == 1))
 	{
@@ -1012,12 +1025,13 @@ ia64_pseudo_register_write (struct gdbar
 	  else
 	    {
 	      char nat_buf[8];
-	      nat_collection = read_memory_integer (nat_addr, 8);
+	      nat_collection = read_memory_integer (nat_addr, 8, byte_order);
 	      if (natN_val)
 		nat_collection |= natN_mask;
 	      else
 		nat_collection &= ~natN_mask;
-	      store_unsigned_integer (nat_buf, register_size (gdbarch, regnum), nat_collection);
+	      store_unsigned_integer (nat_buf, register_size (gdbarch, regnum),
+				      byte_order, nat_collection);
 	      write_memory (nat_addr, nat_buf, 8);
 	    }
 	}
@@ -1042,7 +1056,8 @@ ia64_pseudo_register_write (struct gdbar
 	  regnum = VP16_REGNUM 
 	         + ((regnum - VP16_REGNUM) + rrb_pr) % 48;
 	}
-      prN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum)); 
+      prN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum),
+					  byte_order);
       prN_mask = (1LL << (regnum - VP0_REGNUM));
       if (prN_val == 0)
 	pr &= ~prN_mask;
@@ -1365,8 +1380,10 @@ examine_prologue (CORE_ADDR pc, CORE_ADD
 		 this'll be wrong.  FIXME */
 	      if (this_frame)
 		{
+		  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+		  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 		  get_frame_register (this_frame, sp_regnum, buf);
-		  saved_sp = extract_unsigned_integer (buf, 8);
+		  saved_sp = extract_unsigned_integer (buf, 8, byte_order);
 		}
 	      spill_addr  = saved_sp
 	                  + (rM == 12 ? 0 : mem_stack_frame_size) 
@@ -1571,6 +1588,9 @@ examine_prologue (CORE_ADDR pc, CORE_ADD
 
   if (!frameless && this_frame)
     {
+      struct gdbarch *gdbarch = get_frame_arch (this_frame);
+      enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
       /* Extract the size of the rotating portion of the stack
 	 frame and the register rename base from the current
 	 frame marker. */
@@ -1604,12 +1624,13 @@ examine_prologue (CORE_ADDR pc, CORE_ADD
       cfm = 0;
       if (cache->saved_regs[IA64_CFM_REGNUM] != 0)
 	{
-	  cfm = read_memory_integer (cache->saved_regs[IA64_CFM_REGNUM], 8);
+	  cfm = read_memory_integer (cache->saved_regs[IA64_CFM_REGNUM],
+				     8, byte_order);
 	}
       else if (cfm_reg != 0)
 	{
 	  get_frame_register (this_frame, cfm_reg, buf);
-	  cfm = extract_unsigned_integer (buf, 8);
+	  cfm = extract_unsigned_integer (buf, 8, byte_order);
 	}
       cache->prev_cfm = cfm;
       
@@ -1674,6 +1695,8 @@ ia64_skip_prologue (struct gdbarch *gdba
 static struct ia64_frame_cache *
 ia64_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct ia64_frame_cache *cache;
   char buf[8];
   CORE_ADDR cfm, sof, sol, bsp, psr;
@@ -1686,19 +1709,19 @@ ia64_frame_cache (struct frame_info *thi
   *this_cache = cache;
 
   get_frame_register (this_frame, sp_regnum, buf);
-  cache->saved_sp = extract_unsigned_integer (buf, 8);
+  cache->saved_sp = extract_unsigned_integer (buf, 8, byte_order);
 
   /* We always want the bsp to point to the end of frame.
      This way, we can always get the beginning of frame (bof)
      by subtracting frame size.  */
   get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
-  cache->bsp = extract_unsigned_integer (buf, 8);
+  cache->bsp = extract_unsigned_integer (buf, 8, byte_order);
   
   get_frame_register (this_frame, IA64_PSR_REGNUM, buf);
-  psr = extract_unsigned_integer (buf, 8);
+  psr = extract_unsigned_integer (buf, 8, byte_order);
 
   get_frame_register (this_frame, IA64_CFM_REGNUM, buf);
-  cfm = extract_unsigned_integer (buf, 8);
+  cfm = extract_unsigned_integer (buf, 8, byte_order);
 
   cache->sof = (cfm & 0x7f);
   cache->sol = (cfm >> 7) & 0x7f;
@@ -1743,6 +1766,7 @@ ia64_frame_prev_register (struct frame_i
 			  int regnum)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct ia64_frame_cache *cache = ia64_frame_cache (this_frame, this_cache);
   char buf[8];
 
@@ -1768,7 +1792,8 @@ ia64_frame_prev_register (struct frame_i
          that frame by adding the size of output:
             (sof (size of frame) - sol (size of locals)).  */
       val = ia64_frame_prev_register (this_frame, this_cache, IA64_CFM_REGNUM);
-      prev_cfm = extract_unsigned_integer (value_contents_all (val), 8);
+      prev_cfm = extract_unsigned_integer (value_contents_all (val),
+					   8, byte_order);
       bsp = rse_address_add (cache->bsp, -(cache->sof));
       prev_bsp =
         rse_address_add (bsp, (prev_cfm & 0x7f) - ((prev_cfm >> 7) & 0x7f));
@@ -1854,14 +1879,14 @@ ia64_frame_prev_register (struct frame_i
 	     the nat collection from rnat.  Otherwise, we fetch the nat
 	     collection from the computed address.  */
 	  get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
-	  bsp = extract_unsigned_integer (buf, 8); 
+	  bsp = extract_unsigned_integer (buf, 8, byte_order);
 	  if (nat_addr >= bsp)
 	    {
 	      get_frame_register (this_frame, IA64_RNAT_REGNUM, buf);
-	      nat_collection = extract_unsigned_integer (buf, 8);
+	      nat_collection = extract_unsigned_integer (buf, 8, byte_order);
 	    }
 	  else
-	    nat_collection = read_memory_integer (nat_addr, 8);
+	    nat_collection = read_memory_integer (nat_addr, 8, byte_order);
 	  nat_bit = (gr_addr >> 3) & 0x3f;
 	  natval = (nat_collection >> nat_bit) & 1;
 	}
@@ -1877,12 +1902,12 @@ ia64_frame_prev_register (struct frame_i
       if (addr != 0)
         {
           read_memory (addr, buf, register_size (gdbarch, IA64_IP_REGNUM));
-          pc = extract_unsigned_integer (buf, 8);
+          pc = extract_unsigned_integer (buf, 8, byte_order);
         }
       else if (cache->frameless)
 	{
 	  get_frame_register (this_frame, IA64_BR0_REGNUM, buf);
-	  pc = extract_unsigned_integer (buf, 8);
+	  pc = extract_unsigned_integer (buf, 8, byte_order);
 	}
       pc &= ~0xf;
       return frame_unwind_got_constant (this_frame, regnum, pc);
@@ -1900,17 +1925,17 @@ ia64_frame_prev_register (struct frame_i
       CORE_ADDR addr = cache->saved_regs[IA64_VRAP_REGNUM];
 
       get_frame_register (this_frame, IA64_PSR_REGNUM, buf);
-      psr = extract_unsigned_integer (buf, 8);
+      psr = extract_unsigned_integer (buf, 8, byte_order);
 
       if (addr != 0)
 	{
 	  read_memory (addr, buf, register_size (gdbarch, IA64_IP_REGNUM));
-	  pc = extract_unsigned_integer (buf, 8);
+	  pc = extract_unsigned_integer (buf, 8, byte_order);
 	}
       else if (cache->frameless)
 	{
 	  get_frame_register (this_frame, IA64_BR0_REGNUM, buf);
-	  pc = extract_unsigned_integer (buf, 8);
+	  pc = extract_unsigned_integer (buf, 8, byte_order);
 	}
       psr &= ~(3LL << 41);
       slot_num = pc & 0x3LL;
@@ -1951,11 +1976,11 @@ ia64_frame_prev_register (struct frame_i
           reg_val = ia64_frame_prev_register (this_frame, this_cache,
                                               IA64_CFM_REGNUM);
 	  prev_cfm = extract_unsigned_integer (value_contents_all (reg_val),
-                                               8);
+                                               8, byte_order);
 	  reg_val = ia64_frame_prev_register (this_frame, this_cache,
                                               IA64_BSP_REGNUM);
 	  prev_bsp = extract_unsigned_integer (value_contents_all (reg_val),
-                                               8);
+                                               8, byte_order);
 	  prev_bof = rse_address_add (prev_bsp, -(prev_cfm & 0x7f));
 
 	  addr = rse_address_add (prev_bof, (regnum - IA64_GR32_REGNUM));
@@ -2006,47 +2031,50 @@ static void
 ia64_sigtramp_frame_init_saved_regs (struct frame_info *this_frame,
 				     struct ia64_frame_cache *cache)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   if (tdep->sigcontext_register_address)
     {
       int regno;
 
       cache->saved_regs[IA64_VRAP_REGNUM] = 
-	tdep->sigcontext_register_address (cache->base, IA64_IP_REGNUM);
+	tdep->sigcontext_register_address (gdbarch, cache->base, IA64_IP_REGNUM);
       cache->saved_regs[IA64_CFM_REGNUM] = 
-	tdep->sigcontext_register_address (cache->base, IA64_CFM_REGNUM);
+	tdep->sigcontext_register_address (gdbarch, cache->base, IA64_CFM_REGNUM);
       cache->saved_regs[IA64_PSR_REGNUM] = 
-	tdep->sigcontext_register_address (cache->base, IA64_PSR_REGNUM);
+	tdep->sigcontext_register_address (gdbarch, cache->base, IA64_PSR_REGNUM);
       cache->saved_regs[IA64_BSP_REGNUM] = 
-	tdep->sigcontext_register_address (cache->base, IA64_BSP_REGNUM);
+	tdep->sigcontext_register_address (gdbarch, cache->base, IA64_BSP_REGNUM);
       cache->saved_regs[IA64_RNAT_REGNUM] = 
-	tdep->sigcontext_register_address (cache->base, IA64_RNAT_REGNUM);
+	tdep->sigcontext_register_address (gdbarch, cache->base, IA64_RNAT_REGNUM);
       cache->saved_regs[IA64_CCV_REGNUM] = 
-	tdep->sigcontext_register_address (cache->base, IA64_CCV_REGNUM);
+	tdep->sigcontext_register_address (gdbarch, cache->base, IA64_CCV_REGNUM);
       cache->saved_regs[IA64_UNAT_REGNUM] = 
-	tdep->sigcontext_register_address (cache->base, IA64_UNAT_REGNUM);
+	tdep->sigcontext_register_address (gdbarch, cache->base, IA64_UNAT_REGNUM);
       cache->saved_regs[IA64_FPSR_REGNUM] = 
-	tdep->sigcontext_register_address (cache->base, IA64_FPSR_REGNUM);
+	tdep->sigcontext_register_address (gdbarch, cache->base, IA64_FPSR_REGNUM);
       cache->saved_regs[IA64_PFS_REGNUM] = 
-	tdep->sigcontext_register_address (cache->base, IA64_PFS_REGNUM);
+	tdep->sigcontext_register_address (gdbarch, cache->base, IA64_PFS_REGNUM);
       cache->saved_regs[IA64_LC_REGNUM] = 
-	tdep->sigcontext_register_address (cache->base, IA64_LC_REGNUM);
+	tdep->sigcontext_register_address (gdbarch, cache->base, IA64_LC_REGNUM);
       for (regno = IA64_GR1_REGNUM; regno <= IA64_GR31_REGNUM; regno++)
 	cache->saved_regs[regno] =
-	  tdep->sigcontext_register_address (cache->base, regno);
+	  tdep->sigcontext_register_address (gdbarch, cache->base, regno);
       for (regno = IA64_BR0_REGNUM; regno <= IA64_BR7_REGNUM; regno++)
 	cache->saved_regs[regno] =
-	  tdep->sigcontext_register_address (cache->base, regno);
+	  tdep->sigcontext_register_address (gdbarch, cache->base, regno);
       for (regno = IA64_FR2_REGNUM; regno <= IA64_FR31_REGNUM; regno++)
 	cache->saved_regs[regno] =
-	  tdep->sigcontext_register_address (cache->base, regno);
+	  tdep->sigcontext_register_address (gdbarch, cache->base, regno);
     }
 }
 
 static struct ia64_frame_cache *
 ia64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct ia64_frame_cache *cache;
   CORE_ADDR addr;
   char buf[8];
@@ -2060,13 +2088,13 @@ ia64_sigtramp_frame_cache (struct frame_
   get_frame_register (this_frame, sp_regnum, buf);
   /* Note that frame size is hard-coded below.  We cannot calculate it
      via prologue examination.  */
-  cache->base = extract_unsigned_integer (buf, 8) + 16;
+  cache->base = extract_unsigned_integer (buf, 8, byte_order) + 16;
 
   get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
-  cache->bsp = extract_unsigned_integer (buf, 8);
+  cache->bsp = extract_unsigned_integer (buf, 8, byte_order);
 
   get_frame_register (this_frame, IA64_CFM_REGNUM, buf);
-  cache->cfm = extract_unsigned_integer (buf, 8);
+  cache->cfm = extract_unsigned_integer (buf, 8, byte_order);
   cache->sof = cache->cfm & 0x7f;
 
   ia64_sigtramp_frame_init_saved_regs (this_frame, cache);
@@ -2102,6 +2130,7 @@ ia64_sigtramp_frame_prev_register (struc
   char buf[MAX_REGISTER_SIZE];
 
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct ia64_frame_cache *cache =
     ia64_sigtramp_frame_cache (this_frame, this_cache);
 
@@ -2118,7 +2147,7 @@ ia64_sigtramp_frame_prev_register (struc
       if (addr != 0)
 	{
 	  read_memory (addr, buf, register_size (gdbarch, IA64_IP_REGNUM));
-	  pc = extract_unsigned_integer (buf, 8);
+	  pc = extract_unsigned_integer (buf, 8, byte_order);
 	}
       pc &= ~0xf;
       return frame_unwind_got_constant (this_frame, regnum, pc);
@@ -2301,6 +2330,7 @@ ia64_access_reg (unw_addr_space_t as, un
   unw_word_t bsp, sof, sol, cfm, psr, ip;
   struct frame_info *this_frame = arg;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   long new_sof, old_sof;
   char buf[MAX_REGISTER_SIZE];
   
@@ -2313,9 +2343,9 @@ ia64_access_reg (unw_addr_space_t as, un
 	/* Libunwind expects to see the pc value which means the slot number
 	   from the psr must be merged with the ip word address.  */
 	get_frame_register (this_frame, IA64_IP_REGNUM, buf);
-	ip = extract_unsigned_integer (buf, 8); 
+	ip = extract_unsigned_integer (buf, 8, byte_order);
 	get_frame_register (this_frame, IA64_PSR_REGNUM, buf);
-	psr = extract_unsigned_integer (buf, 8); 
+	psr = extract_unsigned_integer (buf, 8, byte_order);
 	*val = ip | ((psr >> 41) & 0x3);
 	break;
  
@@ -2324,9 +2354,9 @@ ia64_access_reg (unw_addr_space_t as, un
 	   frame so we must account for the fact that ptrace() will return a value
 	   for bsp that points *after* the current register frame.  */
 	get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
-	bsp = extract_unsigned_integer (buf, 8);
+	bsp = extract_unsigned_integer (buf, 8, byte_order);
 	get_frame_register (this_frame, IA64_CFM_REGNUM, buf);
-	cfm = extract_unsigned_integer (buf, 8); 
+	cfm = extract_unsigned_integer (buf, 8, byte_order);
 	sof = (cfm & 0x7f);
 	*val = ia64_rse_skip_regs (bsp, -sof);
 	break;
@@ -2335,13 +2365,13 @@ ia64_access_reg (unw_addr_space_t as, un
 	/* Libunwind wants bspstore to be after the current register frame.
 	   This is what ptrace() and gdb treats as the regular bsp value.  */
 	get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
-	*val = extract_unsigned_integer (buf, 8);
+	*val = extract_unsigned_integer (buf, 8, byte_order);
 	break;
 
       default:
 	/* For all other registers, just unwind the value directly.  */
 	get_frame_register (this_frame, regnum, buf);
-	*val = extract_unsigned_integer (buf, 8); 
+	*val = extract_unsigned_integer (buf, 8, byte_order);
 	break;
     }
       
@@ -2379,6 +2409,7 @@ ia64_access_rse_reg (unw_addr_space_t as
   unw_word_t bsp, sof, sol, cfm, psr, ip;
   struct regcache *regcache = arg;
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   long new_sof, old_sof;
   char buf[MAX_REGISTER_SIZE];
   
@@ -2391,9 +2422,9 @@ ia64_access_rse_reg (unw_addr_space_t as
 	/* Libunwind expects to see the pc value which means the slot number
 	   from the psr must be merged with the ip word address.  */
 	regcache_cooked_read (regcache, IA64_IP_REGNUM, buf);
-	ip = extract_unsigned_integer (buf, 8); 
+	ip = extract_unsigned_integer (buf, 8, byte_order);
 	regcache_cooked_read (regcache, IA64_PSR_REGNUM, buf);
-	psr = extract_unsigned_integer (buf, 8); 
+	psr = extract_unsigned_integer (buf, 8, byte_order);
 	*val = ip | ((psr >> 41) & 0x3);
 	break;
 	  
@@ -2402,9 +2433,9 @@ ia64_access_rse_reg (unw_addr_space_t as
 	   frame so we must account for the fact that ptrace() will return a value
 	   for bsp that points *after* the current register frame.  */
 	regcache_cooked_read (regcache, IA64_BSP_REGNUM, buf);
-	bsp = extract_unsigned_integer (buf, 8);
+	bsp = extract_unsigned_integer (buf, 8, byte_order);
 	regcache_cooked_read (regcache, IA64_CFM_REGNUM, buf);
-	cfm = extract_unsigned_integer (buf, 8); 
+	cfm = extract_unsigned_integer (buf, 8, byte_order);
 	sof = (cfm & 0x7f);
 	*val = ia64_rse_skip_regs (bsp, -sof);
 	break;
@@ -2413,13 +2444,13 @@ ia64_access_rse_reg (unw_addr_space_t as
 	/* Libunwind wants bspstore to be after the current register frame.
 	   This is what ptrace() and gdb treats as the regular bsp value.  */
 	regcache_cooked_read (regcache, IA64_BSP_REGNUM, buf);
-	*val = extract_unsigned_integer (buf, 8);
+	*val = extract_unsigned_integer (buf, 8, byte_order);
 	break;
 
       default:
         /* For all other registers, just unwind the value directly.  */
 	regcache_cooked_read (regcache, regnum, buf);
-	*val = extract_unsigned_integer (buf, 8); 
+	*val = extract_unsigned_integer (buf, 8, byte_order);
 	break;
     }
       
@@ -2606,7 +2637,7 @@ ia64_find_unwind_table (struct objfile *
 
   dip->start_ip = p_text->p_vaddr + load_base;
   dip->end_ip = dip->start_ip + p_text->p_memsz;
-  dip->gp = ia64_find_global_pointer (ip);
+  dip->gp = ia64_find_global_pointer (get_objfile_arch (objfile), ip);
   dip->format = UNW_INFO_FORMAT_REMOTE_TABLE;
   dip->u.rti.name_ptr = (unw_word_t) bfd_get_filename (bfd);
   dip->u.rti.segbase = segbase;
@@ -2732,6 +2763,7 @@ ia64_libunwind_frame_this_id (struct fra
 			      struct frame_id *this_id)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct frame_id id;
   char buf[8];
   CORE_ADDR bsp;
@@ -2747,7 +2779,7 @@ ia64_libunwind_frame_this_id (struct fra
   /* We must add the bsp as the special address for frame comparison 
      purposes.  */
   get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
-  bsp = extract_unsigned_integer (buf, 8);
+  bsp = extract_unsigned_integer (buf, 8, byte_order);
 
   (*this_id) = frame_id_build_special (id.stack_addr, id.code_addr, bsp);
 
@@ -2766,6 +2798,7 @@ ia64_libunwind_frame_prev_register (stru
 {
   int reg = regnum;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct value *val;
 
   if (VP0_REGNUM <= regnum && regnum <= VP63_REGNUM)
@@ -2789,7 +2822,7 @@ ia64_libunwind_frame_prev_register (stru
 	  /* Fetch predicate register rename base from current frame
 	     marker for this frame.  */
 	  get_frame_register (this_frame, IA64_CFM_REGNUM, buf);
-	  cfm = extract_unsigned_integer (buf, 8); 
+	  cfm = extract_unsigned_integer (buf, 8, byte_order);
 	  rrb_pr = (cfm >> 32) & 0x3f;
 	  
 	  /* Adjust the register number to account for register rotation.  */
@@ -2819,10 +2852,12 @@ ia64_libunwind_frame_prev_register (stru
          register will be if we pop the frame back which is why we might
          have been called.  We know that libunwind will pass us back the
          beginning of the current frame so we should just add sof to it. */
-      prev_bsp = extract_unsigned_integer (value_contents_all (val), 8);
+      prev_bsp = extract_unsigned_integer (value_contents_all (val),
+					   8, byte_order);
       cfm_val = libunwind_frame_prev_register (this_frame, this_cache,
                                                IA64_CFM_REGNUM);
-      prev_cfm = extract_unsigned_integer (value_contents_all (cfm_val), 8);
+      prev_cfm = extract_unsigned_integer (value_contents_all (cfm_val),
+					   8, byte_order);
       prev_bsp = rse_address_add (prev_bsp, (prev_cfm & 0x7f));
 
       return frame_unwind_got_constant (this_frame, regnum, prev_bsp);
@@ -2859,6 +2894,7 @@ ia64_libunwind_sigtramp_frame_this_id (s
 				       struct frame_id *this_id)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   char buf[8];
   CORE_ADDR bsp;
   struct frame_id id;
@@ -2874,7 +2910,7 @@ ia64_libunwind_sigtramp_frame_this_id (s
   /* We must add the bsp as the special address for frame comparison 
      purposes.  */
   get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
-  bsp = extract_unsigned_integer (buf, 8);
+  bsp = extract_unsigned_integer (buf, 8, byte_order);
 
   /* For a sigtramp frame, we don't make the check for previous ip being 0.  */
   (*this_id) = frame_id_build_special (id.stack_addr, id.code_addr, bsp);
@@ -2892,6 +2928,8 @@ static struct value *
 ia64_libunwind_sigtramp_frame_prev_register (struct frame_info *this_frame,
 					     void **this_cache, int regnum)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct value *prev_ip_val;
   CORE_ADDR prev_ip;
 
@@ -2899,7 +2937,8 @@ ia64_libunwind_sigtramp_frame_prev_regis
      method of getting previous registers.  */
   prev_ip_val = libunwind_frame_prev_register (this_frame, this_cache,
                                                IA64_IP_REGNUM);
-  prev_ip = extract_unsigned_integer (value_contents_all (prev_ip_val), 8);
+  prev_ip = extract_unsigned_integer (value_contents_all (prev_ip_val),
+				      8, byte_order);
 
   if (prev_ip == 0)
     {
@@ -3221,8 +3260,9 @@ slot_alignment_is_next_even (struct type
    d_un.d_ptr value is the global pointer.  */
 
 static CORE_ADDR
-ia64_find_global_pointer (CORE_ADDR faddr)
+ia64_find_global_pointer (struct gdbarch *gdbarch, CORE_ADDR faddr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct obj_section *faddr_sect;
      
   faddr_sect = find_pc_section (faddr);
@@ -3252,7 +3292,7 @@ ia64_find_global_pointer (CORE_ADDR fadd
 	      status = target_read_memory (addr, buf, sizeof (buf));
 	      if (status != 0)
 		break;
-	      tag = extract_signed_integer (buf, sizeof (buf));
+	      tag = extract_signed_integer (buf, sizeof (buf), byte_order);
 
 	      if (tag == DT_PLTGOT)
 		{
@@ -3261,7 +3301,8 @@ ia64_find_global_pointer (CORE_ADDR fadd
 		  status = target_read_memory (addr + 8, buf, sizeof (buf));
 		  if (status != 0)
 		    break;
-		  global_pointer = extract_unsigned_integer (buf, sizeof (buf));
+		  global_pointer = extract_unsigned_integer (buf, sizeof (buf),
+							     byte_order);
 
 		  /* The payoff... */
 		  return global_pointer;
@@ -3281,8 +3322,9 @@ ia64_find_global_pointer (CORE_ADDR fadd
    corresponding (canonical) function descriptor.  Return 0 if
    not found.  */
 static CORE_ADDR
-find_extant_func_descr (CORE_ADDR faddr)
+find_extant_func_descr (struct gdbarch *gdbarch, CORE_ADDR faddr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct obj_section *faddr_sect;
 
   /* Return early if faddr is already a function descriptor.  */
@@ -3315,7 +3357,7 @@ find_extant_func_descr (CORE_ADDR faddr)
 	      status = target_read_memory (addr, buf, sizeof (buf));
 	      if (status != 0)
 		break;
-	      faddr2 = extract_signed_integer (buf, sizeof (buf));
+	      faddr2 = extract_signed_integer (buf, sizeof (buf), byte_order);
 
 	      if (faddr == faddr2)
 		return addr;
@@ -3334,9 +3376,11 @@ find_extant_func_descr (CORE_ADDR faddr)
 static CORE_ADDR
 find_func_descr (struct regcache *regcache, CORE_ADDR faddr, CORE_ADDR *fdaptr)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR fdesc;
 
-  fdesc = find_extant_func_descr (faddr);
+  fdesc = find_extant_func_descr (gdbarch, faddr);
 
   if (fdesc == 0)
     {
@@ -3346,14 +3390,14 @@ find_func_descr (struct regcache *regcac
       fdesc = *fdaptr;
       *fdaptr += 16;
 
-      global_pointer = ia64_find_global_pointer (faddr);
+      global_pointer = ia64_find_global_pointer (gdbarch, faddr);
 
       if (global_pointer == 0)
 	regcache_cooked_read_unsigned (regcache,
 				       IA64_GR1_REGNUM, &global_pointer);
 
-      store_unsigned_integer (buf, 8, faddr);
-      store_unsigned_integer (buf + 8, 8, global_pointer);
+      store_unsigned_integer (buf, 8, byte_order, faddr);
+      store_unsigned_integer (buf + 8, 8, byte_order, global_pointer);
 
       write_memory (fdesc, buf, 16);
     }
@@ -3368,13 +3412,14 @@ static CORE_ADDR
 ia64_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
 				 struct target_ops *targ)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct obj_section *s;
 
   s = find_pc_section (addr);
 
   /* check if ADDR points to a function descriptor.  */
   if (s && strcmp (s->the_bfd_section->name, ".opd") == 0)
-    return read_memory_unsigned_integer (addr, 8);
+    return read_memory_unsigned_integer (addr, 8, byte_order);
 
   /* Normally, functions live inside a section that is executable.
      So, if ADDR points to a non-executable section, then treat it
@@ -3382,7 +3427,7 @@ ia64_convert_from_func_ptr_addr (struct 
      the target address itself points to a section that is executable.  */
   if (s && (s->the_bfd_section->flags & SEC_CODE) == 0)
     {
-      CORE_ADDR pc = read_memory_unsigned_integer (addr, 8);
+      CORE_ADDR pc = read_memory_unsigned_integer (addr, 8, byte_order);
       struct obj_section *pc_section = find_pc_section (pc);
 
       if (pc_section && (pc_section->the_bfd_section->flags & SEC_CODE))
@@ -3397,7 +3442,7 @@ ia64_convert_from_func_ptr_addr (struct 
       minsym = lookup_minimal_symbol_by_pc (addr);
 
       if (minsym && is_vtable_name (SYMBOL_LINKAGE_NAME (minsym)))
-	return read_memory_unsigned_integer (addr, 8);
+	return read_memory_unsigned_integer (addr, 8, byte_order);
     }
 
   return addr;
@@ -3415,6 +3460,7 @@ ia64_push_dummy_call (struct gdbarch *gd
 		      int nargs, struct value **args, CORE_ADDR sp,
 		      int struct_return, CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int argno;
   struct value *arg;
   struct type *type;
@@ -3495,8 +3541,9 @@ ia64_push_dummy_call (struct gdbarch *gd
 	  && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC)
 	{
 	  char val_buf[8];
-	  ULONGEST faddr = extract_unsigned_integer (value_contents (arg), 8);
-	  store_unsigned_integer (val_buf, 8,
+	  ULONGEST faddr = extract_unsigned_integer (value_contents (arg),
+						     8, byte_order);
+	  store_unsigned_integer (val_buf, 8, byte_order,
 				  find_func_descr (regcache, faddr,
 						   &funcdescaddr));
 	  if (slotnum < rseslots)
@@ -3556,7 +3603,7 @@ ia64_push_dummy_call (struct gdbarch *gd
       regcache_cooked_write_unsigned (regcache, IA64_GR8_REGNUM, (ULONGEST)struct_addr);
     }
 
-  global_pointer = ia64_find_global_pointer (func_addr);
+  global_pointer = ia64_find_global_pointer (gdbarch, func_addr);
 
   if (global_pointer != 0)
     regcache_cooked_write_unsigned (regcache, IA64_GR1_REGNUM, global_pointer);
@@ -3571,14 +3618,15 @@ ia64_push_dummy_call (struct gdbarch *gd
 static struct frame_id
 ia64_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   char buf[8];
   CORE_ADDR sp, bsp;
 
   get_frame_register (this_frame, sp_regnum, buf);
-  sp = extract_unsigned_integer (buf, 8);
+  sp = extract_unsigned_integer (buf, 8, byte_order);
 
   get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
-  bsp = extract_unsigned_integer (buf, 8);
+  bsp = extract_unsigned_integer (buf, 8, byte_order);
 
   if (gdbarch_debug >= 1)
     fprintf_unfiltered (gdb_stdlog,
@@ -3592,13 +3640,14 @@ ia64_dummy_id (struct gdbarch *gdbarch, 
 static CORE_ADDR 
 ia64_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   char buf[8];
   CORE_ADDR ip, psr, pc;
 
   frame_unwind_register (next_frame, IA64_IP_REGNUM, buf);
-  ip = extract_unsigned_integer (buf, 8);
+  ip = extract_unsigned_integer (buf, 8, byte_order);
   frame_unwind_register (next_frame, IA64_PSR_REGNUM, buf);
-  psr = extract_unsigned_integer (buf, 8);
+  psr = extract_unsigned_integer (buf, 8, byte_order);
  
   pc = (ip & ~0xf) | ((psr >> 41) & 3);
   return pc;
Index: gdb-head/gdb/ia64-tdep.h
===================================================================
--- gdb-head.orig/gdb/ia64-tdep.h
+++ gdb-head/gdb/ia64-tdep.h
@@ -196,7 +196,7 @@
 
 struct gdbarch_tdep
 {
-  CORE_ADDR (*sigcontext_register_address) (CORE_ADDR, int);
+  CORE_ADDR (*sigcontext_register_address) (struct gdbarch *, CORE_ADDR, int);
   int (*pc_in_sigtramp) (CORE_ADDR);
 
   /* ISA-specific data types.  */
Index: gdb-head/gdb/iq2000-tdep.c
===================================================================
--- gdb-head.orig/gdb/iq2000-tdep.c
+++ gdb-head/gdb/iq2000-tdep.c
@@ -90,8 +90,10 @@ static CORE_ADDR
 iq2000_pointer_to_address (struct gdbarch *gdbarch,
 			   struct type * type, const gdb_byte * buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
-  CORE_ADDR addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
+  CORE_ADDR addr
+    = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
 
   if (target == TYPE_CODE_FUNC
       || target == TYPE_CODE_METHOD
@@ -108,11 +110,12 @@ static void
 iq2000_address_to_pointer (struct gdbarch *gdbarch,
 			   struct type *type, gdb_byte *buf, CORE_ADDR addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
 
   if (target == TYPE_CODE_FUNC || target == TYPE_CODE_METHOD)
     addr = insn_ptr_from_addr (addr);
-  store_unsigned_integer (buf, TYPE_LENGTH (type), addr);
+  store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr);
 }
 
 /* Real register methods: */
@@ -195,11 +198,13 @@ find_last_line_symbol (CORE_ADDR start, 
    Returns the address of the first instruction after the prologue.  */
 
 static CORE_ADDR
-iq2000_scan_prologue (CORE_ADDR scan_start,
+iq2000_scan_prologue (struct gdbarch *gdbarch,
+		      CORE_ADDR scan_start,
 		      CORE_ADDR scan_end,
 		      struct frame_info *fi,
 		      struct iq2000_frame_cache *cache)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct symtab_and_line sal;
   CORE_ADDR pc;
   CORE_ADDR loop_end;
@@ -234,7 +239,7 @@ iq2000_scan_prologue (CORE_ADDR scan_sta
 
   for (pc = scan_start; pc < loop_end; pc += 4)
     {
-      LONGEST insn = read_memory_unsigned_integer (pc, 4);
+      LONGEST insn = read_memory_unsigned_integer (pc, 4, byte_order);
       /* Skip any instructions writing to (sp) or decrementing the
          SP. */
       if ((insn & 0xffe00000) == 0xac200000)
@@ -351,7 +356,7 @@ iq2000_skip_prologue (struct gdbarch *gd
 
       /* No useable line symbol.  Use prologue parsing method.  */
       iq2000_init_frame_cache (&cache);
-      return iq2000_scan_prologue (func_addr, func_end, NULL, &cache);
+      return iq2000_scan_prologue (gdbarch, func_addr, func_end, NULL, &cache);
     }
 
   /* No function symbol -- just return the PC.  */
@@ -361,6 +366,7 @@ iq2000_skip_prologue (struct gdbarch *gd
 static struct iq2000_frame_cache *
 iq2000_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct iq2000_frame_cache *cache;
   CORE_ADDR current_pc;
   int i;
@@ -379,7 +385,7 @@ iq2000_frame_cache (struct frame_info *t
   current_pc = get_frame_pc (this_frame);
   find_pc_partial_function (current_pc, NULL, &cache->pc, NULL);
   if (cache->pc != 0)
-    iq2000_scan_prologue (cache->pc, current_pc, this_frame, cache);
+    iq2000_scan_prologue (gdbarch, cache->pc, current_pc, this_frame, cache);
   if (!cache->using_fp)
     cache->base = get_frame_register_unsigned (this_frame, E_SP_REGNUM);
 
@@ -531,6 +537,9 @@ static void
 iq2000_extract_return_value (struct type *type, struct regcache *regcache,
 			     void *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   /* If the function's return value is 8 bytes or less, it is
      returned in a register, and if larger than 8 bytes, it is 
      returned in a stack location which is pointed to by the same
@@ -551,7 +560,7 @@ iq2000_extract_return_value (struct type
 	  /* By using store_unsigned_integer we avoid having to
 	     do anything special for small big-endian values.  */
 	  regcache_cooked_read_unsigned (regcache, regno++, &tmp);
-	  store_unsigned_integer (valbuf, size, tmp);
+	  store_unsigned_integer (valbuf, size, byte_order, tmp);
 	  len -= size;
 	  valbuf = ((char *) valbuf) + size;
 	}
@@ -636,6 +645,7 @@ iq2000_push_dummy_call (struct gdbarch *
 		        int nargs, struct value **args, CORE_ADDR sp,
 		        int struct_return, CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   const bfd_byte *val;
   bfd_byte buf[4];
   struct type *type;
@@ -767,7 +777,7 @@ iq2000_push_dummy_call (struct gdbarch *
 	    regcache_cooked_write_unsigned (regcache, argreg++, struct_ptr);
 	  else
 	    {
-	      store_unsigned_integer (buf, 4, struct_ptr);
+	      store_unsigned_integer (buf, 4, byte_order, struct_ptr);
 	      write_memory (sp + stackspace, buf, 4);
 	      stackspace += 4;
 	    }
Index: gdb-head/gdb/irix5-nat.c
===================================================================
--- gdb-head.orig/gdb/irix5-nat.c
+++ gdb-head/gdb/irix5-nat.c
@@ -84,6 +84,7 @@ fill_gregset (const struct regcache *reg
   greg_t *regp = &(*gregsetp)[0];
   gdb_byte buf[MAX_REGISTER_SIZE];
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   /* Under Irix6, if GDB is built with N32 ABI and is debugging an O32
      executable, we have to sign extend the registers to 64 bits before
@@ -94,7 +95,7 @@ fill_gregset (const struct regcache *reg
       {
 	size = register_size (gdbarch, regi);
 	regcache_raw_collect (regcache, regi, buf);
-	*(regp + regi) = extract_signed_integer (buf, size);
+	*(regp + regi) = extract_signed_integer (buf, size, byte_order);
       }
 
   if ((regno == -1) || (regno == gdbarch_pc_regnum (gdbarch)))
@@ -102,7 +103,7 @@ fill_gregset (const struct regcache *reg
       regi = mips_regnum (gdbarch)->pc;
       size = register_size (gdbarch, regi);
       regcache_raw_collect (regcache, regi, buf);
-      *(regp + CTX_EPC) = extract_signed_integer (buf, size);
+      *(regp + CTX_EPC) = extract_signed_integer (buf, size, byte_order);
     }
 
   if ((regno == -1) || (regno == mips_regnum (gdbarch)->cause))
@@ -110,7 +111,7 @@ fill_gregset (const struct regcache *reg
       regi = mips_regnum (gdbarch)->cause;
       size = register_size (gdbarch, regi);
       regcache_raw_collect (regcache, regi, buf);
-      *(regp + CTX_CAUSE) = extract_signed_integer (buf, size);
+      *(regp + CTX_CAUSE) = extract_signed_integer (buf, size, byte_order);
     }
 
   if ((regno == -1) || (regno == mips_regnum (gdbarch)->hi))
@@ -118,7 +119,7 @@ fill_gregset (const struct regcache *reg
       regi = mips_regnum (gdbarch)->hi;
       size = register_size (gdbarch, regi);
       regcache_raw_collect (regcache, regi, buf);
-      *(regp + CTX_MDHI) = extract_signed_integer (buf, size);
+      *(regp + CTX_MDHI) = extract_signed_integer (buf, size, byte_order);
     }
 
   if ((regno == -1) || (regno == mips_regnum (gdbarch)->lo))
@@ -126,7 +127,7 @@ fill_gregset (const struct regcache *reg
       regi = mips_regnum (gdbarch)->lo;
       size = register_size (gdbarch, regi);
       regcache_raw_collect (regcache, regi, buf);
-      *(regp + CTX_MDLO) = extract_signed_integer (buf, size);
+      *(regp + CTX_MDLO) = extract_signed_integer (buf, size, byte_order);
     }
 }
 
Index: gdb-head/gdb/jv-lang.c
===================================================================
--- gdb-head.orig/gdb/jv-lang.c
+++ gdb-head/gdb/jv-lang.c
@@ -907,6 +907,7 @@ evaluate_subexp_java (struct type *expec
       if (TYPE_CODE (type) == TYPE_CODE_STRUCT
 	  && i > 2 && name[i - 1] == ']')
 	{
+	  enum bfd_endian byte_order = gdbarch_byte_order (exp->gdbarch);
 	  CORE_ADDR address;
 	  long length, index;
 	  struct type *el_type;
@@ -927,7 +928,7 @@ evaluate_subexp_java (struct type *expec
 	  address = value_as_address (arg1);
 	  address += get_java_object_header_size (exp->gdbarch);
 	  read_memory (address, buf4, 4);
-	  length = (long) extract_signed_integer (buf4, 4);
+	  length = (long) extract_signed_integer (buf4, 4, byte_order);
 	  index = (long) value_as_long (arg2);
 	  if (index >= length || index < 0)
 	    error (_("array index (%ld) out of bounds (length: %ld)"),
Index: gdb-head/gdb/jv-valprint.c
===================================================================
--- gdb-head.orig/gdb/jv-valprint.c
+++ gdb-head/gdb/jv-valprint.c
@@ -39,6 +39,7 @@ java_value_print (struct value *val, str
 		  const struct value_print_options *options)
 {
   struct gdbarch *gdbarch = get_type_arch (value_type (val));
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct type *type;
   CORE_ADDR address;
   int i;
@@ -81,7 +82,7 @@ java_value_print (struct value *val, str
       i = 0;
       read_memory (address + get_java_object_header_size (gdbarch), buf4, 4);
 
-      length = (long) extract_signed_integer (buf4, 4);
+      length = (long) extract_signed_integer (buf4, 4, byte_order);
       fprintf_filtered (stream, "{length: %ld", length);
 
       if (el_type == NULL)
@@ -110,7 +111,8 @@ java_value_print (struct value *val, str
                      pulls a host sized pointer out of the target and
                      then extracts that as an address (while assuming
                      that the address is unsigned)!  */
-		  element = extract_unsigned_integer (buf, sizeof (buf));
+		  element = extract_unsigned_integer (buf, sizeof (buf),
+						      byte_order);
 		}
 
 	      for (reps = 1; i + reps < length; reps++)
@@ -121,7 +123,8 @@ java_value_print (struct value *val, str
                      pulls a host sized pointer out of the target and
                      then extracts that as an address (while assuming
                      that the address is unsigned)!  */
-		  next_element = extract_unsigned_integer (buf, sizeof (buf));
+		  next_element = extract_unsigned_integer (buf, sizeof (buf),
+							   byte_order);
 		  if (next_element != element)
 		    break;
 		}
Index: gdb-head/gdb/m32c-tdep.c
===================================================================
--- gdb-head.orig/gdb/m32c-tdep.c
+++ gdb-head/gdb/m32c-tdep.c
@@ -2003,6 +2003,7 @@ m32c_push_dummy_call (struct gdbarch *gd
 		      CORE_ADDR struct_addr)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned long mach = gdbarch_bfd_arch_info (gdbarch)->mach;
   CORE_ADDR cfa;
   int i;
@@ -2040,7 +2041,7 @@ m32c_push_dummy_call (struct gdbarch *gd
     {
       int ptr_len = TYPE_LENGTH (tdep->ptr_voyd);
       sp -= ptr_len;
-      write_memory_unsigned_integer (sp, ptr_len, struct_addr);
+      write_memory_unsigned_integer (sp, ptr_len, byte_order, struct_addr);
     }
 
   /* Push the arguments.  */
@@ -2061,7 +2062,8 @@ m32c_push_dummy_call (struct gdbarch *gd
 	     sure it ends up in the least significant end of r1.  (GDB
 	     should avoid assuming endianness, even on uni-endian
 	     processors.)  */
-	  ULONGEST u = extract_unsigned_integer (arg_bits, arg_size);
+	  ULONGEST u = extract_unsigned_integer (arg_bits, arg_size,
+						 byte_order);
 	  struct m32c_reg *reg = (mach == bfd_mach_m16c) ? tdep->r1 : tdep->r0;
 	  regcache_cooked_write_unsigned (regcache, reg->num, u);
 	}
@@ -2092,7 +2094,8 @@ m32c_push_dummy_call (struct gdbarch *gd
 
   /* Push the return address.  */
   sp -= tdep->ret_addr_bytes;
-  write_memory_unsigned_integer (sp, tdep->ret_addr_bytes, bp_addr);
+  write_memory_unsigned_integer (sp, tdep->ret_addr_bytes, byte_order,
+				 bp_addr);
 
   /* Update the stack pointer.  */
   regcache_cooked_write_unsigned (regcache, tdep->sp->num, sp);
@@ -2178,6 +2181,7 @@ m32c_return_value (struct gdbarch *gdbar
 		   const gdb_byte *writebuf)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   enum return_value_convention conv;
   ULONGEST valtype_len = TYPE_LENGTH (valtype);
 
@@ -2200,7 +2204,7 @@ m32c_return_value (struct gdbarch *gdbar
 	{
 	  ULONGEST u;
 	  regcache_cooked_read_unsigned (regcache, tdep->r0->num, &u);
-	  store_unsigned_integer (readbuf, valtype_len, u);
+	  store_unsigned_integer (readbuf, valtype_len, byte_order, u);
 	}
       else
 	{
@@ -2230,7 +2234,8 @@ m32c_return_value (struct gdbarch *gdbar
       /* Anything that fits in r0 is returned there.  */
       if (valtype_len <= TYPE_LENGTH (tdep->r0->type))
 	{
-	  ULONGEST u = extract_unsigned_integer (writebuf, valtype_len);
+	  ULONGEST u = extract_unsigned_integer (writebuf, valtype_len,
+						 byte_order);
 	  regcache_cooked_write_unsigned (regcache, tdep->r0->num, u);
 	}
       else
@@ -2306,7 +2311,9 @@ m32c_return_value (struct gdbarch *gdbar
 static CORE_ADDR
 m32c_skip_trampoline_code (struct frame_info *frame, CORE_ADDR stop_pc)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   /* It would be nicer to simply look up the addresses of known
      trampolines once, and then compare stop_pc with them.  However,
@@ -2329,13 +2336,14 @@ m32c_skip_trampoline_code (struct frame_
 	     m32c_jsri*16*.  */
 	  CORE_ADDR sp = get_frame_sp (get_current_frame ());
 	  CORE_ADDR target
-	    = read_memory_unsigned_integer (sp + tdep->ret_addr_bytes, 2);
+	    = read_memory_unsigned_integer (sp + tdep->ret_addr_bytes,
+					    2, byte_order);
 
 	  /* What we have now is the address of a jump instruction.
 	     What we need is the destination of that jump.
 	     The opcode is 1 byte, and the destination is the next 3 bytes.
 	  */
-	  target = read_memory_unsigned_integer (target + 1, 3);
+	  target = read_memory_unsigned_integer (target + 1, 3, byte_order);
 	  return target;
 	}
     }
@@ -2403,6 +2411,7 @@ static void
 m32c_m16c_address_to_pointer (struct gdbarch *gdbarch,
 			      struct type *type, gdb_byte *buf, CORE_ADDR addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   enum type_code target_code;
   gdb_assert (TYPE_CODE (type) == TYPE_CODE_PTR ||
 	      TYPE_CODE (type) == TYPE_CODE_REF);
@@ -2444,7 +2453,7 @@ m32c_m16c_address_to_pointer (struct gdb
       addr = SYMBOL_VALUE_ADDRESS (tramp_msym);
     }
 
-  store_unsigned_integer (buf, TYPE_LENGTH (type), addr);
+  store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr);
 }
 
 
@@ -2452,13 +2461,14 @@ static CORE_ADDR
 m32c_m16c_pointer_to_address (struct gdbarch *gdbarch,
 			      struct type *type, const gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR ptr;
   enum type_code target_code;
 
   gdb_assert (TYPE_CODE (type) == TYPE_CODE_PTR ||
 	      TYPE_CODE (type) == TYPE_CODE_REF);
 
-  ptr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
+  ptr = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
 
   target_code = TYPE_CODE (TYPE_TARGET_TYPE (type));
 
Index: gdb-head/gdb/m32r-tdep.c
===================================================================
--- gdb-head.orig/gdb/m32r-tdep.c
+++ gdb-head/gdb/m32r-tdep.c
@@ -248,15 +248,18 @@ static void
 m32r_store_return_value (struct type *type, struct regcache *regcache,
 			 const void *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR regval;
   int len = TYPE_LENGTH (type);
 
-  regval = extract_unsigned_integer (valbuf, len > 4 ? 4 : len);
+  regval = extract_unsigned_integer (valbuf, len > 4 ? 4 : len, byte_order);
   regcache_cooked_write_unsigned (regcache, RET1_REGNUM, regval);
 
   if (len > 4)
     {
-      regval = extract_unsigned_integer ((gdb_byte *) valbuf + 4, len - 4);
+      regval = extract_unsigned_integer ((gdb_byte *) valbuf + 4,
+					 len - 4, byte_order);
       regcache_cooked_write_unsigned (regcache, RET1_REGNUM + 1, regval);
     }
 }
@@ -265,9 +268,11 @@ m32r_store_return_value (struct type *ty
    should be cached because this thrashing is getting nuts.  */
 
 static int
-decode_prologue (CORE_ADDR start_pc, CORE_ADDR scan_limit,
+decode_prologue (struct gdbarch *gdbarch,
+		 CORE_ADDR start_pc, CORE_ADDR scan_limit,
 		 CORE_ADDR *pl_endptr, unsigned long *framelength)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned long framesize;
   int insn;
   int op1;
@@ -283,10 +288,10 @@ decode_prologue (CORE_ADDR start_pc, COR
   for (current_pc = start_pc; current_pc < scan_limit; current_pc += 2)
     {
       /* Check if current pc's location is readable. */
-      if (!safe_read_memory_integer (current_pc, 2, &return_value))
+      if (!safe_read_memory_integer (current_pc, 2, byte_order, &return_value))
 	return -1;
 
-      insn = read_memory_unsigned_integer (current_pc, 2);
+      insn = read_memory_unsigned_integer (current_pc, 2, byte_order);
 
       if (insn == 0x0000)
 	break;
@@ -308,25 +313,30 @@ decode_prologue (CORE_ADDR start_pc, COR
 	      current_pc += 2;	/* skip the immediate data */
 
 	      /* Check if current pc's location is readable. */
-	      if (!safe_read_memory_integer (current_pc, 2, &return_value))
+	      if (!safe_read_memory_integer (current_pc, 2, byte_order,
+					     &return_value))
 		return -1;
 
 	      if (insn == 0x8faf)	/* add3 sp, sp, xxxx */
 		/* add 16 bit sign-extended offset */
 		{
 		  framesize +=
-		    -((short) read_memory_unsigned_integer (current_pc, 2));
+		    -((short) read_memory_unsigned_integer (current_pc,
+							    2, byte_order));
 		}
 	      else
 		{
 		  if (((insn >> 8) == 0xe4)	/* ld24 r4, xxxxxx; sub sp, r4 */
-		      && safe_read_memory_integer (current_pc + 2, 2,
+		      && safe_read_memory_integer (current_pc + 2,
+						   2, byte_order,
 						   &return_value)
 		      && read_memory_unsigned_integer (current_pc + 2,
-						       2) == 0x0f24)
+						       2, byte_order)
+			 == 0x0f24)
 		    /* subtract 24 bit sign-extended negative-offset */
 		    {
-		      insn = read_memory_unsigned_integer (current_pc - 2, 4);
+		      insn = read_memory_unsigned_integer (current_pc - 2,
+							   4, byte_order);
 		      if (insn & 0x00800000)	/* sign extend */
 			insn |= 0xff000000;	/* negative */
 		      else
@@ -452,6 +462,7 @@ decode_prologue (CORE_ADDR start_pc, COR
 static CORE_ADDR
 m32r_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR func_addr, func_end;
   struct symtab_and_line sal;
   LONGEST return_value;
@@ -478,11 +489,11 @@ m32r_skip_prologue (struct gdbarch *gdba
     func_end = pc + DEFAULT_SEARCH_LIMIT;
 
   /* If pc's location is not readable, just quit. */
-  if (!safe_read_memory_integer (pc, 4, &return_value))
+  if (!safe_read_memory_integer (pc, 4, byte_order, &return_value))
     return pc;
 
   /* Find the end of prologue.  */
-  if (decode_prologue (pc, func_end, &sal.end, NULL) < 0)
+  if (decode_prologue (gdbarch, pc, func_end, &sal.end, NULL) < 0)
     return pc;
 
   return sal.end;
@@ -669,6 +680,7 @@ m32r_push_dummy_call (struct gdbarch *gd
 		      struct value **args, CORE_ADDR sp, int struct_return,
 		      CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int stack_offset, stack_alloc;
   int argreg = ARG1_REGNUM;
   int argnum;
@@ -713,7 +725,8 @@ m32r_push_dummy_call (struct gdbarch *gd
       if (len > 8
 	  && (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION))
 	{
-	  store_unsigned_integer (valbuf, 4, value_address (args[argnum]));
+	  store_unsigned_integer (valbuf, 4, byte_order,
+				  value_address (args[argnum]));
 	  typecode = TYPE_CODE_PTR;
 	  len = 4;
 	  val = valbuf;
@@ -741,7 +754,8 @@ m32r_push_dummy_call (struct gdbarch *gd
 	      /* there's room in a register */
 	      regval =
 		extract_unsigned_integer (val,
-					  register_size (gdbarch, argreg));
+					  register_size (gdbarch, argreg),
+					  byte_order);
 	      regcache_cooked_write_unsigned (regcache, argreg++, regval);
 	    }
 
@@ -767,6 +781,8 @@ static void
 m32r_extract_return_value (struct type *type, struct regcache *regcache,
 			   void *dst)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   bfd_byte *valbuf = dst;
   int len = TYPE_LENGTH (type);
   ULONGEST tmp;
@@ -774,14 +790,14 @@ m32r_extract_return_value (struct type *
   /* By using store_unsigned_integer we avoid having to do
      anything special for small big-endian values.  */
   regcache_cooked_read_unsigned (regcache, RET1_REGNUM, &tmp);
-  store_unsigned_integer (valbuf, (len > 4 ? len - 4 : len), tmp);
+  store_unsigned_integer (valbuf, (len > 4 ? len - 4 : len), byte_order, tmp);
 
   /* Ignore return values more than 8 bytes in size because the m32r
      returns anything more than 8 bytes in the stack. */
   if (len > 4)
     {
       regcache_cooked_read_unsigned (regcache, RET1_REGNUM + 1, &tmp);
-      store_unsigned_integer (valbuf + len - 4, 4, tmp);
+      store_unsigned_integer (valbuf + len - 4, 4, byte_order, tmp);
     }
 }
 
Index: gdb-head/gdb/m68hc11-tdep.c
===================================================================
--- gdb-head.orig/gdb/m68hc11-tdep.c
+++ gdb-head/gdb/m68hc11-tdep.c
@@ -284,6 +284,8 @@ m68hc11_pseudo_register_read (struct gdb
 			      struct regcache *regcache,
 			      int regno, gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   /* The PC is a pseudo reg only for 68HC12 with the memory bank
      addressing mode.  */
   if (regno == M68HC12_HARD_PC_REGNUM)
@@ -301,7 +303,7 @@ m68hc11_pseudo_register_read (struct gdb
           pc += (page << 14);
           pc += 0x1000000;
         }
-      store_unsigned_integer (buf, regsize, pc);
+      store_unsigned_integer (buf, regsize, byte_order, pc);
       return;
     }
 
@@ -325,6 +327,8 @@ m68hc11_pseudo_register_write (struct gd
 			       struct regcache *regcache,
 			       int regno, const gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   /* The PC is a pseudo reg only for 68HC12 with the memory bank
      addressing mode.  */
   if (regno == M68HC12_HARD_PC_REGNUM)
@@ -334,7 +338,7 @@ m68hc11_pseudo_register_write (struct gd
       CORE_ADDR pc;
 
       memcpy (tmp, buf, regsize);
-      pc = extract_unsigned_integer (tmp, regsize);
+      pc = extract_unsigned_integer (tmp, regsize, byte_order);
       if (pc >= 0x1000000)
         {
           pc -= 0x1000000;
@@ -497,9 +501,11 @@ static struct insn_sequence m6812_prolog
    Returns a pointer to the sequence when it is recognized and
    the optional value (constant/address) associated with it.  */
 static struct insn_sequence *
-m68hc11_analyze_instruction (struct insn_sequence *seq, CORE_ADDR pc,
+m68hc11_analyze_instruction (struct gdbarch *gdbarch,
+			     struct insn_sequence *seq, CORE_ADDR pc,
                              CORE_ADDR *val)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned char buffer[MAX_CODES];
   unsigned bufsize;
   unsigned j;
@@ -515,7 +521,7 @@ m68hc11_analyze_instruction (struct insn
           if (bufsize < j + 1)
             {
               buffer[bufsize] = read_memory_unsigned_integer (pc + bufsize,
-                                                              1);
+                                                              1, byte_order);
               bufsize++;
             }
           /* Continue while we match the opcode.  */
@@ -551,13 +557,13 @@ m68hc11_analyze_instruction (struct insn
                 }
               else if ((buffer[j] & 0xfe) == 0xf0)
                 {
-                  v = read_memory_unsigned_integer (pc + j + 1, 1);
+                  v = read_memory_unsigned_integer (pc + j + 1, 1, byte_order);
                   if (buffer[j] & 1)
                     v |= 0xff00;
                 }
               else if (buffer[j] == 0xf2)
                 {
-                  v = read_memory_unsigned_integer (pc + j + 1, 2);
+                  v = read_memory_unsigned_integer (pc + j + 1, 2, byte_order);
                 }
               cur_val = v;
               break;
@@ -678,7 +684,7 @@ m68hc11_scan_prologue (struct gdbarch *g
       struct insn_sequence *seq;
       CORE_ADDR val;
 
-      seq = m68hc11_analyze_instruction (seq_table, pc, &val);
+      seq = m68hc11_analyze_instruction (gdbarch, seq_table, pc, &val);
       if (seq == 0)
         break;
 
@@ -1158,6 +1164,7 @@ m68hc11_push_dummy_call (struct gdbarch 
                          int nargs, struct value **args, CORE_ADDR sp,
                          int struct_return, CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int argnum;
   int first_stack_argnum;
   struct type *type;
@@ -1180,7 +1187,8 @@ m68hc11_push_dummy_call (struct gdbarch 
         {
           ULONGEST v;
 
-          v = extract_unsigned_integer (value_contents (args[0]), len);
+          v = extract_unsigned_integer (value_contents (args[0]),
+					len, byte_order);
           first_stack_argnum = 1;
 
           regcache_cooked_write_unsigned (regcache, HARD_D_REGNUM, v);
@@ -1211,7 +1219,7 @@ m68hc11_push_dummy_call (struct gdbarch 
 
   /* Store return address.  */
   sp -= 2;
-  store_unsigned_integer (buf, 2, bp_addr);
+  store_unsigned_integer (buf, 2, byte_order, bp_addr);
   write_memory (sp, buf, 2);
 
   /* Finally, update the stack pointer...  */
Index: gdb-head/gdb/m68klinux-tdep.c
===================================================================
--- gdb-head.orig/gdb/m68klinux-tdep.c
+++ gdb-head/gdb/m68klinux-tdep.c
@@ -65,6 +65,8 @@
 static int
 m68k_linux_pc_in_sigtramp (struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR sp;
   gdb_byte buf[12];
   unsigned long insn0, insn1, insn2;
@@ -72,14 +74,14 @@ m68k_linux_pc_in_sigtramp (struct frame_
 
   if (!safe_frame_unwind_memory (this_frame, pc - 4, buf, sizeof (buf)))
     return 0;
-  insn1 = extract_unsigned_integer (buf + 4, 4);
-  insn2 = extract_unsigned_integer (buf + 8, 4);
+  insn1 = extract_unsigned_integer (buf + 4, 4, byte_order);
+  insn2 = extract_unsigned_integer (buf + 8, 4, byte_order);
   if (IS_SIGTRAMP (insn1, insn2))
     return 1;
   if (IS_RT_SIGTRAMP (insn1, insn2))
     return 2;
 
-  insn0 = extract_unsigned_integer (buf, 4);
+  insn0 = extract_unsigned_integer (buf, 4, byte_order);
   if (IS_SIGTRAMP (insn0, insn1))
     return 1;
   if (IS_RT_SIGTRAMP (insn0, insn1))
@@ -222,6 +224,8 @@ m68k_linux_inferior_created (struct targ
 static struct m68k_linux_sigtramp_info
 m68k_linux_get_sigtramp_info (struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR sp;
   struct m68k_linux_sigtramp_info info;
 
@@ -239,7 +243,7 @@ m68k_linux_get_sigtramp_info (struct fra
   sp = get_frame_register_unsigned (this_frame, M68K_SP_REGNUM);
 
   /* Get sigcontext address, it is the third parameter on the stack.  */
-  info.sigcontext_addr = read_memory_unsigned_integer (sp + 8, 4);
+  info.sigcontext_addr = read_memory_unsigned_integer (sp + 8, 4, byte_order);
 
   if (m68k_linux_pc_in_sigtramp (this_frame) == 2)
     info.sc_reg_offset = m68k_linux_ucontext_reg_offset;
@@ -258,7 +262,9 @@ m68k_linux_sigtramp_frame_cache (struct 
 {
   struct frame_id this_id;
   struct trad_frame_cache *cache;
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct m68k_linux_sigtramp_info info;
   gdb_byte buf[4];
   int i;
@@ -274,8 +280,8 @@ m68k_linux_sigtramp_frame_cache (struct 
      trampoline.  */
   get_frame_register (this_frame, M68K_SP_REGNUM, buf);
   /* See the end of m68k_push_dummy_call.  */
-  this_id = frame_id_build (extract_unsigned_integer (buf, 4) - 4 + 8,
-			    get_frame_pc (this_frame));
+  this_id = frame_id_build (extract_unsigned_integer (buf, 4, byte_order)
+			    - 4 + 8, get_frame_pc (this_frame));
   trad_frame_set_id (cache, this_id);
 
   info = m68k_linux_get_sigtramp_info (this_frame);
Index: gdb-head/gdb/m68k-tdep.c
===================================================================
--- gdb-head.orig/gdb/m68k-tdep.c
+++ gdb-head/gdb/m68k-tdep.c
@@ -495,6 +495,7 @@ m68k_push_dummy_call (struct gdbarch *gd
 		      CORE_ADDR struct_addr)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[4];
   int i;
 
@@ -522,17 +523,17 @@ m68k_push_dummy_call (struct gdbarch *gd
   /* Store struct value address.  */
   if (struct_return)
     {
-      store_unsigned_integer (buf, 4, struct_addr);
+      store_unsigned_integer (buf, 4, byte_order, struct_addr);
       regcache_cooked_write (regcache, tdep->struct_value_regnum, buf);
     }
 
   /* Store return address.  */
   sp -= 4;
-  store_unsigned_integer (buf, 4, bp_addr);
+  store_unsigned_integer (buf, 4, byte_order, bp_addr);
   write_memory (sp, buf, 4);
 
   /* Finally, update the stack pointer...  */
-  store_unsigned_integer (buf, 4, sp);
+  store_unsigned_integer (buf, 4, byte_order, sp);
   regcache_cooked_write (regcache, M68K_SP_REGNUM, buf);
 
   /* ...and fake a frame pointer.  */
@@ -613,15 +614,17 @@ m68k_alloc_frame_cache (void)
    Otherwise, return PC.  */
 
 static CORE_ADDR
-m68k_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR current_pc,
+m68k_analyze_frame_setup (struct gdbarch *gdbarch,
+			  CORE_ADDR pc, CORE_ADDR current_pc,
 			  struct m68k_frame_cache *cache)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int op;
 
   if (pc >= current_pc)
     return current_pc;
 
-  op = read_memory_unsigned_integer (pc, 2);
+  op = read_memory_unsigned_integer (pc, 2, byte_order);
 
   if (op == P_LINKW_FP || op == P_LINKL_FP || op == P_PEA_FP)
     {
@@ -631,14 +634,14 @@ m68k_analyze_frame_setup (CORE_ADDR pc, 
 	{
 	  /* link.w %fp, #-N */
 	  /* link.w %fp, #0; adda.l #-N, %sp */
-	  cache->locals = -read_memory_integer (pc + 2, 2);
+	  cache->locals = -read_memory_integer (pc + 2, 2, byte_order);
 
 	  if (pc + 4 < current_pc && cache->locals == 0)
 	    {
-	      op = read_memory_unsigned_integer (pc + 4, 2);
+	      op = read_memory_unsigned_integer (pc + 4, 2, byte_order);
 	      if (op == P_ADDAL_SP)
 		{
-		  cache->locals = read_memory_integer (pc + 6, 4);
+		  cache->locals = read_memory_integer (pc + 6, 4, byte_order);
 		  return pc + 10;
 		}
 	    }
@@ -648,7 +651,7 @@ m68k_analyze_frame_setup (CORE_ADDR pc, 
       else if (op == P_LINKL_FP)
 	{
 	  /* link.l %fp, #-N */
-	  cache->locals = -read_memory_integer (pc + 2, 4);
+	  cache->locals = -read_memory_integer (pc + 2, 4, byte_order);
 	  return pc + 6;
 	}
       else
@@ -658,7 +661,7 @@ m68k_analyze_frame_setup (CORE_ADDR pc, 
 
 	  if (pc + 2 < current_pc)
 	    {
-	      op = read_memory_unsigned_integer (pc + 2, 2);
+	      op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
 
 	      if (op == P_MOVEAL_SP_FP)
 		{
@@ -677,7 +680,7 @@ m68k_analyze_frame_setup (CORE_ADDR pc, 
       cache->locals = (op & 07000) == 0 ? 8 : (op & 07000) >> 9;
       if (pc + 2 < current_pc)
 	{
-	  op = read_memory_unsigned_integer (pc + 2, 2);
+	  op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
 	  if ((op & 0170777) == P_SUBQW_SP || (op & 0170777) == P_SUBQL_SP)
 	    {
 	      cache->locals += (op & 07000) == 0 ? 8 : (op & 07000) >> 9;
@@ -690,13 +693,13 @@ m68k_analyze_frame_setup (CORE_ADDR pc, 
     {
       /* adda.w #-N,%sp */
       /* lea (-N,%sp),%sp */
-      cache->locals = -read_memory_integer (pc + 2, 2);
+      cache->locals = -read_memory_integer (pc + 2, 2, byte_order);
       return pc + 4;
     }
   else if (op == P_ADDAL_SP)
     {
       /* adda.l #-N,%sp */
-      cache->locals = -read_memory_integer (pc + 2, 4);
+      cache->locals = -read_memory_integer (pc + 2, 4, byte_order);
       return pc + 6;
     }
 
@@ -713,6 +716,8 @@ m68k_analyze_register_saves (struct gdba
 			     CORE_ADDR current_pc,
 			     struct m68k_frame_cache *cache)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   if (cache->locals >= 0)
     {
       CORE_ADDR offset;
@@ -722,12 +727,12 @@ m68k_analyze_register_saves (struct gdba
       offset = -4 - cache->locals;
       while (pc < current_pc)
 	{
-	  op = read_memory_unsigned_integer (pc, 2);
+	  op = read_memory_unsigned_integer (pc, 2, byte_order);
 	  if (op == P_FMOVEMX_SP
 	      && gdbarch_tdep (gdbarch)->fpregs_present)
 	    {
 	      /* fmovem.x REGS,-(%sp) */
-	      op = read_memory_unsigned_integer (pc + 2, 2);
+	      op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
 	      if ((op & 0xff00) == 0xe000)
 		{
 		  mask = op & 0xff;
@@ -755,7 +760,7 @@ m68k_analyze_register_saves (struct gdba
 	  else if (op == P_MOVEML_SP)
 	    {
 	      /* movem.l REGS,-(%sp) */
-	      mask = read_memory_unsigned_integer (pc + 2, 2);
+	      mask = read_memory_unsigned_integer (pc + 2, 2, byte_order);
 	      for (i = 0; i < 16; i++, mask >>= 1)
 		{
 		  if (mask & 1)
@@ -811,15 +816,16 @@ static CORE_ADDR
 m68k_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
 		       CORE_ADDR current_pc, struct m68k_frame_cache *cache)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned int op;
 
-  pc = m68k_analyze_frame_setup (pc, current_pc, cache);
+  pc = m68k_analyze_frame_setup (gdbarch, pc, current_pc, cache);
   pc = m68k_analyze_register_saves (gdbarch, pc, current_pc, cache);
   if (pc >= current_pc)
     return current_pc;
 
   /* Check for GOT setup.  */
-  op = read_memory_unsigned_integer (pc, 4);
+  op = read_memory_unsigned_integer (pc, 4, byte_order);
   if (op == P_LEA_PC_A5)
     {
       /* lea (%pc,N),%a5 */
@@ -859,6 +865,8 @@ m68k_unwind_pc (struct gdbarch *gdbarch,
 static struct m68k_frame_cache *
 m68k_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct m68k_frame_cache *cache;
   gdb_byte buf[4];
   int i;
@@ -879,7 +887,7 @@ m68k_frame_cache (struct frame_info *thi
      in progress when the signal occurred.  */
 
   get_frame_register (this_frame, M68K_FP_REGNUM, buf);
-  cache->base = extract_unsigned_integer (buf, 4);
+  cache->base = extract_unsigned_integer (buf, 4, byte_order);
   if (cache->base == 0)
     return cache;
 
@@ -902,7 +910,8 @@ m68k_frame_cache (struct frame_info *thi
 	 functions this might work too.  */
 
       get_frame_register (this_frame, M68K_SP_REGNUM, buf);
-      cache->base = extract_unsigned_integer (buf, 4) + cache->sp_offset;
+      cache->base = extract_unsigned_integer (buf, 4, byte_order)
+		    + cache->sp_offset;
     }
 
   /* Now that we have the base address for the stack frame we can
@@ -998,7 +1007,8 @@ m68k_get_longjmp_target (struct frame_in
   gdb_byte *buf;
   CORE_ADDR sp, jb_addr;
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   if (tdep->jb_pc < 0)
     {
@@ -1015,14 +1025,15 @@ m68k_get_longjmp_target (struct frame_in
     return 0;
 
   jb_addr = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch)
-					     / TARGET_CHAR_BIT);
+					     / TARGET_CHAR_BIT, byte_order);
 
   if (target_read_memory (jb_addr + tdep->jb_pc * tdep->jb_elt_size, buf,
-			  gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT))
+			  gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT),
+			  byte_order)
     return 0;
 
   *pc = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch)
-					 / TARGET_CHAR_BIT);
+					 / TARGET_CHAR_BIT, byte_order);
   return 1;
 }
 
Index: gdb-head/gdb/m88k-tdep.c
===================================================================
--- gdb-head.orig/gdb/m88k-tdep.c
+++ gdb-head/gdb/m88k-tdep.c
@@ -39,9 +39,9 @@
 /* Fetch the instruction at PC.  */
 
 static unsigned long
-m88k_fetch_instruction (CORE_ADDR pc)
+m88k_fetch_instruction (CORE_ADDR pc, enum bfd_endian byte_order)
 {
-  return read_memory_unsigned_integer (pc, 4);
+  return read_memory_unsigned_integer (pc, 4, byte_order);
 }
 
 /* Register information.  */
@@ -526,9 +526,11 @@ struct m88k_prologue_insn m88k_prologue_
    prologue.  */
 
 static CORE_ADDR
-m88k_analyze_prologue (CORE_ADDR pc, CORE_ADDR limit,
+m88k_analyze_prologue (struct gdbarch *gdbarch,
+		       CORE_ADDR pc, CORE_ADDR limit,
 		       struct m88k_frame_cache *cache)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR end = limit;
 
   /* Provide a dummy cache if necessary.  */
@@ -548,7 +550,7 @@ m88k_analyze_prologue (CORE_ADDR pc, COR
   while (pc < limit)
     {
       struct m88k_prologue_insn *pi = m88k_prologue_insn_table;
-      unsigned long insn = m88k_fetch_instruction (pc);
+      unsigned long insn = m88k_fetch_instruction (pc, byte_order);
 
       while ((insn & pi->mask) != pi->insn)
 	pi++;
@@ -643,12 +645,14 @@ m88k_skip_prologue (struct gdbarch *gdba
 	return sal.end;
     }
 
-  return m88k_analyze_prologue (pc, pc + m88k_max_prologue_size, NULL);
+  return m88k_analyze_prologue (gdbarch, pc, pc + m88k_max_prologue_size,
+				NULL);
 }
 
 static struct m88k_frame_cache *
 m88k_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct m88k_frame_cache *cache;
   CORE_ADDR frame_sp;
 
@@ -661,7 +665,8 @@ m88k_frame_cache (struct frame_info *thi
 
   cache->pc = get_frame_func (this_frame);
   if (cache->pc != 0)
-    m88k_analyze_prologue (cache->pc, get_frame_pc (this_frame), cache);
+    m88k_analyze_prologue (gdbarch, cache->pc, get_frame_pc (this_frame),
+			   cache);
 
   /* Calculate the stack pointer used in the prologue.  */
   if (cache->fp_offset != -1)
Index: gdb-head/gdb/mep-tdep.c
===================================================================
--- gdb-head.orig/gdb/mep-tdep.c
+++ gdb-head/gdb/mep-tdep.c
@@ -1139,6 +1139,7 @@ mep_pseudo_cr32_read (struct gdbarch *gd
                       int cookednum,
                       void *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   /* Read the raw register into a 64-bit buffer, and then return the
      appropriate end of that buffer.  */
   int rawnum = mep_pseudo_to_raw[cookednum];
@@ -1148,7 +1149,8 @@ mep_pseudo_cr32_read (struct gdbarch *gd
   gdb_assert (TYPE_LENGTH (register_type (gdbarch, cookednum)) == 4);
   regcache_raw_read (regcache, rawnum, buf64);
   /* Slow, but legible.  */
-  store_unsigned_integer (buf, 4, extract_unsigned_integer (buf64, 8));
+  store_unsigned_integer (buf, 4, byte_order,
+			  extract_unsigned_integer (buf64, 8, byte_order));
 }
 
 
@@ -1188,6 +1190,7 @@ mep_pseudo_csr_write (struct gdbarch *gd
                       int cookednum,
                       const void *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int size = register_size (gdbarch, cookednum);
   struct mep_csr_register *r
     = &mep_csr_registers[cookednum - MEP_FIRST_CSR_REGNUM];
@@ -1204,7 +1207,7 @@ mep_pseudo_csr_write (struct gdbarch *gd
       ULONGEST mixed_bits;
           
       regcache_raw_read_unsigned (regcache, r->raw, &old_bits);
-      new_bits = extract_unsigned_integer (buf, size);
+      new_bits = extract_unsigned_integer (buf, size, byte_order);
       mixed_bits = ((r->writeable_bits & new_bits)
                     | (~r->writeable_bits & old_bits));
       regcache_raw_write_unsigned (regcache, r->raw, mixed_bits);
@@ -1218,6 +1221,7 @@ mep_pseudo_cr32_write (struct gdbarch *g
                        int cookednum,
                        const void *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   /* Expand the 32-bit value into a 64-bit value, and write that to
      the pseudoregister.  */
   int rawnum = mep_pseudo_to_raw[cookednum];
@@ -1226,7 +1230,8 @@ mep_pseudo_cr32_write (struct gdbarch *g
   gdb_assert (TYPE_LENGTH (register_type (gdbarch, rawnum)) == sizeof (buf64));
   gdb_assert (TYPE_LENGTH (register_type (gdbarch, cookednum)) == 4);
   /* Slow, but legible.  */
-  store_unsigned_integer (buf64, 8, extract_unsigned_integer (buf, 4));
+  store_unsigned_integer (buf64, 8, byte_order,
+			  extract_unsigned_integer (buf, 4, byte_order));
   regcache_raw_write (regcache, rawnum, buf64);
 }
 
@@ -1415,8 +1420,9 @@ mep_pc_in_vliw_section (CORE_ADDR pc)
    anyway.  */
 
 static CORE_ADDR 
-mep_get_insn (CORE_ADDR pc, long *insn)
+mep_get_insn (struct gdbarch *gdbarch, CORE_ADDR pc, long *insn)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int pc_in_vliw_section;
   int vliw_mode;
   int insn_len;
@@ -1453,7 +1459,7 @@ mep_get_insn (CORE_ADDR pc, long *insn)
     vliw_mode = 0;
 
   read_memory (pc, buf, sizeof (buf));
-  *insn = extract_unsigned_integer (buf, 2) << 16;
+  *insn = extract_unsigned_integer (buf, 2, byte_order) << 16;
 
   /* The major opcode --- the top four bits of the first 16-bit
      part --- indicates whether this instruction is 16 or 32 bits
@@ -1463,7 +1469,7 @@ mep_get_insn (CORE_ADDR pc, long *insn)
     {
       /* Fetch the second 16-bit part of the instruction.  */
       read_memory (pc + 2, buf, sizeof (buf));
-      *insn = *insn | extract_unsigned_integer (buf, 2);
+      *insn = *insn | extract_unsigned_integer (buf, 2, byte_order);
     }
 
   /* If we're in VLIW code, then the VLIW width determines the address
@@ -1700,7 +1706,7 @@ mep_analyze_prologue (struct gdbarch *gd
       CORE_ADDR next_pc;
       pv_t pre_insn_fp, pre_insn_sp;
 
-      next_pc = mep_get_insn (pc, &insn);
+      next_pc = mep_get_insn (gdbarch, pc, &insn);
 
       /* A zero return from mep_get_insn means that either we weren't
          able to read the instruction from memory, or that we don't
@@ -2294,6 +2300,7 @@ mep_push_dummy_call (struct gdbarch *gdb
                      int struct_return,
                      CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR *copy = (CORE_ADDR *) alloca (argc * sizeof (copy[0]));
   CORE_ADDR func_addr = find_function_addr (function, NULL);
   int i;
@@ -2334,7 +2341,8 @@ mep_push_dummy_call (struct gdbarch *gdb
       /* Arguments that fit in a GPR get expanded to fill the GPR.  */
       if (arg_size <= MEP_GPR_SIZE)
         value = extract_unsigned_integer (value_contents (argv[i]),
-                                          TYPE_LENGTH (value_type (argv[i])));
+                                          TYPE_LENGTH (value_type (argv[i])),
+					  byte_order);
 
       /* Arguments too large to fit in a GPR get copied to the stack,
          and we pass a pointer to the copy.  */
@@ -2350,7 +2358,7 @@ mep_push_dummy_call (struct gdbarch *gdb
       else
         {
           char buf[MEP_GPR_SIZE];
-          store_unsigned_integer (buf, MEP_GPR_SIZE, value);
+          store_unsigned_integer (buf, MEP_GPR_SIZE, byte_order, value);
           write_memory (arg_stack, buf, MEP_GPR_SIZE);
           arg_stack += MEP_GPR_SIZE;
         }

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]