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 2


(second part of the version I checked in -- split off due to mailing list
size limits)

Index: gdb-head/gdb/mi/mi-main.c
===================================================================
--- gdb-head.orig/gdb/mi/mi-main.c
+++ gdb-head/gdb/mi/mi-main.c
@@ -1030,6 +1030,8 @@ mi_cmd_data_read_memory (char *command, 
 void
 mi_cmd_data_write_memory (char *command, char **argv, int argc)
 {
+  struct gdbarch *gdbarch = get_current_arch ();
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR addr;
   char word_format;
   long word_size;
@@ -1087,7 +1089,7 @@ mi_cmd_data_write_memory (char *command,
   /* Get the value into an array.  */
   buffer = xmalloc (word_size);
   old_chain = make_cleanup (xfree, buffer);
-  store_signed_integer (buffer, word_size, value);
+  store_signed_integer (buffer, word_size, byte_order, value);
   /* Write it down to memory.  */
   write_memory (addr, buffer, word_size);
   /* Free the buffer.  */
Index: gdb-head/gdb/mips-linux-tdep.c
===================================================================
--- gdb-head.orig/gdb/mips-linux-tdep.c
+++ gdb-head/gdb/mips-linux-tdep.c
@@ -55,6 +55,7 @@ mips_linux_get_longjmp_target (struct fr
 {
   CORE_ADDR jb_addr;
   struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   char buf[gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT];
 
   jb_addr = get_frame_register_unsigned (frame, MIPS_A0_REGNUM);
@@ -65,7 +66,8 @@ mips_linux_get_longjmp_target (struct fr
     return 0;
 
   *pc = extract_unsigned_integer (buf,
-				  gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
+				  gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT,
+				  byte_order);
 
   return 1;
 }
@@ -77,10 +79,11 @@ mips_linux_get_longjmp_target (struct fr
 static void
 supply_32bit_reg (struct regcache *regcache, int regnum, const void *addr)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[MAX_REGISTER_SIZE];
-  store_signed_integer (buf,
-			register_size (get_regcache_arch (regcache), regnum),
-                        extract_signed_integer (addr, 4));
+  store_signed_integer (buf, register_size (gdbarch, regnum), byte_order,
+                        extract_signed_integer (addr, 4, byte_order));
   regcache_raw_supply (regcache, regnum, buf);
 }
 
@@ -258,6 +261,7 @@ mips64_linux_get_longjmp_target (struct 
 {
   CORE_ADDR jb_addr;
   struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   void *buf = alloca (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
   int element_size = gdbarch_ptr_bit (gdbarch) == 32 ? 4 : 8;
 
@@ -269,7 +273,8 @@ mips64_linux_get_longjmp_target (struct 
     return 0;
 
   *pc = extract_unsigned_integer (buf,
-				  gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
+				  gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT,
+				  byte_order);
 
   return 1;
 }
@@ -343,6 +348,7 @@ mips64_fill_gregset (const struct regcac
 		     mips64_elf_gregset_t *gregsetp, int regno)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int regaddr, regi;
   mips64_elf_greg_t *regp = *gregsetp;
   void *dst;
@@ -388,9 +394,10 @@ mips64_fill_gregset (const struct regcac
       LONGEST val;
 
       regcache_raw_collect (regcache, regno, buf);
-      val = extract_signed_integer (buf, register_size (gdbarch, regno));
+      val = extract_signed_integer (buf, register_size (gdbarch, regno),
+				    byte_order);
       dst = regp + regaddr;
-      store_signed_integer (dst, 8, val);
+      store_signed_integer (dst, 8, byte_order, val);
     }
 }
 
@@ -440,6 +447,7 @@ mips64_fill_fpregset (const struct regca
 		      mips64_elf_fpregset_t *fpregsetp, int regno)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte *to;
 
   if ((regno >= gdbarch_fp0_regnum (gdbarch))
@@ -468,9 +476,10 @@ mips64_fill_fpregset (const struct regca
       LONGEST val;
 
       regcache_raw_collect (regcache, regno, buf);
-      val = extract_signed_integer (buf, register_size (gdbarch, regno));
+      val = extract_signed_integer (buf, register_size (gdbarch, regno),
+				    byte_order);
       to = (gdb_byte *) (*fpregsetp + 32);
-      store_signed_integer (to, 4, val);
+      store_signed_integer (to, 4, byte_order, val);
     }
   else if (regno == mips_regnum (gdbarch)->fp_implementation_revision)
     {
@@ -478,9 +487,10 @@ mips64_fill_fpregset (const struct regca
       LONGEST val;
 
       regcache_raw_collect (regcache, regno, buf);
-      val = extract_signed_integer (buf, register_size (gdbarch, regno));
+      val = extract_signed_integer (buf, register_size (gdbarch, regno),
+				    byte_order);
       to = (gdb_byte *) (*fpregsetp + 32) + 4;
-      store_signed_integer (to, 4, val);
+      store_signed_integer (to, 4, byte_order, val);
     }
   else if (regno == -1)
     {
@@ -605,6 +615,7 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc,
   unsigned char buf[28], *p;
   ULONGEST insn, insn1;
   int n64 = (mips_abi (target_gdbarch) == MIPS_ABI_N64);
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
 
   read_memory (pc - 12, buf, 28);
 
@@ -622,7 +633,7 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc,
   p = buf + 12;
   while (p >= buf)
     {
-      insn = extract_unsigned_integer (p, 4);
+      insn = extract_unsigned_integer (p, 4, byte_order);
       if (insn == insn1)
 	break;
       p -= 4;
@@ -630,7 +641,7 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc,
   if (p < buf)
     return 0;
 
-  insn = extract_unsigned_integer (p + 4, 4);
+  insn = extract_unsigned_integer (p + 4, 4, byte_order);
   if (n64)
     {
       /* daddu t7,ra */
@@ -644,12 +655,12 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc,
 	return 0;
     }
 
-  insn = extract_unsigned_integer (p + 8, 4);
+  insn = extract_unsigned_integer (p + 8, 4, byte_order);
   /* jalr t9,ra */
   if (insn != 0x0320f809)
     return 0;
 
-  insn = extract_unsigned_integer (p + 12, 4);
+  insn = extract_unsigned_integer (p + 12, 4, byte_order);
   if (n64)
     {
       /* daddiu t8,zero,0 */
Index: gdb-head/gdb/mipsnbsd-tdep.c
===================================================================
--- gdb-head.orig/gdb/mipsnbsd-tdep.c
+++ gdb-head/gdb/mipsnbsd-tdep.c
@@ -294,6 +294,7 @@ static int
 mipsnbsd_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR jb_addr;
   char *buf;
 
@@ -305,8 +306,8 @@ mipsnbsd_get_longjmp_target (struct fram
   			  NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch)))
     return 0;
 
-  *pc = extract_unsigned_integer (buf, NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch));
-
+  *pc = extract_unsigned_integer (buf, NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch),
+				  byte_order);
   return 1;
 }
 
Index: gdb-head/gdb/mips-tdep.c
===================================================================
--- gdb-head.orig/gdb/mips-tdep.c
+++ gdb-head/gdb/mips-tdep.c
@@ -880,8 +880,9 @@ mips_write_pc (struct regcache *regcache
    is odd, assume it's a MIPS16 instruction; otherwise MIPS32.  */
 
 static ULONGEST
-mips_fetch_instruction (CORE_ADDR addr)
+mips_fetch_instruction (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[MIPS_INSN32_SIZE];
   int instlen;
   int status;
@@ -896,7 +897,7 @@ mips_fetch_instruction (CORE_ADDR addr)
   status = target_read_memory (addr, buf, instlen);
   if (status)
     memory_error (status, addr);
-  return extract_unsigned_integer (buf, instlen);
+  return extract_unsigned_integer (buf, instlen, byte_order);
 }
 
 /* These the fields of 32 bit mips instructions */
@@ -927,9 +928,10 @@ mips32_relative_offset (ULONGEST inst)
 static CORE_ADDR
 mips32_next_pc (struct frame_info *frame, CORE_ADDR pc)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
   unsigned long inst;
   int op;
-  inst = mips_fetch_instruction (pc);
+  inst = mips_fetch_instruction (gdbarch, pc);
   if ((inst & 0xe0000000) != 0)	/* Not a special, jump or branch instruction */
     {
       if (itype_op (inst) >> 2 == 5)
@@ -1151,16 +1153,17 @@ extended_offset (unsigned int extension)
    when the offset is to be used in relative addressing.  */
 
 static unsigned int
-fetch_mips_16 (CORE_ADDR pc)
+fetch_mips_16 (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[8];
   pc &= 0xfffffffe;		/* clear the low order bit */
   target_read_memory (pc, buf, 2);
-  return extract_unsigned_integer (buf, 2);
+  return extract_unsigned_integer (buf, 2, byte_order);
 }
 
 static void
-unpack_mips16 (CORE_ADDR pc,
+unpack_mips16 (struct gdbarch *gdbarch, CORE_ADDR pc,
 	       unsigned int extension,
 	       unsigned int inst,
 	       enum mips16_inst_fmts insn_format, struct upk_mips16 *upk)
@@ -1228,7 +1231,7 @@ unpack_mips16 (CORE_ADDR pc,
 	unsigned int nexthalf;
 	value = ((inst & 0x1f) << 5) | ((inst >> 5) & 0x1f);
 	value = value << 16;
-	nexthalf = mips_fetch_instruction (pc + 2);	/* low bit still set */
+	nexthalf = mips_fetch_instruction (gdbarch, pc + 2);	/* low bit still set */
 	value |= nexthalf;
 	offset = value;
 	regx = -1;
@@ -1254,6 +1257,7 @@ static CORE_ADDR
 extended_mips16_next_pc (struct frame_info *frame, CORE_ADDR pc,
 			 unsigned int extension, unsigned int insn)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
   int op = (insn >> 11);
   switch (op)
     {
@@ -1261,7 +1265,7 @@ extended_mips16_next_pc (struct frame_in
       {
 	CORE_ADDR offset;
 	struct upk_mips16 upk;
-	unpack_mips16 (pc, extension, insn, itype, &upk);
+	unpack_mips16 (gdbarch, pc, extension, insn, itype, &upk);
 	offset = upk.offset;
 	if (offset & 0x800)
 	  {
@@ -1274,7 +1278,7 @@ extended_mips16_next_pc (struct frame_in
     case 3:			/* JAL , JALX - Watch out, these are 32 bit instruction */
       {
 	struct upk_mips16 upk;
-	unpack_mips16 (pc, extension, insn, jalxtype, &upk);
+	unpack_mips16 (gdbarch, pc, extension, insn, jalxtype, &upk);
 	pc = add_offset_16 (pc, upk.offset);
 	if ((insn >> 10) & 0x01)	/* Exchange mode */
 	  pc = pc & ~0x01;	/* Clear low bit, indicate 32 bit mode */
@@ -1286,7 +1290,7 @@ extended_mips16_next_pc (struct frame_in
       {
 	struct upk_mips16 upk;
 	int reg;
-	unpack_mips16 (pc, extension, insn, ritype, &upk);
+	unpack_mips16 (gdbarch, pc, extension, insn, ritype, &upk);
 	reg = get_frame_register_signed (frame, upk.regx);
 	if (reg == 0)
 	  pc += (upk.offset << 1) + 2;
@@ -1298,7 +1302,7 @@ extended_mips16_next_pc (struct frame_in
       {
 	struct upk_mips16 upk;
 	int reg;
-	unpack_mips16 (pc, extension, insn, ritype, &upk);
+	unpack_mips16 (gdbarch, pc, extension, insn, ritype, &upk);
 	reg = get_frame_register_signed (frame, upk.regx);
 	if (reg != 0)
 	  pc += (upk.offset << 1) + 2;
@@ -1310,7 +1314,7 @@ extended_mips16_next_pc (struct frame_in
       {
 	struct upk_mips16 upk;
 	int reg;
-	unpack_mips16 (pc, extension, insn, i8type, &upk);
+	unpack_mips16 (gdbarch, pc, extension, insn, i8type, &upk);
 	/* upk.regx contains the opcode */
 	reg = get_frame_register_signed (frame, 24);  /* Test register is 24 */
 	if (((upk.regx == 0) && (reg == 0))	/* BTEZ */
@@ -1358,7 +1362,8 @@ extended_mips16_next_pc (struct frame_in
          that. */
       {
 	pc += 2;
-	pc = extended_mips16_next_pc (frame, pc, insn, fetch_mips_16 (pc));
+	pc = extended_mips16_next_pc (frame, pc, insn,
+				      fetch_mips_16 (gdbarch, pc));
 	break;
       }
     default:
@@ -1373,7 +1378,8 @@ extended_mips16_next_pc (struct frame_in
 static CORE_ADDR
 mips16_next_pc (struct frame_info *frame, CORE_ADDR pc)
 {
-  unsigned int insn = fetch_mips_16 (pc);
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  unsigned int insn = fetch_mips_16 (gdbarch, pc);
   return extended_mips16_next_pc (frame, pc, 0, insn);
 }
 
@@ -1463,7 +1469,8 @@ mips16_get_imm (unsigned short prev_inst
    Return the address of the first instruction past the prologue.  */
 
 static CORE_ADDR
-mips16_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
+mips16_scan_prologue (struct gdbarch *gdbarch,
+		      CORE_ADDR start_pc, CORE_ADDR limit_pc,
                       struct frame_info *this_frame,
                       struct mips_frame_cache *this_cache)
 {
@@ -1482,7 +1489,6 @@ mips16_scan_prologue (CORE_ADDR start_pc
   int extend_bytes = 0;
   int prev_extend_bytes;
   CORE_ADDR end_prologue_addr = 0;
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
 
   /* Can be called when there's no process, and hence when there's no
      THIS_FRAME.  */
@@ -1503,7 +1509,7 @@ mips16_scan_prologue (CORE_ADDR start_pc
       prev_inst = inst;
 
       /* Fetch and decode the instruction.   */
-      inst = (unsigned short) mips_fetch_instruction (cur_pc);
+      inst = (unsigned short) mips_fetch_instruction (gdbarch, cur_pc);
 
       /* Normally we ignore extend instructions.  However, if it is
          not followed by a valid prologue instruction, then this
@@ -1769,6 +1775,7 @@ mips16_scan_prologue (CORE_ADDR start_pc
 static struct mips_frame_cache *
 mips_insn16_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct mips_frame_cache *cache;
 
   if ((*this_cache) != NULL)
@@ -1784,19 +1791,18 @@ mips_insn16_frame_cache (struct frame_in
 
     find_pc_partial_function (pc, NULL, &start_addr, NULL);
     if (start_addr == 0)
-      start_addr = heuristic_proc_start (get_frame_arch (this_frame), pc);
+      start_addr = heuristic_proc_start (gdbarch, pc);
     /* We can't analyze the prologue if we couldn't find the begining
        of the function.  */
     if (start_addr == 0)
       return cache;
 
-    mips16_scan_prologue (start_addr, pc, this_frame, *this_cache);
+    mips16_scan_prologue (gdbarch, start_addr, pc, this_frame, *this_cache);
   }
   
   /* gdbarch_sp_regnum contains the value and not the address.  */
   trad_frame_set_value (cache->saved_regs,
-			gdbarch_num_regs (get_frame_arch (this_frame))
-			+ MIPS_SP_REGNUM,
+			gdbarch_num_regs (gdbarch) + MIPS_SP_REGNUM,
 			cache->base);
 
   return (*this_cache);
@@ -1891,7 +1897,8 @@ reset_saved_regs (struct gdbarch *gdbarc
    Return the address of the first instruction past the prologue.  */
 
 static CORE_ADDR
-mips32_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
+mips32_scan_prologue (struct gdbarch *gdbarch,
+		      CORE_ADDR start_pc, CORE_ADDR limit_pc,
                       struct frame_info *this_frame,
                       struct mips_frame_cache *this_cache)
 {
@@ -1905,7 +1912,6 @@ mips32_scan_prologue (CORE_ADDR start_pc
   int seen_sp_adjust = 0;
   int load_immediate_bytes = 0;
   int in_delay_slot = 0;
-  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   int regsize_is_64_bits = (mips_abi_regsize (gdbarch) == 8);
 
   /* Can be called when there's no process, and hence when there's no
@@ -1929,7 +1935,7 @@ restart:
       int reg;
 
       /* Fetch the instruction.   */
-      inst = (unsigned long) mips_fetch_instruction (cur_pc);
+      inst = (unsigned long) mips_fetch_instruction (gdbarch, cur_pc);
 
       /* Save some code by pre-extracting some useful fields.  */
       high_word = (inst >> 16) & 0xffff;
@@ -2117,6 +2123,7 @@ restart:
 static struct mips_frame_cache *
 mips_insn32_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct mips_frame_cache *cache;
 
   if ((*this_cache) != NULL)
@@ -2133,19 +2140,18 @@ mips_insn32_frame_cache (struct frame_in
 
     find_pc_partial_function (pc, NULL, &start_addr, NULL);
     if (start_addr == 0)
-      start_addr = heuristic_proc_start (get_frame_arch (this_frame), pc);
+      start_addr = heuristic_proc_start (gdbarch, pc);
     /* We can't analyze the prologue if we couldn't find the begining
        of the function.  */
     if (start_addr == 0)
       return cache;
 
-    mips32_scan_prologue (start_addr, pc, this_frame, *this_cache);
+    mips32_scan_prologue (gdbarch, start_addr, pc, this_frame, *this_cache);
   }
   
   /* gdbarch_sp_regnum contains the value and not the address.  */
   trad_frame_set_value (cache->saved_regs,
-			gdbarch_num_regs (get_frame_arch (this_frame))
-			+ MIPS_SP_REGNUM,
+			gdbarch_num_regs (gdbarch) + MIPS_SP_REGNUM,
 			cache->base);
 
   return (*this_cache);
@@ -2391,7 +2397,7 @@ deal_with_atomic_sequence (struct gdbarc
   if (pc & 0x01)
     return 0;
 
-  insn = mips_fetch_instruction (loc);
+  insn = mips_fetch_instruction (gdbarch, loc);
   /* Assume all atomic sequences start with a ll/lld instruction.  */
   if (itype_op (insn) != LL_OPCODE && itype_op (insn) != LLD_OPCODE)
     return 0;
@@ -2402,7 +2408,7 @@ deal_with_atomic_sequence (struct gdbarc
     {
       int is_branch = 0;
       loc += MIPS_INSN32_SIZE;
-      insn = mips_fetch_instruction (loc);
+      insn = mips_fetch_instruction (gdbarch, loc);
 
       /* Assume that there is at most one branch in the atomic
 	 sequence.  If a branch is found, put a breakpoint in its
@@ -2495,7 +2501,7 @@ mips_software_single_step (struct frame_
    end of a function. */
 
 static int
-mips_about_to_return (CORE_ADDR pc)
+mips_about_to_return (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   if (mips_pc_is_mips16 (pc))
     /* This mips16 case isn't necessarily reliable.  Sometimes the compiler
@@ -2504,9 +2510,9 @@ mips_about_to_return (CORE_ADDR pc)
        as $a3), then a "jr" using that register.  This second case
        is almost impossible to distinguish from an indirect jump
        used for switch statements, so we don't even try.  */
-    return mips_fetch_instruction (pc) == 0xe820;	/* jr $ra */
+    return mips_fetch_instruction (gdbarch, pc) == 0xe820;	/* jr $ra */
   else
-    return mips_fetch_instruction (pc) == 0x3e00008;	/* jr $ra */
+    return mips_fetch_instruction (gdbarch, pc) == 0x3e00008;	/* jr $ra */
 }
 
 
@@ -2589,12 +2595,12 @@ heuristic-fence-post' command.\n",
 	   addiu sp,-n
 	   daddiu sp,-n
 	   extend -n followed by 'addiu sp,+n' or 'daddiu sp,+n'  */
-	inst = mips_fetch_instruction (start_pc);
+	inst = mips_fetch_instruction (gdbarch, start_pc);
 	if ((inst & 0xff80) == 0x6480)		/* save */
 	  {
 	    if (start_pc - instlen >= fence)
 	      {
-		inst = mips_fetch_instruction (start_pc - instlen);
+		inst = mips_fetch_instruction (gdbarch, start_pc - instlen);
 		if ((inst & 0xf800) == 0xf000)	/* extend */
 		  start_pc -= instlen;
 	      }
@@ -2612,7 +2618,7 @@ heuristic-fence-post' command.\n",
 	else
 	  seen_adjsp = 0;
       }
-    else if (mips_about_to_return (start_pc))
+    else if (mips_about_to_return (gdbarch, start_pc))
       {
 	/* Skip return and its delay slot.  */
 	start_pc += 2 * MIPS_INSN32_SIZE;
@@ -2697,6 +2703,7 @@ mips_eabi_push_dummy_call (struct gdbarc
   int len = 0;
   int stack_offset = 0;
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR func_addr = find_function_addr (function, NULL);
   int regsize = mips_abi_regsize (gdbarch);
 
@@ -2765,7 +2772,8 @@ mips_eabi_push_dummy_call (struct gdbarc
       if (len > regsize
 	  && (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION))
 	{
-	  store_unsigned_integer (valbuf, regsize, value_address (arg));
+	  store_unsigned_integer (valbuf, regsize, byte_order,
+				  value_address (arg));
 	  typecode = TYPE_CODE_PTR;
 	  len = regsize;
 	  val = valbuf;
@@ -2813,14 +2821,16 @@ mips_eabi_push_dummy_call (struct gdbarc
 	      unsigned long regval;
 
 	      /* Write the low word of the double to the even register(s).  */
-	      regval = extract_unsigned_integer (val + low_offset, 4);
+	      regval = extract_unsigned_integer (val + low_offset,
+						 4, byte_order);
 	      if (mips_debug)
 		fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
 				    float_argreg, phex (regval, 4));
 	      regcache_cooked_write_unsigned (regcache, float_argreg++, regval);
 
 	      /* Write the high word of the double to the odd register(s).  */
-	      regval = extract_unsigned_integer (val + 4 - low_offset, 4);
+	      regval = extract_unsigned_integer (val + 4 - low_offset,
+						 4, byte_order);
 	      if (mips_debug)
 		fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
 				    float_argreg, phex (regval, 4));
@@ -2832,7 +2842,7 @@ mips_eabi_push_dummy_call (struct gdbarc
 	         in a single register.  */
 	      /* On 32 bit ABI's the float_argreg is further adjusted
 	         above to ensure that it is even register aligned.  */
-	      LONGEST regval = extract_unsigned_integer (val, len);
+	      LONGEST regval = extract_unsigned_integer (val, len, byte_order);
 	      if (mips_debug)
 		fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
 				    float_argreg, phex (regval, len));
@@ -2919,7 +2929,7 @@ mips_eabi_push_dummy_call (struct gdbarc
 		  && !fp_register_arg_p (gdbarch, typecode, arg_type))
 		{
 		  LONGEST regval =
-		    extract_unsigned_integer (val, partial_len);
+		    extract_unsigned_integer (val, partial_len, byte_order);
 
 		  if (mips_debug)
 		    fprintf_filtered (gdb_stdlog, " - reg=%d val=%s",
@@ -3084,6 +3094,7 @@ mips_n32n64_push_dummy_call (struct gdba
   int len = 0;
   int stack_offset = 0;
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR func_addr = find_function_addr (function, NULL);
 
   /* For shared libraries, "t9" needs to point at the function
@@ -3161,7 +3172,7 @@ mips_n32n64_push_dummy_call (struct gdba
 	  /* This is a floating point value that fits entirely
 	     in a single register or a pair of registers.  */
 	  int reglen = (len <= MIPS64_REGSIZE ? len : MIPS64_REGSIZE);
-	  LONGEST regval = extract_unsigned_integer (val, reglen);
+	  LONGEST regval = extract_unsigned_integer (val, reglen, byte_order);
 	  if (mips_debug)
 	    fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
 				float_argreg, phex (regval, reglen));
@@ -3175,7 +3186,8 @@ mips_n32n64_push_dummy_call (struct gdba
 	  argreg++;
 	  if (len == 16)
 	    {
-	      regval = extract_unsigned_integer (val + reglen, reglen);
+	      regval = extract_unsigned_integer (val + reglen,
+						 reglen, byte_order);
 	      if (mips_debug)
 		fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
 				    float_argreg, phex (regval, reglen));
@@ -3275,9 +3287,11 @@ mips_n32n64_push_dummy_call (struct gdba
 		      || (partial_len < 4
 			  && typecode == TYPE_CODE_INT
 			  && !TYPE_UNSIGNED (arg_type)))
-		    regval = extract_signed_integer (val, partial_len);
+		    regval = extract_signed_integer (val, partial_len,
+						     byte_order);
 		  else
-		    regval = extract_unsigned_integer (val, partial_len);
+		    regval = extract_unsigned_integer (val, partial_len,
+						       byte_order);
 
 		  /* A non-floating-point argument being passed in a
 		     general register.  If a struct or union, and if
@@ -3522,6 +3536,7 @@ mips_o32_push_dummy_call (struct gdbarch
   int len = 0;
   int stack_offset = 0;
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR func_addr = find_function_addr (function, NULL);
 
   /* For shared libraries, "t9" needs to point at the function
@@ -3624,7 +3639,8 @@ mips_o32_push_dummy_call (struct gdbarch
 	      unsigned long regval;
 
 	      /* Write the low word of the double to the even register(s).  */
-	      regval = extract_unsigned_integer (val + low_offset, 4);
+	      regval = extract_unsigned_integer (val + low_offset,
+						 4, byte_order);
 	      if (mips_debug)
 		fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
 				    float_argreg, phex (regval, 4));
@@ -3635,7 +3651,8 @@ mips_o32_push_dummy_call (struct gdbarch
 	      regcache_cooked_write_unsigned (regcache, argreg++, regval);
 
 	      /* Write the high word of the double to the odd register(s).  */
-	      regval = extract_unsigned_integer (val + 4 - low_offset, 4);
+	      regval = extract_unsigned_integer (val + 4 - low_offset,
+						 4, byte_order);
 	      if (mips_debug)
 		fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
 				    float_argreg, phex (regval, 4));
@@ -3652,7 +3669,7 @@ mips_o32_push_dummy_call (struct gdbarch
 	         in a single register.  */
 	      /* On 32 bit ABI's the float_argreg is further adjusted
 	         above to ensure that it is even register aligned.  */
-	      LONGEST regval = extract_unsigned_integer (val, len);
+	      LONGEST regval = extract_unsigned_integer (val, len, byte_order);
 	      if (mips_debug)
 		fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
 				    float_argreg, phex (regval, len));
@@ -3740,7 +3757,8 @@ mips_o32_push_dummy_call (struct gdbarch
 	         purpose register.  */
 	      if (argreg <= MIPS_LAST_ARG_REGNUM (gdbarch))
 		{
-		  LONGEST regval = extract_signed_integer (val, partial_len);
+		  LONGEST regval = extract_signed_integer (val, partial_len,
+							   byte_order);
 		  /* Value may need to be sign extended, because
 		     mips_isa_regsize() != mips_abi_regsize().  */
 
@@ -3982,6 +4000,7 @@ mips_o64_push_dummy_call (struct gdbarch
   int len = 0;
   int stack_offset = 0;
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR func_addr = find_function_addr (function, NULL);
 
   /* For shared libraries, "t9" needs to point at the function
@@ -4063,7 +4082,7 @@ mips_o64_push_dummy_call (struct gdbarch
       if (fp_register_arg_p (gdbarch, typecode, arg_type)
 	  && float_argreg <= MIPS_LAST_FP_ARG_REGNUM (gdbarch))
 	{
-	  LONGEST regval = extract_unsigned_integer (val, len);
+	  LONGEST regval = extract_unsigned_integer (val, len, byte_order);
 	  if (mips_debug)
 	    fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
 				float_argreg, phex (regval, len));
@@ -4145,7 +4164,8 @@ mips_o64_push_dummy_call (struct gdbarch
 	         purpose register.  */
 	      if (argreg <= MIPS_LAST_ARG_REGNUM (gdbarch))
 		{
-		  LONGEST regval = extract_signed_integer (val, partial_len);
+		  LONGEST regval = extract_signed_integer (val, partial_len,
+							   byte_order);
 		  /* Value may need to be sign extended, because
 		     mips_isa_regsize() != mips_abi_regsize().  */
 
@@ -4649,6 +4669,7 @@ static int
 mips_single_step_through_delay (struct gdbarch *gdbarch,
 				struct frame_info *frame)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR pc = get_frame_pc (frame);
   gdb_byte buf[MIPS_INSN32_SIZE];
 
@@ -4663,7 +4684,7 @@ mips_single_step_through_delay (struct g
     /* If error reading memory, guess that it is not a delayed
        branch.  */
     return 0;
-  return is_delayed (extract_unsigned_integer (buf, sizeof buf));
+  return is_delayed (extract_unsigned_integer (buf, sizeof buf, byte_order));
 }
 
 /* To skip prologues, I use this predicate.  Returns either PC itself
@@ -4703,15 +4724,15 @@ mips_skip_prologue (struct gdbarch *gdba
     limit_pc = pc + 100;          /* Magic.  */
 
   if (mips_pc_is_mips16 (pc))
-    return mips16_scan_prologue (pc, limit_pc, NULL, NULL);
+    return mips16_scan_prologue (gdbarch, pc, limit_pc, NULL, NULL);
   else
-    return mips32_scan_prologue (pc, limit_pc, NULL, NULL);
+    return mips32_scan_prologue (gdbarch, pc, limit_pc, NULL, NULL);
 }
 
 /* Check whether the PC is in a function epilogue (32-bit version).
    This is a helper function for mips_in_function_epilogue_p.  */
 static int
-mips32_in_function_epilogue_p (CORE_ADDR pc)
+mips32_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   CORE_ADDR func_addr = 0, func_end = 0;
 
@@ -4730,7 +4751,7 @@ mips32_in_function_epilogue_p (CORE_ADDR
 	  unsigned long high_word;
 	  unsigned long inst;
 
-	  inst = mips_fetch_instruction (pc);
+	  inst = mips_fetch_instruction (gdbarch, pc);
 	  high_word = (inst >> 16) & 0xffff;
 
 	  if (high_word != 0x27bd	/* addiu $sp,$sp,offset */
@@ -4749,7 +4770,7 @@ mips32_in_function_epilogue_p (CORE_ADDR
 /* Check whether the PC is in a function epilogue (16-bit version).
    This is a helper function for mips_in_function_epilogue_p.  */
 static int
-mips16_in_function_epilogue_p (CORE_ADDR pc)
+mips16_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   CORE_ADDR func_addr = 0, func_end = 0;
 
@@ -4767,7 +4788,7 @@ mips16_in_function_epilogue_p (CORE_ADDR
 	{
 	  unsigned short inst;
 
-	  inst = mips_fetch_instruction (pc);
+	  inst = mips_fetch_instruction (gdbarch, pc);
 
 	  if ((inst & 0xf800) == 0xf000)	/* extend */
 	    continue;
@@ -4792,9 +4813,9 @@ static int
 mips_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   if (mips_pc_is_mips16 (pc))
-    return mips16_in_function_epilogue_p (pc);
+    return mips16_in_function_epilogue_p (gdbarch, pc);
   else
-    return mips32_in_function_epilogue_p (pc);
+    return mips32_in_function_epilogue_p (gdbarch, pc);
 }
 
 /* Root of all "set mips "/"show mips " commands. This will eventually be
@@ -5077,6 +5098,7 @@ mips_breakpoint_from_pc (struct gdbarch 
 static CORE_ADDR
 mips_skip_mips16_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
   char *name;
   CORE_ADDR start_addr;
 
@@ -5135,7 +5157,7 @@ mips_skip_mips16_trampoline_code (struct
 	         instructions.  FIXME.  */
 	      for (i = 0, pc = 0; i < 20; i++, target_pc += MIPS_INSN32_SIZE)
 		{
-		  inst = mips_fetch_instruction (target_pc);
+		  inst = mips_fetch_instruction (gdbarch, target_pc);
 		  if ((inst & 0xffff0000) == 0x3c010000)	/* lui $at */
 		    pc = (inst << 16) & 0xffff0000;	/* high word */
 		  else if ((inst & 0xffff0000) == 0x24210000)	/* addiu $at */
@@ -5161,6 +5183,8 @@ mips_skip_mips16_trampoline_code (struct
 static CORE_ADDR
 mips_skip_pic_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);
   struct minimal_symbol *msym;
   int i;
   gdb_byte stub_code[16];
@@ -5186,7 +5210,8 @@ mips_skip_pic_trampoline_code (struct fr
       if (target_read_memory (pc, stub_code, 16) != 0)
 	return 0;
       for (i = 0; i < 4; i++)
-	stub_words[i] = extract_unsigned_integer (stub_code + i * 4, 4);
+	stub_words[i] = extract_unsigned_integer (stub_code + i * 4,
+						  4, byte_order);
 
       /* A stub contains these instructions:
 	 lui	t9, %hi(target)
@@ -5298,7 +5323,8 @@ static CORE_ADDR
 mips_integer_to_address (struct gdbarch *gdbarch,
 			 struct type *type, const gdb_byte *buf)
 {
-  return (CORE_ADDR) 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);
 }
 
 /* Dummy virtual frame pointer method.  This is no more or less accurate
Index: gdb-head/gdb/mn10300-tdep.c
===================================================================
--- gdb-head.orig/gdb/mn10300-tdep.c
+++ gdb-head/gdb/mn10300-tdep.c
@@ -387,6 +387,7 @@ mn10300_analyze_prologue (struct gdbarch
                           CORE_ADDR start_pc, CORE_ADDR limit_pc,
                           struct mn10300_prologue *result)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR pc, next_pc;
   int rn;
   pv_t regs[MN10300_MAX_NUM_REGS];
@@ -545,7 +546,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  if (status != 0)
 	    break;
 
-	  imm8 = extract_signed_integer (buf, 1);
+	  imm8 = extract_signed_integer (buf, 1, byte_order);
 	  regs[E_SP_REGNUM] = pv_add_constant (regs[E_SP_REGNUM], imm8);
 
 	  pc += 3;
@@ -562,7 +563,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  if (status != 0)
 	    break;
 
-	  imm16 = extract_signed_integer (buf, 2);
+	  imm16 = extract_signed_integer (buf, 2, byte_order);
 	  regs[E_SP_REGNUM] = pv_add_constant (regs[E_SP_REGNUM], imm16);
 
 	  pc += 4;
@@ -580,7 +581,7 @@ mn10300_analyze_prologue (struct gdbarch
 	    break;
 
 
-	  imm32 = extract_signed_integer (buf, 4);
+	  imm32 = extract_signed_integer (buf, 4, byte_order);
 	  regs[E_SP_REGNUM] = pv_add_constant (regs[E_SP_REGNUM], imm32);
 
 	  pc += 6;
@@ -594,7 +595,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  LONGEST imm8;
 
 	  aN = instr[0] & 0x03;
-	  imm8 = extract_signed_integer (&instr[1], 1);
+	  imm8 = extract_signed_integer (&instr[1], 1, byte_order);
 
 	  regs[E_A0_REGNUM + aN] = pv_add_constant (regs[E_A0_REGNUM + aN],
 	                                            imm8);
@@ -615,7 +616,7 @@ mn10300_analyze_prologue (struct gdbarch
 	    break;
 
 
-	  imm16 = extract_signed_integer (buf, 2);
+	  imm16 = extract_signed_integer (buf, 2, byte_order);
 
 	  regs[E_A0_REGNUM + aN] = pv_add_constant (regs[E_A0_REGNUM + aN],
 	                                            imm16);
@@ -635,7 +636,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  if (status != 0)
 	    break;
 
-	  imm32 = extract_signed_integer (buf, 2);
+	  imm32 = extract_signed_integer (buf, 2, byte_order);
 
 	  regs[E_A0_REGNUM + aN] = pv_add_constant (regs[E_A0_REGNUM + aN],
 	                                            imm32);
@@ -722,7 +723,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  sM = (buf[0] & 0xf0) >> 4;
 	  rN = buf[0] & 0x0f;
 	  fsM = (Y << 4) | sM;
-	  d8 = extract_signed_integer (&buf[1], 1);
+	  d8 = extract_signed_integer (&buf[1], 1, byte_order);
 
 	  pv_area_store (stack,
 	                 pv_add_constant (regs[translate_rreg (rN)], d8),
@@ -746,7 +747,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  sM = (buf[0] & 0xf0) >> 4;
 	  rN = buf[0] & 0x0f;
 	  fsM = (Y << 4) | sM;
-	  d24 = extract_signed_integer (&buf[1], 3);
+	  d24 = extract_signed_integer (&buf[1], 3, byte_order);
 
 	  pv_area_store (stack,
 	                 pv_add_constant (regs[translate_rreg (rN)], d24),
@@ -770,7 +771,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  sM = (buf[0] & 0xf0) >> 4;
 	  rN = buf[0] & 0x0f;
 	  fsM = (Y << 4) | sM;
-	  d32 = extract_signed_integer (&buf[1], 4);
+	  d32 = extract_signed_integer (&buf[1], 4, byte_order);
 
 	  pv_area_store (stack,
 	                 pv_add_constant (regs[translate_rreg (rN)], d32),
@@ -793,7 +794,7 @@ mn10300_analyze_prologue (struct gdbarch
 
 	  sM = (buf[0] & 0xf0) >> 4;
 	  fsM = (Y << 4) | sM;
-	  d8 = extract_signed_integer (&buf[1], 1);
+	  d8 = extract_signed_integer (&buf[1], 1, byte_order);
 
 	  pv_area_store (stack,
 	                 pv_add_constant (regs[E_SP_REGNUM], d8),
@@ -816,7 +817,7 @@ mn10300_analyze_prologue (struct gdbarch
 
 	  sM = (buf[0] & 0xf0) >> 4;
 	  fsM = (Y << 4) | sM;
-	  d24 = extract_signed_integer (&buf[1], 3);
+	  d24 = extract_signed_integer (&buf[1], 3, byte_order);
 
 	  pv_area_store (stack,
 	                 pv_add_constant (regs[E_SP_REGNUM], d24),
@@ -839,7 +840,7 @@ mn10300_analyze_prologue (struct gdbarch
 
 	  sM = (buf[0] & 0xf0) >> 4;
 	  fsM = (Y << 4) | sM;
-	  d32 = extract_signed_integer (&buf[1], 4);
+	  d32 = extract_signed_integer (&buf[1], 4, byte_order);
 
 	  pv_area_store (stack,
 	                 pv_add_constant (regs[E_SP_REGNUM], d32),
@@ -887,7 +888,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  sM = (buf[0] & 0xf0) >> 4;
 	  rN = buf[0] & 0x0f;
 	  fsM = (Y << 4) | sM;
-	  imm8 = extract_signed_integer (&buf[1], 1);
+	  imm8 = extract_signed_integer (&buf[1], 1, byte_order);
 
 	  rN_regnum = translate_rreg (rN);
 
@@ -912,7 +913,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  sM = (buf[0] & 0xf0) >> 4;
 	  rN = buf[0] & 0x0f;
 	  fsM = (Y << 4) | sM;
-	  imm24 = extract_signed_integer (&buf[1], 3);
+	  imm24 = extract_signed_integer (&buf[1], 3, byte_order);
 
 	  rN_regnum = translate_rreg (rN);
 
@@ -937,7 +938,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  sM = (buf[0] & 0xf0) >> 4;
 	  rN = buf[0] & 0x0f;
 	  fsM = (Y << 4) | sM;
-	  imm32 = extract_signed_integer (&buf[1], 4);
+	  imm32 = extract_signed_integer (&buf[1], 4, byte_order);
 
 	  rN_regnum = translate_rreg (rN);
 
@@ -952,7 +953,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  int aN = instr[0] & 0x03;
 	  LONGEST imm8;
 
-	  imm8 = extract_signed_integer (&instr[1], 1);
+	  imm8 = extract_signed_integer (&instr[1], 1, byte_order);
 
 	  regs[E_A0_REGNUM + aN] = pv_constant (imm8);
 	  pc += 2;
@@ -968,7 +969,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  if (status != 0)
 	    break;
 
-	  imm16 = extract_signed_integer (buf, 2);
+	  imm16 = extract_signed_integer (buf, 2, byte_order);
 	  regs[E_A0_REGNUM + aN] = pv_constant (imm16);
 	  pc += 3;
 	}
@@ -983,7 +984,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  if (status != 0)
 	    break;
 
-	  imm32 = extract_signed_integer (buf, 4);
+	  imm32 = extract_signed_integer (buf, 4, byte_order);
 	  regs[E_A0_REGNUM + aN] = pv_constant (imm32);
 	  pc += 6;
 	}
@@ -993,7 +994,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  int dN = instr[0] & 0x03;
 	  LONGEST imm8;
 
-	  imm8 = extract_signed_integer (&instr[1], 1);
+	  imm8 = extract_signed_integer (&instr[1], 1, byte_order);
 
 	  regs[E_D0_REGNUM + dN] = pv_constant (imm8);
 	  pc += 2;
@@ -1009,7 +1010,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  if (status != 0)
 	    break;
 
-	  imm16 = extract_signed_integer (buf, 2);
+	  imm16 = extract_signed_integer (buf, 2, byte_order);
 	  regs[E_D0_REGNUM + dN] = pv_constant (imm16);
 	  pc += 3;
 	}
@@ -1024,7 +1025,7 @@ mn10300_analyze_prologue (struct gdbarch
 	  if (status != 0)
 	    break;
 
-	  imm32 = extract_signed_integer (buf, 4);
+	  imm32 = extract_signed_integer (buf, 4, byte_order);
 	  regs[E_D0_REGNUM + dN] = pv_constant (imm32);
 	  pc += 6;
 	}
@@ -1223,6 +1224,7 @@ mn10300_push_dummy_call (struct gdbarch 
 			 int struct_return,
 			 CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   const int push_size = register_size (gdbarch, E_PC_REGNUM);
   int regs_used;
   int len, arg_len; 
@@ -1270,7 +1272,7 @@ mn10300_push_dummy_call (struct gdbarch 
 	{
 	  /* Change to pointer-to-type.  */
 	  arg_len = push_size;
-	  store_unsigned_integer (valbuf, push_size, 
+	  store_unsigned_integer (valbuf, push_size, byte_order,
 				  value_address (*args));
 	  val = &valbuf[0];
 	}
@@ -1283,7 +1285,7 @@ mn10300_push_dummy_call (struct gdbarch 
       while (regs_used < 2 && arg_len > 0)
 	{
 	  regcache_cooked_write_unsigned (regcache, regs_used, 
-				  extract_unsigned_integer (val, push_size));
+		  extract_unsigned_integer (val, push_size, byte_order));
 	  val += push_size;
 	  arg_len -= push_size;
 	  regs_used++;
@@ -1305,7 +1307,7 @@ mn10300_push_dummy_call (struct gdbarch 
 
   /* Push the return address that contains the magic breakpoint.  */
   sp -= 4;
-  write_memory_unsigned_integer (sp, push_size, bp_addr);
+  write_memory_unsigned_integer (sp, push_size, byte_order, bp_addr);
 
   /* The CPU also writes the return address always into the
      MDR register on "call".  */
Index: gdb-head/gdb/monitor.c
===================================================================
--- gdb-head.orig/gdb/monitor.c
+++ gdb-head/gdb/monitor.c
@@ -870,6 +870,8 @@ monitor_detach (struct target_ops *ops, 
 char *
 monitor_supply_register (struct regcache *regcache, int regno, char *valstr)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST val;
   unsigned char regbuf[MAX_REGISTER_SIZE];
   char *p;
@@ -905,8 +907,7 @@ monitor_supply_register (struct regcache
 
   /* supply register stores in target byte order, so swap here */
 
-  store_unsigned_integer (regbuf,
-			  register_size (get_regcache_arch (regcache), regno),
+  store_unsigned_integer (regbuf, register_size (gdbarch, regno), byte_order,
 			  val);
 
   regcache_raw_supply (regcache, regno, regbuf);
@@ -1409,6 +1410,7 @@ monitor_files_info (struct target_ops *o
 static int
 monitor_write_memory (CORE_ADDR memaddr, char *myaddr, int len)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   unsigned int val, hostval;
   char *cmd;
   int i;
@@ -1465,7 +1467,7 @@ monitor_write_memory (CORE_ADDR memaddr,
       cmd = current_monitor->setmem.cmdb;
     }
 
-  val = extract_unsigned_integer (myaddr, len);
+  val = extract_unsigned_integer (myaddr, len, byte_order);
 
   if (len == 4)
     {
@@ -1670,6 +1672,7 @@ monitor_write_memory_block (CORE_ADDR me
 static int
 monitor_read_memory_single (CORE_ADDR memaddr, char *myaddr, int len)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   unsigned int val;
   char membuf[sizeof (int) * 2 + 1];
   char *p;
@@ -1786,7 +1789,7 @@ monitor_read_memory_single (CORE_ADDR me
 
   /* supply register stores in target byte order, so swap here */
 
-  store_unsigned_integer (myaddr, len, val);
+  store_unsigned_integer (myaddr, len, byte_order, val);
 
   return len;
 }
Index: gdb-head/gdb/mt-tdep.c
===================================================================
--- gdb-head.orig/gdb/mt-tdep.c
+++ gdb-head/gdb/mt-tdep.c
@@ -339,6 +339,8 @@ mt_return_value (struct gdbarch *gdbarch
 		 struct type *type, struct regcache *regcache,
 		 gdb_byte *readbuf, const gdb_byte *writebuf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   if (TYPE_LENGTH (type) > 4)
     {
       /* Return values > 4 bytes are returned in memory, 
@@ -369,7 +371,8 @@ mt_return_value (struct gdbarch *gdbarch
 
 	  /* Return values of <= 4 bytes are returned in R11.  */
 	  regcache_cooked_read_unsigned (regcache, MT_R11_REGNUM, &temp);
-	  store_unsigned_integer (readbuf, TYPE_LENGTH (type), temp);
+	  store_unsigned_integer (readbuf, TYPE_LENGTH (type),
+				  byte_order, temp);
 	}
 
       if (writebuf)
@@ -403,6 +406,7 @@ mt_return_value (struct gdbarch *gdbarch
 static CORE_ADDR
 mt_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR func_addr = 0, func_end = 0;
   char *func_name;
   unsigned long instr;
@@ -430,7 +434,7 @@ mt_skip_prologue (struct gdbarch *gdbarc
   /* No function symbol, or no line symbol.  Use prologue scanning method.  */
   for (;; pc += 4)
     {
-      instr = read_memory_unsigned_integer (pc, 4);
+      instr = read_memory_unsigned_integer (pc, 4, byte_order);
       if (instr == 0x12000000)	/* nop */
 	continue;
       if (instr == 0x12ddc000)	/* copy sp into fp */
@@ -474,13 +478,15 @@ static int
 mt_select_coprocessor (struct gdbarch *gdbarch,
 			struct regcache *regcache, int regno)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned index, base;
   gdb_byte copro[4];
 
   /* Get the copro pseudo regnum. */
   regcache_raw_read (regcache, MT_COPRO_REGNUM, copro);
-  base = (extract_signed_integer (&copro[0], 2) * MT_COPRO_PSEUDOREG_DIM_2
-	  + extract_signed_integer (&copro[2], 2));
+  base = ((extract_signed_integer (&copro[0], 2, byte_order)
+	   * MT_COPRO_PSEUDOREG_DIM_2)
+	  + extract_signed_integer (&copro[2], 2, byte_order));
 
   regno -= MT_COPRO_PSEUDOREG_ARRAY;
   index = regno % MT_COPRO_PSEUDOREG_REGS;
@@ -491,8 +497,10 @@ mt_select_coprocessor (struct gdbarch *g
 	 coprocessor register cache.  */
       unsigned ix;
 
-      store_signed_integer (&copro[0], 2, regno / MT_COPRO_PSEUDOREG_DIM_2);
-      store_signed_integer (&copro[2], 2, regno % MT_COPRO_PSEUDOREG_DIM_2);
+      store_signed_integer (&copro[0], 2, byte_order,
+			    regno / MT_COPRO_PSEUDOREG_DIM_2);
+      store_signed_integer (&copro[2], 2, byte_order,
+			    regno % MT_COPRO_PSEUDOREG_DIM_2);
       regcache_raw_write (regcache, MT_COPRO_REGNUM, copro);
       
       /* We must flush the cache, as it is now invalid.  */
@@ -519,6 +527,8 @@ static void
 mt_pseudo_register_read (struct gdbarch *gdbarch,
 			  struct regcache *regcache, int regno, gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   switch (regno)
     {
     case MT_COPRO_REGNUM:
@@ -537,7 +547,7 @@ mt_pseudo_register_read (struct gdbarch 
 	  regcache_cooked_read_unsigned (regcache, MT_EXMAC_REGNUM, &ext_mac);
 	  newmac =
 	    (oldmac & 0xffffffff) | ((long long) (ext_mac & 0xff) << 32);
-	  store_signed_integer (buf, 8, newmac);
+	  store_signed_integer (buf, 8, byte_order, newmac);
 	}
       else
 	regcache_raw_read (regcache, MT_MAC_REGNUM, buf);
@@ -567,6 +577,7 @@ mt_pseudo_register_write (struct gdbarch
 			   struct regcache *regcache,
 			   int regno, const gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int i;
 
   switch (regno)
@@ -587,7 +598,7 @@ mt_pseudo_register_write (struct gdbarch
 	  unsigned int oldmac, ext_mac;
 	  ULONGEST newmac;
 
-	  newmac = extract_unsigned_integer (buf, 8);
+	  newmac = extract_unsigned_integer (buf, 8, byte_order);
 	  oldmac = newmac & 0xffffffff;
 	  ext_mac = (newmac >> 32) & 0xff;
 	  regcache_cooked_write_unsigned (regcache, MT_MAC_REGNUM, oldmac);
@@ -626,6 +637,8 @@ mt_registers_info (struct gdbarch *gdbar
 		   struct ui_file *file,
 		   struct frame_info *frame, int regnum, int all)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   if (regnum == -1)
     {
       int lim;
@@ -672,10 +685,10 @@ mt_registers_info (struct gdbarch *gdbar
 
 	  for (i = 0; i < regsize; i++)
 	    fprintf_filtered (file, "%02x", (unsigned int)
-			      extract_unsigned_integer (buff + i, 1));
+			      extract_unsigned_integer (buff + i, 1, byte_order));
 	  fputs_filtered ("\t", file);
 	  print_longest (file, 'd', 0,
-			 extract_unsigned_integer (buff, regsize));
+			 extract_unsigned_integer (buff, regsize, byte_order));
 	  fputs_filtered ("\n", file);
 	}
       else if (regnum == MT_COPRO_REGNUM
@@ -709,13 +722,13 @@ mt_registers_info (struct gdbarch *gdbar
 	  /* Get the two "real" mac registers.  */
 	  frame_register_read (frame, MT_MAC_REGNUM, buf);
 	  oldmac = extract_unsigned_integer
-	    (buf, register_size (gdbarch, MT_MAC_REGNUM));
+	    (buf, register_size (gdbarch, MT_MAC_REGNUM), byte_order);
 	  if (gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_mrisc2
 	      || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_ms2)
 	    {
 	      frame_register_read (frame, MT_EXMAC_REGNUM, buf);
 	      ext_mac = extract_unsigned_integer
-		(buf, register_size (gdbarch, MT_EXMAC_REGNUM));
+		(buf, register_size (gdbarch, MT_EXMAC_REGNUM), byte_order);
 	    }
 	  else
 	    ext_mac = 0;
@@ -755,6 +768,7 @@ mt_push_dummy_call (struct gdbarch *gdba
 		     int struct_return, CORE_ADDR struct_addr)
 {
 #define wordsize 4
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[MT_MAX_STRUCT_SIZE];
   int argreg = MT_1ST_ARGREG;
   int split_param_len = 0;
@@ -778,7 +792,7 @@ mt_push_dummy_call (struct gdbarch *gdba
 	  regcache_cooked_write_unsigned (regcache, argreg++,
 					  extract_unsigned_integer
 					  (value_contents (args[i]),
-					   wordsize));
+					   wordsize, byte_order));
 	  break;
 	case 8:
 	case 12:
@@ -791,7 +805,7 @@ mt_push_dummy_call (struct gdbarch *gdba
 		  /* This word of the argument is passed in a register.  */
 		  regcache_cooked_write_unsigned (regcache, argreg++,
 						  extract_unsigned_integer
-						  (val, wordsize));
+						  (val, wordsize, byte_order));
 		  typelen -= wordsize;
 		  val += wordsize;
 		}
Index: gdb-head/gdb/objc-lang.c
===================================================================
--- gdb-head.orig/gdb/objc-lang.c
+++ gdb-head/gdb/objc-lang.c
@@ -1610,58 +1610,69 @@ _initialize_objc_language (void)
 }
 
 static void 
-read_objc_method (CORE_ADDR addr, struct objc_method *method)
+read_objc_method (struct gdbarch *gdbarch, CORE_ADDR addr,
+		  struct objc_method *method)
 {
-  method->name  = read_memory_unsigned_integer (addr + 0, 4);
-  method->types = read_memory_unsigned_integer (addr + 4, 4);
-  method->imp   = read_memory_unsigned_integer (addr + 8, 4);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  method->name  = read_memory_unsigned_integer (addr + 0, 4, byte_order);
+  method->types = read_memory_unsigned_integer (addr + 4, 4, byte_order);
+  method->imp   = read_memory_unsigned_integer (addr + 8, 4, byte_order);
 }
 
-static 
-unsigned long read_objc_methlist_nmethods (CORE_ADDR addr)
+static unsigned long
+read_objc_methlist_nmethods (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
-  return read_memory_unsigned_integer (addr + 4, 4);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  return read_memory_unsigned_integer (addr + 4, 4, byte_order);
 }
 
 static void 
-read_objc_methlist_method (CORE_ADDR addr, unsigned long num, 
-			   struct objc_method *method)
+read_objc_methlist_method (struct gdbarch *gdbarch, CORE_ADDR addr,
+			   unsigned long num, struct objc_method *method)
 {
-  gdb_assert (num < read_objc_methlist_nmethods (addr));
-  read_objc_method (addr + 8 + (12 * num), method);
+  gdb_assert (num < read_objc_methlist_nmethods (gdbarch, addr));
+  read_objc_method (gdbarch, addr + 8 + (12 * num), method);
 }
   
 static void 
-read_objc_object (CORE_ADDR addr, struct objc_object *object)
+read_objc_object (struct gdbarch *gdbarch, CORE_ADDR addr,
+		  struct objc_object *object)
 {
-  object->isa = read_memory_unsigned_integer (addr, 4);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  object->isa = read_memory_unsigned_integer (addr, 4, byte_order);
 }
 
 static void 
-read_objc_super (CORE_ADDR addr, struct objc_super *super)
+read_objc_super (struct gdbarch *gdbarch, CORE_ADDR addr,
+		 struct objc_super *super)
 {
-  super->receiver = read_memory_unsigned_integer (addr, 4);
-  super->class = read_memory_unsigned_integer (addr + 4, 4);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  super->receiver = read_memory_unsigned_integer (addr, 4, byte_order);
+  super->class = read_memory_unsigned_integer (addr + 4, 4, byte_order);
 };
 
 static void 
-read_objc_class (CORE_ADDR addr, struct objc_class *class)
+read_objc_class (struct gdbarch *gdbarch, CORE_ADDR addr,
+		 struct objc_class *class)
 {
-  class->isa = read_memory_unsigned_integer (addr, 4);
-  class->super_class = read_memory_unsigned_integer (addr + 4, 4);
-  class->name = read_memory_unsigned_integer (addr + 8, 4);
-  class->version = read_memory_unsigned_integer (addr + 12, 4);
-  class->info = read_memory_unsigned_integer (addr + 16, 4);
-  class->instance_size = read_memory_unsigned_integer (addr + 18, 4);
-  class->ivars = read_memory_unsigned_integer (addr + 24, 4);
-  class->methods = read_memory_unsigned_integer (addr + 28, 4);
-  class->cache = read_memory_unsigned_integer (addr + 32, 4);
-  class->protocols = read_memory_unsigned_integer (addr + 36, 4);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  class->isa = read_memory_unsigned_integer (addr, 4, byte_order);
+  class->super_class = read_memory_unsigned_integer (addr + 4, 4, byte_order);
+  class->name = read_memory_unsigned_integer (addr + 8, 4, byte_order);
+  class->version = read_memory_unsigned_integer (addr + 12, 4, byte_order);
+  class->info = read_memory_unsigned_integer (addr + 16, 4, byte_order);
+  class->instance_size = read_memory_unsigned_integer (addr + 18, 4, byte_order);
+  class->ivars = read_memory_unsigned_integer (addr + 24, 4, byte_order);
+  class->methods = read_memory_unsigned_integer (addr + 28, 4, byte_order);
+  class->cache = read_memory_unsigned_integer (addr + 32, 4, byte_order);
+  class->protocols = read_memory_unsigned_integer (addr + 36, 4, byte_order);
 }
 
 static CORE_ADDR
-find_implementation_from_class (CORE_ADDR class, CORE_ADDR sel)
+find_implementation_from_class (struct gdbarch *gdbarch,
+				CORE_ADDR class, CORE_ADDR sel)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR subclass = class;
 
   while (subclass != 0) 
@@ -1670,7 +1681,7 @@ find_implementation_from_class (CORE_ADD
       struct objc_class class_str;
       unsigned mlistnum = 0;
 
-      read_objc_class (subclass, &class_str);
+      read_objc_class (gdbarch, subclass, &class_str);
 
       for (;;) 
 	{
@@ -1679,16 +1690,17 @@ find_implementation_from_class (CORE_ADD
 	  unsigned long i;
       
 	  mlist = read_memory_unsigned_integer (class_str.methods + 
-						(4 * mlistnum), 4);
+						(4 * mlistnum),
+						4, byte_order);
 	  if (mlist == 0) 
 	    break;
 
-	  nmethods = read_objc_methlist_nmethods (mlist);
+	  nmethods = read_objc_methlist_nmethods (gdbarch, mlist);
 
 	  for (i = 0; i < nmethods; i++) 
 	    {
 	      struct objc_method meth_str;
-	      read_objc_methlist_method (mlist, i, &meth_str);
+	      read_objc_methlist_method (gdbarch, mlist, i, &meth_str);
 
 #if 0
 	      fprintf (stderr, 
@@ -1710,17 +1722,18 @@ find_implementation_from_class (CORE_ADD
 }
 
 static CORE_ADDR
-find_implementation (CORE_ADDR object, CORE_ADDR sel)
+find_implementation (struct gdbarch *gdbarch,
+		     CORE_ADDR object, CORE_ADDR sel)
 {
   struct objc_object ostr;
 
   if (object == 0)
     return 0;
-  read_objc_object (object, &ostr);
+  read_objc_object (gdbarch, object, &ostr);
   if (ostr.isa == 0)
     return 0;
 
-  return find_implementation_from_class (ostr.isa, sel);
+  return find_implementation_from_class (gdbarch, ostr.isa, sel);
 }
 
 static int
@@ -1737,7 +1750,7 @@ resolve_msgsend (CORE_ADDR pc, CORE_ADDR
   object = gdbarch_fetch_pointer_argument (gdbarch, frame, 0, ptr_type);
   sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
 
-  res = find_implementation (object, sel);
+  res = find_implementation (gdbarch, object, sel);
   if (new_pc != 0)
     *new_pc = res;
   if (res == 0)
@@ -1759,7 +1772,7 @@ resolve_msgsend_stret (CORE_ADDR pc, COR
   object = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
   sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 2, ptr_type);
 
-  res = find_implementation (object, sel);
+  res = find_implementation (gdbarch, object, sel);
   if (new_pc != 0)
     *new_pc = res;
   if (res == 0)
@@ -1783,11 +1796,11 @@ resolve_msgsend_super (CORE_ADDR pc, COR
   super = gdbarch_fetch_pointer_argument (gdbarch, frame, 0, ptr_type);
   sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
 
-  read_objc_super (super, &sstr);
+  read_objc_super (gdbarch, super, &sstr);
   if (sstr.class == 0)
     return 0;
   
-  res = find_implementation_from_class (sstr.class, sel);
+  res = find_implementation_from_class (gdbarch, sstr.class, sel);
   if (new_pc != 0)
     *new_pc = res;
   if (res == 0)
@@ -1811,11 +1824,11 @@ resolve_msgsend_super_stret (CORE_ADDR p
   super = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
   sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 2, ptr_type);
 
-  read_objc_super (super, &sstr);
+  read_objc_super (gdbarch, super, &sstr);
   if (sstr.class == 0)
     return 0;
   
-  res = find_implementation_from_class (sstr.class, sel);
+  res = find_implementation_from_class (gdbarch, sstr.class, sel);
   if (new_pc != 0)
     *new_pc = res;
   if (res == 0)
Index: gdb-head/gdb/p-lang.c
===================================================================
--- gdb-head.orig/gdb/p-lang.c
+++ gdb-head/gdb/p-lang.c
@@ -217,6 +217,7 @@ pascal_printstr (struct ui_file *stream,
 		 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;
@@ -227,7 +228,8 @@ pascal_printstr (struct ui_file *stream,
      the last byte of it is a null, we don't print that, in traditional C
      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--;
 
   if (length == 0)
@@ -253,13 +255,14 @@ pascal_printstr (struct ui_file *stream,
 	  need_comma = 0;
 	}
 
-      current_char = extract_unsigned_integer (string + i * width, width);
+      current_char = extract_unsigned_integer (string + i * width, width,
+					       byte_order);
 
       rep1 = i + 1;
       reps = 1;
       while (rep1 < length 
-	     && extract_unsigned_integer (string + rep1 * width, width) 
-		== current_char)
+	     && extract_unsigned_integer (string + rep1 * width, width,
+					  byte_order) == current_char)
 	{
 	  ++rep1;
 	  ++reps;
Index: gdb-head/gdb/ppc-linux-tdep.c
===================================================================
--- gdb-head.orig/gdb/ppc-linux-tdep.c
+++ gdb-head/gdb/ppc-linux-tdep.c
@@ -329,10 +329,11 @@ insn_ds_field (unsigned int insn)
 /* If DESC is the address of a 64-bit PowerPC GNU/Linux function
    descriptor, return the descriptor's entry point.  */
 static CORE_ADDR
-ppc64_desc_entry_point (CORE_ADDR desc)
+ppc64_desc_entry_point (struct gdbarch *gdbarch, CORE_ADDR desc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   /* The first word of the descriptor is the entry point.  */
-  return (CORE_ADDR) read_memory_unsigned_integer (desc, 8);
+  return (CORE_ADDR) read_memory_unsigned_integer (desc, 8, byte_order);
 }
 
 
@@ -483,7 +484,8 @@ static CORE_ADDR
 ppc64_standard_linkage1_target (struct frame_info *frame,
 				CORE_ADDR pc, unsigned int *insn)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   /* The address of the function descriptor this linkage function
      references.  */
@@ -494,7 +496,7 @@ ppc64_standard_linkage1_target (struct f
        + insn_ds_field (insn[2]));
 
   /* The first word of the descriptor is the entry point.  Return that.  */
-  return ppc64_desc_entry_point (desc);
+  return ppc64_desc_entry_point (gdbarch, desc);
 }
 
 static struct core_regset_section ppc_linux_vsx_regset_sections[] =
@@ -525,7 +527,8 @@ static CORE_ADDR
 ppc64_standard_linkage2_target (struct frame_info *frame,
 				CORE_ADDR pc, unsigned int *insn)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   /* The address of the function descriptor this linkage function
      references.  */
@@ -536,14 +539,15 @@ ppc64_standard_linkage2_target (struct f
        + insn_ds_field (insn[2]));
 
   /* The first word of the descriptor is the entry point.  Return that.  */
-  return ppc64_desc_entry_point (desc);
+  return ppc64_desc_entry_point (gdbarch, desc);
 }
 
 static CORE_ADDR
 ppc64_standard_linkage3_target (struct frame_info *frame,
 				CORE_ADDR pc, unsigned int *insn)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   /* The address of the function descriptor this linkage function
      references.  */
@@ -553,7 +557,7 @@ ppc64_standard_linkage3_target (struct f
        + insn_ds_field (insn[1]));
 
   /* The first word of the descriptor is the entry point.  Return that.  */
-  return ppc64_desc_entry_point (desc);
+  return ppc64_desc_entry_point (gdbarch, desc);
 }
 
 
@@ -621,6 +625,7 @@ ppc64_linux_convert_from_func_ptr_addr (
 					CORE_ADDR addr,
 					struct target_ops *targ)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct target_section *s = target_section_by_addr (targ, addr);
 
   /* Check if ADDR points to a function descriptor.  */
@@ -652,7 +657,7 @@ ppc64_linux_convert_from_func_ptr_addr (
       res = bfd_get_section_contents (s->bfd, s->the_bfd_section,
 				      &buf, addr - s->addr, 8);
       if (res != 0)
-	return extract_unsigned_integer (buf, 8)
+	return extract_unsigned_integer (buf, 8, byte_order)
 		- bfd_section_vma (s->bfd, s->the_bfd_section) + s->addr;
    }
 
@@ -847,6 +852,7 @@ ppc_linux_sigtramp_cache (struct frame_i
   int i;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   base = get_frame_register_unsigned (this_frame,
 				      gdbarch_sp_regnum (gdbarch));
@@ -859,7 +865,7 @@ ppc_linux_sigtramp_cache (struct frame_i
   regs = base + offset;
   /* Use that to find the address of the corresponding register
      buffers.  */
-  gpregs = read_memory_unsigned_integer (regs, tdep->wordsize);
+  gpregs = read_memory_unsigned_integer (regs, tdep->wordsize, byte_order);
   fpregs = gpregs + 48 * tdep->wordsize;
 
   /* General purpose.  */
Index: gdb-head/gdb/ppcobsd-tdep.c
===================================================================
--- gdb-head.orig/gdb/ppcobsd-tdep.c
+++ gdb-head/gdb/ppcobsd-tdep.c
@@ -126,6 +126,8 @@ ppcobsd_sigtramp_frame_sniffer (const st
 				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);
   CORE_ADDR pc = get_frame_pc (this_frame);
   CORE_ADDR start_pc = (pc & ~(ppcobsd_page_size - 1));
   const int *offset;
@@ -145,12 +147,13 @@ ppcobsd_sigtramp_frame_sniffer (const st
 	continue;
 
       /* Check for "li r0,SYS_sigreturn".  */
-      insn = extract_unsigned_integer (buf, PPC_INSN_SIZE);
+      insn = extract_unsigned_integer (buf, PPC_INSN_SIZE, byte_order);
       if (insn != 0x38000067)
 	continue;
 
       /* Check for "sc".  */
-      insn = extract_unsigned_integer (buf + PPC_INSN_SIZE, PPC_INSN_SIZE);
+      insn = extract_unsigned_integer (buf + PPC_INSN_SIZE,
+				       PPC_INSN_SIZE, byte_order);
       if (insn != 0x44000002)
 	continue;
 
@@ -165,6 +168,7 @@ ppcobsd_sigtramp_frame_cache (struct fra
 {
   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;
   CORE_ADDR addr, base, func;
   gdb_byte buf[PPC_INSN_SIZE];
@@ -185,7 +189,7 @@ ppcobsd_sigtramp_frame_cache (struct fra
   /* Calculate the offset where we can find `struct sigcontext'.  We
      base our calculation on the amount of stack space reserved by the
      first instruction of the signal trampoline.  */
-  insn = extract_unsigned_integer (buf, PPC_INSN_SIZE);
+  insn = extract_unsigned_integer (buf, PPC_INSN_SIZE, byte_order);
   sigcontext_offset = (0x10000 - (insn & 0x0000ffff)) + 8;
 
   base = get_frame_register_unsigned (this_frame, gdbarch_sp_regnum (gdbarch));
Index: gdb-head/gdb/ppc-sysv-tdep.c
===================================================================
--- gdb-head.orig/gdb/ppc-sysv-tdep.c
+++ gdb-head/gdb/ppc-sysv-tdep.c
@@ -49,6 +49,7 @@ ppc_sysv_abi_push_dummy_call (struct gdb
 			      int struct_return, CORE_ADDR struct_addr)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST saved_sp;
   int argspace = 0;		/* 0 is an initial wrong guess.  */
   int write_pass;
@@ -398,13 +399,13 @@ ppc_sysv_abi_push_dummy_call (struct gdb
 		    write_memory (sp + structoffset, val, len);
 		  /* ... and then a "word" pointing to that address is
 		     passed as the parameter.  */
-		  store_unsigned_integer (word, tdep->wordsize,
+		  store_unsigned_integer (word, tdep->wordsize, byte_order,
 					  sp + structoffset);
 		  structoffset += len;
 		}
 	      else if (TYPE_CODE (type) == TYPE_CODE_INT)
 		/* Sign or zero extend the "int" into a "word".  */
-		store_unsigned_integer (word, tdep->wordsize,
+		store_unsigned_integer (word, tdep->wordsize, byte_order,
 					unpack_long (type, val));
 	      else
 		/* Always goes in the low address.  */
@@ -462,7 +463,7 @@ ppc_sysv_abi_push_dummy_call (struct gdb
   regcache_cooked_write_signed (regcache, gdbarch_sp_regnum (gdbarch), sp);
 
   /* Write the backchain (it occupies WORDSIZED bytes).  */
-  write_memory_signed_integer (sp, tdep->wordsize, saved_sp);
+  write_memory_signed_integer (sp, tdep->wordsize, byte_order, saved_sp);
 
   /* Point the inferior function call's return address at the dummy's
      breakpoint.  */
@@ -556,6 +557,7 @@ do_ppc_sysv_return_value (struct gdbarch
 			  const gdb_byte *writebuf, int broken_gcc)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_assert (tdep->wordsize == 4);
   if (TYPE_CODE (type) == TYPE_CODE_FLT
       && TYPE_LENGTH (type) <= 8
@@ -675,7 +677,8 @@ do_ppc_sysv_return_value (struct gdbarch
 	  ULONGEST regval;
 	  regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
 					 &regval);
-	  store_unsigned_integer (readbuf, TYPE_LENGTH (type), regval);
+	  store_unsigned_integer (readbuf, TYPE_LENGTH (type), byte_order,
+				  regval);
 	}
       if (writebuf)
 	{
@@ -892,6 +895,7 @@ ppc64_sysv_abi_push_dummy_call (struct g
 {
   CORE_ADDR func_addr = find_function_addr (function, NULL);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST back_chain;
   /* See for-loop comment below.  */
   int write_pass;
@@ -1194,7 +1198,7 @@ ppc64_sysv_abi_push_dummy_call (struct g
 						    tdep->ppc_gp0_regnum +
 						    greg, word);
 		  write_memory_unsigned_integer (gparam, tdep->wordsize,
-						 word);
+						 byte_order, word);
 		}
 	      greg++;
 	      gparam = align_up (gparam + TYPE_LENGTH (type), tdep->wordsize);
@@ -1315,7 +1319,7 @@ ppc64_sysv_abi_push_dummy_call (struct g
   regcache_cooked_write_signed (regcache, gdbarch_sp_regnum (gdbarch), sp);
 
   /* Write the backchain (it occupies WORDSIZED bytes).  */
-  write_memory_signed_integer (sp, tdep->wordsize, back_chain);
+  write_memory_signed_integer (sp, tdep->wordsize, byte_order, back_chain);
 
   /* Point the inferior function call's return address at the dummy's
      breakpoint.  */
@@ -1330,7 +1334,7 @@ ppc64_sysv_abi_push_dummy_call (struct g
 	/* The TOC is the second double word in the descriptor.  */
 	CORE_ADDR toc =
 	  read_memory_unsigned_integer (desc_addr + tdep->wordsize,
-					tdep->wordsize);
+					tdep->wordsize, byte_order);
 	regcache_cooked_write_unsigned (regcache,
 					tdep->ppc_gp0_regnum + 2, toc);
       }
@@ -1356,6 +1360,7 @@ ppc64_sysv_abi_return_value (struct gdba
 			     gdb_byte *readbuf, const gdb_byte *writebuf)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   /* This function exists to support a calling convention that
      requires floating-point registers.  It shouldn't be used on
@@ -1402,7 +1407,8 @@ ppc64_sysv_abi_return_value (struct gdba
 	  ULONGEST regval;
 	  regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
 					 &regval);
-	  store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), regval);
+	  store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), byte_order,
+				  regval);
 	}
       return RETURN_VALUE_REGISTER_CONVENTION;
     }
Index: gdb-head/gdb/printcmd.c
===================================================================
--- gdb-head.orig/gdb/printcmd.c
+++ gdb-head/gdb/printcmd.c
@@ -2282,6 +2282,7 @@ printf_command (char *arg, int from_tty)
 	      int j;
 	      struct gdbarch *gdbarch
 		= get_type_arch (value_type (val_args[i]));
+	      enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 	      struct type *wctype = lookup_typename (current_language, gdbarch,
 						     "wchar_t", NULL, 0);
 	      int wcwidth = TYPE_LENGTH (wctype);
@@ -2296,7 +2297,7 @@ printf_command (char *arg, int from_tty)
 		{
 		  QUIT;
 		  read_memory (tem + j, buf, wcwidth);
-		  if (extract_unsigned_integer (buf, wcwidth) == 0)
+		  if (extract_unsigned_integer (buf, wcwidth, byte_order) == 0)
 		    break;
 		}
 
@@ -2309,7 +2310,7 @@ printf_command (char *arg, int from_tty)
 	      obstack_init (&output);
 	      inner_cleanup = make_cleanup_obstack_free (&output);
 
-	      convert_between_encodings (target_wide_charset (),
+	      convert_between_encodings (target_wide_charset (byte_order),
 					 host_charset (),
 					 str, j, wcwidth,
 					 &output, translit_char);
@@ -2323,6 +2324,7 @@ printf_command (char *arg, int from_tty)
 	    {
 	      struct gdbarch *gdbarch
 		= get_type_arch (value_type (val_args[i]));
+	      enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 	      struct type *wctype = lookup_typename (current_language, gdbarch,
 						     "wchar_t", NULL, 0);
 	      struct type *valtype;
@@ -2340,7 +2342,7 @@ printf_command (char *arg, int from_tty)
 	      obstack_init (&output);
 	      inner_cleanup = make_cleanup_obstack_free (&output);
 
-	      convert_between_encodings (target_wide_charset (),
+	      convert_between_encodings (target_wide_charset (byte_order),
 					 host_charset (),
 					 bytes, TYPE_LENGTH (valtype),
 					 TYPE_LENGTH (valtype),
@@ -2431,6 +2433,7 @@ printf_command (char *arg, int from_tty)
 	      struct type *param_type = value_type (val_args[i]);
 	      unsigned int param_len = TYPE_LENGTH (param_type);
 	      struct gdbarch *gdbarch = get_type_arch (param_type);
+	      enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
 	      /* DFP output data.  */
 	      struct value *dfp_value = NULL;
@@ -2490,18 +2493,19 @@ printf_command (char *arg, int from_tty)
 
 	      /* Conversion between different DFP types.  */
 	      if (TYPE_CODE (param_type) == TYPE_CODE_DECFLOAT)
-		decimal_convert (param_ptr, param_len, dec, dfp_len);
+		decimal_convert (param_ptr, param_len, byte_order,
+				 dec, dfp_len, byte_order);
 	      else
 		/* If this is a non-trivial conversion, just output 0.
 		   A correct converted value can be displayed by explicitly
 		   casting to a DFP type.  */
-		decimal_from_string (dec, dfp_len, "0");
+		decimal_from_string (dec, dfp_len, byte_order, "0");
 
 	      dfp_value = value_from_decfloat (dfp_type, dec);
 
 	      dfp_ptr = (gdb_byte *) value_contents (dfp_value);
 
-	      decimal_to_string (dfp_ptr, dfp_len, decstr);
+	      decimal_to_string (dfp_ptr, dfp_len, byte_order, decstr);
 
 	      /* Print the DFP value.  */
 	      printf_filtered (current_substring, decstr);
Index: gdb-head/gdb/procfs.c
===================================================================
--- gdb-head.orig/gdb/procfs.c
+++ gdb-head/gdb/procfs.c
@@ -162,6 +162,7 @@ static int
 procfs_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
                   gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   gdb_byte *ptr = *readptr;
 
   if (endptr == ptr)
@@ -170,11 +171,11 @@ procfs_auxv_parse (struct target_ops *op
   if (endptr - ptr < 8 * 2)
     return -1;
 
-  *typep = extract_unsigned_integer (ptr, 4);
+  *typep = extract_unsigned_integer (ptr, 4, byte_order);
   ptr += 8;
   /* The size of data is always 64-bit.  If the application is 32-bit,
      it will be zero extended, as expected.  */
-  *valp = extract_unsigned_integer (ptr, 8);
+  *valp = extract_unsigned_integer (ptr, 8, byte_order);
   ptr += 8;
 
   *readptr = ptr;
Index: gdb-head/gdb/p-valprint.c
===================================================================
--- gdb-head.orig/gdb/p-valprint.c
+++ gdb-head/gdb/p-valprint.c
@@ -57,6 +57,7 @@ pascal_val_print (struct type *type, con
 		  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;
@@ -95,7 +96,8 @@ pascal_val_print (struct type *type, con
 		  /* Look for a NULL char. */
 		  for (temp_len = 0;
 		       extract_unsigned_integer (valaddr + embedded_offset +
-						 temp_len * eltlen, eltlen)
+						 temp_len * eltlen, eltlen,
+						 byte_order)
 		       && temp_len < len && temp_len < options->print_max;
 		       temp_len++);
 		  len = temp_len;
@@ -143,9 +145,9 @@ pascal_val_print (struct type *type, con
 	  /* Print vtable entry - we only get here if we ARE using
 	     -fvtable_thunks.  (Otherwise, look under TYPE_CODE_STRUCT.) */
 	  /* Extract the address, assume that it is unsigned.  */
-	  print_address_demangle (gdbarch,
-				  extract_unsigned_integer (valaddr + embedded_offset, TYPE_LENGTH (type)),
-				  stream, demangle);
+	  addr = extract_unsigned_integer (valaddr + embedded_offset,
+					   TYPE_LENGTH (type), byte_order);
+	  print_address_demangle (gdbarch, addr, stream, demangle);
 	  break;
 	}
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
@@ -193,7 +195,8 @@ pascal_val_print (struct type *type, con
               void *buffer;
               buffer = xmalloc (length_size);
               read_memory (addr + length_pos, buffer, length_size);
-	      string_length = extract_unsigned_integer (buffer, length_size);
+	      string_length = extract_unsigned_integer (buffer, length_size,
+							byte_order);
               xfree (buffer);
               i = val_print_string (char_type ,addr + string_pos, string_length, stream, options);
 	    }
@@ -294,7 +297,7 @@ pascal_val_print (struct type *type, con
 	  print_address_demangle
 	    (gdbarch,
 	     extract_unsigned_integer (valaddr + embedded_offset + TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8,
-				       TYPE_LENGTH (TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET))),
+				       TYPE_LENGTH (TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET)), byte_order),
 	     stream, demangle);
 	}
       else
@@ -302,7 +305,7 @@ pascal_val_print (struct type *type, con
           if (is_pascal_string_type (type, &length_pos, &length_size,
                                      &string_pos, &char_type, NULL))
 	    {
-	      len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size);
+	      len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size, byte_order);
 	      LA_PRINT_STRING (stream, char_type, valaddr + embedded_offset + string_pos, len, 0, options);
 	    }
 	  else
Index: gdb-head/gdb/regcache.c
===================================================================
--- gdb-head.orig/gdb/regcache.c
+++ gdb-head/gdb/regcache.c
@@ -570,8 +570,9 @@ regcache_raw_read_signed (struct regcach
   gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
   buf = alloca (regcache->descr->sizeof_register[regnum]);
   regcache_raw_read (regcache, regnum, buf);
-  (*val) = extract_signed_integer (buf,
-				   regcache->descr->sizeof_register[regnum]);
+  (*val) = extract_signed_integer
+	     (buf, regcache->descr->sizeof_register[regnum],
+	      gdbarch_byte_order (regcache->descr->gdbarch));
 }
 
 void
@@ -583,8 +584,9 @@ regcache_raw_read_unsigned (struct regca
   gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
   buf = alloca (regcache->descr->sizeof_register[regnum]);
   regcache_raw_read (regcache, regnum, buf);
-  (*val) = extract_unsigned_integer (buf,
-				     regcache->descr->sizeof_register[regnum]);
+  (*val) = extract_unsigned_integer
+	     (buf, regcache->descr->sizeof_register[regnum],
+	      gdbarch_byte_order (regcache->descr->gdbarch));
 }
 
 void
@@ -594,7 +596,8 @@ regcache_raw_write_signed (struct regcac
   gdb_assert (regcache != NULL);
   gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
   buf = alloca (regcache->descr->sizeof_register[regnum]);
-  store_signed_integer (buf, regcache->descr->sizeof_register[regnum], val);
+  store_signed_integer (buf, regcache->descr->sizeof_register[regnum],
+			gdbarch_byte_order (regcache->descr->gdbarch), val);
   regcache_raw_write (regcache, regnum, buf);
 }
 
@@ -606,7 +609,8 @@ regcache_raw_write_unsigned (struct regc
   gdb_assert (regcache != NULL);
   gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
   buf = alloca (regcache->descr->sizeof_register[regnum]);
-  store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum], val);
+  store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum],
+			  gdbarch_byte_order (regcache->descr->gdbarch), val);
   regcache_raw_write (regcache, regnum, buf);
 }
 
@@ -637,8 +641,9 @@ regcache_cooked_read_signed (struct regc
   gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_cooked_registers);
   buf = alloca (regcache->descr->sizeof_register[regnum]);
   regcache_cooked_read (regcache, regnum, buf);
-  (*val) = extract_signed_integer (buf,
-				   regcache->descr->sizeof_register[regnum]);
+  (*val) = extract_signed_integer
+	     (buf, regcache->descr->sizeof_register[regnum],
+	      gdbarch_byte_order (regcache->descr->gdbarch));
 }
 
 void
@@ -650,8 +655,9 @@ regcache_cooked_read_unsigned (struct re
   gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_cooked_registers);
   buf = alloca (regcache->descr->sizeof_register[regnum]);
   regcache_cooked_read (regcache, regnum, buf);
-  (*val) = extract_unsigned_integer (buf,
-				     regcache->descr->sizeof_register[regnum]);
+  (*val) = extract_unsigned_integer
+	     (buf, regcache->descr->sizeof_register[regnum],
+	      gdbarch_byte_order (regcache->descr->gdbarch));
 }
 
 void
@@ -662,7 +668,8 @@ regcache_cooked_write_signed (struct reg
   gdb_assert (regcache != NULL);
   gdb_assert (regnum >=0 && regnum < regcache->descr->nr_cooked_registers);
   buf = alloca (regcache->descr->sizeof_register[regnum]);
-  store_signed_integer (buf, regcache->descr->sizeof_register[regnum], val);
+  store_signed_integer (buf, regcache->descr->sizeof_register[regnum],
+			gdbarch_byte_order (regcache->descr->gdbarch), val);
   regcache_cooked_write (regcache, regnum, buf);
 }
 
@@ -674,7 +681,8 @@ regcache_cooked_write_unsigned (struct r
   gdb_assert (regcache != NULL);
   gdb_assert (regnum >=0 && regnum < regcache->descr->nr_cooked_registers);
   buf = alloca (regcache->descr->sizeof_register[regnum]);
-  store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum], val);
+  store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum],
+			  gdbarch_byte_order (regcache->descr->gdbarch), val);
   regcache_cooked_write (regcache, regnum, buf);
 }
 
Index: gdb-head/gdb/remote-m32r-sdi.c
===================================================================
--- gdb-head.orig/gdb/remote-m32r-sdi.c
+++ gdb-head/gdb/remote-m32r-sdi.c
@@ -917,6 +917,8 @@ static void
 m32r_fetch_register (struct target_ops *ops,
 		     struct regcache *regcache, int regno)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned long val, val2, regid;
 
   if (regno == -1)
@@ -947,7 +949,7 @@ m32r_fetch_register (struct target_ops *
 
       /* We got the number the register holds, but gdb expects to see a
          value in the target byte ordering.  */
-      store_unsigned_integer (buffer, 4, val);
+      store_unsigned_integer (buffer, 4, byte_order, val);
       regcache_raw_supply (regcache, regno, buffer);
     }
   return;
Index: gdb-head/gdb/remote-mips.c
===================================================================
--- gdb-head.orig/gdb/remote-mips.c
+++ gdb-head/gdb/remote-mips.c
@@ -93,7 +93,7 @@ static void mips_prepare_to_store (struc
 static unsigned int mips_fetch_word (CORE_ADDR addr);
 
 static int mips_store_word (CORE_ADDR addr, unsigned int value,
-			    char *old_contents);
+			    int *old_contents);
 
 static int mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
 			     int write, 
@@ -1749,26 +1749,27 @@ mips_wait (struct target_ops *ops,
     {
       struct regcache *regcache = get_current_regcache ();
       struct gdbarch *gdbarch = get_regcache_arch (regcache);
+      enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
       char buf[MAX_REGISTER_SIZE];
 
-      store_unsigned_integer (buf,
-			      register_size
-			        (gdbarch, gdbarch_pc_regnum (gdbarch)), rpc);
+      store_unsigned_integer
+	(buf, register_size (gdbarch, gdbarch_pc_regnum (gdbarch)),
+	 byte_order, rpc);
       regcache_raw_supply (regcache, gdbarch_pc_regnum (gdbarch), buf);
 
       store_unsigned_integer
-	(buf, register_size (gdbarch, gdbarch_pc_regnum (gdbarch)), rfp);
+	(buf, register_size (gdbarch, gdbarch_pc_regnum (gdbarch)),
+	 byte_order, rfp);
       regcache_raw_supply (regcache, 30, buf);	/* This register they are avoiding and so it is unnamed */
 
-      store_unsigned_integer (buf, register_size (gdbarch,
-			      gdbarch_sp_regnum (gdbarch)), rsp);
+      store_unsigned_integer
+	(buf, register_size (gdbarch, gdbarch_sp_regnum (gdbarch)),
+	 byte_order, rsp);
       regcache_raw_supply (regcache, gdbarch_sp_regnum (gdbarch), buf);
 
-      store_unsigned_integer (buf,
-			      register_size (gdbarch,
-					     gdbarch_deprecated_fp_regnum
-					       (gdbarch)),
-			      0);
+      store_unsigned_integer
+	(buf, register_size (gdbarch, gdbarch_deprecated_fp_regnum (gdbarch)),
+	 byte_order, 0);
       regcache_raw_supply (regcache,
 			   gdbarch_deprecated_fp_regnum (gdbarch), buf);
 
@@ -1899,6 +1900,7 @@ mips_fetch_registers (struct target_ops 
 		      struct regcache *regcache, int regno)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned LONGEST val;
   int err;
 
@@ -1943,7 +1945,8 @@ mips_fetch_registers (struct target_ops 
 
     /* We got the number the register holds, but gdb expects to see a
        value in the target byte ordering.  */
-    store_unsigned_integer (buf, register_size (gdbarch, regno), val);
+    store_unsigned_integer (buf, register_size (gdbarch, regno),
+			    byte_order, val);
     regcache_raw_supply (regcache, regno, buf);
   }
 }
@@ -2007,7 +2010,7 @@ mips_fetch_word (CORE_ADDR addr)
 
 /* FIXME! make sure only 32-bit quantities get stored! */
 static int
-mips_store_word (CORE_ADDR addr, unsigned int val, char *old_contents)
+mips_store_word (CORE_ADDR addr, unsigned int val, int *old_contents)
 {
   int err;
   unsigned int oldcontents;
@@ -2023,7 +2026,7 @@ mips_store_word (CORE_ADDR addr, unsigne
 	return errno;
     }
   if (old_contents != NULL)
-    store_unsigned_integer (old_contents, 4, oldcontents);
+    *old_contents = oldcontents;
   return 0;
 }
 
@@ -2040,6 +2043,7 @@ static int
 mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
 		  struct mem_attrib *attrib, struct target_ops *target)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   int i;
   CORE_ADDR addr;
   int count;
@@ -2064,14 +2068,15 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb
       if (addr != memaddr || len < 4)
 	{
 	  /* Need part of initial word -- fetch it.  */
-	  store_unsigned_integer (&buffer[0], 4, mips_fetch_word (addr));
+	  store_unsigned_integer (&buffer[0], 4, byte_order,
+				  mips_fetch_word (addr));
 	}
 
       if (count > 1)
 	{
 	  /* Need part of last word -- fetch it.  FIXME: we do this even
 	     if we don't need it.  */
-	  store_unsigned_integer (&buffer[(count - 1) * 4], 4,
+	  store_unsigned_integer (&buffer[(count - 1) * 4], 4, byte_order,
 				  mips_fetch_word (addr + (count - 1) * 4));
 	}
 
@@ -2083,9 +2088,9 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb
 
       for (i = 0; i < count; i++, addr += 4)
 	{
-	  status = mips_store_word (addr,
-			       extract_unsigned_integer (&buffer[i * 4], 4),
-				    NULL);
+	  int word;
+	  word = extract_unsigned_integer (&buffer[i * 4], 4, byte_order);
+	  status = mips_store_word (addr, word, NULL);
 	  /* Report each kilobyte (we download 32-bit words at a time) */
 	  if (i % 256 == 255)
 	    {
@@ -2107,7 +2112,8 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb
       /* Read all the longwords */
       for (i = 0; i < count; i++, addr += 4)
 	{
-	  store_unsigned_integer (&buffer[i * 4], 4, mips_fetch_word (addr));
+	  store_unsigned_integer (&buffer[i * 4], 4, byte_order,
+				  mips_fetch_word (addr));
 	  QUIT;
 	}
 
Index: gdb-head/gdb/rs6000-aix-tdep.c
===================================================================
--- gdb-head.orig/gdb/rs6000-aix-tdep.c
+++ gdb-head/gdb/rs6000-aix-tdep.c
@@ -194,6 +194,7 @@ rs6000_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 ii;
   int len = 0;
   int argno;			/* current argument number */
@@ -404,7 +405,7 @@ ran_out_of_registers_for_arguments:
   regcache_raw_write_signed (regcache, gdbarch_sp_regnum (gdbarch), sp);
 
   /* Set back chain properly.  */
-  store_unsigned_integer (tmp_buffer, wordsize, saved_sp);
+  store_unsigned_integer (tmp_buffer, wordsize, byte_order, saved_sp);
   write_memory (sp, tmp_buffer, wordsize);
 
   /* Point the inferior function call's return address at the dummy's
@@ -429,6 +430,7 @@ rs6000_return_value (struct gdbarch *gdb
 		     gdb_byte *readbuf, const gdb_byte *writebuf)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[8];
 
   /* The calling convention this function implements assumes the
@@ -500,7 +502,8 @@ rs6000_return_value (struct gdbarch *gdb
 	  /* For reading we don't have to worry about sign extension.  */
 	  regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
 					 &regval);
-	  store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), regval);
+	  store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), byte_order,
+				  regval);
 	}
       if (writebuf)
 	{
@@ -567,6 +570,8 @@ rs6000_convert_from_func_ptr_addr (struc
 				   CORE_ADDR addr,
 				   struct target_ops *targ)
 {
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct obj_section *s;
 
   s = find_pc_section (addr);
@@ -578,7 +583,7 @@ rs6000_convert_from_func_ptr_addr (struc
   if (s && (s->the_bfd_section->flags & SEC_CODE) == 0)
     {
       CORE_ADDR pc =
-        read_memory_unsigned_integer (addr, gdbarch_tdep (gdbarch)->wordsize);
+        read_memory_unsigned_integer (addr, tdep->wordsize, byte_order);
       struct obj_section *pc_section = find_pc_section (pc);
 
       if (pc_section && (pc_section->the_bfd_section->flags & SEC_CODE))
@@ -595,7 +600,9 @@ static CORE_ADDR
 branch_dest (struct frame_info *frame, int opcode, int instr,
 	     CORE_ADDR pc, CORE_ADDR safety)
 {
-  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 dest;
   int immediate;
   int absolute;
@@ -635,7 +642,7 @@ branch_dest (struct frame_info *frame, i
 	  if (dest < AIX_TEXT_SEGMENT_BASE)
 	    dest = read_memory_unsigned_integer
 		     (get_frame_base (frame) + SIG_FRAME_PC_OFFSET,
-		      tdep->wordsize);
+		      tdep->wordsize, byte_order);
 	}
 
       else if (ext_op == 528)	/* br cond to count reg */
@@ -664,6 +671,7 @@ static int
 rs6000_software_single_step (struct frame_info *frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int ii, insn;
   CORE_ADDR loc;
   CORE_ADDR breaks[2];
@@ -671,7 +679,7 @@ rs6000_software_single_step (struct fram
 
   loc = get_frame_pc (frame);
 
-  insn = read_memory_integer (loc, 4);
+  insn = read_memory_integer (loc, 4, byte_order);
 
   if (ppc_deal_with_atomic_sequence (frame))
     return 1;
Index: gdb-head/gdb/rs6000-tdep.c
===================================================================
--- gdb-head.orig/gdb/rs6000-tdep.c
+++ gdb-head/gdb/rs6000-tdep.c
@@ -874,6 +874,7 @@ static int
 rs6000_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   bfd_byte insn_buf[PPC_INSN_SIZE];
   CORE_ADDR scan_pc, func_start, func_end, epilogue_start, epilogue_end;
   unsigned long insn;
@@ -898,7 +899,7 @@ rs6000_in_function_epilogue_p (struct gd
     {
       if (!safe_frame_unwind_memory (curfrm, scan_pc, insn_buf, PPC_INSN_SIZE))
         return 0;
-      insn = extract_unsigned_integer (insn_buf, PPC_INSN_SIZE);
+      insn = extract_unsigned_integer (insn_buf, PPC_INSN_SIZE, byte_order);
       if (insn == 0x4e800020)
         break;
       /* Assume a bctr is a tail call unless it points strictly within
@@ -924,7 +925,7 @@ rs6000_in_function_epilogue_p (struct gd
     {
       if (!safe_frame_unwind_memory (curfrm, scan_pc, insn_buf, PPC_INSN_SIZE))
         return 0;
-      insn = extract_unsigned_integer (insn_buf, PPC_INSN_SIZE);
+      insn = extract_unsigned_integer (insn_buf, PPC_INSN_SIZE, byte_order);
       if (insn_changes_sp_or_jumps (insn))
         return 1;
     }
@@ -971,10 +972,11 @@ ppc_displaced_step_fixup (struct gdbarch
 			  CORE_ADDR from, CORE_ADDR to,
 			  struct regcache *regs)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   /* Since we use simple_displaced_step_copy_insn, our closure is a
      copy of the instruction.  */
   ULONGEST insn  = extract_unsigned_integer ((gdb_byte *) closure,
-					      PPC_INSN_SIZE);
+					      PPC_INSN_SIZE, byte_order);
   ULONGEST opcode = 0;
   /* Offset for non PC-relative instructions.  */
   LONGEST offset = PPC_INSN_SIZE;
@@ -1072,11 +1074,12 @@ int 
 ppc_deal_with_atomic_sequence (struct frame_info *frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR pc = get_frame_pc (frame);
   CORE_ADDR breaks[2] = {-1, -1};
   CORE_ADDR loc = pc;
   CORE_ADDR closing_insn; /* Instruction that closes the atomic sequence.  */
-  int insn = read_memory_integer (loc, PPC_INSN_SIZE);
+  int insn = read_memory_integer (loc, PPC_INSN_SIZE, byte_order);
   int insn_count;
   int index;
   int last_breakpoint = 0; /* Defaults to 0 (no breakpoints placed).  */  
@@ -1094,7 +1097,7 @@ ppc_deal_with_atomic_sequence (struct fr
   for (insn_count = 0; insn_count < atomic_sequence_length; ++insn_count)
     {
       loc += PPC_INSN_SIZE;
-      insn = read_memory_integer (loc, PPC_INSN_SIZE);
+      insn = read_memory_integer (loc, PPC_INSN_SIZE, byte_order);
 
       /* Assume that there is at most one conditional branch in the atomic
          sequence.  If a conditional branch is found, put a breakpoint in 
@@ -1129,7 +1132,7 @@ ppc_deal_with_atomic_sequence (struct fr
 
   closing_insn = loc;
   loc += PPC_INSN_SIZE;
-  insn = read_memory_integer (loc, PPC_INSN_SIZE);
+  insn = read_memory_integer (loc, PPC_INSN_SIZE, byte_order);
 
   /* Insert a breakpoint right after the end of the atomic sequence.  */
   breaks[0] = loc;
@@ -1240,7 +1243,7 @@ store_param_on_stack_p (unsigned long op
    they can use to access PIC data using PC-relative offsets.  */
 
 static int
-bl_to_blrl_insn_p (CORE_ADDR pc, int insn)
+bl_to_blrl_insn_p (CORE_ADDR pc, int insn, enum bfd_endian byte_order)
 {
   CORE_ADDR dest;
   int immediate;
@@ -1254,7 +1257,7 @@ bl_to_blrl_insn_p (CORE_ADDR pc, int ins
   else
     dest = pc + immediate;
 
-  dest_insn = read_memory_integer (dest, 4);
+  dest_insn = read_memory_integer (dest, 4, byte_order);
   if ((dest_insn & 0xfc00ffff) == 0x4c000021) /* blrl */
     return 1;
 
@@ -1276,15 +1279,16 @@ bl_to_blrl_insn_p (CORE_ADDR pc, int ins
 #define BL_DISPLACEMENT_MASK 0x03fffffc
 
 static unsigned long
-rs6000_fetch_instruction (const CORE_ADDR pc)
+rs6000_fetch_instruction (struct gdbarch *gdbarch, const CORE_ADDR pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[4];
   unsigned long op;
 
   /* Fetch the instruction and convert it to an integer.  */
   if (target_read_memory (pc, buf, 4))
     return 0;
-  op = extract_unsigned_integer (buf, 4);
+  op = extract_unsigned_integer (buf, 4, byte_order);
 
   return op;
 }
@@ -1295,10 +1299,10 @@ rs6000_fetch_instruction (const CORE_ADD
    instruction immediately past this sequence.  Otherwise, return START_PC.  */
    
 static CORE_ADDR
-rs6000_skip_stack_check (const CORE_ADDR start_pc)
+rs6000_skip_stack_check (struct gdbarch *gdbarch, const CORE_ADDR start_pc)
 {
   CORE_ADDR pc = start_pc;
-  unsigned long op = rs6000_fetch_instruction (pc);
+  unsigned long op = rs6000_fetch_instruction (gdbarch, pc);
 
   /* First possible sequence: A small number of probes.
          stw 0, -<some immediate>(1)
@@ -1310,7 +1314,7 @@ rs6000_skip_stack_check (const CORE_ADDR
       while ((op & 0xffff0000) == 0x90010000)
         {
           pc = pc + 4;
-          op = rs6000_fetch_instruction (pc);
+          op = rs6000_fetch_instruction (gdbarch, pc);
         }
       return pc;
     }
@@ -1336,17 +1340,17 @@ rs6000_skip_stack_check (const CORE_ADDR
 
       /* lis 0,-<some immediate> */
       pc = pc + 4;
-      op = rs6000_fetch_instruction (pc);
+      op = rs6000_fetch_instruction (gdbarch, pc);
       if ((op & 0xffff0000) != 0x3c000000)
         break;
 
       pc = pc + 4;
-      op = rs6000_fetch_instruction (pc);
+      op = rs6000_fetch_instruction (gdbarch, pc);
       /* [possibly ori 0,0,<some immediate>] */
       if ((op & 0xffff0000) == 0x60000000)
         {
           pc = pc + 4;
-          op = rs6000_fetch_instruction (pc);
+          op = rs6000_fetch_instruction (gdbarch, pc);
         }
       /* add 0,12,0 */
       if (op != 0x7c0c0214)
@@ -1354,41 +1358,41 @@ rs6000_skip_stack_check (const CORE_ADDR
 
       /* cmpw 0,12,0 */
       pc = pc + 4;
-      op = rs6000_fetch_instruction (pc);
+      op = rs6000_fetch_instruction (gdbarch, pc);
       if (op != 0x7c0c0000)
         break;
 
       /* beq 0,<disp> */
       pc = pc + 4;
-      op = rs6000_fetch_instruction (pc);
+      op = rs6000_fetch_instruction (gdbarch, pc);
       if ((op & 0xff9f0001) != 0x41820000)
         break;
 
       /* addi 12,12,-<some immediate> */
       pc = pc + 4;
-      op = rs6000_fetch_instruction (pc);
+      op = rs6000_fetch_instruction (gdbarch, pc);
       if ((op & 0xffff0000) != 0x398c0000)
         break;
 
       /* stw 0,0(12) */
       pc = pc + 4;
-      op = rs6000_fetch_instruction (pc);
+      op = rs6000_fetch_instruction (gdbarch, pc);
       if (op != 0x900c0000)
         break;
 
       /* b <disp> */
       pc = pc + 4;
-      op = rs6000_fetch_instruction (pc);
+      op = rs6000_fetch_instruction (gdbarch, pc);
       if ((op & 0xfc000001) != 0x48000000)
         break;
 
       /* [possibly one last probe: stw 0,<some immediate>(12)] */
       pc = pc + 4;
-      op = rs6000_fetch_instruction (pc);
+      op = rs6000_fetch_instruction (gdbarch, pc);
       if ((op & 0xffff0000) == 0x900c0000)
         {
           pc = pc + 4;
-          op = rs6000_fetch_instruction (pc);
+          op = rs6000_fetch_instruction (gdbarch, pc);
         }
 
       /* We found a valid stack-check sequence, return the new PC.  */
@@ -1425,26 +1429,26 @@ rs6000_skip_stack_check (const CORE_ADDR
 
           /* addic 0,0,-<some immediate> */
           pc = pc + 4;
-          op = rs6000_fetch_instruction (pc);
+          op = rs6000_fetch_instruction (gdbarch, pc);
           if ((op & 0xffff0000) != 0x30000000)
             break;
         }
 
       /* lis 12,<some immediate> */
       pc = pc + 4;
-      op = rs6000_fetch_instruction (pc);
+      op = rs6000_fetch_instruction (gdbarch, pc);
       if ((op & 0xffff0000) != 0x3d800000)
         break;
       
       /* lwz 12,<some immediate>(12) */
       pc = pc + 4;
-      op = rs6000_fetch_instruction (pc);
+      op = rs6000_fetch_instruction (gdbarch, pc);
       if ((op & 0xffff0000) != 0x818c0000)
         break;
 
       /* twllt 0,12 */
       pc = pc + 4;
-      op = rs6000_fetch_instruction (pc);
+      op = rs6000_fetch_instruction (gdbarch, pc);
       if ((op & 0xfffffffe) != 0x7c406008)
         break;
 
@@ -1504,6 +1508,7 @@ skip_prologue (struct gdbarch *gdbarch, 
   int r0_contains_arg = 0;
   const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (gdbarch);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   memset (fdata, 0, sizeof (struct rs6000_framedata));
   fdata->saved_gpr = -1;
@@ -1515,7 +1520,7 @@ skip_prologue (struct gdbarch *gdbarch, 
   fdata->nosavedpc = 1;
   fdata->lr_register = -1;
 
-  pc = rs6000_skip_stack_check (pc);
+  pc = rs6000_skip_stack_check (gdbarch, pc);
   if (pc >= lim_pc)
     pc = lim_pc;
 
@@ -1537,7 +1542,7 @@ skip_prologue (struct gdbarch *gdbarch, 
       /* Fetch the instruction and convert it to an integer.  */
       if (target_read_memory (pc, buf, 4))
 	break;
-      op = extract_unsigned_integer (buf, 4);
+      op = extract_unsigned_integer (buf, 4, byte_order);
 
       if ((op & 0xfc1fffff) == 0x7c0802a6)
 	{			/* mflr Rx */
@@ -1709,7 +1714,7 @@ skip_prologue (struct gdbarch *gdbarch, 
 
 	  /* If the return address has already been saved, we can skip
 	     calls to blrl (for PIC).  */
-          if (lr_reg != -1 && bl_to_blrl_insn_p (pc, op))
+          if (lr_reg != -1 && bl_to_blrl_insn_p (pc, op, byte_order))
 	    {
 	      fdata->used_bl = 1;
 	      continue;
@@ -1729,7 +1734,7 @@ skip_prologue (struct gdbarch *gdbarch, 
 		break;
 	    }
 
-	  op = read_memory_integer (pc + 4, 4);
+	  op = read_memory_integer (pc + 4, 4, byte_order);
 
 	  /* At this point, make sure this is not a trampoline
 	     function (a function that simply calls another functions,
@@ -2047,7 +2052,7 @@ skip_prologue (struct gdbarch *gdbarch, 
 
   if ((op & 0xfc000001) == 0x48000001)
     {				/* bl foo, an initializer function? */
-      op = read_memory_integer (pc + 4, 4);
+      op = read_memory_integer (pc + 4, 4, byte_order);
 
       if (op == 0x4def7b82)
 	{			/* cror 0xf, 0xf, 0xf (nop) */
@@ -2112,12 +2117,13 @@ rs6000_skip_prologue (struct gdbarch *gd
 static CORE_ADDR
 rs6000_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;
 
   if (target_read_memory (pc, buf, 4))
     return pc;
-  op = extract_unsigned_integer (buf, 4);
+  op = extract_unsigned_integer (buf, 4, byte_order);
 
   if ((op & BL_MASK) == BL_INSTRUCTION)
     {
@@ -2168,7 +2174,8 @@ rs6000_frame_align (struct gdbarch *gdba
    @FIX code.  */
 
 static int
-rs6000_in_solib_return_trampoline (CORE_ADDR pc, char *name)
+rs6000_in_solib_return_trampoline (struct gdbarch *gdbarch,
+				   CORE_ADDR pc, char *name)
 {
   return name && !strncmp (name, "@FIX", 4);
 }
@@ -2190,7 +2197,9 @@ rs6000_in_solib_return_trampoline (CORE_
 static CORE_ADDR
 rs6000_skip_trampoline_code (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);
   unsigned int ii, op;
   int rel;
   CORE_ADDR solib_target_pc;
@@ -2211,10 +2220,11 @@ rs6000_skip_trampoline_code (struct fram
   /* Check for bigtoc fixup code.  */
   msymbol = lookup_minimal_symbol_by_pc (pc);
   if (msymbol 
-      && rs6000_in_solib_return_trampoline (pc, SYMBOL_LINKAGE_NAME (msymbol)))
+      && rs6000_in_solib_return_trampoline (gdbarch, pc,
+					    SYMBOL_LINKAGE_NAME (msymbol)))
     {
       /* Double-check that the third instruction from PC is relative "b".  */
-      op = read_memory_integer (pc + 8, 4);
+      op = read_memory_integer (pc + 8, 4, byte_order);
       if ((op & 0xfc000003) == 0x48000000)
 	{
 	  /* Extract bits 6-29 as a signed 24-bit relative word address and
@@ -2231,12 +2241,12 @@ rs6000_skip_trampoline_code (struct fram
 
   for (ii = 0; trampoline_code[ii]; ++ii)
     {
-      op = read_memory_integer (pc + (ii * 4), 4);
+      op = read_memory_integer (pc + (ii * 4), 4, byte_order);
       if (op != trampoline_code[ii])
 	return 0;
     }
   ii = get_frame_register_unsigned (frame, 11);	/* r11 holds destination addr   */
-  pc = read_memory_unsigned_integer (ii, tdep->wordsize); /* (r11) value */
+  pc = read_memory_unsigned_integer (ii, tdep->wordsize, byte_order);
   return pc;
 }
 
@@ -3039,6 +3049,7 @@ rs6000_frame_cache (struct frame_info *t
   struct rs6000_frame_cache *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 rs6000_framedata fdata;
   int wordsize = tdep->wordsize;
   CORE_ADDR func, pc;
@@ -3096,7 +3107,8 @@ rs6000_frame_cache (struct frame_info *t
 
   if (!fdata.frameless)
     /* Frameless really means stackless.  */
-    cache->base = read_memory_unsigned_integer (cache->base, wordsize);
+    cache->base
+      = read_memory_unsigned_integer (cache->base, wordsize, byte_order);
 
   trad_frame_set_value (cache->saved_regs,
 			gdbarch_sp_regnum (gdbarch), cache->base);
Index: gdb-head/gdb/s390-tdep.c
===================================================================
--- gdb-head.orig/gdb/s390-tdep.c
+++ gdb-head/gdb/s390-tdep.c
@@ -166,18 +166,19 @@ static void
 s390_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
 			   int regnum, gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST val;
 
   switch (regnum)
     {
     case S390_PC_REGNUM:
       regcache_raw_read_unsigned (regcache, S390_PSWA_REGNUM, &val);
-      store_unsigned_integer (buf, 4, val & 0x7fffffff);
+      store_unsigned_integer (buf, 4, byte_order, val & 0x7fffffff);
       break;
 
     case S390_CC_REGNUM:
       regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &val);
-      store_unsigned_integer (buf, 4, (val >> 12) & 3);
+      store_unsigned_integer (buf, 4, byte_order, (val >> 12) & 3);
       break;
 
     default:
@@ -189,19 +190,20 @@ static void
 s390_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
 			    int regnum, const gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST val, psw;
 
   switch (regnum)
     {
     case S390_PC_REGNUM:
-      val = extract_unsigned_integer (buf, 4);
+      val = extract_unsigned_integer (buf, 4, byte_order);
       regcache_raw_read_unsigned (regcache, S390_PSWA_REGNUM, &psw);
       psw = (psw & 0x80000000) | (val & 0x7fffffff);
       regcache_raw_write_unsigned (regcache, S390_PSWA_REGNUM, psw);
       break;
 
     case S390_CC_REGNUM:
-      val = extract_unsigned_integer (buf, 4);
+      val = extract_unsigned_integer (buf, 4, byte_order);
       regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &psw);
       psw = (psw & ~((ULONGEST)3 << 12)) | ((val & 3) << 12);
       regcache_raw_write_unsigned (regcache, S390_PSWM_REGNUM, psw);
@@ -216,6 +218,7 @@ static void
 s390x_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
 			    int regnum, gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST val;
 
   switch (regnum)
@@ -226,7 +229,7 @@ s390x_pseudo_register_read (struct gdbar
 
     case S390_CC_REGNUM:
       regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &val);
-      store_unsigned_integer (buf, 4, (val >> 44) & 3);
+      store_unsigned_integer (buf, 4, byte_order, (val >> 44) & 3);
       break;
 
     default:
@@ -238,6 +241,7 @@ static void
 s390x_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
 			     int regnum, const gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST val, psw;
 
   switch (regnum)
@@ -247,7 +251,7 @@ s390x_pseudo_register_write (struct gdba
       break;
 
     case S390_CC_REGNUM:
-      val = extract_unsigned_integer (buf, 4);
+      val = extract_unsigned_integer (buf, 4, byte_order);
       regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &psw);
       psw = (psw & ~((ULONGEST)3 << 44)) | ((val & 3) << 44);
       regcache_raw_write_unsigned (regcache, S390_PSWM_REGNUM, psw);
@@ -677,9 +681,10 @@ struct s390_prologue_data {
   /* The stack.  */
   struct pv_area *stack;
 
-  /* The size of a GPR or FPR.  */
+  /* The size and byte-order of a GPR or FPR.  */
   int gpr_size;
   int fpr_size;
+  enum bfd_endian byte_order;
 
   /* The general-purpose registers.  */
   pv_t gpr[S390_NUM_GPRS];
@@ -777,7 +782,8 @@ s390_load (struct s390_prologue_data *da
       if (secp != NULL
           && (bfd_get_section_flags (secp->bfd, secp->the_bfd_section)
               & SEC_READONLY))
-        return pv_constant (read_memory_integer (addr.k, size));
+        return pv_constant (read_memory_integer (addr.k, size,
+						 data->byte_order));
     }
 
   /* Check whether we are accessing one of our save slots.  */
@@ -864,6 +870,7 @@ s390_analyze_prologue (struct gdbarch *g
        (i.e. when running a 32-bit binary under a 64-bit kernel).  */
     data->gpr_size = word_size;
     data->fpr_size = 8;
+    data->byte_order = gdbarch_byte_order (gdbarch);
 
     for (i = 0; i < S390_NUM_GPRS; i++)
       data->gpr[i] = pv_register (S390_R0_REGNUM + i, 0);
@@ -1356,20 +1363,22 @@ s390_backchain_frame_unwind_cache (struc
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   int word_size = gdbarch_ptr_bit (gdbarch) / 8;
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR backchain;
   ULONGEST reg;
   LONGEST sp;
 
   /* Get the backchain.  */
   reg = get_frame_register_unsigned (this_frame, S390_SP_REGNUM);
-  backchain = read_memory_unsigned_integer (reg, word_size);
+  backchain = read_memory_unsigned_integer (reg, word_size, byte_order);
 
   /* A zero backchain terminates the frame chain.  As additional
      sanity check, let's verify that the spill slot for SP in the
      save area pointed to by the backchain in fact links back to
      the save area.  */
   if (backchain != 0
-      && safe_read_memory_integer (backchain + 15*word_size, word_size, &sp)
+      && safe_read_memory_integer (backchain + 15*word_size,
+				   word_size, byte_order, &sp)
       && (CORE_ADDR)sp == backchain)
     {
       /* We don't know which registers were saved, but it will have
@@ -1540,6 +1549,7 @@ s390_sigtramp_frame_unwind_cache (struct
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   int word_size = gdbarch_ptr_bit (gdbarch) / 8;
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct s390_sigtramp_unwind_cache *info;
   ULONGEST this_sp, prev_sp;
   CORE_ADDR next_ra, next_cfa, sigreg_ptr;
@@ -1570,7 +1580,8 @@ s390_sigtramp_frame_unwind_cache (struct
 	pointer to sigregs  */
   else
     {
-      sigreg_ptr = read_memory_unsigned_integer (next_cfa + 8, word_size);
+      sigreg_ptr = read_memory_unsigned_integer (next_cfa + 8,
+						 word_size, byte_order);
     }
 
   /* The sigregs structure looks like this:
@@ -1617,7 +1628,7 @@ s390_sigtramp_frame_unwind_cache (struct
   /* Restore the previous frame's SP.  */
   prev_sp = read_memory_unsigned_integer (
 			info->saved_regs[S390_SP_REGNUM].addr,
-			word_size);
+			word_size, byte_order);
 
   /* Determine our frame base.  */
   info->frame_base = prev_sp + 16*word_size + 32;
@@ -1910,8 +1921,9 @@ s390_function_arg_integer (struct type *
 /* Return ARG, a `SIMPLE_ARG', sign-extended or zero-extended to a full
    word as required for the ABI.  */
 static LONGEST
-extend_simple_arg (struct value *arg)
+extend_simple_arg (struct gdbarch *gdbarch, struct value *arg)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct type *type = value_type (arg);
 
   /* Even structs get passed in the least significant bits of the
@@ -1919,10 +1931,10 @@ extend_simple_arg (struct value *arg)
      an integer, but it does take care of the extension.  */
   if (TYPE_UNSIGNED (type))
     return extract_unsigned_integer (value_contents (arg),
-                                     TYPE_LENGTH (type));
+                                     TYPE_LENGTH (type), byte_order);
   else
     return extract_signed_integer (value_contents (arg),
-                                   TYPE_LENGTH (type));
+                                   TYPE_LENGTH (type), byte_order);
 }
 
 
@@ -1985,6 +1997,7 @@ s390_push_dummy_call (struct gdbarch *gd
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   int word_size = gdbarch_ptr_bit (gdbarch) / 8;
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST orig_sp;
   int i;
 
@@ -2050,7 +2063,8 @@ s390_push_dummy_call (struct gdbarch *gd
 	      }
 	    else
 	      {
-		write_memory_unsigned_integer (starg, word_size, copy_addr[i]);
+		write_memory_unsigned_integer (starg, word_size, byte_order,
+					       copy_addr[i]);
 		starg += word_size;
 	      }
 	  }
@@ -2080,14 +2094,14 @@ s390_push_dummy_call (struct gdbarch *gd
 	      {
 		/* Integer arguments are always extended to word size.  */
 		regcache_cooked_write_signed (regcache, S390_R0_REGNUM + gr,
-					      extend_simple_arg (arg));
+					      extend_simple_arg (gdbarch, arg));
 		gr++;
 	      }
 	    else
 	      {
 		/* Integer arguments are always extended to word size.  */
-		write_memory_signed_integer (starg, word_size,
-                                             extend_simple_arg (arg));
+		write_memory_signed_integer (starg, word_size, byte_order,
+                                             extend_simple_arg (gdbarch, arg));
                 starg += word_size;
 	      }
 	  }
@@ -2182,6 +2196,7 @@ s390_return_value (struct gdbarch *gdbar
 		   struct type *type, struct regcache *regcache,
 		   gdb_byte *out, const gdb_byte *in)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int word_size = gdbarch_ptr_bit (gdbarch) / 8;
   int length = TYPE_LENGTH (type);
   enum return_value_convention rvc = 
@@ -2204,10 +2219,10 @@ s390_return_value (struct gdbarch *gdbar
 	      /* Integer arguments are always extended to word size.  */
 	      if (TYPE_UNSIGNED (type))
 		regcache_cooked_write_unsigned (regcache, S390_R2_REGNUM,
-			extract_unsigned_integer (in, length));
+			extract_unsigned_integer (in, length, byte_order));
 	      else
 		regcache_cooked_write_signed (regcache, S390_R2_REGNUM,
-			extract_signed_integer (in, length));
+			extract_signed_integer (in, length, byte_order));
 	    }
 	  else if (length == 2*word_size)
 	    {
Index: gdb-head/gdb/scm-exp.c
===================================================================
--- gdb-head.orig/gdb/scm-exp.c
+++ gdb-head/gdb/scm-exp.c
@@ -312,7 +312,8 @@ tryagain:
 	  if (!is_scmvalue_type (value_type (val)))
 	    error ("quoted scm form yields non-SCM value");
 	  svalue = extract_signed_integer (value_contents (val),
-					   TYPE_LENGTH (value_type (val)));
+					   TYPE_LENGTH (value_type (val)),
+					   gdbarch_byte_order (parse_gdbarch));
 	  goto handle_immediate;
 	}
       return;
Index: gdb-head/gdb/scm-lang.c
===================================================================
--- gdb-head.orig/gdb/scm-lang.c
+++ gdb-head/gdb/scm-lang.c
@@ -68,11 +68,12 @@ is_scmvalue_type (struct type *type)
    of the 0'th one.  */
 
 LONGEST
-scm_get_field (LONGEST svalue, int index, int size)
+scm_get_field (LONGEST svalue, int index, int size,
+	       enum bfd_endian byte_order)
 {
   gdb_byte buffer[20];
   read_memory (SCM2PTR (svalue) + index * size, buffer, size);
-  return extract_signed_integer (buffer, size);
+  return extract_signed_integer (buffer, size, byte_order);
 }
 
 /* Unpack a value of type TYPE in buffer VALADDR as an integer
@@ -84,7 +85,10 @@ scm_unpack (struct type *type, const gdb
 {
   if (is_scmvalue_type (type))
     {
-      LONGEST svalue = extract_signed_integer (valaddr, TYPE_LENGTH (type));
+      enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
+      LONGEST svalue
+	= extract_signed_integer (valaddr, TYPE_LENGTH (type), byte_order);
+
       if (context == TYPE_CODE_BOOL)
 	{
 	  if (svalue == SCM_BOOL_F)
Index: gdb-head/gdb/scm-lang.h
===================================================================
--- gdb-head.orig/gdb/scm-lang.h
+++ gdb-head/gdb/scm-lang.h
@@ -35,8 +35,8 @@
 #define SCM_LENGTH(x) (((unsigned long)SCM_CAR(x))>>8)
 #define SCM_NCONSP(x) (1 & (int)SCM_CAR(x))
 #define SCM_NECONSP(x) (SCM_NCONSP(x) && (1 != SCM_TYP3(x)))
-#define SCM_CAR(x) scm_get_field (x, 0, SCM_SIZE)
-#define SCM_CDR(x) scm_get_field (x, 1, SCM_SIZE)
+#define SCM_CAR(x) scm_get_field (x, 0, SCM_SIZE, SCM_BYTE_ORDER)
+#define SCM_CDR(x) scm_get_field (x, 1, SCM_SIZE, SCM_BYTE_ORDER)
 #define SCM_VELTS(x) ((SCM *)SCM_CDR(x))
 #define SCM_CLOSCAR(x) (SCM_CAR(x)-scm_tc3_closure)
 #define SCM_CODE(x) SCM_CAR(SCM_CLOSCAR (x))
@@ -52,7 +52,7 @@ extern int scm_val_print (struct type *,
 			  struct ui_file *, int,
 			  const struct value_print_options *);
 
-extern LONGEST scm_get_field (LONGEST, int, int);
+extern LONGEST scm_get_field (LONGEST, int, int, enum bfd_endian);
 
 extern int is_scmvalue_type (struct type *);
 
Index: gdb-head/gdb/scm-valprint.c
===================================================================
--- gdb-head.orig/gdb/scm-valprint.c
+++ gdb-head/gdb/scm-valprint.c
@@ -133,6 +133,7 @@ scm_scmlist_print (struct type *type, LO
 		   const struct value_print_options *options)
 {
 #define SCM_SIZE (TYPE_LENGTH (type))
+#define SCM_BYTE_ORDER (gdbarch_byte_order (get_type_arch (type)))
   unsigned int more = options->print_max;
   if (recurse > 6)
     {
@@ -158,6 +159,7 @@ scm_scmlist_print (struct type *type, LO
       fputs_filtered (" . ", stream);
       scm_scmval_print (type, svalue, stream, recurse + 1, options);
     }
+#undef SCM_BYTE_ORDER
 #undef SCM_SIZE
 }
 
@@ -166,11 +168,13 @@ scm_ipruk (char *hdr, struct type *type,
 	   struct ui_file *stream)
 {
 #define SCM_SIZE (TYPE_LENGTH (type))
+#define SCM_BYTE_ORDER (gdbarch_byte_order (get_type_arch (type)))
   fprintf_filtered (stream, "#<unknown-%s", hdr);
   if (SCM_CELLP (ptr))
     fprintf_filtered (stream, " (0x%lx . 0x%lx) @",
 		      (long) SCM_CAR (ptr), (long) SCM_CDR (ptr));
   fprintf_filtered (stream, " 0x%s>", phex_nz (ptr, SCM_SIZE));
+#undef SCM_BYTE_ORDER
 #undef SCM_SIZE
 }
 
@@ -182,6 +186,7 @@ scm_scmval_print (struct type *type, LON
   struct gdbarch *gdbarch = get_type_arch (type);
 
 #define SCM_SIZE (TYPE_LENGTH (type))
+#define SCM_BYTE_ORDER (gdbarch_byte_order (gdbarch))
 taloop:
   switch (7 & (int) svalue)
     {
@@ -307,13 +312,14 @@ taloop:
 	    int len = SCM_LENGTH (svalue);
 	    int i;
 	    LONGEST elements = SCM_CDR (svalue);
+	    LONGEST val;
 	    fputs_filtered ("#(", stream);
 	    for (i = 0; i < len; ++i)
 	      {
 		if (i > 0)
 		  fputs_filtered (" ", stream);
-		scm_scmval_print (type, scm_get_field (elements, i, SCM_SIZE),
-				  stream, recurse + 1, options);
+		val = scm_get_field (elements, i, SCM_SIZE, SCM_BYTE_ORDER);
+		scm_scmval_print (type, val, stream, recurse + 1, options);
 	      }
 	    fputs_filtered (")", stream);
 	  }
@@ -403,6 +409,7 @@ taloop:
 	}
       break;
     }
+#undef SCM_BYTE_ORDER
 #undef SCM_SIZE
 }
 
@@ -414,7 +421,9 @@ scm_val_print (struct type *type, const 
 {
   if (is_scmvalue_type (type))
     {
-      LONGEST svalue = extract_signed_integer (valaddr, TYPE_LENGTH (type));
+      enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
+      LONGEST svalue
+	= extract_signed_integer (valaddr, TYPE_LENGTH (type), byte_order);
 
       if (scm_inferior_print (type, svalue, stream, recurse, options) >= 0)
 	{
Index: gdb-head/gdb/score-tdep.c
===================================================================
--- gdb-head.orig/gdb/score-tdep.c
+++ gdb-head/gdb/score-tdep.c
@@ -324,6 +324,7 @@ static const gdb_byte *
 score_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
 			  int *lenptr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[SCORE_INSTLEN] = { 0 };
   int ret;
   unsigned int raw;
@@ -333,9 +334,9 @@ score_breakpoint_from_pc (struct gdbarch
       error ("Error: target_read_memory in file:%s, line:%d!",
              __FILE__, __LINE__);
     }
-  raw = extract_unsigned_integer (buf, SCORE_INSTLEN);
+  raw = extract_unsigned_integer (buf, SCORE_INSTLEN, byte_order);
 
-  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
+  if (byte_order == BFD_ENDIAN_BIG)
     {
       if (!(raw & 0x80008000))
         {
@@ -476,6 +477,7 @@ score_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 argnum;
   int argreg;
   int arglen = 0;
@@ -553,7 +555,8 @@ score_push_dummy_call (struct gdbarch *g
       while (arglen > 0)
         {
           int partial_len = arglen < SCORE_REGSIZE ? arglen : SCORE_REGSIZE;
-          ULONGEST regval = extract_unsigned_integer (val, partial_len);
+          ULONGEST regval = extract_unsigned_integer (val, partial_len,
+						      byte_order);
 
           /* The last part of a arg should shift left when
              gdbarch_byte_order is BFD_ENDIAN_BIG.  */
@@ -642,6 +645,7 @@ score_adjust_memblock_ptr (char **memblo
 static inst_t *
 score_fetch_inst (struct gdbarch *gdbarch, CORE_ADDR addr, char *memblock)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   static inst_t inst = { 0, 0 };
   char buf[SCORE_INSTLEN] = { 0 };
   int big;
@@ -664,10 +668,10 @@ score_fetch_inst (struct gdbarch *gdbarc
         }
     }
 
-  inst.raw = extract_unsigned_integer (buf, SCORE_INSTLEN);
+  inst.raw = extract_unsigned_integer (buf, SCORE_INSTLEN, byte_order);
   inst.is15 = !(inst.raw & 0x80008000);
   inst.v = RM_PBITS (inst.raw);
-  big = (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG);
+  big = (byte_order == BFD_ENDIAN_BIG);
   if (inst.is15)
     {
       if (big ^ ((addr & 0x2) == 2))
Index: gdb-head/gdb/sh64-tdep.c
===================================================================
--- gdb-head.orig/gdb/sh64-tdep.c
+++ gdb-head/gdb/sh64-tdep.c
@@ -481,8 +481,10 @@ after_prologue (CORE_ADDR pc)
 }
 
 static CORE_ADDR 
-look_for_args_moves (CORE_ADDR start_pc, int media_mode)
+look_for_args_moves (struct gdbarch *gdbarch,
+		     CORE_ADDR start_pc, int media_mode)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR here, end;
   int w;
   int insn_size = (media_mode ? 4 : 2);
@@ -491,7 +493,8 @@ look_for_args_moves (CORE_ADDR start_pc,
     {
       if (media_mode)
 	{
-	  w = read_memory_integer (UNMAKE_ISA32_ADDR (here), insn_size);
+	  w = read_memory_integer (UNMAKE_ISA32_ADDR (here),
+				   insn_size, byte_order);
 	  here += insn_size;
 	  if (IS_MEDIA_IND_ARG_MOV (w))
 	    {
@@ -500,7 +503,7 @@ look_for_args_moves (CORE_ADDR start_pc,
 		 the SP has been saved, unfortunately.  */
 	 
 	      int next_insn = read_memory_integer (UNMAKE_ISA32_ADDR (here),
-						   insn_size);
+						   insn_size, byte_order);
 	      here += insn_size;
 	      if (IS_MEDIA_MOV_TO_R14 (next_insn))
 		start_pc = here;	  
@@ -515,7 +518,7 @@ look_for_args_moves (CORE_ADDR start_pc,
 	}
       else
 	{
-	  w = read_memory_integer (here, insn_size);
+	  w = read_memory_integer (here, insn_size, byte_order);
 	  w = w & 0xffff;
 	  here += insn_size;
 	  if (IS_COMPACT_IND_ARG_MOV (w))
@@ -524,7 +527,8 @@ look_for_args_moves (CORE_ADDR start_pc,
 		 is where the debug info says it is. This can happen after
 		 the SP has been saved, unfortunately.  */
 	 
-	      int next_insn = 0xffff & read_memory_integer (here, insn_size);
+	      int next_insn = 0xffff & read_memory_integer (here, insn_size,
+							    byte_order);
 	      here += insn_size;
 	      if (IS_COMPACT_MOV_TO_R14 (next_insn))
 		start_pc = here;
@@ -557,11 +561,13 @@ look_for_args_moves (CORE_ADDR start_pc,
 	      /* This must be followed by a JSR @r0 instruction and by
                  a NOP instruction. After these, the prologue is over!  */
 	 
-	      int next_insn = 0xffff & read_memory_integer (here, insn_size);
+	      int next_insn = 0xffff & read_memory_integer (here, insn_size,
+							    byte_order);
 	      here += insn_size;
 	      if (IS_JSR_R0 (next_insn))
 		{
-		  next_insn = 0xffff & read_memory_integer (here, insn_size);
+		  next_insn = 0xffff & read_memory_integer (here, insn_size,
+							    byte_order);
 		  here += insn_size;
 
 		  if (IS_NOP (next_insn))
@@ -577,8 +583,9 @@ look_for_args_moves (CORE_ADDR start_pc,
 }
 
 static CORE_ADDR
-sh64_skip_prologue_hard_way (CORE_ADDR start_pc)
+sh64_skip_prologue_hard_way (struct gdbarch *gdbarch, CORE_ADDR start_pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR here, end;
   int updated_fp = 0;
   int insn_size = 4;
@@ -598,7 +605,8 @@ sh64_skip_prologue_hard_way (CORE_ADDR s
 
       if (media_mode)
 	{
-	  int w = read_memory_integer (UNMAKE_ISA32_ADDR (here), insn_size);
+	  int w = read_memory_integer (UNMAKE_ISA32_ADDR (here),
+				       insn_size, byte_order);
 	  here += insn_size;
 	  if (IS_STQ_R18_R14 (w) || IS_STQ_R18_R15 (w) || IS_STQ_R14_R15 (w)
 	      || IS_STL_R14_R15 (w) || IS_STL_R18_R15 (w)
@@ -617,13 +625,14 @@ sh64_skip_prologue_hard_way (CORE_ADDR s
 		/* Don't bail out yet, we may have arguments stored in
 		   registers here, according to the debug info, so that
 		   gdb can print the frames correctly.  */
-		start_pc = look_for_args_moves (here - insn_size, media_mode);
+		start_pc = look_for_args_moves (gdbarch,
+						here - insn_size, media_mode);
 		break;
 	      }
 	}
       else
 	{
-	  int w = 0xffff & read_memory_integer (here, insn_size);
+	  int w = 0xffff & read_memory_integer (here, insn_size, byte_order);
 	  here += insn_size;
 
 	  if (IS_STS_R0 (w) || IS_STS_PR (w)
@@ -643,7 +652,8 @@ sh64_skip_prologue_hard_way (CORE_ADDR s
 		/* Don't bail out yet, we may have arguments stored in
 		   registers here, according to the debug info, so that
 		   gdb can print the frames correctly.  */
-		start_pc = look_for_args_moves (here - insn_size, media_mode);
+		start_pc = look_for_args_moves (gdbarch,
+						here - insn_size, media_mode);
 		break;
 	      }
 	}
@@ -667,7 +677,7 @@ sh64_skip_prologue (struct gdbarch *gdba
   if (post_prologue_pc != 0)
     return max (pc, post_prologue_pc);
   else
-    return sh64_skip_prologue_hard_way (pc);
+    return sh64_skip_prologue_hard_way (gdbarch, pc);
 }
 
 /* Should call_function allocate stack space for a struct return?  */
@@ -845,6 +855,7 @@ sh64_analyze_prologue (struct gdbarch *g
   int gdb_register_number;
   int register_number;
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   
   cache->sp_offset = 0;
 
@@ -866,13 +877,14 @@ sh64_analyze_prologue (struct gdbarch *g
     {
       insn = read_memory_integer (cache->media_mode ? UNMAKE_ISA32_ADDR (pc)
 						    : pc,
-				  insn_size);
+				  insn_size, byte_order);
 
       if (!cache->media_mode)
 	{
 	  if (IS_STS_PR (insn))
 	    {
-	      int next_insn = read_memory_integer (pc + insn_size, insn_size);
+	      int next_insn = read_memory_integer (pc + insn_size,
+						   insn_size, byte_order);
 	      if (IS_MOV_TO_R15 (next_insn))
 		{
 		  cache->saved_regs[PR_REGNUM] =
@@ -1029,6 +1041,7 @@ sh64_push_dummy_call (struct gdbarch *gd
 		      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 int_argreg;
   int float_argreg;
@@ -1109,7 +1122,8 @@ sh64_push_dummy_call (struct gdbarch *gd
 	      if (int_argreg <= ARGLAST_REGNUM)
 		{			
 		  /* there's room in a register */
-		  regval = extract_unsigned_integer (val, argreg_size);
+		  regval = extract_unsigned_integer (val, argreg_size,
+						     byte_order);
 		  regcache_cooked_write_unsigned (regcache, int_argreg, regval);
 		}
 	      /* Store the value 8 bytes at a time.  This means that
@@ -1197,6 +1211,7 @@ sh64_extract_return_value (struct type *
 			   void *valbuf)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int len = TYPE_LENGTH (type);
 
   if (TYPE_CODE (type) == TYPE_CODE_FLT)
@@ -1587,6 +1602,7 @@ static void
 sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
 			   int reg_nr, gdb_byte *buffer)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int base_regnum;
   int portion;
   int offset = 0;
@@ -1726,17 +1742,17 @@ sh64_pseudo_register_read (struct gdbarc
       /* Get FPSCR into a local buffer */
       regcache_raw_read (regcache, fpscr_base_regnum, temp_buffer);
       /* Get value as an int.  */
-      fpscr_value = extract_unsigned_integer (temp_buffer, 4);
+      fpscr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
       /* Get SR into a local buffer */
       regcache_raw_read (regcache, sr_base_regnum, temp_buffer);
       /* Get value as an int.  */
-      sr_value = extract_unsigned_integer (temp_buffer, 4);
+      sr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
       /* Build the new value.  */
       fpscr_c_part1_value = fpscr_value & 0x3fffd;
       fpscr_c_part2_value = (sr_value & 0x7000) << 6;
       fpscr_c_value = fpscr_c_part1_value | fpscr_c_part2_value;
       /* Store that in out buffer!!! */
-      store_unsigned_integer (buffer, 4, fpscr_c_value);
+      store_unsigned_integer (buffer, 4, byte_order, fpscr_c_value);
       /* FIXME There is surely an endianness gotcha here.  */
     }
 
@@ -1754,6 +1770,7 @@ static void
 sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
 			    int reg_nr, const gdb_byte *buffer)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int base_regnum, portion;
   int offset;
   char temp_buffer[MAX_REGISTER_SIZE];
@@ -1892,7 +1909,7 @@ sh64_pseudo_register_write (struct gdbar
        */
       /* *INDENT-ON* */
       /* Get value as an int.  */
-      fpscr_c_value = extract_unsigned_integer (buffer, 4);
+      fpscr_c_value = extract_unsigned_integer (buffer, 4, byte_order);
 
       /* Build the new values.  */
       fpscr_mask = 0x0003fffd;
@@ -1902,17 +1919,17 @@ sh64_pseudo_register_write (struct gdbar
       sr_value = (fpscr_value & sr_mask) >> 6;
       
       regcache_raw_read (regcache, fpscr_base_regnum, temp_buffer);
-      old_fpscr_value = extract_unsigned_integer (temp_buffer, 4);
+      old_fpscr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
       old_fpscr_value &= 0xfffc0002;
       fpscr_value |= old_fpscr_value;
-      store_unsigned_integer (temp_buffer, 4, fpscr_value);
+      store_unsigned_integer (temp_buffer, 4, byte_order, fpscr_value);
       regcache_raw_write (regcache, fpscr_base_regnum, temp_buffer);
       
       regcache_raw_read (regcache, sr_base_regnum, temp_buffer);
-      old_sr_value = extract_unsigned_integer (temp_buffer, 4);
+      old_sr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
       old_sr_value &= 0xffff8fff;
       sr_value |= old_sr_value;
-      store_unsigned_integer (temp_buffer, 4, sr_value);
+      store_unsigned_integer (temp_buffer, 4, byte_order, sr_value);
       regcache_raw_write (regcache, sr_base_regnum, temp_buffer);
     }
 
@@ -2321,6 +2338,7 @@ sh64_frame_prev_register (struct frame_i
 {
   struct sh64_frame_cache *cache = sh64_frame_cache (this_frame, this_cache);
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   gdb_assert (regnum >= 0);
 
@@ -2339,7 +2357,8 @@ sh64_frame_prev_register (struct frame_i
           && (regnum == MEDIA_FP_REGNUM || regnum == PR_REGNUM))
         {
 	  CORE_ADDR val;
-	  val = read_memory_unsigned_integer (cache->saved_regs[regnum], 4);
+	  val = read_memory_unsigned_integer (cache->saved_regs[regnum],
+					      4, byte_order);
 	  return frame_unwind_got_constant (this_frame, regnum, val);
         }
 
Index: gdb-head/gdb/sh-tdep.c
===================================================================
--- gdb-head.orig/gdb/sh-tdep.c
+++ gdb-head/gdb/sh-tdep.c
@@ -520,9 +520,11 @@ sh_breakpoint_from_pc (struct gdbarch *g
 #define IS_ADD_IMM_FP(x) 	(((x) & 0xff00) == 0x7e00)
 
 static CORE_ADDR
-sh_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
+sh_analyze_prologue (struct gdbarch *gdbarch,
+		     CORE_ADDR pc, CORE_ADDR current_pc,
 		     struct sh_frame_cache *cache, ULONGEST fpscr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST inst;
   CORE_ADDR opc;
   int offset;
@@ -536,7 +538,7 @@ sh_analyze_prologue (CORE_ADDR pc, CORE_
   cache->uses_fp = 0;
   for (opc = pc + (2 * 28); pc < opc; pc += 2)
     {
-      inst = read_memory_unsigned_integer (pc, 2);
+      inst = read_memory_unsigned_integer (pc, 2, byte_order);
       /* See where the registers will be saved to */
       if (IS_PUSH (inst))
 	{
@@ -580,7 +582,7 @@ sh_analyze_prologue (CORE_ADDR pc, CORE_
 		  sav_reg = reg;
 		  offset = (inst & 0xff) << 1;
 		  sav_offset =
-		    read_memory_integer ((pc + 4) + offset, 2);
+		    read_memory_integer ((pc + 4) + offset, 2, byte_order);
 		}
 	    }
 	}
@@ -594,7 +596,8 @@ sh_analyze_prologue (CORE_ADDR pc, CORE_
 		  sav_reg = reg;
 		  offset = (inst & 0xff) << 2;
 		  sav_offset =
-		    read_memory_integer (((pc & 0xfffffffc) + 4) + offset, 4);
+		    read_memory_integer (((pc & 0xfffffffc) + 4) + offset,
+					 4, byte_order);
 		}
 	    }
 	}
@@ -609,7 +612,8 @@ sh_analyze_prologue (CORE_ADDR pc, CORE_
 		  sav_offset = GET_SOURCE_REG (inst) << 16;
 		  /* MOVI20 is a 32 bit instruction! */
 		  pc += 2;
-		  sav_offset |= read_memory_unsigned_integer (pc, 2);
+		  sav_offset
+		    |= read_memory_unsigned_integer (pc, 2, byte_order);
 		  /* Now sav_offset contains an unsigned 20 bit value.
 		     It must still get sign extended.  */
 		  if (sav_offset & 0x00080000)
@@ -648,7 +652,7 @@ sh_analyze_prologue (CORE_ADDR pc, CORE_
 	  pc += 2;
 	  for (opc = pc + 12; pc < opc; pc += 2)
 	    {
-	      inst = read_memory_integer (pc, 2);
+	      inst = read_memory_integer (pc, 2, byte_order);
 	      if (IS_MOV_ARG_TO_IND_R14 (inst))
 		{
 		  reg = GET_SOURCE_REG (inst);
@@ -678,7 +682,7 @@ sh_analyze_prologue (CORE_ADDR pc, CORE_
 	     jsr, which will be very confusing.  Most likely the next
 	     instruction is going to be IS_MOV_SP_FP in the delay slot.  If
 	     so, note that before returning the current pc. */
-	  inst = read_memory_integer (pc + 2, 2);
+	  inst = read_memory_integer (pc + 2, 2, byte_order);
 	  if (IS_MOV_SP_FP (inst))
 	    cache->uses_fp = 1;
 	  break;
@@ -741,7 +745,7 @@ sh_skip_prologue (struct gdbarch *gdbarc
     return max (pc, start_pc);
 
   cache.sp_offset = -4;
-  pc = sh_analyze_prologue (start_pc, (CORE_ADDR) -1, &cache, 0);
+  pc = sh_analyze_prologue (gdbarch, start_pc, (CORE_ADDR) -1, &cache, 0);
   if (!cache.uses_fp)
     return start_pc;
 
@@ -1055,6 +1059,7 @@ sh_push_dummy_call_fpu (struct gdbarch *
 			CORE_ADDR sp, int struct_return,
 			CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int stack_offset = 0;
   int argreg = ARG0_REGNUM;
   int flt_argreg = 0;
@@ -1130,7 +1135,7 @@ sh_push_dummy_call_fpu (struct gdbarch *
 	    {
 	      /* Argument goes in a float argument register.  */
 	      reg_size = register_size (gdbarch, flt_argreg);
-	      regval = extract_unsigned_integer (val, reg_size);
+	      regval = extract_unsigned_integer (val, reg_size, byte_order);
 	      /* In little endian mode, float types taking two registers
 	         (doubles on sh4, long doubles on sh2e, sh3e and sh4) must
 		 be stored swapped in the argument registers.  The below
@@ -1145,7 +1150,7 @@ sh_push_dummy_call_fpu (struct gdbarch *
 						  regval);
 		  val += reg_size;
 		  len -= reg_size;
-		  regval = extract_unsigned_integer (val, reg_size);
+		  regval = extract_unsigned_integer (val, reg_size, byte_order);
 		}
 	      regcache_cooked_write_unsigned (regcache, flt_argreg++, regval);
 	    }
@@ -1153,7 +1158,7 @@ sh_push_dummy_call_fpu (struct gdbarch *
 	    {
 	      /* there's room in a register */
 	      reg_size = register_size (gdbarch, argreg);
-	      regval = extract_unsigned_integer (val, reg_size);
+	      regval = extract_unsigned_integer (val, reg_size, byte_order);
 	      regcache_cooked_write_unsigned (regcache, argreg++, regval);
 	    }
 	  /* Store the value one register at a time or in one step on stack.  */
@@ -1167,7 +1172,7 @@ sh_push_dummy_call_fpu (struct gdbarch *
       if (sh_is_renesas_calling_convention (func_type))
 	/* If the function uses the Renesas ABI, subtract another 4 bytes from
 	   the stack and store the struct return address there.  */
-	write_memory_unsigned_integer (sp -= 4, 4, struct_addr);
+	write_memory_unsigned_integer (sp -= 4, 4, byte_order, struct_addr);
       else
 	/* Using the gcc ABI, the "struct return pointer" pseudo-argument has
 	   its own dedicated register.  */
@@ -1194,6 +1199,7 @@ sh_push_dummy_call_nofpu (struct gdbarch
 			  CORE_ADDR sp, int struct_return,
 			  CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int stack_offset = 0;
   int argreg = ARG0_REGNUM;
   int argnum;
@@ -1253,7 +1259,7 @@ sh_push_dummy_call_nofpu (struct gdbarch
 	    {
 	      /* there's room in a register */
 	      reg_size = register_size (gdbarch, argreg);
-	      regval = extract_unsigned_integer (val, reg_size);
+	      regval = extract_unsigned_integer (val, reg_size, byte_order);
 	      regcache_cooked_write_unsigned (regcache, argreg++, regval);
 	    }
 	  /* Store the value reg_size bytes at a time.  This means that things
@@ -1269,7 +1275,7 @@ sh_push_dummy_call_nofpu (struct gdbarch
       if (sh_is_renesas_calling_convention (func_type))
 	/* If the function uses the Renesas ABI, subtract another 4 bytes from
 	   the stack and store the struct return address there.  */
-	write_memory_unsigned_integer (sp -= 4, 4, struct_addr);
+	write_memory_unsigned_integer (sp -= 4, 4, byte_order, struct_addr);
       else
 	/* Using the gcc ABI, the "struct return pointer" pseudo-argument has
 	   its own dedicated register.  */
@@ -1295,6 +1301,8 @@ static void
 sh_extract_return_value_nofpu (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);
   int return_register = R0_REGNUM;
   int offset;
@@ -1304,7 +1312,7 @@ sh_extract_return_value_nofpu (struct ty
       ULONGEST c;
 
       regcache_cooked_read_unsigned (regcache, R0_REGNUM, &c);
-      store_unsigned_integer (valbuf, len, c);
+      store_unsigned_integer (valbuf, len, byte_order, c);
     }
   else if (len == 8)
     {
@@ -1345,12 +1353,14 @@ static void
 sh_store_return_value_nofpu (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)
     {
-      val = extract_unsigned_integer (valbuf, len);
+      val = extract_unsigned_integer (valbuf, len, byte_order);
       regcache_cooked_write_unsigned (regcache, R0_REGNUM, val);
     }
   else
@@ -2504,6 +2514,7 @@ sh_alloc_frame_cache (void)
 static struct sh_frame_cache *
 sh_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct sh_frame_cache *cache;
   CORE_ADDR current_pc;
   int i;
@@ -2529,7 +2540,7 @@ sh_frame_cache (struct frame_info *this_
     {
       ULONGEST fpscr;
       fpscr = get_frame_register_unsigned (this_frame, FPSCR_REGNUM);
-      sh_analyze_prologue (cache->pc, current_pc, cache, fpscr);
+      sh_analyze_prologue (gdbarch, cache->pc, current_pc, cache, fpscr);
     }
 
   if (!cache->uses_fp)
@@ -2542,8 +2553,7 @@ sh_frame_cache (struct frame_info *this_
          frame by looking at the stack pointer.  For truly "frameless"
          functions this might work too.  */
       cache->base = get_frame_register_unsigned
-		    (this_frame,
-		     gdbarch_sp_regnum (get_frame_arch (this_frame)));
+		     (this_frame, gdbarch_sp_regnum (gdbarch));
     }
 
   /* Now that we have the base address for the stack frame we can
@@ -2648,6 +2658,7 @@ static const struct frame_base sh_frame_
 static int
 sh_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR func_addr = 0, func_end = 0;
 
   if (find_pc_partial_function (pc, NULL, &func_addr, &func_end))
@@ -2665,7 +2676,7 @@ sh_in_function_epilogue_p (struct gdbarc
 
       /* First search forward until hitting an rts. */
       while (addr < func_end
-	     && !IS_RTS (read_memory_unsigned_integer (addr, 2)))
+	     && !IS_RTS (read_memory_unsigned_integer (addr, 2, byte_order)))
 	addr += 2;
       if (addr >= func_end)
 	return 0;
@@ -2673,33 +2684,35 @@ sh_in_function_epilogue_p (struct gdbarc
       /* At this point we should find a mov.l @r15+,r14 instruction,
          either before or after the rts.  If not, then the function has
          probably no "normal" epilogue and we bail out here. */
-      inst = read_memory_unsigned_integer (addr - 2, 2);
-      if (IS_RESTORE_FP (read_memory_unsigned_integer (addr - 2, 2)))
+      inst = read_memory_unsigned_integer (addr - 2, 2, byte_order);
+      if (IS_RESTORE_FP (read_memory_unsigned_integer (addr - 2, 2,
+						       byte_order)))
 	addr -= 2;
-      else if (!IS_RESTORE_FP (read_memory_unsigned_integer (addr + 2, 2)))
+      else if (!IS_RESTORE_FP (read_memory_unsigned_integer (addr + 2, 2,
+							     byte_order)))
 	return 0;
 
-      inst = read_memory_unsigned_integer (addr - 2, 2);
+      inst = read_memory_unsigned_integer (addr - 2, 2, byte_order);
 
       /* Step over possible lds.l @r15+,macl. */
       if (IS_MACL_LDS (inst))
 	{
 	  addr -= 2;
-	  inst = read_memory_unsigned_integer (addr - 2, 2);
+	  inst = read_memory_unsigned_integer (addr - 2, 2, byte_order);
 	}
 
       /* Step over possible lds.l @r15+,pr. */
       if (IS_LDS (inst))
 	{
 	  addr -= 2;
-	  inst = read_memory_unsigned_integer (addr - 2, 2);
+	  inst = read_memory_unsigned_integer (addr - 2, 2, byte_order);
 	}
 
       /* Step over possible mov r14,r15. */
       if (IS_MOV_FP_SP (inst))
 	{
 	  addr -= 2;
-	  inst = read_memory_unsigned_integer (addr - 2, 2);
+	  inst = read_memory_unsigned_integer (addr - 2, 2, byte_order);
 	}
 
       /* Now check for FP adjustments, using add #imm,r14 or add rX, r14
@@ -2708,7 +2721,7 @@ sh_in_function_epilogue_p (struct gdbarc
 	     && (IS_ADD_REG_TO_FP (inst) || IS_ADD_IMM_FP (inst)))
 	{
 	  addr -= 2;
-	  inst = read_memory_unsigned_integer (addr - 2, 2);
+	  inst = read_memory_unsigned_integer (addr - 2, 2, byte_order);
 	}
 
       /* On SH2a check if the previous instruction was perhaps a MOVI20.
@@ -2716,7 +2729,8 @@ sh_in_function_epilogue_p (struct gdbarc
       if ((gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_sh2a
            || gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_sh2a_nofpu)
           && addr > func_addr + 6
-	  && IS_MOVI20 (read_memory_unsigned_integer (addr - 4, 2)))
+	  && IS_MOVI20 (read_memory_unsigned_integer (addr - 4, 2,
+						      byte_order)))
 	addr -= 4;
 
       if (pc >= addr)
Index: gdb-head/gdb/solib-frv.c
===================================================================
--- gdb-head.orig/gdb/solib-frv.c
+++ gdb-head/gdb/solib-frv.c
@@ -97,6 +97,7 @@ struct int_elf32_fdpic_loadmap {
 static struct int_elf32_fdpic_loadmap *
 fetch_loadmap (CORE_ADDR ldmaddr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   struct ext_elf32_fdpic_loadmap ext_ldmbuf_partial;
   struct ext_elf32_fdpic_loadmap *ext_ldmbuf;
   struct int_elf32_fdpic_loadmap *int_ldmbuf;
@@ -113,7 +114,8 @@ fetch_loadmap (CORE_ADDR ldmaddr)
 
   /* Extract the version.  */
   version = extract_unsigned_integer (ext_ldmbuf_partial.version,
-                                      sizeof ext_ldmbuf_partial.version);
+                                      sizeof ext_ldmbuf_partial.version,
+				      byte_order);
   if (version != 0)
     {
       /* We only handle version 0.  */
@@ -122,7 +124,8 @@ fetch_loadmap (CORE_ADDR ldmaddr)
 
   /* Extract the number of segments.  */
   nsegs = extract_unsigned_integer (ext_ldmbuf_partial.nsegs,
-                                    sizeof ext_ldmbuf_partial.nsegs);
+                                    sizeof ext_ldmbuf_partial.nsegs,
+				    byte_order);
 
   if (nsegs <= 0)
     return NULL;
@@ -158,13 +161,16 @@ fetch_loadmap (CORE_ADDR ldmaddr)
     {
       int_ldmbuf->segs[seg].addr
 	= extract_unsigned_integer (ext_ldmbuf->segs[seg].addr,
-	                            sizeof (ext_ldmbuf->segs[seg].addr));
+	                            sizeof (ext_ldmbuf->segs[seg].addr),
+				    byte_order);
       int_ldmbuf->segs[seg].p_vaddr
 	= extract_unsigned_integer (ext_ldmbuf->segs[seg].p_vaddr,
-	                            sizeof (ext_ldmbuf->segs[seg].p_vaddr));
+	                            sizeof (ext_ldmbuf->segs[seg].p_vaddr),
+				    byte_order);
       int_ldmbuf->segs[seg].p_memsz
 	= extract_unsigned_integer (ext_ldmbuf->segs[seg].p_memsz,
-	                            sizeof (ext_ldmbuf->segs[seg].p_memsz));
+	                            sizeof (ext_ldmbuf->segs[seg].p_memsz),
+				    byte_order);
     }
 
   xfree (ext_ldmbuf);
@@ -359,6 +365,7 @@ static CORE_ADDR main_lm_addr = 0;
 static CORE_ADDR
 lm_base (void)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   struct minimal_symbol *got_sym;
   CORE_ADDR addr;
   gdb_byte buf[FRV_PTR_SIZE];
@@ -394,7 +401,7 @@ lm_base (void)
 
   if (target_read_memory (addr, buf, sizeof buf) != 0)
     return 0;
-  lm_base_cache = extract_unsigned_integer (buf, sizeof buf);
+  lm_base_cache = extract_unsigned_integer (buf, sizeof buf, byte_order);
 
   if (solib_frv_debug)
     fprintf_unfiltered (gdb_stdlog,
@@ -427,6 +434,7 @@ lm_base (void)
 static struct so_list *
 frv_current_sos (void)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   CORE_ADDR lm_addr, mgot;
   struct so_list *sos_head = NULL;
   struct so_list **sos_next_ptr = &sos_head;
@@ -472,7 +480,8 @@ frv_current_sos (void)
 
       got_addr
 	= extract_unsigned_integer (lm_buf.l_addr.got_value,
-				    sizeof (lm_buf.l_addr.got_value));
+				    sizeof (lm_buf.l_addr.got_value),
+				    byte_order);
       /* If the got_addr is the same as mgotr, then we're looking at the
 	 entry for the main executable.  By convention, we don't include
 	 this in the list of shared objects.  */
@@ -486,7 +495,8 @@ frv_current_sos (void)
 
 	  /* Fetch the load map address.  */
 	  addr = extract_unsigned_integer (lm_buf.l_addr.map,
-					   sizeof lm_buf.l_addr.map);
+					   sizeof lm_buf.l_addr.map,
+					   byte_order);
 	  loadmap = fetch_loadmap (addr);
 	  if (loadmap == NULL)
 	    {
@@ -501,7 +511,8 @@ frv_current_sos (void)
 	  sop->lm_info->lm_addr = lm_addr;
 	  /* Fetch the name.  */
 	  addr = extract_unsigned_integer (lm_buf.l_name,
-					   sizeof (lm_buf.l_name));
+					   sizeof (lm_buf.l_name),
+					   byte_order);
 	  target_read_string (addr, &name_buf, SO_NAME_MAX_PATH_SIZE - 1,
 			      &errcode);
 
@@ -528,7 +539,8 @@ frv_current_sos (void)
 	  main_lm_addr = lm_addr;
 	}
 
-      lm_addr = extract_unsigned_integer (lm_buf.l_next, sizeof (lm_buf.l_next));
+      lm_addr = extract_unsigned_integer (lm_buf.l_next,
+					  sizeof (lm_buf.l_next), byte_order);
     }
 
   enable_break2 ();
@@ -625,6 +637,7 @@ static int enable_break2_done = 0;
 static int
 enable_break2 (void)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   int success = 0;
   char **bkpt_namep;
   asection *interp_sect;
@@ -756,7 +769,7 @@ enable_break2 (void)
 	  warning (_("Unable to fetch contents of _dl_debug_addr (at address %s) from dynamic linker"),
 	           hex_string_custom (addr, 8));
 	}
-      addr = extract_unsigned_integer (addr_buf, sizeof addr_buf);
+      addr = extract_unsigned_integer (addr_buf, sizeof addr_buf, byte_order);
 
       /* Fetch the r_brk field.  It's 8 bytes from the start of
          _dl_debug_addr.  */
@@ -768,7 +781,7 @@ enable_break2 (void)
 	  bfd_close (tmp_bfd);
 	  return 0;
 	}
-      addr = extract_unsigned_integer (addr_buf, sizeof addr_buf);
+      addr = extract_unsigned_integer (addr_buf, sizeof addr_buf, byte_order);
 
       /* Now fetch the function entry point.  */
       if (target_read_memory (addr, addr_buf, sizeof addr_buf) != 0)
@@ -779,7 +792,7 @@ enable_break2 (void)
 	  bfd_close (tmp_bfd);
 	  return 0;
 	}
-      addr = extract_unsigned_integer (addr_buf, sizeof addr_buf);
+      addr = extract_unsigned_integer (addr_buf, sizeof addr_buf, byte_order);
 
       /* We're done with the temporary bfd.  */
       bfd_close (tmp_bfd);
@@ -1127,6 +1140,7 @@ find_canonical_descriptor_in_load_object
   (CORE_ADDR entry_point, CORE_ADDR got_value, char *name, bfd *abfd,
    struct lm_info *lm)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   arelent *rel;
   unsigned int i;
   CORE_ADDR addr = 0;
@@ -1219,18 +1233,20 @@ find_canonical_descriptor_in_load_object
 	  /* Fetch address of candidate descriptor.  */
 	  if (target_read_memory (addr, buf, sizeof buf) != 0)
 	    continue;
-	  addr = extract_unsigned_integer (buf, sizeof buf);
+	  addr = extract_unsigned_integer (buf, sizeof buf, byte_order);
 
 	  /* Check for matching entry point.  */
 	  if (target_read_memory (addr, buf, sizeof buf) != 0)
 	    continue;
-	  if (extract_unsigned_integer (buf, sizeof buf) != entry_point)
+	  if (extract_unsigned_integer (buf, sizeof buf, byte_order)
+	      != entry_point)
 	    continue;
 
 	  /* Check for matching got value.  */
 	  if (target_read_memory (addr + 4, buf, sizeof buf) != 0)
 	    continue;
-	  if (extract_unsigned_integer (buf, sizeof buf) != got_value)
+	  if (extract_unsigned_integer (buf, sizeof buf, byte_order)
+	      != got_value)
 	    continue;
 
 	  /* Match was successful!  Exit loop.  */
Index: gdb-head/gdb/solib-irix.c
===================================================================
--- gdb-head.orig/gdb/solib-irix.c
+++ gdb-head/gdb/solib-irix.c
@@ -130,9 +130,9 @@ union irix_obj_info
    appropriate type.  Calling extract_signed_integer seems simpler.  */
 
 static CORE_ADDR
-extract_mips_address (void *addr, int len)
+extract_mips_address (void *addr, int len, enum bfd_endian byte_order)
 {
-  return extract_signed_integer (addr, len);
+  return extract_signed_integer (addr, len, byte_order);
 }
 
 /* Fetch and return the link map data associated with ADDR.  Note that
@@ -142,6 +142,7 @@ extract_mips_address (void *addr, int le
 static struct lm_info
 fetch_lm_info (CORE_ADDR addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   struct lm_info li;
   union irix_obj_info buf;
 
@@ -154,24 +155,27 @@ fetch_lm_info (CORE_ADDR addr)
      being at the end of a page or the like.)  */
   read_memory (addr, (char *) &buf, sizeof (buf.ol32));
 
-  if (extract_unsigned_integer (buf.magic.b, sizeof (buf.magic)) != 0xffffffff)
+  if (extract_unsigned_integer (buf.magic.b, sizeof (buf.magic), byte_order)
+      != 0xffffffff)
     {
       /* Use buf.ol32... */
       char obj_buf[432];
       CORE_ADDR obj_addr = extract_mips_address (&buf.ol32.data,
-						 sizeof (buf.ol32.data));
-      li.next = extract_mips_address (&buf.ol32.next, sizeof (buf.ol32.next));
+						 sizeof (buf.ol32.data),
+						 byte_order);
+      li.next = extract_mips_address (&buf.ol32.next,
+				      sizeof (buf.ol32.next), byte_order);
 
       read_memory (obj_addr, obj_buf, sizeof (obj_buf));
 
-      li.pathname_addr = extract_mips_address (&obj_buf[236], 4);
+      li.pathname_addr = extract_mips_address (&obj_buf[236], 4, byte_order);
       li.pathname_len = 0;	/* unknown */
-      li.reloc_offset = extract_mips_address (&obj_buf[196], 4)
-	- extract_mips_address (&obj_buf[248], 4);
+      li.reloc_offset = extract_mips_address (&obj_buf[196], 4, byte_order)
+	- extract_mips_address (&obj_buf[248], 4, byte_order);
 
     }
   else if (extract_unsigned_integer (buf.oi32.oi_size.b,
-				     sizeof (buf.oi32.oi_size))
+				     sizeof (buf.oi32.oi_size), byte_order)
 	   == sizeof (buf.oi32))
     {
       /* Use buf.oi32...  */
@@ -183,19 +187,22 @@ fetch_lm_info (CORE_ADDR addr)
 
       /* Fill in fields using buffer contents.  */
       li.next = extract_mips_address (&buf.oi32.oi_next,
-				      sizeof (buf.oi32.oi_next));
+				      sizeof (buf.oi32.oi_next), byte_order);
       li.reloc_offset = extract_mips_address (&buf.oi32.oi_ehdr,
-					      sizeof (buf.oi32.oi_ehdr))
+					      sizeof (buf.oi32.oi_ehdr),
+					      byte_order)
 	- extract_mips_address (&buf.oi32.oi_orig_ehdr,
-				sizeof (buf.oi32.oi_orig_ehdr));
+				sizeof (buf.oi32.oi_orig_ehdr), byte_order);
       li.pathname_addr = extract_mips_address (&buf.oi32.oi_pathname,
-					       sizeof (buf.oi32.oi_pathname));
+					       sizeof (buf.oi32.oi_pathname),
+					       byte_order);
       li.pathname_len = extract_unsigned_integer (buf.oi32.oi_pathname_len.b,
 						  sizeof (buf.oi32.
-							  oi_pathname_len));
+							  oi_pathname_len),
+						  byte_order);
     }
   else if (extract_unsigned_integer (buf.oi64.oi_size.b,
-				     sizeof (buf.oi64.oi_size))
+				     sizeof (buf.oi64.oi_size), byte_order)
 	   == sizeof (buf.oi64))
     {
       /* Use buf.oi64...  */
@@ -207,16 +214,19 @@ fetch_lm_info (CORE_ADDR addr)
 
       /* Fill in fields using buffer contents.  */
       li.next = extract_mips_address (&buf.oi64.oi_next,
-				      sizeof (buf.oi64.oi_next));
+				      sizeof (buf.oi64.oi_next), byte_order);
       li.reloc_offset = extract_mips_address (&buf.oi64.oi_ehdr,
-					      sizeof (buf.oi64.oi_ehdr))
+					      sizeof (buf.oi64.oi_ehdr),
+					      byte_order)
 	- extract_mips_address (&buf.oi64.oi_orig_ehdr,
-				sizeof (buf.oi64.oi_orig_ehdr));
+				sizeof (buf.oi64.oi_orig_ehdr), byte_order);
       li.pathname_addr = extract_mips_address (&buf.oi64.oi_pathname,
-					       sizeof (buf.oi64.oi_pathname));
+					       sizeof (buf.oi64.oi_pathname),
+					       byte_order);
       li.pathname_len = extract_unsigned_integer (buf.oi64.oi_pathname_len.b,
 						  sizeof (buf.oi64.
-							  oi_pathname_len));
+							  oi_pathname_len),
+						  byte_order);
     }
   else
     {
@@ -494,6 +504,8 @@ irix_solib_create_inferior_hook (void)
 static struct so_list *
 irix_current_sos (void)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+  int addr_size = gdbarch_addr_bit (target_gdbarch) / TARGET_CHAR_BIT;
   CORE_ADDR lma;
   char addr_buf[8];
   struct so_list *head = 0;
@@ -513,12 +525,8 @@ irix_current_sos (void)
 	return 0;
     }
 
-  read_memory (debug_base,
-	       addr_buf,
-	       gdbarch_addr_bit (target_gdbarch) / TARGET_CHAR_BIT);
-  lma = extract_mips_address (addr_buf,
-			      gdbarch_addr_bit (target_gdbarch)
-				/ TARGET_CHAR_BIT);
+  read_memory (debug_base, addr_buf, addr_size);
+  lma = extract_mips_address (addr_buf, addr_size, byte_order);
 
   while (lma)
     {
@@ -603,6 +611,8 @@ irix_current_sos (void)
 static int
 irix_open_symbol_file_object (void *from_ttyp)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+  int addr_size = gdbarch_addr_bit (target_gdbarch) / TARGET_CHAR_BIT;
   CORE_ADDR lma;
   char addr_buf[8];
   struct lm_info lm;
@@ -619,12 +629,8 @@ irix_open_symbol_file_object (void *from
     return 0;			/* failed somehow...  */
 
   /* First link map member should be the executable.  */
-  read_memory (debug_base,
-	       addr_buf,
-	       gdbarch_addr_bit (target_gdbarch) / TARGET_CHAR_BIT);
-  lma = extract_mips_address (addr_buf,
-			      gdbarch_addr_bit (target_gdbarch)
-				/ TARGET_CHAR_BIT);
+  read_memory (debug_base, addr_buf, addr_size);
+  lma = extract_mips_address (addr_buf, addr_size, byte_order);
   if (lma == 0)
     return 0;			/* failed somehow...  */
 
Index: gdb-head/gdb/solib-som.c
===================================================================
--- gdb-head.orig/gdb/solib-som.c
+++ gdb-head/gdb/solib-som.c
@@ -184,6 +184,7 @@ struct {
 static void
 som_solib_create_inferior_hook (void)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   struct minimal_symbol *msymbol;
   unsigned int dld_flags, status, have_endo;
   asection *shlib_info;
@@ -222,7 +223,7 @@ som_solib_create_inferior_hook (void)
     goto keep_going;
 
   anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
-  store_unsigned_integer (buf, 4, PIDGET (inferior_ptid));
+  store_unsigned_integer (buf, 4, byte_order, PIDGET (inferior_ptid));
   status = target_write_memory (anaddr, buf, 4);
   if (status != 0)
     {
@@ -265,7 +266,7 @@ GDB will be unable to track shl_load/shl
       anaddr = SYMBOL_VALUE (msymbol);
       dld_cache.hook_stub.address = anaddr;
     }
-  store_unsigned_integer (buf, 4, anaddr);
+  store_unsigned_integer (buf, 4, byte_order, anaddr);
 
   msymbol = lookup_minimal_symbol ("__dld_hook", NULL, symfile_objfile);
   if (msymbol == NULL)
@@ -313,7 +314,7 @@ keep_going:
   status = target_read_memory (anaddr, buf, 4);
   if (status != 0)
     error (_("Unable to read __dld_flags."));
-  dld_flags = extract_unsigned_integer (buf, 4);
+  dld_flags = extract_unsigned_integer (buf, 4, byte_order);
 
   /* If the libraries were not mapped private on HP-UX 11 and later, warn
      the user.  On HP-UX 10 and earlier, there is no easy way to specify
@@ -333,7 +334,7 @@ keep_going:
     dld_flags |= DLD_FLAGS_MAPPRIVATE;
   if (have_endo)
     dld_flags |= DLD_FLAGS_HOOKVALID;
-  store_unsigned_integer (buf, 4, dld_flags);
+  store_unsigned_integer (buf, 4, byte_order, dld_flags);
   status = target_write_memory (anaddr, buf, 4);
   if (status != 0)
     error (_("Unable to write __dld_flags."));
@@ -527,6 +528,7 @@ struct dld_list {
 static CORE_ADDR
 link_map_start (void)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   struct minimal_symbol *sym;
   CORE_ADDR addr;
   char buf[4];
@@ -537,7 +539,7 @@ link_map_start (void)
     error (_("Unable to find __dld_flags symbol in object file."));
   addr = SYMBOL_VALUE_ADDRESS (sym);
   read_memory (addr, buf, 4);
-  dld_flags = extract_unsigned_integer (buf, 4);
+  dld_flags = extract_unsigned_integer (buf, 4, byte_order);
   if ((dld_flags & DLD_FLAGS_LISTVALID) == 0)
     error (_("__dld_list is not valid according to __dld_flags."));
 
@@ -558,12 +560,12 @@ link_map_start (void)
     addr = SYMBOL_VALUE_ADDRESS (sym);
 
   read_memory (addr, buf, 4);
-  addr = extract_unsigned_integer (buf, 4);
+  addr = extract_unsigned_integer (buf, 4, byte_order);
   if (addr == 0)
     return 0;
 
   read_memory (addr, buf, 4);
-  return extract_unsigned_integer (buf, 4);
+  return extract_unsigned_integer (buf, 4, byte_order);
 }
 
 /* Does this so's name match the main binary? */
@@ -576,6 +578,7 @@ match_main (const char *name)
 static struct so_list *
 som_current_sos (void)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   CORE_ADDR lm;
   struct so_list *head = 0;
   struct so_list **link_ptr = &head;
@@ -600,7 +603,7 @@ som_current_sos (void)
       read_memory (lm, (gdb_byte *)&dbuf, sizeof (struct dld_list));
 
       addr = extract_unsigned_integer ((gdb_byte *)&dbuf.name,
-				       sizeof (dbuf.name));
+				       sizeof (dbuf.name), byte_order);
       target_read_string (addr, &namebuf, SO_NAME_MAX_PATH_SIZE - 1, &errcode);
       if (errcode != 0)
 	warning (_("Can't read pathname for load map: %s."),
@@ -621,7 +624,8 @@ som_current_sos (void)
 	    lmi->lm_addr = lm;
 
 #define EXTRACT(_fld) \
-  extract_unsigned_integer ((gdb_byte *)&dbuf._fld, sizeof (dbuf._fld));
+  extract_unsigned_integer ((gdb_byte *)&dbuf._fld, \
+			    sizeof (dbuf._fld), byte_order);
 
 	    lmi->text_addr = EXTRACT (text_addr);
 	    tmp = EXTRACT (info);
@@ -636,7 +640,8 @@ som_current_sos (void)
 	    lmi->got_value = EXTRACT (got_value);
 	    tmp = EXTRACT (tsd_start_addr_ptr);
 	    read_memory (tmp, tsdbuf, 4);
-	    lmi->tsd_start_addr = extract_unsigned_integer (tsdbuf, 4);
+	    lmi->tsd_start_addr
+	      = extract_unsigned_integer (tsdbuf, 4, byte_order);
 
 #ifdef SOLIB_SOM_DBG
 	    printf ("\n+ library \"%s\" is described at %s\n", new->so_name,
@@ -690,6 +695,7 @@ som_current_sos (void)
 static int
 som_open_symbol_file_object (void *from_ttyp)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   CORE_ADDR lm, l_name;
   char *filename;
   int errcode;
@@ -709,7 +715,7 @@ som_open_symbol_file_object (void *from_
 
   /* Convert the address to host format.  Assume that the address is
      unsigned.  */
-  l_name = extract_unsigned_integer (buf, 4);
+  l_name = extract_unsigned_integer (buf, 4, byte_order);
 
   if (l_name == 0)
     return 0;		/* No filename.  */
Index: gdb-head/gdb/solib-sunos.c
===================================================================
--- gdb-head.orig/gdb/solib-sunos.c
+++ gdb-head/gdb/solib-sunos.c
@@ -120,7 +120,8 @@ static char *main_name_list[] =
    Assume that the address is unsigned.  */
 
 #define SOLIB_EXTRACT_ADDRESS(MEMBER) \
-	extract_unsigned_integer (&(MEMBER), sizeof (MEMBER))
+	extract_unsigned_integer (&(MEMBER), sizeof (MEMBER), \
+				  gdbarch_byte_order (target_gdbarch))
 
 /* local data declarations */
 
@@ -140,33 +141,36 @@ static CORE_ADDR flag_addr;
 static CORE_ADDR
 LM_ADDR (struct so_list *so)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   int lm_addr_offset = offsetof (struct link_map, lm_addr);
   int lm_addr_size = fieldsize (struct link_map, lm_addr);
 
   return (CORE_ADDR) extract_signed_integer (so->lm_info->lm + lm_addr_offset, 
-					     lm_addr_size);
+					     lm_addr_size, byte_order);
 }
 
 static CORE_ADDR
 LM_NEXT (struct so_list *so)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   int lm_next_offset = offsetof (struct link_map, lm_next);
   int lm_next_size = fieldsize (struct link_map, lm_next);
 
   /* Assume that the address is unsigned.  */
   return extract_unsigned_integer (so->lm_info->lm + lm_next_offset,
-				   lm_next_size);
+				   lm_next_size, byte_order);
 }
 
 static CORE_ADDR
 LM_NAME (struct so_list *so)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   int lm_name_offset = offsetof (struct link_map, lm_name);
   int lm_name_size = fieldsize (struct link_map, lm_name);
 
   /* Assume that the address is unsigned.  */
   return extract_unsigned_integer (so->lm_info->lm + lm_name_offset,
-				   lm_name_size);
+				   lm_name_size, byte_order);
 }
 
 static CORE_ADDR debug_base;	/* Base of dynamic linker structures */
Index: gdb-head/gdb/solib-svr4.c
===================================================================
--- gdb-head.orig/gdb/solib-svr4.c
+++ gdb-head/gdb/solib-svr4.c
@@ -465,6 +465,7 @@ bfd_lookup_symbol (bfd *abfd, char *symn
 static gdb_byte *
 read_program_header (int type, int *p_sect_size, int *p_arch_size)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   CORE_ADDR at_phdr, at_phent, at_phnum;
   int arch_size, sect_size;
   CORE_ADDR sect_addr;
@@ -501,7 +502,8 @@ read_program_header (int type, int *p_se
 				  (gdb_byte *)&phdr, sizeof (phdr)))
 	    return 0;
 
-	  if (extract_unsigned_integer ((gdb_byte *)phdr.p_type, 4) == type)
+	  if (extract_unsigned_integer ((gdb_byte *)phdr.p_type,
+					4, byte_order) == type)
 	    break;
 	}
 
@@ -509,8 +511,10 @@ read_program_header (int type, int *p_se
 	return 0;
 
       /* Retrieve address and size.  */
-      sect_addr = extract_unsigned_integer ((gdb_byte *)phdr.p_vaddr, 4);
-      sect_size = extract_unsigned_integer ((gdb_byte *)phdr.p_memsz, 4);
+      sect_addr = extract_unsigned_integer ((gdb_byte *)phdr.p_vaddr,
+					    4, byte_order);
+      sect_size = extract_unsigned_integer ((gdb_byte *)phdr.p_memsz,
+					    4, byte_order);
     }
   else
     {
@@ -524,7 +528,8 @@ read_program_header (int type, int *p_se
 				  (gdb_byte *)&phdr, sizeof (phdr)))
 	    return 0;
 
-	  if (extract_unsigned_integer ((gdb_byte *)phdr.p_type, 4) == type)
+	  if (extract_unsigned_integer ((gdb_byte *)phdr.p_type,
+					4, byte_order) == type)
 	    break;
 	}
 
@@ -532,8 +537,10 @@ read_program_header (int type, int *p_se
 	return 0;
 
       /* Retrieve address and size.  */
-      sect_addr = extract_unsigned_integer ((gdb_byte *)phdr.p_vaddr, 8);
-      sect_size = extract_unsigned_integer ((gdb_byte *)phdr.p_memsz, 8);
+      sect_addr = extract_unsigned_integer ((gdb_byte *)phdr.p_vaddr,
+					    8, byte_order);
+      sect_size = extract_unsigned_integer ((gdb_byte *)phdr.p_memsz,
+					    8, byte_order);
     }
 
   /* Read in requested program header.  */
@@ -673,6 +680,7 @@ scan_dyntag (int dyntag, bfd *abfd, CORE
 static int
 scan_dyntag_auxv (int dyntag, CORE_ADDR *ptr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   int sect_size, arch_size, step;
   long dyn_tag;
   CORE_ADDR dyn_ptr;
@@ -693,14 +701,18 @@ scan_dyntag_auxv (int dyntag, CORE_ADDR 
     if (arch_size == 32)
       {
 	Elf32_External_Dyn *dynp = (Elf32_External_Dyn *) buf;
-	dyn_tag = extract_unsigned_integer ((gdb_byte *) dynp->d_tag, 4);
-	dyn_ptr = extract_unsigned_integer ((gdb_byte *) dynp->d_un.d_ptr, 4);
+	dyn_tag = extract_unsigned_integer ((gdb_byte *) dynp->d_tag,
+					    4, byte_order);
+	dyn_ptr = extract_unsigned_integer ((gdb_byte *) dynp->d_un.d_ptr,
+					    4, byte_order);
       }
     else
       {
 	Elf64_External_Dyn *dynp = (Elf64_External_Dyn *) buf;
-	dyn_tag = extract_unsigned_integer ((gdb_byte *) dynp->d_tag, 8);
-	dyn_ptr = extract_unsigned_integer ((gdb_byte *) dynp->d_un.d_ptr, 8);
+	dyn_tag = extract_unsigned_integer ((gdb_byte *) dynp->d_tag,
+					    8, byte_order);
+	dyn_ptr = extract_unsigned_integer ((gdb_byte *) dynp->d_un.d_ptr,
+					    8, byte_order);
       }
     if (dyn_tag == DT_NULL)
       break;
@@ -870,13 +882,14 @@ solib_svr4_r_ldsomap (struct svr4_info *
 {
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
   struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   ULONGEST version;
 
   /* Check version, and return zero if `struct r_debug' doesn't have
      the r_ldsomap member.  */
   version
     = read_memory_unsigned_integer (info->debug_base + lmo->r_version_offset,
-				    lmo->r_version_size);
+				    lmo->r_version_size, byte_order);
   if (version < 2 || lmo->r_ldsomap_offset == -1)
     return 0;
 
Index: gdb-head/gdb/sparc64-linux-tdep.c
===================================================================
--- gdb-head.orig/gdb/sparc64-linux-tdep.c
+++ gdb-head/gdb/sparc64-linux-tdep.c
@@ -109,6 +109,9 @@ sparc64_linux_step_trap (struct frame_in
 {
   if (insn == 0x91d0206d)
     {
+      struct gdbarch *gdbarch = get_frame_arch (frame);
+      enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
       ULONGEST sp = get_frame_register_unsigned (frame, SPARC_SP_REGNUM);
       if (sp & 1)
 	sp += BIAS;
@@ -122,7 +125,8 @@ sparc64_linux_step_trap (struct frame_in
 	 register save area.  The saved PC sits at a 136 byte offset
 	 into there.  */
 
-      return read_memory_unsigned_integer (sp + 192 + 128 + 136, 8);
+      return read_memory_unsigned_integer (sp + 192 + 128 + 136,
+					   8, byte_order);
     }
 
   return 0;
Index: gdb-head/gdb/sparc64nbsd-tdep.c
===================================================================
--- gdb-head.orig/gdb/sparc64nbsd-tdep.c
+++ gdb-head/gdb/sparc64nbsd-tdep.c
@@ -92,6 +92,7 @@ struct trad_frame_saved_reg *
 sparc64nbsd_sigcontext_saved_regs (CORE_ADDR sigcontext_addr,
 				   struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct trad_frame_saved_reg *saved_regs;
   CORE_ADDR addr, sp;
   int regnum, delta;
@@ -134,7 +135,7 @@ sparc64nbsd_sigcontext_saved_regs (CORE_
 
   /* Handle StackGhost.  */
   {
-    ULONGEST wcookie = sparc_fetch_wcookie ();
+    ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
 
     if (wcookie != 0)
       {
Index: gdb-head/gdb/sparc64obsd-tdep.c
===================================================================
--- gdb-head.orig/gdb/sparc64obsd-tdep.c
+++ gdb-head/gdb/sparc64obsd-tdep.c
@@ -294,15 +294,17 @@ static void
 sparc64obsd_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 fp, fp_addr = addr + SPARC64OBSD_UTHREAD_FP_OFFSET;
   gdb_byte buf[8];
 
   gdb_assert (regnum >= -1);
 
-  fp = read_memory_unsigned_integer (fp_addr, 8);
+  fp = read_memory_unsigned_integer (fp_addr, 8, byte_order);
   if (regnum == SPARC_SP_REGNUM || regnum == -1)
     {
-      store_unsigned_integer (buf, 8, fp);
+      store_unsigned_integer (buf, 8, byte_order, fp);
       regcache_raw_supply (regcache, SPARC_SP_REGNUM, buf);
 
       if (regnum == SPARC_SP_REGNUM)
@@ -314,15 +316,15 @@ sparc64obsd_supply_uthread (struct regca
     {
       CORE_ADDR i7, i7_addr = addr + SPARC64OBSD_UTHREAD_PC_OFFSET;
 
-      i7 = read_memory_unsigned_integer (i7_addr, 8);
+      i7 = read_memory_unsigned_integer (i7_addr, 8, byte_order);
       if (regnum == SPARC64_PC_REGNUM || regnum == -1)
 	{
-	  store_unsigned_integer (buf, 8, i7 + 8);
+	  store_unsigned_integer (buf, 8, byte_order, i7 + 8);
 	  regcache_raw_supply (regcache, SPARC64_PC_REGNUM, buf);
 	}
       if (regnum == SPARC64_NPC_REGNUM || regnum == -1)
 	{
-	  store_unsigned_integer (buf, 8, i7 + 12);
+	  store_unsigned_integer (buf, 8, byte_order, i7 + 12);
 	  regcache_raw_supply (regcache, SPARC64_NPC_REGNUM, buf);
 	}
 
@@ -337,6 +339,8 @@ static void
 sparc64obsd_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;
   gdb_byte buf[8];
 
@@ -355,15 +359,15 @@ sparc64obsd_collect_uthread(const struct
       CORE_ADDR i7, i7_addr = addr + SPARC64OBSD_UTHREAD_PC_OFFSET;
 
       regcache_raw_collect (regcache, SPARC64_PC_REGNUM, buf);
-      i7 = extract_unsigned_integer (buf, 8) - 8;
-      write_memory_unsigned_integer (i7_addr, 8, i7);
+      i7 = extract_unsigned_integer (buf, 8, byte_order) - 8;
+      write_memory_unsigned_integer (i7_addr, 8, byte_order, i7);
 
       if (regnum == SPARC64_PC_REGNUM)
 	return;
     }
 
   regcache_raw_collect (regcache, SPARC_SP_REGNUM, buf);
-  sp = extract_unsigned_integer (buf, 8);
+  sp = extract_unsigned_integer (buf, 8, byte_order);
   sparc_collect_rwindow (regcache, sp, regnum);
 }
 
Index: gdb-head/gdb/sparc64-tdep.c
===================================================================
--- gdb-head.orig/gdb/sparc64-tdep.c
+++ gdb-head/gdb/sparc64-tdep.c
@@ -320,6 +320,7 @@ sparc64_pseudo_register_read (struct gdb
 			      struct regcache *regcache,
 			      int regnum, gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_assert (regnum >= SPARC64_NUM_REGS);
 
   if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D30_REGNUM)
@@ -370,7 +371,7 @@ sparc64_pseudo_register_read (struct gdb
 	  state = (state >> 32) & ((1 << 8) - 1);
 	  break;
 	}
-      store_unsigned_integer (buf, 8, state);
+      store_unsigned_integer (buf, 8, byte_order, state);
     }
 }
 
@@ -379,6 +380,7 @@ sparc64_pseudo_register_write (struct gd
 			       struct regcache *regcache,
 			       int regnum, const gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_assert (regnum >= SPARC64_NUM_REGS);
 
   if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D30_REGNUM)
@@ -414,7 +416,7 @@ sparc64_pseudo_register_write (struct gd
       ULONGEST state, bits;
 
       regcache_raw_read_unsigned (regcache, SPARC64_STATE_REGNUM, &state);
-      bits = extract_unsigned_integer (buf, 8);
+      bits = extract_unsigned_integer (buf, 8, byte_order);
       switch (regnum)
 	{
 	case SPARC64_CWP_REGNUM:
@@ -486,6 +488,7 @@ static struct value *
 sparc64_frame_prev_register (struct frame_info *this_frame, void **this_cache,
 			     int regnum)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct sparc_frame_cache *cache =
     sparc64_frame_cache (this_frame, this_cache);
 
@@ -500,7 +503,7 @@ sparc64_frame_prev_register (struct fram
 
   /* Handle StackGhost.  */
   {
-    ULONGEST wcookie = sparc_fetch_wcookie ();
+    ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
 
     if (wcookie != 0 && !cache->frameless_p && regnum == SPARC_I7_REGNUM)
       {
@@ -1166,7 +1169,9 @@ sparc64_supply_gregset (const struct spa
 			struct regcache *regcache,
 			int regnum, const void *gregs)
 {
-  int sparc32 = (gdbarch_ptr_bit (get_regcache_arch (regcache)) == 32);
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  int sparc32 = (gdbarch_ptr_bit (gdbarch) == 32);
   const gdb_byte *regs = gregs;
   int i;
 
@@ -1178,10 +1183,10 @@ sparc64_supply_gregset (const struct spa
 	  ULONGEST tstate, psr;
 	  gdb_byte buf[4];
 
-	  tstate = extract_unsigned_integer (regs + offset, 8);
+	  tstate = extract_unsigned_integer (regs + offset, 8, byte_order);
 	  psr = ((tstate & TSTATE_CWP) | PSR_S | ((tstate & TSTATE_ICC) >> 12)
 		 | ((tstate & TSTATE_XCC) >> 20) | PSR_V8PLUS);
-	  store_unsigned_integer (buf, 4, psr);
+	  store_unsigned_integer (buf, 4, byte_order, psr);
 	  regcache_raw_supply (regcache, SPARC32_PSR_REGNUM, buf);
 	}
 
@@ -1280,7 +1285,9 @@ sparc64_collect_gregset (const struct sp
 			 const struct regcache *regcache,
 			 int regnum, void *gregs)
 {
-  int sparc32 = (gdbarch_ptr_bit (get_regcache_arch (regcache)) == 32);
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  int sparc32 = (gdbarch_ptr_bit (gdbarch) == 32);
   gdb_byte *regs = gregs;
   int i;
 
@@ -1292,13 +1299,13 @@ sparc64_collect_gregset (const struct sp
 	  ULONGEST tstate, psr;
 	  gdb_byte buf[8];
 
-	  tstate = extract_unsigned_integer (regs + offset, 8);
+	  tstate = extract_unsigned_integer (regs + offset, 8, byte_order);
 	  regcache_raw_collect (regcache, SPARC32_PSR_REGNUM, buf);
-	  psr = extract_unsigned_integer (buf, 4);
+	  psr = extract_unsigned_integer (buf, 4, byte_order);
 	  tstate |= (psr & PSR_ICC) << 12;
 	  if ((psr & (PSR_VERS | PSR_IMPL)) == PSR_V8PLUS)
 	    tstate |= (psr & PSR_XCC) << 20;
-	  store_unsigned_integer (buf, 8, tstate);
+	  store_unsigned_integer (buf, 8, byte_order, tstate);
 	  memcpy (regs + offset, buf, 8);
 	}
 
Index: gdb-head/gdb/sparc-linux-tdep.c
===================================================================
--- gdb-head.orig/gdb/sparc-linux-tdep.c
+++ gdb-head/gdb/sparc-linux-tdep.c
@@ -139,6 +139,9 @@ sparc32_linux_step_trap (struct frame_in
       /* __NR_rt_sigreturn is 101 and __NR_sigreturn is 216  */
       if (sc_num == 101 || sc_num == 216)
 	{
+	  struct gdbarch *gdbarch = get_frame_arch (frame);
+	  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
 	  ULONGEST sp, pc_offset;
 
 	  sp = get_frame_register_unsigned (frame, SPARC_SP_REGNUM);
@@ -158,7 +161,7 @@ sparc32_linux_step_trap (struct frame_in
 	  if (sc_num == 101)
 	    pc_offset += 128;
 
-	  return read_memory_unsigned_integer (sp + pc_offset, 4);
+	  return read_memory_unsigned_integer (sp + pc_offset, 4, byte_order);
 	}
     }
 
Index: gdb-head/gdb/sparcnbsd-tdep.c
===================================================================
--- gdb-head.orig/gdb/sparcnbsd-tdep.c
+++ gdb-head/gdb/sparcnbsd-tdep.c
@@ -99,6 +99,7 @@ sparc32nbsd_pc_in_sigtramp (CORE_ADDR pc
 struct trad_frame_saved_reg *
 sparc32nbsd_sigcontext_saved_regs (struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct trad_frame_saved_reg *saved_regs;
   CORE_ADDR addr, sigcontext_addr;
   int regnum, delta;
@@ -147,7 +148,7 @@ sparc32nbsd_sigcontext_saved_regs (struc
 
   /* Handle StackGhost.  */
   {
-    ULONGEST wcookie = sparc_fetch_wcookie ();
+    ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
 
     if (wcookie != 0)
       {
Index: gdb-head/gdb/sparcobsd-tdep.c
===================================================================
--- gdb-head.orig/gdb/sparcobsd-tdep.c
+++ gdb-head/gdb/sparcobsd-tdep.c
@@ -155,15 +155,17 @@ static void
 sparc32obsd_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 fp, fp_addr = addr + SPARC32OBSD_UTHREAD_FP_OFFSET;
   gdb_byte buf[4];
 
   gdb_assert (regnum >= -1);
 
-  fp = read_memory_unsigned_integer (fp_addr, 4);
+  fp = read_memory_unsigned_integer (fp_addr, 4, byte_order);
   if (regnum == SPARC_SP_REGNUM || regnum == -1)
     {
-      store_unsigned_integer (buf, 4, fp);
+      store_unsigned_integer (buf, 4, byte_order, fp);
       regcache_raw_supply (regcache, SPARC_SP_REGNUM, buf);
 
       if (regnum == SPARC_SP_REGNUM)
@@ -175,15 +177,15 @@ sparc32obsd_supply_uthread (struct regca
     {
       CORE_ADDR i7, i7_addr = addr + SPARC32OBSD_UTHREAD_PC_OFFSET;
 
-      i7 = read_memory_unsigned_integer (i7_addr, 4);
+      i7 = read_memory_unsigned_integer (i7_addr, 4, byte_order);
       if (regnum == SPARC32_PC_REGNUM || regnum == -1)
 	{
-	  store_unsigned_integer (buf, 4, i7 + 8);
+	  store_unsigned_integer (buf, 4, byte_order, i7 + 8);
 	  regcache_raw_supply (regcache, SPARC32_PC_REGNUM, buf);
 	}
       if (regnum == SPARC32_NPC_REGNUM || regnum == -1)
 	{
-	  store_unsigned_integer (buf, 4, i7 + 12);
+	  store_unsigned_integer (buf, 4, byte_order, i7 + 12);
 	  regcache_raw_supply (regcache, SPARC32_NPC_REGNUM, buf);
 	}
 
@@ -198,6 +200,8 @@ static void
 sparc32obsd_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;
   gdb_byte buf[4];
 
@@ -216,15 +220,15 @@ sparc32obsd_collect_uthread(const struct
       CORE_ADDR i7, i7_addr = addr + SPARC32OBSD_UTHREAD_PC_OFFSET;
 
       regcache_raw_collect (regcache, SPARC32_PC_REGNUM, buf);
-      i7 = extract_unsigned_integer (buf, 4) - 8;
-      write_memory_unsigned_integer (i7_addr, 4, i7);
+      i7 = extract_unsigned_integer (buf, 4, byte_order) - 8;
+      write_memory_unsigned_integer (i7_addr, 4, byte_order, i7);
 
       if (regnum == SPARC32_PC_REGNUM)
 	return;
     }
 
   regcache_raw_collect (regcache, SPARC_SP_REGNUM, buf);
-  sp = extract_unsigned_integer (buf, 4);
+  sp = extract_unsigned_integer (buf, 4, byte_order);
   sparc_collect_rwindow (regcache, sp, regnum);
 }
 
Index: gdb-head/gdb/sparc-tdep.c
===================================================================
--- gdb-head.orig/gdb/sparc-tdep.c
+++ gdb-head/gdb/sparc-tdep.c
@@ -152,8 +152,9 @@ sparc_is_unimp_insn (CORE_ADDR pc)
 /* Fetch StackGhost Per-Process XOR cookie.  */
 
 ULONGEST
-sparc_fetch_wcookie (void)
+sparc_fetch_wcookie (struct gdbarch *gdbarch)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct target_ops *ops = &current_target;
   gdb_byte buf[8];
   int len;
@@ -165,7 +166,7 @@ sparc_fetch_wcookie (void)
   /* We should have either an 32-bit or an 64-bit cookie.  */
   gdb_assert (len == 4 || len == 8);
 
-  return extract_unsigned_integer (buf, len);
+  return extract_unsigned_integer (buf, len, byte_order);
 }
 
 
@@ -400,6 +401,8 @@ sparc32_push_dummy_code (struct gdbarch 
 			 CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
 			 struct regcache *regcache)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   *bp_addr = sp - 4;
   *real_pc = funcaddr;
 
@@ -408,7 +411,8 @@ sparc32_push_dummy_code (struct gdbarch 
       gdb_byte buf[4];
 
       /* This is an UNIMP instruction.  */
-      store_unsigned_integer (buf, 4, TYPE_LENGTH (value_type) & 0x1fff);
+      store_unsigned_integer (buf, 4, byte_order,
+			      TYPE_LENGTH (value_type) & 0x1fff);
       write_memory (sp - 8, buf, 4);
       return sp - 8;
     }
@@ -422,6 +426,7 @@ sparc32_store_arguments (struct regcache
 			 int struct_return, CORE_ADDR struct_addr)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   /* Number of words in the "parameter array".  */
   int num_elements = 0;
   int element = 0;
@@ -504,7 +509,7 @@ sparc32_store_arguments (struct regcache
     {
       gdb_byte buf[4];
 
-      store_unsigned_integer (buf, 4, struct_addr);
+      store_unsigned_integer (buf, 4, byte_order, struct_addr);
       write_memory (sp, buf, 4);
     }
 
@@ -954,6 +959,7 @@ static struct value *
 sparc32_frame_prev_register (struct frame_info *this_frame,
 			     void **this_cache, int regnum)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct sparc_frame_cache *cache =
     sparc32_frame_cache (this_frame, this_cache);
 
@@ -974,7 +980,7 @@ sparc32_frame_prev_register (struct fram
 
   /* Handle StackGhost.  */
   {
-    ULONGEST wcookie = sparc_fetch_wcookie ();
+    ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
 
     if (wcookie != 0 && !cache->frameless_p && regnum == SPARC_I7_REGNUM)
       {
@@ -1133,6 +1139,8 @@ sparc32_return_value (struct gdbarch *gd
 		      struct type *type, struct regcache *regcache,
 		      gdb_byte *readbuf, const gdb_byte *writebuf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   /* The psABI says that "...every stack frame reserves the word at
      %fp+64.  If a function returns a structure, union, or
      quad-precision value, this word should hold the address of the
@@ -1149,7 +1157,7 @@ sparc32_return_value (struct gdbarch *gd
 	  CORE_ADDR addr;
 
 	  regcache_cooked_read_unsigned (regcache, SPARC_SP_REGNUM, &sp);
-	  addr = read_memory_unsigned_integer (sp + 64, 4);
+	  addr = read_memory_unsigned_integer (sp + 64, 4, byte_order);
 	  read_memory (addr, readbuf, TYPE_LENGTH (type));
 	}
 
@@ -1448,6 +1456,8 @@ sparc32_gdbarch_init (struct gdbarch_inf
 void
 sparc_supply_rwindow (struct regcache *regcache, CORE_ADDR sp, int regnum)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int offset = 0;
   gdb_byte buf[8];
   int i;
@@ -1466,10 +1476,12 @@ sparc_supply_rwindow (struct regcache *r
 	      /* Handle StackGhost.  */
 	      if (i == SPARC_I7_REGNUM)
 		{
-		  ULONGEST wcookie = sparc_fetch_wcookie ();
-		  ULONGEST i7 = extract_unsigned_integer (buf + offset, 8);
+		  ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
+		  ULONGEST i7;
 
-		  store_unsigned_integer (buf + offset, 8, i7 ^ wcookie);
+		  i7 = extract_unsigned_integer (buf + offset, 8, byte_order);
+		  store_unsigned_integer (buf + offset, 8, byte_order,
+					  i7 ^ wcookie);
 		}
 
 	      regcache_raw_supply (regcache, i, buf);
@@ -1500,10 +1512,12 @@ sparc_supply_rwindow (struct regcache *r
 	      /* Handle StackGhost.  */
 	      if (i == SPARC_I7_REGNUM)
 		{
-		  ULONGEST wcookie = sparc_fetch_wcookie ();
-		  ULONGEST i7 = extract_unsigned_integer (buf + offset, 4);
+		  ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
+		  ULONGEST i7;
 
-		  store_unsigned_integer (buf + offset, 4, i7 ^ wcookie);
+		  i7 = extract_unsigned_integer (buf + offset, 4, byte_order);
+		  store_unsigned_integer (buf + offset, 4, byte_order,
+					  i7 ^ wcookie);
 		}
 
 	      regcache_raw_supply (regcache, i, buf);
@@ -1516,6 +1530,8 @@ void
 sparc_collect_rwindow (const struct regcache *regcache,
 		       CORE_ADDR sp, int regnum)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int offset = 0;
   gdb_byte buf[8];
   int i;
@@ -1534,10 +1550,11 @@ sparc_collect_rwindow (const struct regc
 	      /* Handle StackGhost.  */
 	      if (i == SPARC_I7_REGNUM)
 		{
-		  ULONGEST wcookie = sparc_fetch_wcookie ();
-		  ULONGEST i7 = extract_unsigned_integer (buf + offset, 8);
+		  ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
+		  ULONGEST i7;
 
-		  store_unsigned_integer (buf, 8, i7 ^ wcookie);
+		  i7 = extract_unsigned_integer (buf + offset, 8, byte_order);
+		  store_unsigned_integer (buf, 8, byte_order, i7 ^ wcookie);
 		}
 
 	      target_write_memory (sp + ((i - SPARC_L0_REGNUM) * 8), buf, 8);
@@ -1563,10 +1580,12 @@ sparc_collect_rwindow (const struct regc
 	      /* Handle StackGhost.  */
 	      if (i == SPARC_I7_REGNUM)
 		{
-		  ULONGEST wcookie = sparc_fetch_wcookie ();
-		  ULONGEST i7 = extract_unsigned_integer (buf + offset, 4);
+		  ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
+		  ULONGEST i7;
 
-		  store_unsigned_integer (buf + offset, 4, i7 ^ wcookie);
+		  i7 = extract_unsigned_integer (buf + offset, 4, byte_order);
+		  store_unsigned_integer (buf + offset, 4, byte_order,
+					  i7 ^ wcookie);
 		}
 
 	      target_write_memory (sp + ((i - SPARC_L0_REGNUM) * 4),
Index: gdb-head/gdb/sparc-tdep.h
===================================================================
--- gdb-head.orig/gdb/sparc-tdep.h
+++ gdb-head/gdb/sparc-tdep.h
@@ -157,7 +157,7 @@ struct sparc_frame_cache
 extern unsigned long sparc_fetch_instruction (CORE_ADDR pc);
 
 /* Fetch StackGhost Per-Process XOR cookie.  */
-extern ULONGEST sparc_fetch_wcookie (void);
+extern ULONGEST sparc_fetch_wcookie (struct gdbarch *gdbarch);
 
 extern CORE_ADDR sparc_analyze_prologue (struct gdbarch *gdbarch,
 					 CORE_ADDR pc, CORE_ADDR current_pc,
Index: gdb-head/gdb/spu-linux-nat.c
===================================================================
--- gdb-head.orig/gdb/spu-linux-nat.c
+++ gdb-head/gdb/spu-linux-nat.c
@@ -204,6 +204,7 @@ store_ppc_memory (ULONGEST memaddr, cons
 static int 
 parse_spufs_run (int *fd, ULONGEST *addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   gdb_byte buf[4];
   ULONGEST pc = fetch_ppc_register (32);  /* nip */
 
@@ -211,7 +212,7 @@ parse_spufs_run (int *fd, ULONGEST *addr
   if (fetch_ppc_memory (pc-4, buf, 4) != 0)
     return 0;
   /* It should be a "sc" instruction.  */
-  if (extract_unsigned_integer (buf, 4) != INSTR_SC)
+  if (extract_unsigned_integer (buf, 4, byte_order) != INSTR_SC)
     return 0;
   /* System call number should be NR_spu_run.  */
   if (fetch_ppc_register (0) != NR_spu_run)
@@ -483,8 +484,10 @@ spu_fetch_inferior_registers (struct tar
   /* The ID register holds the spufs file handle.  */
   if (regno == -1 || regno == SPU_ID_REGNUM)
     {
+      struct gdbarch *gdbarch = get_regcache_arch (regcache);
+      enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
       char buf[4];
-      store_unsigned_integer (buf, 4, fd);
+      store_unsigned_integer (buf, 4, byte_order, fd);
       regcache_raw_supply (regcache, SPU_ID_REGNUM, buf);
     }
 
Index: gdb-head/gdb/spu-tdep.c
===================================================================
--- gdb-head.orig/gdb/spu-tdep.c
+++ gdb-head/gdb/spu-tdep.c
@@ -170,6 +170,8 @@ static void
 spu_pseudo_register_read_spu (struct regcache *regcache, const char *regname,
 			      gdb_byte *buf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte reg[32];
   char annex[32];
   ULONGEST id;
@@ -180,7 +182,7 @@ spu_pseudo_register_read_spu (struct reg
   target_read (&current_target, TARGET_OBJECT_SPU, annex,
 	       reg, 0, sizeof reg);
 
-  store_unsigned_integer (buf, 4, strtoulst (reg, NULL, 16));
+  store_unsigned_integer (buf, 4, byte_order, strtoulst (reg, NULL, 16));
 }
 
 static void
@@ -229,6 +231,8 @@ static void
 spu_pseudo_register_write_spu (struct regcache *regcache, const char *regname,
 			       const gdb_byte *buf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte reg[32];
   char annex[32];
   ULONGEST id;
@@ -236,7 +240,7 @@ spu_pseudo_register_write_spu (struct re
   regcache_raw_read_unsigned (regcache, SPU_ID_REGNUM, &id);
   xsnprintf (annex, sizeof annex, "%d/%s", (int) id, regname);
   xsnprintf (reg, sizeof reg, "0x%s",
-	     phex_nz (extract_unsigned_integer (buf, 4), 4));
+	     phex_nz (extract_unsigned_integer (buf, 4, byte_order), 4));
   target_write (&current_target, TARGET_OBJECT_SPU, annex,
 		reg, 0, strlen (reg));
 }
@@ -330,7 +334,9 @@ static CORE_ADDR
 spu_pointer_to_address (struct gdbarch *gdbarch,
 			struct type *type, const gdb_byte *buf)
 {
-  ULONGEST addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  ULONGEST addr
+    = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
   ULONGEST lslr = SPU_LS_SIZE - 1; /* Hard-wired LS size.  */
 
   if (target_has_registers && target_has_stack && target_has_memory)
@@ -530,9 +536,11 @@ struct spu_prologue_data
   };
 
 static CORE_ADDR
-spu_analyze_prologue (CORE_ADDR start_pc, CORE_ADDR end_pc,
+spu_analyze_prologue (struct gdbarch *gdbarch,
+		      CORE_ADDR start_pc, CORE_ADDR end_pc,
                       struct spu_prologue_data *data)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int found_sp = 0;
   int found_fp = 0;
   int found_lr = 0;
@@ -592,7 +600,7 @@ spu_analyze_prologue (CORE_ADDR start_pc
 
       if (target_read_memory (pc, buf, 4))
 	break;
-      insn = extract_unsigned_integer (buf, 4);
+      insn = extract_unsigned_integer (buf, 4, byte_order);
 
       /* AI is the typical instruction to set up a stack frame.
          It is also used to initialize the frame pointer.  */
@@ -706,7 +714,7 @@ static CORE_ADDR
 spu_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   struct spu_prologue_data data;
-  return spu_analyze_prologue (pc, (CORE_ADDR)-1, &data);
+  return spu_analyze_prologue (gdbarch, pc, (CORE_ADDR)-1, &data);
 }
 
 /* Return the frame pointer in use at address PC.  */
@@ -715,7 +723,7 @@ spu_virtual_frame_pointer (struct gdbarc
 			   int *reg, LONGEST *offset)
 {
   struct spu_prologue_data data;
-  spu_analyze_prologue (pc, (CORE_ADDR)-1, &data);
+  spu_analyze_prologue (gdbarch, pc, (CORE_ADDR)-1, &data);
 
   if (data.size != -1 && data.cfa_reg != -1)
     {
@@ -751,6 +759,7 @@ spu_virtual_frame_pointer (struct gdbarc
 static int
 spu_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR scan_pc, func_start, func_end, epilogue_start, epilogue_end;
   bfd_byte buf[4];
   unsigned int insn;
@@ -780,7 +789,7 @@ spu_in_function_epilogue_p (struct gdbar
     {
       if (target_read_memory (scan_pc, buf, 4))
 	return 0;
-      insn = extract_unsigned_integer (buf, 4);
+      insn = extract_unsigned_integer (buf, 4, byte_order);
 
       if (is_branch (insn, &immed, &ra))
 	{
@@ -808,7 +817,7 @@ spu_in_function_epilogue_p (struct gdbar
     {
       if (target_read_memory (scan_pc, buf, 4))
 	return 0;
-      insn = extract_unsigned_integer (buf, 4);
+      insn = extract_unsigned_integer (buf, 4, byte_order);
 
       if (is_branch (insn, &immed, &ra))
 	return 0;
@@ -841,6 +850,8 @@ static struct spu_unwind_cache *
 spu_frame_unwind_cache (struct frame_info *this_frame,
 			void **this_prologue_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct spu_unwind_cache *info;
   struct spu_prologue_data data;
   gdb_byte buf[16];
@@ -863,8 +874,8 @@ spu_frame_unwind_cache (struct frame_inf
       data.size = -1;
     }
   else
-    spu_analyze_prologue (info->func, get_frame_pc (this_frame), &data);
-
+    spu_analyze_prologue (gdbarch, info->func, get_frame_pc (this_frame),
+			  &data);
 
   /* If successful, use prologue analysis data.  */
   if (data.size != -1 && data.cfa_reg != -1)
@@ -874,7 +885,7 @@ spu_frame_unwind_cache (struct frame_inf
 
       /* Determine CFA via unwound CFA_REG plus CFA_OFFSET.  */
       get_frame_register (this_frame, data.cfa_reg, buf);
-      cfa = extract_unsigned_integer (buf, 4) + data.cfa_offset;
+      cfa = extract_unsigned_integer (buf, 4, byte_order) + data.cfa_offset;
 
       /* Call-saved register slots.  */
       for (i = 0; i < SPU_NUM_GPRS; i++)
@@ -897,7 +908,7 @@ spu_frame_unwind_cache (struct frame_inf
 
       /* Get the backchain.  */
       reg = get_frame_register_unsigned (this_frame, SPU_SP_REGNUM);
-      status = safe_read_memory_integer (reg, 4, &backchain);
+      status = safe_read_memory_integer (reg, 4, byte_order, &backchain);
 
       /* A zero backchain terminates the frame chain.  Also, sanity
          check against the local store size limit.  */
@@ -933,12 +944,12 @@ spu_frame_unwind_cache (struct frame_inf
      slot 1 contains the partition number of the overlay section to
      be returned to, and slot 2 contains the return address within
      that section.  Return the latter address in that case.  */
-  if (extract_unsigned_integer (buf + 8, 4) != 0)
+  if (extract_unsigned_integer (buf + 8, 4, byte_order) != 0)
     trad_frame_set_value (info->saved_regs, SPU_PC_REGNUM,
-			  extract_unsigned_integer (buf + 8, 4));
+			  extract_unsigned_integer (buf + 8, 4, byte_order));
   else
     trad_frame_set_value (info->saved_regs, SPU_PC_REGNUM,
-			  extract_unsigned_integer (buf, 4));
+			  extract_unsigned_integer (buf, 4, byte_order));
  
   return info;
 }
@@ -1126,6 +1137,7 @@ spu_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);
   CORE_ADDR sp_delta;
   int i;
   int regnum = SPU_ARG1_REGNUM;
@@ -1134,7 +1146,7 @@ spu_push_dummy_call (struct gdbarch *gdb
 
   /* Set the return address.  */
   memset (buf, 0, sizeof buf);
-  store_unsigned_integer (buf, 4, bp_addr);
+  store_unsigned_integer (buf, 4, byte_order, bp_addr);
   regcache_cooked_write (regcache, SPU_LR_REGNUM, buf);
 
   /* If STRUCT_RETURN is true, then the struct return address (in
@@ -1143,7 +1155,7 @@ spu_push_dummy_call (struct gdbarch *gdb
   if (struct_return)
     {
       memset (buf, 0, sizeof buf);
-      store_unsigned_integer (buf, 4, struct_addr);
+      store_unsigned_integer (buf, 4, byte_order, struct_addr);
       regcache_cooked_write (regcache, regnum++, buf);
     }
 
@@ -1207,11 +1219,11 @@ spu_push_dummy_call (struct gdbarch *gdb
   target_write_memory (sp, buf, 16);
 
   /* Finally, update all slots of the SP register.  */
-  sp_delta = sp - extract_unsigned_integer (buf, 4);
+  sp_delta = sp - extract_unsigned_integer (buf, 4, byte_order);
   for (i = 0; i < 4; i++)
     {
-      CORE_ADDR sp_slot = extract_unsigned_integer (buf + 4*i, 4);
-      store_unsigned_integer (buf + 4*i, 4, sp_slot + sp_delta);
+      CORE_ADDR sp_slot = extract_unsigned_integer (buf + 4*i, 4, byte_order);
+      store_unsigned_integer (buf + 4*i, 4, byte_order, sp_slot + sp_delta);
     }
   regcache_cooked_write (regcache, SPU_RAW_SP_REGNUM, buf);
 
@@ -1289,6 +1301,7 @@ static int
 spu_software_single_step (struct frame_info *frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR pc, next_pc;
   unsigned int insn;
   int offset, reg;
@@ -1298,7 +1311,7 @@ spu_software_single_step (struct frame_i
 
   if (target_read_memory (pc, buf, 4))
     return 1;
-  insn = extract_unsigned_integer (buf, 4);
+  insn = extract_unsigned_integer (buf, 4, byte_order);
 
   /* Next sequential instruction is at PC + 4, except if the current
      instruction is a PPE-assisted call, in which case it is at PC + 8.
@@ -1319,7 +1332,7 @@ spu_software_single_step (struct frame_i
       else if (reg != -1)
 	{
 	  get_frame_register_bytes (frame, reg, 0, 4, buf);
-	  target += extract_unsigned_integer (buf, 4) & -4;
+	  target += extract_unsigned_integer (buf, 4, byte_order) & -4;
 	}
 
       target = target & (SPU_LS_SIZE - 1);
@@ -1336,16 +1349,18 @@ spu_software_single_step (struct frame_i
 static int
 spu_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[4];
   CORE_ADDR jb_addr;
 
   /* Jump buffer is pointed to by the argument register $r3.  */
   get_frame_register_bytes (frame, SPU_ARG1_REGNUM, 0, 4, buf);
-  jb_addr = extract_unsigned_integer (buf, 4);
+  jb_addr = extract_unsigned_integer (buf, 4, byte_order);
   if (target_read_memory (jb_addr, buf, 4))
     return 0;
 
-  *pc = extract_unsigned_integer (buf, 4);
+  *pc = extract_unsigned_integer (buf, 4, byte_order);
   return 1;
 }
 
@@ -1401,6 +1416,8 @@ struct spu_overlay_table
 static struct spu_overlay_table *
 spu_get_overlay_table (struct objfile *objfile)
 {
+  enum bfd_endian byte_order = bfd_big_endian (objfile->obfd)?
+		   BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
   struct minimal_symbol *ovly_table_msym, *ovly_buf_table_msym;
   CORE_ADDR ovly_table_base, ovly_buf_table_base;
   unsigned ovly_table_size, ovly_buf_table_size;
@@ -1436,10 +1453,14 @@ spu_get_overlay_table (struct objfile *o
 
   for (i = 0; i < ovly_table_size / 16; i++)
     {
-      CORE_ADDR vma  = extract_unsigned_integer (ovly_table + 16*i + 0, 4);
-      CORE_ADDR size = extract_unsigned_integer (ovly_table + 16*i + 4, 4);
-      CORE_ADDR pos  = extract_unsigned_integer (ovly_table + 16*i + 8, 4);
-      CORE_ADDR buf  = extract_unsigned_integer (ovly_table + 16*i + 12, 4);
+      CORE_ADDR vma  = extract_unsigned_integer (ovly_table + 16*i + 0,
+						 4, byte_order);
+      CORE_ADDR size = extract_unsigned_integer (ovly_table + 16*i + 4,
+						 4, byte_order);
+      CORE_ADDR pos  = extract_unsigned_integer (ovly_table + 16*i + 8,
+						 4, byte_order);
+      CORE_ADDR buf  = extract_unsigned_integer (ovly_table + 16*i + 12,
+						 4, byte_order);
 
       if (buf == 0 || (buf - 1) * 4 >= ovly_buf_table_size)
 	continue;
@@ -1465,6 +1486,8 @@ spu_get_overlay_table (struct objfile *o
 static void
 spu_overlay_update_osect (struct obj_section *osect)
 {
+  enum bfd_endian byte_order = bfd_big_endian (osect->objfile->obfd)?
+		   BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
   struct spu_overlay_table *ovly_table;
   CORE_ADDR val;
 
@@ -1476,7 +1499,7 @@ spu_overlay_update_osect (struct obj_sec
   if (ovly_table->mapped_ptr == 0)
     return;
 
-  val = read_memory_unsigned_integer (ovly_table->mapped_ptr, 4);
+  val = read_memory_unsigned_integer (ovly_table->mapped_ptr, 4, byte_order);
   osect->ovly_mapped = (val == ovly_table->mapped_val);
 }
 
@@ -1595,6 +1618,8 @@ static void
 info_spu_signal_command (char *args, int from_tty)
 {
   struct frame_info *frame = get_selected_frame (NULL);
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST signal1 = 0;
   ULONGEST signal1_type = 0;
   int signal1_pending = 0;
@@ -1607,7 +1632,7 @@ info_spu_signal_command (char *args, int
   LONGEST len;
   int rc, id;
 
-  if (gdbarch_bfd_arch_info (get_frame_arch (frame))->arch != bfd_arch_spu)
+  if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu)
     error (_("\"info spu\" is only supported on the SPU architecture."));
 
   id = get_frame_register_unsigned (frame, SPU_ID_REGNUM);
@@ -1618,7 +1643,7 @@ info_spu_signal_command (char *args, int
     error (_("Could not read signal1."));
   else if (len == 4)
     {
-      signal1 = extract_unsigned_integer (buf, 4);
+      signal1 = extract_unsigned_integer (buf, 4, byte_order);
       signal1_pending = 1;
     }
     
@@ -1636,7 +1661,7 @@ info_spu_signal_command (char *args, int
     error (_("Could not read signal2."));
   else if (len == 4)
     {
-      signal2 = extract_unsigned_integer (buf, 4);
+      signal2 = extract_unsigned_integer (buf, 4, byte_order);
       signal2_pending = 1;
     }
     
@@ -1686,7 +1711,7 @@ info_spu_signal_command (char *args, int
 }
 
 static void
-info_spu_mailbox_list (gdb_byte *buf, int nr,
+info_spu_mailbox_list (gdb_byte *buf, int nr, enum bfd_endian byte_order,
 		       const char *field, const char *msg)
 {
   struct cleanup *chain;
@@ -1705,7 +1730,7 @@ info_spu_mailbox_list (gdb_byte *buf, in
       struct cleanup *val_chain;
       ULONGEST val;
       val_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "mbox");
-      val = extract_unsigned_integer (buf + 4*i, 4);
+      val = extract_unsigned_integer (buf + 4*i, 4, byte_order);
       ui_out_field_fmt (uiout, field, "0x%s", phex (val, 4));
       do_cleanups (val_chain);
 
@@ -1720,13 +1745,15 @@ static void
 info_spu_mailbox_command (char *args, int from_tty)
 {
   struct frame_info *frame = get_selected_frame (NULL);
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct cleanup *chain;
   char annex[32];
   gdb_byte buf[1024];
   LONGEST len;
   int i, id;
 
-  if (gdbarch_bfd_arch_info (get_frame_arch (frame))->arch != bfd_arch_spu)
+  if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu)
     error (_("\"info spu\" is only supported on the SPU architecture."));
 
   id = get_frame_register_unsigned (frame, SPU_ID_REGNUM);
@@ -1739,7 +1766,8 @@ info_spu_mailbox_command (char *args, in
   if (len < 0)
     error (_("Could not read mbox_info."));
 
-  info_spu_mailbox_list (buf, len / 4, "mbox", "SPU Outbound Mailbox");
+  info_spu_mailbox_list (buf, len / 4, byte_order,
+			 "mbox", "SPU Outbound Mailbox");
 
   xsnprintf (annex, sizeof annex, "%d/ibox_info", id);
   len = target_read (&current_target, TARGET_OBJECT_SPU, annex,
@@ -1747,7 +1775,8 @@ info_spu_mailbox_command (char *args, in
   if (len < 0)
     error (_("Could not read ibox_info."));
 
-  info_spu_mailbox_list (buf, len / 4, "ibox", "SPU Outbound Interrupt Mailbox");
+  info_spu_mailbox_list (buf, len / 4, byte_order,
+			 "ibox", "SPU Outbound Interrupt Mailbox");
 
   xsnprintf (annex, sizeof annex, "%d/wbox_info", id);
   len = target_read (&current_target, TARGET_OBJECT_SPU, annex,
@@ -1755,7 +1784,8 @@ info_spu_mailbox_command (char *args, in
   if (len < 0)
     error (_("Could not read wbox_info."));
 
-  info_spu_mailbox_list (buf, len / 4, "wbox", "SPU Inbound Mailbox");
+  info_spu_mailbox_list (buf, len / 4, byte_order,
+			 "wbox", "SPU Inbound Mailbox");
 
   do_cleanups (chain);
 }
@@ -1768,7 +1798,7 @@ spu_mfc_get_bitfield (ULONGEST word, int
 }
 
 static void
-info_spu_dma_cmdlist (gdb_byte *buf, int nr)
+info_spu_dma_cmdlist (gdb_byte *buf, int nr, enum bfd_endian byte_order)
 {
   static char *spu_mfc_opcode[256] =
     {
@@ -1825,7 +1855,8 @@ info_spu_dma_cmdlist (gdb_byte *buf, int
 	  if (done & (1 << (nr - 1 - j)))
 	    continue;
 
-	  mfc_cq_dw3 = extract_unsigned_integer (buf + 32*j + 24, 8);
+	  mfc_cq_dw3
+	    = extract_unsigned_integer (buf + 32*j + 24,8, byte_order);
 	  if (!spu_mfc_get_bitfield (mfc_cq_dw3, 16, 16))
 	    continue;
 
@@ -1874,9 +1905,12 @@ info_spu_dma_cmdlist (gdb_byte *buf, int
       /* Decode contents of MFC Command Queue Context Save/Restore Registers.
 	 See "Cell Broadband Engine Registers V1.3", section 3.3.2.1.  */
 
-      mfc_cq_dw0 = extract_unsigned_integer (buf + 32*seq[i], 8);
-      mfc_cq_dw1 = extract_unsigned_integer (buf + 32*seq[i] + 8, 8);
-      mfc_cq_dw2 = extract_unsigned_integer (buf + 32*seq[i] + 16, 8);
+      mfc_cq_dw0
+	= extract_unsigned_integer (buf + 32*seq[i], 8, byte_order);
+      mfc_cq_dw1
+	= extract_unsigned_integer (buf + 32*seq[i] + 8, 8, byte_order);
+      mfc_cq_dw2
+	= extract_unsigned_integer (buf + 32*seq[i] + 16, 8, byte_order);
 
       list_lsa = spu_mfc_get_bitfield (mfc_cq_dw0, 0, 14);
       list_size = spu_mfc_get_bitfield (mfc_cq_dw0, 15, 26);
@@ -1947,6 +1981,8 @@ static void
 info_spu_dma_command (char *args, int from_tty)
 {
   struct frame_info *frame = get_selected_frame (NULL);
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST dma_info_type;
   ULONGEST dma_info_mask;
   ULONGEST dma_info_status;
@@ -1969,11 +2005,16 @@ info_spu_dma_command (char *args, int fr
   if (len <= 0)
     error (_("Could not read dma_info."));
 
-  dma_info_type = extract_unsigned_integer (buf, 8);
-  dma_info_mask = extract_unsigned_integer (buf + 8, 8);
-  dma_info_status = extract_unsigned_integer (buf + 16, 8);
-  dma_info_stall_and_notify = extract_unsigned_integer (buf + 24, 8);
-  dma_info_atomic_command_status = extract_unsigned_integer (buf + 32, 8);
+  dma_info_type
+    = extract_unsigned_integer (buf, 8, byte_order);
+  dma_info_mask
+    = extract_unsigned_integer (buf + 8, 8, byte_order);
+  dma_info_status
+    = extract_unsigned_integer (buf + 16, 8, byte_order);
+  dma_info_stall_and_notify
+    = extract_unsigned_integer (buf + 24, 8, byte_order);
+  dma_info_atomic_command_status
+    = extract_unsigned_integer (buf + 32, 8, byte_order);
   
   chain = make_cleanup_ui_out_tuple_begin_end (uiout, "SPUInfoDMA");
 
@@ -2013,7 +2054,7 @@ info_spu_dma_command (char *args, int fr
       printf_filtered ("\n");
     }
 
-  info_spu_dma_cmdlist (buf + 40, 16);
+  info_spu_dma_cmdlist (buf + 40, 16, byte_order);
   do_cleanups (chain);
 }
 
@@ -2021,6 +2062,8 @@ static void
 info_spu_proxydma_command (char *args, int from_tty)
 {
   struct frame_info *frame = get_selected_frame (NULL);
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST dma_info_type;
   ULONGEST dma_info_mask;
   ULONGEST dma_info_status;
@@ -2030,7 +2073,7 @@ info_spu_proxydma_command (char *args, i
   LONGEST len;
   int i, id;
 
-  if (gdbarch_bfd_arch_info (get_frame_arch (frame))->arch != bfd_arch_spu)
+  if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu)
     error (_("\"info spu\" is only supported on the SPU architecture."));
 
   id = get_frame_register_unsigned (frame, SPU_ID_REGNUM);
@@ -2041,9 +2084,9 @@ info_spu_proxydma_command (char *args, i
   if (len <= 0)
     error (_("Could not read proxydma_info."));
 
-  dma_info_type = extract_unsigned_integer (buf, 8);
-  dma_info_mask = extract_unsigned_integer (buf + 8, 8);
-  dma_info_status = extract_unsigned_integer (buf + 16, 8);
+  dma_info_type = extract_unsigned_integer (buf, 8, byte_order);
+  dma_info_mask = extract_unsigned_integer (buf + 8, 8, byte_order);
+  dma_info_status = extract_unsigned_integer (buf + 16, 8, byte_order);
   
   chain = make_cleanup_ui_out_tuple_begin_end (uiout, "SPUInfoProxyDMA");
 
@@ -2075,7 +2118,7 @@ info_spu_proxydma_command (char *args, i
       printf_filtered ("\n");
     }
 
-  info_spu_dma_cmdlist (buf + 24, 8);
+  info_spu_dma_cmdlist (buf + 24, 8, byte_order);
   do_cleanups (chain);
 }
 
Index: gdb-head/gdb/stack.c
===================================================================
--- gdb-head.orig/gdb/stack.c
+++ gdb-head/gdb/stack.c
@@ -164,6 +164,8 @@ static void
 print_frame_nameless_args (struct frame_info *frame, long start, int num,
 			   int first, struct ui_file *stream)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int i;
   CORE_ADDR argsaddr;
   long arg_value;
@@ -174,7 +176,8 @@ print_frame_nameless_args (struct frame_
       argsaddr = get_frame_args_address (frame);
       if (!argsaddr)
 	return;
-      arg_value = read_memory_integer (argsaddr + start, sizeof (int));
+      arg_value = read_memory_integer (argsaddr + start,
+				       sizeof (int), byte_order);
       if (!first)
 	fprintf_filtered (stream, ", ");
       fprintf_filtered (stream, "%ld", arg_value);
@@ -1184,6 +1187,8 @@ frame_info (char *addr_exp, int from_tty
 			       &realnum, NULL);
 	if (!optimized && lval == not_lval)
 	  {
+	    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+	    int sp_size = register_size (gdbarch, gdbarch_sp_regnum (gdbarch));
 	    gdb_byte value[MAX_REGISTER_SIZE];
 	    CORE_ADDR sp;
 	    frame_register_unwind (fi, gdbarch_sp_regnum (gdbarch),
@@ -1192,9 +1197,7 @@ frame_info (char *addr_exp, int from_tty
 	    /* NOTE: cagney/2003-05-22: This is assuming that the
                stack pointer was packed as an unsigned integer.  That
                may or may not be valid.  */
-	    sp = extract_unsigned_integer (value,
-					   register_size (gdbarch,
-					   gdbarch_sp_regnum (gdbarch)));
+	    sp = extract_unsigned_integer (value, sp_size, byte_order);
 	    printf_filtered (" Previous frame's sp is ");
 	    fputs_filtered (paddress (gdbarch, sp), gdb_stdout);
 	    printf_filtered ("\n");
Index: gdb-head/gdb/symfile.c
===================================================================
--- gdb-head.orig/gdb/symfile.c
+++ gdb-head/gdb/symfile.c
@@ -129,7 +129,8 @@ static void overlay_command (char *, int
 
 static void simple_free_overlay_table (void);
 
-static void read_target_long_array (CORE_ADDR, unsigned int *, int, int);
+static void read_target_long_array (CORE_ADDR, unsigned int *, int, int,
+				    enum bfd_endian);
 
 static int simple_read_overlay_table (void);
 
@@ -3750,7 +3751,7 @@ simple_free_overlay_region_table (void)
    Convert to host order.  int LEN is number of ints  */
 static void
 read_target_long_array (CORE_ADDR memaddr, unsigned int *myaddr,
-			int len, int size)
+			int len, int size, enum bfd_endian byte_order)
 {
   /* FIXME (alloca): Not safe if array is very large. */
   gdb_byte *buf = alloca (len * size);
@@ -3758,7 +3759,7 @@ read_target_long_array (CORE_ADDR memadd
 
   read_memory (memaddr, buf, len * size);
   for (i = 0; i < len; i++)
-    myaddr[i] = extract_unsigned_integer (size * i + buf, size);
+    myaddr[i] = extract_unsigned_integer (size * i + buf, size, byte_order);
 }
 
 /* Find and grab a copy of the target _ovly_table
@@ -3769,6 +3770,7 @@ simple_read_overlay_table (void)
   struct minimal_symbol *novlys_msym, *ovly_table_msym;
   struct gdbarch *gdbarch;
   int word_size;
+  enum bfd_endian byte_order;
 
   simple_free_overlay_table ();
   novlys_msym = lookup_minimal_symbol ("_novlys", NULL, NULL);
@@ -3791,14 +3793,16 @@ simple_read_overlay_table (void)
 
   gdbarch = get_objfile_arch (msymbol_objfile (ovly_table_msym));
   word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
+  byte_order = gdbarch_byte_order (gdbarch);
 
-  cache_novlys = read_memory_integer (SYMBOL_VALUE_ADDRESS (novlys_msym), 4);
+  cache_novlys = read_memory_integer (SYMBOL_VALUE_ADDRESS (novlys_msym),
+				      4, byte_order);
   cache_ovly_table
     = (void *) xmalloc (cache_novlys * sizeof (*cache_ovly_table));
   cache_ovly_table_base = SYMBOL_VALUE_ADDRESS (ovly_table_msym);
   read_target_long_array (cache_ovly_table_base,
                           (unsigned int *) cache_ovly_table,
-                          cache_novlys * 4, word_size);
+                          cache_novlys * 4, word_size, byte_order);
 
   return 1;			/* SUCCESS */
 }
@@ -3810,25 +3814,33 @@ static int
 simple_read_overlay_region_table (void)
 {
   struct minimal_symbol *msym;
+  struct gdbarch *gdbarch;
+  int word_size;
+  enum bfd_endian byte_order;
 
   simple_free_overlay_region_table ();
   msym = lookup_minimal_symbol ("_novly_regions", NULL, NULL);
-  if (msym != NULL)
-    cache_novly_regions = read_memory_integer (SYMBOL_VALUE_ADDRESS (msym), 4);
-  else
+  if (msym == NULL)
     return 0;			/* failure */
+
+  gdbarch = get_objfile_arch (msymbol_objfile (msym));
+  word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
+  byte_order = gdbarch_byte_order (gdbarch);
+
+  cache_novly_regions = read_memory_integer (SYMBOL_VALUE_ADDRESS (msym),
+					     4, byte_order);
+
   cache_ovly_region_table = (void *) xmalloc (cache_novly_regions * 12);
   if (cache_ovly_region_table != NULL)
     {
       msym = lookup_minimal_symbol ("_ovly_region_table", NULL, NULL);
       if (msym != NULL)
 	{
-	  struct gdbarch *gdbarch = get_objfile_arch (msymbol_objfile (msym));
-	  int word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
 	  cache_ovly_region_table_base = SYMBOL_VALUE_ADDRESS (msym);
 	  read_target_long_array (cache_ovly_region_table_base,
 				  (unsigned int *) cache_ovly_region_table,
-				  cache_novly_regions * 3, word_size);
+				  cache_novly_regions * 3,
+				  word_size, byte_order);
 	}
       else
 	return 0;		/* failure */
@@ -3855,6 +3867,7 @@ simple_overlay_update_1 (struct obj_sect
   asection *bsect = osect->the_bfd_section;
   struct gdbarch *gdbarch = get_objfile_arch (osect->objfile);
   int word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   size = bfd_get_section_size (osect->the_bfd_section);
   for (i = 0; i < cache_novlys; i++)
@@ -3864,7 +3877,7 @@ simple_overlay_update_1 (struct obj_sect
       {
 	read_target_long_array (cache_ovly_table_base + i * word_size,
 				(unsigned int *) cache_ovly_table[i],
-				4, word_size);
+				4, word_size, byte_order);
 	if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect)
 	    && cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect)
 	    /* && cache_ovly_table[i][SIZE] == size */ )
Index: gdb-head/gdb/target.c
===================================================================
--- gdb-head.orig/gdb/target.c
+++ gdb-head/gdb/target.c
@@ -1832,13 +1832,13 @@ get_target_memory (struct target_ops *op
 
 ULONGEST
 get_target_memory_unsigned (struct target_ops *ops,
-			    CORE_ADDR addr, int len)
+			    CORE_ADDR addr, int len, enum bfd_endian byte_order)
 {
   gdb_byte buf[sizeof (ULONGEST)];
 
   gdb_assert (len <= sizeof (buf));
   get_target_memory (ops, addr, buf, len);
-  return extract_unsigned_integer (buf, len);
+  return extract_unsigned_integer (buf, len, byte_order);
 }
 
 static void
@@ -2796,6 +2796,7 @@ debug_print_register (const char * func,
     fprintf_unfiltered (gdb_stdlog, "(%d)", regno);
   if (regno >= 0 && regno < gdbarch_num_regs (gdbarch))
     {
+      enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
       int i, size = register_size (gdbarch, regno);
       unsigned char buf[MAX_REGISTER_SIZE];
       regcache_raw_collect (regcache, regno, buf);
@@ -2806,7 +2807,7 @@ debug_print_register (const char * func,
 	}
       if (size <= sizeof (LONGEST))
 	{
-	  ULONGEST val = extract_unsigned_integer (buf, size);
+	  ULONGEST val = extract_unsigned_integer (buf, size, byte_order);
 	  fprintf_unfiltered (gdb_stdlog, " %s %s",
 			      core_addr_to_string_nz (val), plongest (val));
 	}
Index: gdb-head/gdb/target.h
===================================================================
--- gdb-head.orig/gdb/target.h
+++ gdb-head/gdb/target.h
@@ -305,7 +305,8 @@ extern char *target_read_stralloc (struc
 extern void get_target_memory (struct target_ops *ops, CORE_ADDR addr,
 			       gdb_byte *buf, LONGEST len);
 extern ULONGEST get_target_memory_unsigned (struct target_ops *ops,
-					    CORE_ADDR addr, int len);
+					    CORE_ADDR addr, int len,
+					    enum bfd_endian byte_order);
 
 struct thread_info;		/* fwd decl for parameter list below: */
 
Index: gdb-head/gdb/tramp-frame.c
===================================================================
--- gdb-head.orig/gdb/tramp-frame.c
+++ gdb-head/gdb/tramp-frame.c
@@ -81,6 +81,8 @@ static CORE_ADDR
 tramp_frame_start (const struct tramp_frame *tramp,
 		   struct frame_info *this_frame, CORE_ADDR pc)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int ti;
   /* Search through the trampoline for one that matches the
      instruction sequence around PC.  */
@@ -98,7 +100,7 @@ tramp_frame_start (const struct tramp_fr
 					 func + i * tramp->insn_size,
 					 buf, tramp->insn_size))
 	    break;
-	  insn = extract_unsigned_integer (buf, tramp->insn_size);
+	  insn = extract_unsigned_integer (buf, tramp->insn_size, byte_order);
 	  if (tramp->insn[i].bytes != (insn & tramp->insn[i].mask))
 	    break;
 	}
Index: gdb-head/gdb/v850-tdep.c
===================================================================
--- gdb-head.orig/gdb/v850-tdep.c
+++ gdb-head/gdb/v850-tdep.c
@@ -453,9 +453,11 @@ v850_is_save_register (int reg)
    prologue.  */
 
 static CORE_ADDR
-v850_analyze_prologue (CORE_ADDR func_addr, CORE_ADDR pc,
+v850_analyze_prologue (struct gdbarch *gdbarch,
+		       CORE_ADDR func_addr, CORE_ADDR pc,
 		       struct v850_frame_cache *pi, ULONGEST ctbp)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR prologue_end, current_pc;
   struct pifsr pifsrs[E_NUM_REGS + 1];
   struct pifsr *pifsr, *pifsr_tmp;
@@ -488,11 +490,11 @@ v850_analyze_prologue (CORE_ADDR func_ad
       int insn;
       int insn2 = -1; /* dummy value */
 
-      insn = read_memory_integer (current_pc, 2);
+      insn = read_memory_integer (current_pc, 2, byte_order);
       current_pc += 2;
       if ((insn & 0x0780) >= 0x0600)	/* Four byte instruction? */
 	{
-	  insn2 = read_memory_integer (current_pc, 2);
+	  insn2 = read_memory_integer (current_pc, 2, byte_order);
 	  current_pc += 2;
 	}
 
@@ -520,7 +522,8 @@ v850_analyze_prologue (CORE_ADDR func_ad
 	  save_pc = current_pc;
 	  save_end = prologue_end;
 	  regsave_func_p = 1;
-	  current_pc = ctbp + (read_memory_unsigned_integer (adr, 2) & 0xffff);
+	  current_pc = ctbp + (read_memory_unsigned_integer (adr, 2, byte_order)
+			       & 0xffff);
 	  prologue_end = (current_pc
 			  + (2 * 3)	/* prepare list2,imm5,sp/imm */
 			  + 4		/* ctret */
@@ -671,6 +674,7 @@ v850_push_dummy_call (struct gdbarch *gd
 		      int struct_return,
 		      CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int argreg;
   int argnum;
   int len = 0;
@@ -705,7 +709,8 @@ v850_push_dummy_call (struct gdbarch *gd
       if (!v850_type_is_scalar (value_type (*args))
 	  && TYPE_LENGTH (value_type (*args)) > E_MAX_RETTYPE_SIZE_IN_REGS)
 	{
-	  store_unsigned_integer (valbuf, 4, value_address (*args));
+	  store_unsigned_integer (valbuf, 4, byte_order,
+				  value_address (*args));
 	  len = 4;
 	  val = valbuf;
 	}
@@ -720,7 +725,7 @@ v850_push_dummy_call (struct gdbarch *gd
 	  {
 	    CORE_ADDR regval;
 
-	    regval = extract_unsigned_integer (val, v850_reg_size);
+	    regval = extract_unsigned_integer (val, v850_reg_size, byte_order);
 	    regcache_cooked_write_unsigned (regcache, argreg, regval);
 
 	    len -= v850_reg_size;
@@ -751,6 +756,8 @@ static void
 v850_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 <= v850_reg_size)
@@ -758,7 +765,7 @@ v850_extract_return_value (struct type *
       ULONGEST val;
 
       regcache_cooked_read_unsigned (regcache, E_V0_REGNUM, &val);
-      store_unsigned_integer (valbuf, len, val);
+      store_unsigned_integer (valbuf, len, byte_order, val);
     }
   else if (len <= 2 * v850_reg_size)
     {
@@ -776,11 +783,14 @@ static void
 v850_store_return_value (struct type *type, struct regcache *regcache,
 			 const 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 <= v850_reg_size)
-      regcache_cooked_write_unsigned (regcache, E_V0_REGNUM,
-				      extract_unsigned_integer (valbuf, len));
+      regcache_cooked_write_unsigned
+	(regcache, E_V0_REGNUM,
+	 extract_unsigned_integer (valbuf, len, byte_order));
   else if (len <= 2 * v850_reg_size)
     {
       int i, regnum = E_V0_REGNUM;
@@ -834,6 +844,7 @@ v850_alloc_frame_cache (struct frame_inf
 static struct v850_frame_cache *
 v850_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct v850_frame_cache *cache;
   CORE_ADDR current_pc;
   int i;
@@ -859,7 +870,7 @@ v850_frame_cache (struct frame_info *thi
     {
       ULONGEST ctbp;
       ctbp = get_frame_register_unsigned (this_frame, E_CTBP_REGNUM);
-      v850_analyze_prologue (cache->pc, current_pc, cache, ctbp);
+      v850_analyze_prologue (gdbarch, cache->pc, current_pc, cache, ctbp);
     }
 
   if (!cache->uses_fp)
Index: gdb-head/gdb/valarith.c
===================================================================
--- gdb-head.orig/gdb/valarith.c
+++ gdb-head/gdb/valarith.c
@@ -773,7 +773,8 @@ uinteger_pow (ULONGEST v1, LONGEST v2)
    other types if one of them is not decimal floating point.  */
 static void
 value_args_as_decimal (struct value *arg1, struct value *arg2,
-		       gdb_byte *x, int *len_x, gdb_byte *y, int *len_y)
+		       gdb_byte *x, int *len_x, enum bfd_endian *byte_order_x,
+		       gdb_byte *y, int *len_y, enum bfd_endian *byte_order_y)
 {
   struct type *type1, *type2;
 
@@ -796,13 +797,15 @@ value_args_as_decimal (struct value *arg
 
   if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT)
     {
+      *byte_order_x = gdbarch_byte_order (get_type_arch (type1));
       *len_x = TYPE_LENGTH (type1);
       memcpy (x, value_contents (arg1), *len_x);
     }
   else if (is_integral_type (type1))
     {
+      *byte_order_x = gdbarch_byte_order (get_type_arch (type2));
       *len_x = TYPE_LENGTH (type2);
-      decimal_from_integral (arg1, x, *len_x);
+      decimal_from_integral (arg1, x, *len_x, *byte_order_x);
     }
   else
     error (_("Don't know how to convert from %s to %s."), TYPE_NAME (type1),
@@ -813,13 +816,15 @@ value_args_as_decimal (struct value *arg
 
   if (TYPE_CODE (type2) == TYPE_CODE_DECFLOAT)
     {
+      *byte_order_y = gdbarch_byte_order (get_type_arch (type2));
       *len_y = TYPE_LENGTH (type2);
       memcpy (y, value_contents (arg2), *len_y);
     }
   else if (is_integral_type (type2))
     {
+      *byte_order_y = gdbarch_byte_order (get_type_arch (type1));
       *len_y = TYPE_LENGTH (type1);
-      decimal_from_integral (arg2, y, *len_y);
+      decimal_from_integral (arg2, y, *len_y, *byte_order_y);
     }
   else
     error (_("Don't know how to convert from %s to %s."), TYPE_NAME (type1),
@@ -857,6 +862,7 @@ value_binop (struct value *arg1, struct 
     {
       struct type *v_type;
       int len_v1, len_v2, len_v;
+      enum bfd_endian byte_order_v1, byte_order_v2, byte_order_v;
       gdb_byte v1[16], v2[16];
       gdb_byte v[16];
 
@@ -872,8 +878,10 @@ value_binop (struct value *arg1, struct 
 	result_type = type1;
 
       len_v = TYPE_LENGTH (result_type);
+      byte_order_v = gdbarch_byte_order (get_type_arch (result_type));
 
-      value_args_as_decimal (arg1, arg2, v1, &len_v1, v2, &len_v2);
+      value_args_as_decimal (arg1, arg2, v1, &len_v1, &byte_order_v1,
+					 v2, &len_v2, &byte_order_v2);
 
       switch (op)
 	{
@@ -882,7 +890,9 @@ value_binop (struct value *arg1, struct 
 	case BINOP_MUL:
 	case BINOP_DIV:
 	case BINOP_EXP:
-	  decimal_binop (op, v1, len_v1, v2, len_v2, v, len_v);
+	  decimal_binop (op, v1, len_v1, byte_order_v1,
+			     v2, len_v2, byte_order_v2,
+			     v, len_v, byte_order_v);
 	  break;
 
 	default:
@@ -990,6 +1000,7 @@ value_binop (struct value *arg1, struct 
       val = allocate_value (result_type);
       store_signed_integer (value_contents_raw (val),
 			    TYPE_LENGTH (result_type),
+			    gdbarch_byte_order (get_type_arch (result_type)),
 			    v);
     }
   else
@@ -1124,6 +1135,8 @@ value_binop (struct value *arg1, struct 
 	  val = allocate_value (result_type);
 	  store_unsigned_integer (value_contents_raw (val),
 				  TYPE_LENGTH (value_type (val)),
+				  gdbarch_byte_order
+				    (get_type_arch (result_type)),
 				  v);
 	}
       else
@@ -1235,6 +1248,8 @@ value_binop (struct value *arg1, struct 
 	  val = allocate_value (result_type);
 	  store_signed_integer (value_contents_raw (val),
 				TYPE_LENGTH (value_type (val)),
+				gdbarch_byte_order
+				  (get_type_arch (result_type)),
 				v);
 	}
     }
@@ -1257,7 +1272,8 @@ value_logical_not (struct value *arg1)
   if (TYPE_CODE (type1) == TYPE_CODE_FLT)
     return 0 == value_as_double (arg1);
   else if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT)
-    return decimal_is_zero (value_contents (arg1), TYPE_LENGTH (type1));
+    return decimal_is_zero (value_contents (arg1), TYPE_LENGTH (type1),
+			    gdbarch_byte_order (get_type_arch (type1)));
 
   len = TYPE_LENGTH (type1);
   p = value_contents (arg1);
@@ -1341,10 +1357,13 @@ value_equal (struct value *arg1, struct 
     {
       gdb_byte v1[16], v2[16];
       int len_v1, len_v2;
+      enum bfd_endian byte_order_v1, byte_order_v2;
 
-      value_args_as_decimal (arg1, arg2, v1, &len_v1, v2, &len_v2);
+      value_args_as_decimal (arg1, arg2, v1, &len_v1, &byte_order_v1,
+					 v2, &len_v2, &byte_order_v2);
 
-      return decimal_compare (v1, len_v1, v2, len_v2) == 0;
+      return decimal_compare (v1, len_v1, byte_order_v1,
+			      v2, len_v2, byte_order_v2) == 0;
     }
 
   /* FIXME: Need to promote to either CORE_ADDR or LONGEST, whichever
@@ -1415,10 +1434,13 @@ value_less (struct value *arg1, struct v
     {
       gdb_byte v1[16], v2[16];
       int len_v1, len_v2;
+      enum bfd_endian byte_order_v1, byte_order_v2;
 
-      value_args_as_decimal (arg1, arg2, v1, &len_v1, v2, &len_v2);
+      value_args_as_decimal (arg1, arg2, v1, &len_v1, &byte_order_v1,
+					 v2, &len_v2, &byte_order_v2);
 
-      return decimal_compare (v1, len_v1, v2, len_v2) == -1;
+      return decimal_compare (v1, len_v1, byte_order_v1,
+			      v2, len_v2, byte_order_v2) == -1;
     }
   else if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR)
     return value_as_address (arg1) < value_as_address (arg2);
@@ -1531,7 +1553,8 @@ value_bit_index (struct type *type, cons
   if (index < low_bound || index > high_bound)
     return -1;
   rel_index = index - low_bound;
-  word = extract_unsigned_integer (valaddr + (rel_index / TARGET_CHAR_BIT), 1);
+  word = extract_unsigned_integer (valaddr + (rel_index / TARGET_CHAR_BIT), 1,
+				   gdbarch_byte_order (gdbarch));
   rel_index %= TARGET_CHAR_BIT;
   if (gdbarch_bits_big_endian (gdbarch))
     rel_index = TARGET_CHAR_BIT - 1 - rel_index;
Index: gdb-head/gdb/valops.c
===================================================================
--- gdb-head.orig/gdb/valops.c
+++ gdb-head/gdb/valops.c
@@ -422,17 +422,18 @@ value_cast (struct type *type, struct va
     return value_from_double (type, value_as_double (arg2));
   else if (code1 == TYPE_CODE_DECFLOAT && scalar)
     {
+      enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
       int dec_len = TYPE_LENGTH (type);
       gdb_byte dec[16];
 
       if (code2 == TYPE_CODE_FLT)
-	decimal_from_floating (arg2, dec, dec_len);
+	decimal_from_floating (arg2, dec, dec_len, byte_order);
       else if (code2 == TYPE_CODE_DECFLOAT)
 	decimal_convert (value_contents (arg2), TYPE_LENGTH (type2),
-			 dec, dec_len);
+			 byte_order, dec, dec_len, byte_order);
       else
 	/* The only option left is an integral type.  */
-	decimal_from_integral (arg2, dec, dec_len);
+	decimal_from_integral (arg2, dec, dec_len, byte_order);
 
       return value_from_decfloat (type, dec);
     }
@@ -450,8 +451,9 @@ value_cast (struct type *type, struct va
          sees a cast as a simple reinterpretation of the pointer's
          bits.  */
       if (code2 == TYPE_CODE_PTR)
-        longest = extract_unsigned_integer (value_contents (arg2),
-                                            TYPE_LENGTH (type2));
+        longest = extract_unsigned_integer
+		    (value_contents (arg2), TYPE_LENGTH (type2),
+		     gdbarch_byte_order (get_type_arch (type2)));
       else
         longest = value_as_long (arg2);
       return value_from_longest (type, convert_to_boolean ?
@@ -541,8 +543,9 @@ value_one (struct type *type, enum lval_
 
   if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT)
     {
+      enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
       gdb_byte v[16];
-      decimal_from_string (v, TYPE_LENGTH (type), "1");
+      decimal_from_string (v, TYPE_LENGTH (type), byte_order, "1");
       val = value_from_decfloat (type, v);
     }
   else if (TYPE_CODE (type1) == TYPE_CODE_FLT)
Index: gdb-head/gdb/valprint.c
===================================================================
--- gdb-head.orig/gdb/valprint.c
+++ gdb-head/gdb/valprint.c
@@ -409,7 +409,7 @@ val_print_type_code_int (struct type *ty
 
       if (TYPE_UNSIGNED (type)
 	  && extract_long_unsigned_integer (valaddr, TYPE_LENGTH (type),
-					    &val))
+					    byte_order, &val))
 	{
 	  print_longest (stream, 'u', 0, val);
 	}
@@ -605,10 +605,11 @@ void
 print_decimal_floating (const gdb_byte *valaddr, struct type *type,
 			struct ui_file *stream)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
   char decstr[MAX_DECIMAL_STRING];
   unsigned len = TYPE_LENGTH (type);
 
-  decimal_to_string (valaddr, len, decstr);
+  decimal_to_string (valaddr, len, byte_order, decstr);
   fputs_filtered (decstr, stream);
   return;
 }
@@ -1268,7 +1269,7 @@ partial_memory_read (CORE_ADDR memaddr, 
 
 int
 read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
-	     gdb_byte **buffer, int *bytes_read)
+	     enum bfd_endian byte_order, gdb_byte **buffer, int *bytes_read)
 {
   int found_nul;		/* Non-zero if we found the nul char.  */
   int errcode;			/* Errno returned from bad reads.  */
@@ -1340,7 +1341,7 @@ read_string (CORE_ADDR addr, int len, in
 	    {
 	      unsigned long c;
 
-	      c = extract_unsigned_integer (bufptr, width);
+	      c = extract_unsigned_integer (bufptr, width, byte_order);
 	      addr += width;
 	      bufptr += width;
 	      if (c == 0)
@@ -1394,6 +1395,7 @@ val_print_string (struct type *elttype, 
   gdb_byte *buffer = NULL;	/* Dynamically growable fetch buffer.  */
   struct cleanup *old_chain = NULL;	/* Top of the old cleanup chain.  */
   struct gdbarch *gdbarch = get_type_arch (elttype);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int width = TYPE_LENGTH (elttype);
 
   /* First we need to figure out the limit on the number of characters we are
@@ -1406,7 +1408,8 @@ val_print_string (struct type *elttype, 
 
   fetchlimit = (len == -1 ? options->print_max : min (len, options->print_max));
 
-  errcode = read_string (addr, len, width, fetchlimit, &buffer, &bytes_read);
+  errcode = read_string (addr, len, width, fetchlimit, byte_order,
+			 &buffer, &bytes_read);
   old_chain = make_cleanup (xfree, buffer);
 
   addr += bytes_read;
@@ -1415,8 +1418,8 @@ val_print_string (struct type *elttype, 
      terminated early due to an error or finding a null char when LEN is -1.  */
 
   /* Determine found_nul by looking at the last character read.  */
-  found_nul = extract_unsigned_integer (buffer + bytes_read - width, width) == 0;
-
+  found_nul = extract_unsigned_integer (buffer + bytes_read - width, width,
+					byte_order) == 0;
   if (len == -1 && !found_nul)
     {
       gdb_byte *peekbuf;
@@ -1428,7 +1431,7 @@ val_print_string (struct type *elttype, 
       peekbuf = (gdb_byte *) alloca (width);
 
       if (target_read_memory (addr, peekbuf, width) == 0
-	  && extract_unsigned_integer (peekbuf, width) != 0)
+	  && extract_unsigned_integer (peekbuf, width, byte_order) != 0)
 	force_ellipsis = 1;
     }
   else if ((len >= 0 && errcode != 0) || (len > bytes_read / width))
Index: gdb-head/gdb/value.c
===================================================================
--- gdb-head.orig/gdb/value.c
+++ gdb-head/gdb/value.c
@@ -1626,6 +1626,7 @@ value_as_address (struct value *val)
 LONGEST
 unpack_long (struct type *type, const gdb_byte *valaddr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
   enum type_code code = TYPE_CODE (type);
   int len = TYPE_LENGTH (type);
   int nosign = TYPE_UNSIGNED (type);
@@ -1642,9 +1643,9 @@ unpack_long (struct type *type, const gd
     case TYPE_CODE_RANGE:
     case TYPE_CODE_MEMBERPTR:
       if (nosign)
-	return extract_unsigned_integer (valaddr, len);
+	return extract_unsigned_integer (valaddr, len, byte_order);
       else
-	return extract_signed_integer (valaddr, len);
+	return extract_signed_integer (valaddr, len, byte_order);
 
     case TYPE_CODE_FLT:
       return extract_typed_floating (valaddr, type);
@@ -1652,7 +1653,7 @@ unpack_long (struct type *type, const gd
     case TYPE_CODE_DECFLOAT:
       /* libdecnumber has a function to convert from decimal to integer, but
 	 it doesn't work when the decimal number has a fractional part.  */
-      return decimal_to_doublest (valaddr, len);
+      return decimal_to_doublest (valaddr, len, byte_order);
 
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
@@ -1675,6 +1676,7 @@ unpack_long (struct type *type, const gd
 DOUBLEST
 unpack_double (struct type *type, const gdb_byte *valaddr, int *invp)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
   enum type_code code;
   int len;
   int nosign;
@@ -1712,7 +1714,7 @@ unpack_double (struct type *type, const 
       return extract_typed_floating (valaddr, type);
     }
   else if (code == TYPE_CODE_DECFLOAT)
-    return decimal_to_doublest (valaddr, len);
+    return decimal_to_doublest (valaddr, len, byte_order);
   else if (nosign)
     {
       /* Unsigned -- be sure we compensate for signed LONGEST.  */
@@ -1980,6 +1982,7 @@ value_fn_field (struct value **arg1p, st
 LONGEST
 unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
   ULONGEST val;
   ULONGEST valmask;
   int bitpos = TYPE_FIELD_BITPOS (type, fieldno);
@@ -1987,7 +1990,8 @@ unpack_field_as_long (struct type *type,
   int lsbcount;
   struct type *field_type;
 
-  val = extract_unsigned_integer (valaddr + bitpos / 8, sizeof (val));
+  val = extract_unsigned_integer (valaddr + bitpos / 8,
+				  sizeof (val), byte_order);
   field_type = TYPE_FIELD_TYPE (type, fieldno);
   CHECK_TYPEDEF (field_type);
 
@@ -2028,6 +2032,7 @@ void
 modify_field (struct type *type, gdb_byte *addr,
 	      LONGEST fieldval, int bitpos, int bitsize)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
   ULONGEST oword;
   ULONGEST mask = (ULONGEST) -1 >> (8 * sizeof (ULONGEST) - bitsize);
 
@@ -2047,7 +2052,7 @@ modify_field (struct type *type, gdb_byt
       fieldval &= mask;
     }
 
-  oword = extract_unsigned_integer (addr, sizeof oword);
+  oword = extract_unsigned_integer (addr, sizeof oword, byte_order);
 
   /* Shifting for bit field depends on endianness of the target machine.  */
   if (gdbarch_bits_big_endian (get_type_arch (type)))
@@ -2056,7 +2061,7 @@ modify_field (struct type *type, gdb_byt
   oword &= ~(mask << bitpos);
   oword |= fieldval << bitpos;
 
-  store_unsigned_integer (addr, sizeof oword, oword);
+  store_unsigned_integer (addr, sizeof oword, byte_order, oword);
 }
 
 /* Pack NUM into BUF using a target format of TYPE.  */
@@ -2064,6 +2069,7 @@ modify_field (struct type *type, gdb_byt
 void
 pack_long (gdb_byte *buf, struct type *type, LONGEST num)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
   int len;
 
   type = check_typedef (type);
@@ -2078,7 +2084,7 @@ pack_long (gdb_byte *buf, struct type *t
     case TYPE_CODE_BOOL:
     case TYPE_CODE_RANGE:
     case TYPE_CODE_MEMBERPTR:
-      store_signed_integer (buf, len, num);
+      store_signed_integer (buf, len, byte_order, num);
       break;
 
     case TYPE_CODE_REF:
Index: gdb-head/gdb/vax-tdep.c
===================================================================
--- gdb-head.orig/gdb/vax-tdep.c
+++ gdb-head/gdb/vax-tdep.c
@@ -113,6 +113,8 @@ static CORE_ADDR
 vax_store_arguments (struct regcache *regcache, int nargs,
 		     struct value **args, CORE_ADDR sp)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[4];
   int count = 0;
   int i;
@@ -132,11 +134,11 @@ vax_store_arguments (struct regcache *re
 
   /* Push argument count.  */
   sp -= 4;
-  store_unsigned_integer (buf, 4, count);
+  store_unsigned_integer (buf, 4, byte_order, count);
   write_memory (sp, buf, 4);
 
   /* Update the argument pointer.  */
-  store_unsigned_integer (buf, 4, sp);
+  store_unsigned_integer (buf, 4, byte_order, sp);
   regcache_cooked_write (regcache, VAX_AP_REGNUM, buf);
 
   return sp;
@@ -148,6 +150,7 @@ vax_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);
   CORE_ADDR fp = sp;
   gdb_byte buf[4];
 
@@ -160,12 +163,12 @@ vax_push_dummy_call (struct gdbarch *gdb
 
   /* Store return address in the PC slot.  */
   sp -= 4;
-  store_unsigned_integer (buf, 4, bp_addr);
+  store_unsigned_integer (buf, 4, byte_order, bp_addr);
   write_memory (sp, buf, 4);
 
   /* Store the (fake) frame pointer in the FP slot.  */
   sp -= 4;
-  store_unsigned_integer (buf, 4, fp);
+  store_unsigned_integer (buf, 4, byte_order, fp);
   write_memory (sp, buf, 4);
 
   /* Skip the AP slot.  */
@@ -173,16 +176,16 @@ vax_push_dummy_call (struct gdbarch *gdb
 
   /* Store register save mask and control bits.  */
   sp -= 4;
-  store_unsigned_integer (buf, 4, 0);
+  store_unsigned_integer (buf, 4, byte_order, 0);
   write_memory (sp, buf, 4);
 
   /* Store condition handler.  */
   sp -= 4;
-  store_unsigned_integer (buf, 4, 0);
+  store_unsigned_integer (buf, 4, byte_order, 0);
   write_memory (sp, buf, 4);
 
   /* Update the stack pointer and frame pointer.  */
-  store_unsigned_integer (buf, 4, sp);
+  store_unsigned_integer (buf, 4, byte_order, sp);
   regcache_cooked_write (regcache, VAX_SP_REGNUM, buf);
   regcache_cooked_write (regcache, VAX_FP_REGNUM, buf);
 
@@ -269,26 +272,27 @@ vax_breakpoint_from_pc (struct gdbarch *
 static CORE_ADDR
 vax_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
-  gdb_byte op = read_memory_unsigned_integer (pc, 1);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  gdb_byte op = read_memory_unsigned_integer (pc, 1, byte_order);
 
   if (op == 0x11)
     pc += 2;			/* skip brb */
   if (op == 0x31)
     pc += 3;			/* skip brw */
   if (op == 0xC2
-      && (read_memory_unsigned_integer (pc + 2, 1)) == 0x5E)
+      && read_memory_unsigned_integer (pc + 2, 1, byte_order) == 0x5E)
     pc += 3;			/* skip subl2 */
   if (op == 0x9E
-      && (read_memory_unsigned_integer (pc + 1, 1)) == 0xAE
-      && (read_memory_unsigned_integer (pc + 3, 1)) == 0x5E)
+      && read_memory_unsigned_integer (pc + 1, 1, byte_order) == 0xAE
+      && read_memory_unsigned_integer (pc + 3, 1, byte_order) == 0x5E)
     pc += 4;			/* skip movab */
   if (op == 0x9E
-      && (read_memory_unsigned_integer (pc + 1, 1)) == 0xCE
-      && (read_memory_unsigned_integer (pc + 4, 1)) == 0x5E)
+      && read_memory_unsigned_integer (pc + 1, 1, byte_order) == 0xCE
+      && read_memory_unsigned_integer (pc + 4, 1, byte_order) == 0x5E)
     pc += 5;			/* skip movab */
   if (op == 0x9E
-      && (read_memory_unsigned_integer (pc + 1, 1)) == 0xEE
-      && (read_memory_unsigned_integer (pc + 6, 1)) == 0x5E)
+      && read_memory_unsigned_integer (pc + 1, 1, byte_order) == 0xEE
+      && read_memory_unsigned_integer (pc + 6, 1, byte_order) == 0x5E)
     pc += 7;			/* skip movab */
 
   return pc;
Index: gdb-head/gdb/xstormy16-tdep.c
===================================================================
--- gdb-head.orig/gdb/xstormy16-tdep.c
+++ gdb-head/gdb/xstormy16-tdep.c
@@ -233,6 +233,7 @@ xstormy16_push_dummy_call (struct gdbarc
 			   CORE_ADDR sp, int struct_return,
 			   CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR stack_dest = sp;
   int argreg = E_1ST_ARG_REGNUM;
   int i, j;
@@ -266,7 +267,8 @@ xstormy16_push_dummy_call (struct gdbarc
 			extract_unsigned_integer (val + j,
 						  typelen - j ==
 						  1 ? 1 :
-						  xstormy16_reg_size));
+						  xstormy16_reg_size,
+						  byte_order));
     }
 
   /* Align SP */
@@ -289,7 +291,7 @@ xstormy16_push_dummy_call (struct gdbarc
       stack_dest += typelen + slacklen;
     }
 
-  store_unsigned_integer (buf, xstormy16_pc_size, bp_addr);
+  store_unsigned_integer (buf, xstormy16_pc_size, byte_order, bp_addr);
   write_memory (stack_dest, buf, xstormy16_pc_size);
   stack_dest += xstormy16_pc_size;
 
@@ -309,10 +311,12 @@ xstormy16_push_dummy_call (struct gdbarc
    Returns the address of the first instruction after the prologue.  */
 
 static CORE_ADDR
-xstormy16_analyze_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
+xstormy16_analyze_prologue (struct gdbarch *gdbarch,
+			    CORE_ADDR start_addr, CORE_ADDR end_addr,
 			    struct xstormy16_frame_cache *cache,
 			    struct frame_info *this_frame)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR next_addr;
   ULONGEST inst, inst2;
   LONGEST offset;
@@ -328,9 +332,10 @@ xstormy16_analyze_prologue (CORE_ADDR st
   for (next_addr = start_addr;
        next_addr < end_addr; next_addr += xstormy16_inst_size)
     {
-      inst = read_memory_unsigned_integer (next_addr, xstormy16_inst_size);
+      inst = read_memory_unsigned_integer (next_addr,
+					   xstormy16_inst_size, byte_order);
       inst2 = read_memory_unsigned_integer (next_addr + xstormy16_inst_size,
-					    xstormy16_inst_size);
+					    xstormy16_inst_size, byte_order);
 
       if (inst >= 0x0082 && inst <= 0x008d)	/* push r2 .. push r13 */
 	{
@@ -419,7 +424,8 @@ xstormy16_skip_prologue (struct gdbarch 
       memset (&cache, 0, sizeof cache);
 
       /* Don't trust line number debug info in frameless functions. */
-      plg_end = xstormy16_analyze_prologue (func_addr, func_end, &cache, NULL);
+      plg_end = xstormy16_analyze_prologue (gdbarch, func_addr, func_end,
+					    &cache, NULL);
       if (!cache.uses_fp)
         return plg_end;
 
@@ -450,6 +456,7 @@ xstormy16_skip_prologue (struct gdbarch 
 static int
 xstormy16_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR func_addr = 0, func_end = 0;
 
   if (find_pc_partial_function (pc, NULL, &func_addr, &func_end))
@@ -463,19 +470,21 @@ xstormy16_in_function_epilogue_p (struct
 
       /* Check if we're on a `ret' instruction.  Otherwise it's
          too dangerous to proceed. */
-      inst = read_memory_unsigned_integer (addr, xstormy16_inst_size);
+      inst = read_memory_unsigned_integer (addr,
+					   xstormy16_inst_size, byte_order);
       if (inst != 0x0003)
 	return 0;
 
       while ((addr -= xstormy16_inst_size) >= func_addr)
 	{
-	  inst = read_memory_unsigned_integer (addr, xstormy16_inst_size);
+	  inst = read_memory_unsigned_integer (addr,
+					       xstormy16_inst_size, byte_order);
 	  if (inst >= 0x009a && inst <= 0x009d)	/* pop r10...r13 */
 	    continue;
 	  if (inst == 0x305f || inst == 0x307f)	/* dec r15, #0x1/#0x3 */
 	    break;
 	  inst2 = read_memory_unsigned_integer (addr - xstormy16_inst_size,
-						xstormy16_inst_size);
+						xstormy16_inst_size, byte_order);
 	  if (inst2 == 0x314f && inst >= 0x8000)	/* add r15, neg. value */
 	    {
 	      addr -= xstormy16_inst_size;
@@ -501,8 +510,9 @@ xstormy16_breakpoint_from_pc (struct gdb
 /* Given a pointer to a jump table entry, return the address
    of the function it jumps to.  Return 0 if not found. */
 static CORE_ADDR
-xstormy16_resolve_jmp_table_entry (CORE_ADDR faddr)
+xstormy16_resolve_jmp_table_entry (struct gdbarch *gdbarch, CORE_ADDR faddr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct obj_section *faddr_sect = find_pc_section (faddr);
 
   if (faddr_sect)
@@ -516,9 +526,10 @@ xstormy16_resolve_jmp_table_entry (CORE_
 
       if (!target_read_memory (faddr, buf, sizeof buf))
 	{
-	  inst = extract_unsigned_integer (buf, xstormy16_inst_size);
+	  inst = extract_unsigned_integer (buf,
+					   xstormy16_inst_size, byte_order);
 	  inst2 = extract_unsigned_integer (buf + xstormy16_inst_size,
-					    xstormy16_inst_size);
+					    xstormy16_inst_size, byte_order);
 	  addr = inst2 << 8 | (inst & 0xff);
 	  return addr;
 	}
@@ -530,8 +541,9 @@ xstormy16_resolve_jmp_table_entry (CORE_
    address of the corresponding jump table entry.  Return 0 if
    not found. */
 static CORE_ADDR
-xstormy16_find_jmp_table_entry (CORE_ADDR faddr)
+xstormy16_find_jmp_table_entry (struct gdbarch *gdbarch, CORE_ADDR faddr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct obj_section *faddr_sect = find_pc_section (faddr);
 
   if (faddr_sect)
@@ -562,9 +574,10 @@ xstormy16_find_jmp_table_entry (CORE_ADD
 
 	      if (target_read_memory (addr, buf, sizeof buf))
 		return 0;
-	      inst = extract_unsigned_integer (buf, xstormy16_inst_size);
+	      inst = extract_unsigned_integer (buf,
+					       xstormy16_inst_size, byte_order);
 	      inst2 = extract_unsigned_integer (buf + xstormy16_inst_size,
-						xstormy16_inst_size);
+					        xstormy16_inst_size, byte_order);
 	      faddr2 = inst2 << 8 | (inst & 0xff);
 	      if (faddr == faddr2)
 		return addr;
@@ -577,7 +590,8 @@ xstormy16_find_jmp_table_entry (CORE_ADD
 static CORE_ADDR
 xstormy16_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 {
-  CORE_ADDR tmp = xstormy16_resolve_jmp_table_entry (pc);
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  CORE_ADDR tmp = xstormy16_resolve_jmp_table_entry (gdbarch, pc);
 
   if (tmp && tmp != pc)
     return tmp;
@@ -595,12 +609,14 @@ static CORE_ADDR
 xstormy16_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)
     {
-      CORE_ADDR addr2 = xstormy16_resolve_jmp_table_entry (addr);
+      CORE_ADDR addr2 = xstormy16_resolve_jmp_table_entry (gdbarch, addr);
       if (addr2)
 	addr = addr2;
     }
@@ -612,15 +628,16 @@ static void
 xstormy16_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)
     {
-      CORE_ADDR addr2 = xstormy16_find_jmp_table_entry (addr);
+      CORE_ADDR addr2 = xstormy16_find_jmp_table_entry (gdbarch, addr);
       if (addr2)
 	addr = addr2;
     }
-  store_unsigned_integer (buf, TYPE_LENGTH (type), addr);
+  store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr);
 }
 
 static struct xstormy16_frame_cache *
@@ -645,6 +662,7 @@ xstormy16_alloc_frame_cache (void)
 static struct xstormy16_frame_cache *
 xstormy16_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct xstormy16_frame_cache *cache;
   CORE_ADDR current_pc;
   int i;
@@ -662,7 +680,8 @@ xstormy16_frame_cache (struct frame_info
   cache->pc = get_frame_func (this_frame);
   current_pc = get_frame_pc (this_frame);
   if (cache->pc)
-    xstormy16_analyze_prologue (cache->pc, current_pc, cache, this_frame);
+    xstormy16_analyze_prologue (gdbarch, cache->pc, current_pc,
+				cache, this_frame);
 
   if (!cache->uses_fp)
     cache->base = get_frame_register_unsigned (this_frame, E_SP_REGNUM);
Index: gdb-head/gdb/xtensa-tdep.c
===================================================================
--- gdb-head.orig/gdb/xtensa-tdep.c
+++ gdb-head/gdb/xtensa-tdep.c
@@ -165,6 +165,7 @@ windowing_enabled (CORE_ADDR ps)
 static int
 extract_call_winsize (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int winsize = 4;
   int insn;
   gdb_byte buf[4];
@@ -173,7 +174,7 @@ extract_call_winsize (struct gdbarch *gd
 
   /* Read the previous instruction (should be a call[x]{4|8|12}.  */
   read_memory (pc-3, buf, 3);
-  insn = extract_unsigned_integer (buf, 3);
+  insn = extract_unsigned_integer (buf, 3, byte_order);
 
   /* Decode call instruction:
      Little Endian
@@ -183,7 +184,7 @@ extract_call_winsize (struct gdbarch *gd
        call{0,4,8,12}   0101 || {00,01,10,11} || OFFSET
        callx{0,4,8,12}  0000 || {00,01,10,11} || 11 || OFFSET.  */
 
-  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
+  if (byte_order == BFD_ENDIAN_LITTLE)
     {
       if (((insn & 0xf) == 0x5) || ((insn & 0xcf) == 0xc0))
 	winsize = (insn & 0x30) >> 2;   /* 0, 4, 8, 12.  */
@@ -502,6 +503,8 @@ xtensa_pseudo_register_read (struct gdba
 			     int regnum,
 			     gdb_byte *buffer)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   DEBUGTRACE ("xtensa_pseudo_register_read (... regnum = %d (%s) ...)\n",
 	      regnum, xtensa_register_name (gdbarch, regnum));
 
@@ -518,7 +521,7 @@ xtensa_pseudo_register_read (struct gdba
 
       regcache_raw_read (regcache, gdbarch_tdep (gdbarch)->wb_regnum, buf);
       regnum = arreg_number (gdbarch, regnum,
-			     extract_unsigned_integer (buf, 4));
+			     extract_unsigned_integer (buf, 4, byte_order));
     }
 
   /* We can always read non-pseudo registers.  */
@@ -598,6 +601,8 @@ xtensa_pseudo_register_write (struct gdb
 			      int regnum,
 			      const gdb_byte *buffer)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   DEBUGTRACE ("xtensa_pseudo_register_write (... regnum = %d (%s) ...)\n",
 	      regnum, xtensa_register_name (gdbarch, regnum));
 
@@ -616,7 +621,7 @@ xtensa_pseudo_register_write (struct gdb
       regcache_raw_read (regcache,
 			 gdbarch_tdep (gdbarch)->wb_regnum, buf);
       regnum = arreg_number (gdbarch, regnum,
-			     extract_unsigned_integer (buf, 4));
+			     extract_unsigned_integer (buf, 4, byte_order));
     }
 
   /* We can always write 'core' registers.
@@ -1173,6 +1178,7 @@ xtensa_frame_cache (struct frame_info *t
   xtensa_frame_cache_t *cache;
   CORE_ADDR ra, wb, ws, pc, sp, ps;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned int fp_regnum;
   char op1;
   int  windowed;
@@ -1197,7 +1203,7 @@ xtensa_frame_cache (struct frame_info *t
       ws = get_frame_register_unsigned (this_frame,
 					gdbarch_tdep (gdbarch)->ws_regnum);
 
-      op1 = read_memory_integer (pc, 1);
+      op1 = read_memory_integer (pc, 1, byte_order);
       if (XTENSA_IS_ENTRY (gdbarch, op1))
 	{
 	  int callinc = CALLINC (ps);
@@ -1258,8 +1264,8 @@ xtensa_frame_cache (struct frame_info *t
 	      /* Set A4...A7/A11.  */
 	      /* Get the SP of the frame previous to the previous one.
 	         To achieve this, we have to dereference SP twice.  */
-	      sp = (CORE_ADDR) read_memory_integer (sp - 12, 4);
-	      sp = (CORE_ADDR) read_memory_integer (sp - 12, 4);
+	      sp = (CORE_ADDR) read_memory_integer (sp - 12, 4, byte_order);
+	      sp = (CORE_ADDR) read_memory_integer (sp - 12, 4, byte_order);
 	      sp -= cache->wd.callsize * 4;
 
 	      for ( i = 4; i < cache->wd.callsize; i++, sp += 4)
@@ -1279,7 +1285,7 @@ xtensa_frame_cache (struct frame_info *t
 		 We can read caller's SP from the proper spill loction.  */
 	      sp = get_frame_register_unsigned
 		(this_frame, gdbarch_tdep (gdbarch)->a0_base + 1);
-	      cache->prev_sp = read_memory_integer (sp - 12, 4); 
+	      cache->prev_sp = read_memory_integer (sp - 12, 4, byte_order);
 	    }
 	  else
 	    {
@@ -1591,6 +1597,7 @@ xtensa_push_dummy_call (struct gdbarch *
 			int struct_return,
 			CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int i;
   int size, onstack_size;
   gdb_byte *buf = (gdb_byte *) alloca (16);
@@ -1734,7 +1741,7 @@ xtensa_push_dummy_call (struct gdbarch *
 
   if (struct_return)
     {
-      store_unsigned_integer (buf, REGISTER_SIZE, struct_addr);
+      store_unsigned_integer (buf, REGISTER_SIZE, byte_order, struct_addr);
       regcache_cooked_write (regcache, ARG_1ST (gdbarch), buf);
     }
 
@@ -1770,13 +1777,13 @@ xtensa_push_dummy_call (struct gdbarch *
 	     than REGISTER_SIZE; for larger odd-sized structures the excess
 	     will be left-aligned in the register on both endiannesses.  */
 
-	  if (n < REGISTER_SIZE
-	      && gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
+	  if (n < REGISTER_SIZE && byte_order == BFD_ENDIAN_BIG)
 	    {
-	      ULONGEST v = extract_unsigned_integer (cp, REGISTER_SIZE);
+	      ULONGEST v;
+	      v = extract_unsigned_integer (cp, REGISTER_SIZE, byte_order);
 	      v = v >> ((REGISTER_SIZE - n) * TARGET_CHAR_BIT);
 
-	      store_unsigned_integer (buf, REGISTER_SIZE, v);
+	      store_unsigned_integer (buf, REGISTER_SIZE, byte_order, v);
 	      regcache_cooked_write (regcache, r, buf);
 
 	      cp += REGISTER_SIZE;
@@ -1803,7 +1810,7 @@ xtensa_push_dummy_call (struct gdbarch *
     {
       ra = (bp_addr & 0x3fffffff) | 0x40000000;
       regcache_raw_read (regcache, gdbarch_ps_regnum (gdbarch), buf);
-      ps = extract_unsigned_integer (buf, 4) & ~0x00030000;
+      ps = extract_unsigned_integer (buf, 4, byte_order) & ~0x00030000;
       regcache_cooked_write_unsigned
 	(regcache, gdbarch_tdep (gdbarch)->a0_base + 4, ra);
       regcache_cooked_write_unsigned (regcache,
@@ -1816,9 +1823,9 @@ xtensa_push_dummy_call (struct gdbarch *
 	 is only one register window corresponding to WINDOWEBASE.  */
 
       regcache_raw_read (regcache, gdbarch_tdep (gdbarch)->wb_regnum, buf);
-      regcache_cooked_write_unsigned (regcache,
-				      gdbarch_tdep (gdbarch)->ws_regnum,
-				      1 << extract_unsigned_integer (buf, 4));
+      regcache_cooked_write_unsigned
+	(regcache, gdbarch_tdep (gdbarch)->ws_regnum,
+	 1 << extract_unsigned_integer (buf, 4, byte_order));
     }
   else
     {
@@ -1970,10 +1977,12 @@ call0_classify_opcode (xtensa_isa isa, x
    the stack frame.  */
 
 static void
-call0_track_op (xtensa_c0reg_t dst[], xtensa_c0reg_t src[],
+call0_track_op (struct gdbarch *gdbarch,
+		xtensa_c0reg_t dst[], xtensa_c0reg_t src[],
 		xtensa_insn_kind opclass, int nods, unsigned odv[],
 		CORE_ADDR pc, CORE_ADDR litbase, int spreg)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned litaddr, litval;
 
   switch (opclass)
@@ -2027,7 +2036,7 @@ call0_track_op (xtensa_c0reg_t dst[], xt
       litaddr = litbase & 1
 		  ? (litbase & ~1) + (signed)odv[1]
 		  : (pc + 3  + (signed)odv[1]) & ~3;
-      litval = read_memory_integer(litaddr, 4);
+      litval = read_memory_integer (litaddr, 4, byte_order);
       dst[odv[0]].fr_reg = C0_CONST;
       dst[odv[0]].fr_ofs = litval;
       break;
@@ -2080,7 +2089,8 @@ call0_track_op (xtensa_c0reg_t dst[], xt
       because they begin with default assumptions that analysis may change.  */
 
 static CORE_ADDR
-call0_analyze_prologue (CORE_ADDR start, CORE_ADDR pc, CORE_ADDR litbase,
+call0_analyze_prologue (struct gdbarch *gdbarch,
+			CORE_ADDR start, CORE_ADDR pc, CORE_ADDR litbase,
 			int nregs, xtensa_c0reg_t rt[], int *call0)
 {
   CORE_ADDR ia;		    /* Current insn address in prologue.  */
@@ -2271,7 +2281,8 @@ call0_analyze_prologue (CORE_ADDR start,
 	    }
 
 	  /* Track register movement and modification for this operation.  */
-	  call0_track_op (rt, rtmp, opclass, nods, odv, ia, litbase, 1);
+	  call0_track_op (gdbarch, rt, rtmp, opclass,
+			  nods, odv, ia, litbase, 1);
 	}
     }
 done:
@@ -2289,6 +2300,7 @@ call0_frame_cache (struct frame_info *th
 		   xtensa_frame_cache_t *cache, CORE_ADDR pc, CORE_ADDR litbase)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR start_pc;		/* The beginning of the function.  */
   CORE_ADDR body_pc=UINT_MAX;	/* PC, where prologue analysis stopped.  */
   CORE_ADDR sp, fp, ra;
@@ -2299,7 +2311,8 @@ call0_frame_cache (struct frame_info *th
 
   if (find_pc_partial_function (pc, NULL, &start_pc, NULL))
     {
-      body_pc = call0_analyze_prologue (start_pc, pc, litbase, C0_NREGS,
+      body_pc = call0_analyze_prologue (gdbarch, start_pc, pc, litbase,
+					C0_NREGS,
 					&cache->c0.c0_rt[0],
 					&cache->call0);
     }
@@ -2354,7 +2367,8 @@ call0_frame_cache (struct frame_info *th
   to_stk = cache->c0.c0_rt[C0_RA].to_stk;
   if (to_stk != C0_NOSTK)
     ra = (CORE_ADDR) 
-      read_memory_integer (sp + c0_frmsz + cache->c0.c0_rt[C0_RA].to_stk, 4);
+      read_memory_integer (sp + c0_frmsz + cache->c0.c0_rt[C0_RA].to_stk,
+			   4, byte_order);
 
   else if (cache->c0.c0_rt[C0_RA].fr_reg == C0_CONST
 	   && cache->c0.c0_rt[C0_RA].fr_ofs == 0)
@@ -2473,7 +2487,7 @@ xtensa_skip_prologue (struct gdbarch *gd
     }
 
   /* No debug line info.  Analyze prologue for Call0 or simply skip ENTRY.  */
-  body_pc = call0_analyze_prologue(start_pc, 0, 0, 0, NULL, NULL);
+  body_pc = call0_analyze_prologue (gdbarch, start_pc, 0, 0, 0, NULL, NULL);
   return body_pc != 0 ? body_pc : start_pc;
 }
 
Index: gdb-head/gdb/python/python-value.c
===================================================================
--- gdb-head.orig/gdb/python/python-value.c
+++ gdb-head/gdb/python/python-value.c
@@ -573,7 +573,8 @@ valpy_nonzero (PyObject *self)
     return value_as_double (self_value->value) != 0;
   else if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT)
     return !decimal_is_zero (value_contents (self_value->value),
-			     TYPE_LENGTH (type));
+			     TYPE_LENGTH (type),
+			     gdbarch_byte_order (get_type_arch (type)));
   else
     {
       PyErr_SetString (PyExc_TypeError, _("Attempted truth testing on invalid "
Index: gdb-head/gdb/valprint.h
===================================================================
--- gdb-head.orig/gdb/valprint.h
+++ gdb-head/gdb/valprint.h
@@ -144,6 +144,7 @@ extern void print_char_chars (struct ui_
 			      const gdb_byte *, unsigned int, enum bfd_endian);
 
 int read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
-		 gdb_byte **buffer, int *bytes_read);
+		 enum bfd_endian byte_order, gdb_byte **buffer,
+		 int *bytes_read);
 
 #endif
Index: gdb-head/gdb/charset.c
===================================================================
--- gdb-head.orig/gdb/charset.c
+++ gdb-head/gdb/charset.c
@@ -358,9 +358,9 @@ target_charset (void)
 }
 
 const char *
-target_wide_charset (void)
+target_wide_charset (enum bfd_endian byte_order)
 {
-  if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+  if (byte_order == BFD_ENDIAN_BIG)
     {
       if (target_wide_charset_be_name)
 	return target_wide_charset_be_name;
Index: gdb-head/gdb/charset.h
===================================================================
--- gdb-head.orig/gdb/charset.h
+++ gdb-head/gdb/charset.h
@@ -34,7 +34,7 @@
    it.  */
 const char *host_charset (void);
 const char *target_charset (void);
-const char *target_wide_charset (void);
+const char *target_wide_charset (enum bfd_endian byte_order);
 
 /* These values are used to specify the type of transliteration done
    by convert_between_encodings.  */
Index: gdb-head/gdb/ppc-linux-nat.c
===================================================================
--- gdb-head.orig/gdb/ppc-linux-nat.c
+++ gdb-head/gdb/ppc-linux-nat.c
@@ -1523,6 +1523,7 @@ ppc_linux_auxv_parse (struct target_ops 
                       gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
 {
   int sizeof_auxv_field = ppc_linux_target_wordsize ();
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   gdb_byte *ptr = *readptr;
 
   if (endptr == ptr)
@@ -1531,9 +1532,9 @@ ppc_linux_auxv_parse (struct target_ops 
   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/lm32-tdep.c
===================================================================
--- gdb-head.orig/gdb/lm32-tdep.c
+++ gdb-head/gdb/lm32-tdep.c
@@ -125,9 +125,11 @@ lm32_cannot_store_register (struct gdbar
 /* Analyze a function's prologue.  */
 
 static CORE_ADDR
-lm32_analyze_prologue (CORE_ADDR pc, CORE_ADDR limit,
+lm32_analyze_prologue (struct gdbarch *gdbarch,
+		       CORE_ADDR pc, CORE_ADDR limit,
 		       struct lm32_frame_cache *info)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned long instruction;
 
   /* Keep reading though instructions, until we come across an instruction 
@@ -137,7 +139,7 @@ lm32_analyze_prologue (CORE_ADDR pc, COR
     {
 
       /* Read an instruction.  */
-      instruction = read_memory_integer (pc, 4);
+      instruction = read_memory_integer (pc, 4, byte_order);
 
       if ((LM32_OPCODE (instruction) == OP_SW)
 	  && (LM32_REG0 (instruction) == SIM_LM32_SP_REGNUM))
@@ -211,7 +213,7 @@ lm32_skip_prologue (struct gdbarch *gdba
     limit_pc = pc + 100;	/* Magic.  */
 
   frame_info.saved_regs = saved_regs;
-  return lm32_analyze_prologue (pc, limit_pc, &frame_info);
+  return lm32_analyze_prologue (gdbarch, pc, limit_pc, &frame_info);
 }
 
 /* Create a breakpoint instruction.  */
@@ -235,6 +237,7 @@ lm32_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 first_arg_reg = SIM_LM32_R1_REGNUM;
   int num_arg_regs = 8;
   int i;
@@ -283,7 +286,7 @@ lm32_push_dummy_call (struct gdbarch *gd
 
       contents = (gdb_byte *) value_contents (arg);
       len = TYPE_LENGTH (arg_type);
-      val = extract_unsigned_integer (contents, len);
+      val = extract_unsigned_integer (contents, len, byte_order);
 
       /* First num_arg_regs parameters are passed by registers, 
          and the rest are passed on the stack.  */
@@ -309,6 +312,8 @@ static void
 lm32_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 offset;
   ULONGEST l;
   CORE_ADDR return_buffer;
@@ -319,7 +324,7 @@ lm32_extract_return_value (struct type *
     {
       /* Return value is returned in a single register.  */
       regcache_cooked_read_unsigned (regcache, SIM_LM32_R1_REGNUM, &l);
-      store_unsigned_integer (valbuf, TYPE_LENGTH (type), l);
+      store_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order, l);
     }
   else if ((TYPE_CODE (type) == TYPE_CODE_INT) && (TYPE_LENGTH (type) == 8))
     {
@@ -345,19 +350,21 @@ static void
 lm32_store_return_value (struct type *type, struct regcache *regcache,
 			 const gdb_byte *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)
     {
-      val = extract_unsigned_integer (valbuf, len);
+      val = extract_unsigned_integer (valbuf, len, byte_order);
       regcache_cooked_write_unsigned (regcache, SIM_LM32_R1_REGNUM, val);
     }
   else if (len <= 8)
     {
-      val = extract_unsigned_integer (valbuf, 4);
+      val = extract_unsigned_integer (valbuf, 4, byte_order);
       regcache_cooked_write_unsigned (regcache, SIM_LM32_R1_REGNUM, val);
-      val = extract_unsigned_integer (valbuf + 4, len - 4);
+      val = extract_unsigned_integer (valbuf + 4, len - 4, byte_order);
       regcache_cooked_write_unsigned (regcache, SIM_LM32_R2_REGNUM, val);
     }
   else
@@ -435,7 +442,8 @@ lm32_frame_cache (struct frame_info *thi
 
   info->pc = get_frame_func (this_frame);
   current_pc = get_frame_pc (this_frame);
-  lm32_analyze_prologue (info->pc, current_pc, info);
+  lm32_analyze_prologue (get_frame_arch (this_frame),
+			 info->pc, current_pc, info);
 
   /* Compute the frame's base, and the previous frame's SP.  */
   this_base = get_frame_register_unsigned (this_frame, SIM_LM32_SP_REGNUM);
Index: gdb-head/gdb/moxie-tdep.c
===================================================================
--- gdb-head.orig/gdb/moxie-tdep.c
+++ gdb-head/gdb/moxie-tdep.c
@@ -120,15 +120,18 @@ static void
 moxie_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);
 
   /* Things always get returned in RET1_REGNUM, RET2_REGNUM.  */
-  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);
     }
 }
@@ -144,6 +147,8 @@ moxie_analyze_prologue (CORE_ADDR start_
 		      struct moxie_frame_cache *cache,
 		      struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR next_addr;
   ULONGEST inst, inst2;
   LONGEST offset;
@@ -159,7 +164,7 @@ moxie_analyze_prologue (CORE_ADDR start_
 
   for (next_addr = start_addr; next_addr < end_addr; )
     {
-      inst = read_memory_unsigned_integer (next_addr, 2);
+      inst = read_memory_unsigned_integer (next_addr, 2, byte_order);
 
       /* Match "push $rN" where N is between 2 and 13 inclusive.  */
       if (inst >= 0x0614 && inst <= 0x061f)
@@ -174,8 +179,8 @@ moxie_analyze_prologue (CORE_ADDR start_
 	 byte.  */
       else if (inst == 0x01f0)           /* ldi.l $r12, X */
 	{
-	  offset = read_memory_integer (next_addr + 2, 4);
-	  inst2 = read_memory_unsigned_integer (next_addr + 6, 2);
+	  offset = read_memory_integer (next_addr + 2, 4, byte_order);
+	  inst2 = read_memory_unsigned_integer (next_addr + 6, 2, byte_order);
 
 	  if (inst2 == 0x051f)           /* add.l $sp, $r12 */
 	    {
@@ -297,6 +302,8 @@ static void
 moxie_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;
@@ -304,14 +311,14 @@ moxie_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 moxie
      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/solib-darwin.c
===================================================================
--- gdb-head.orig/gdb/solib-darwin.c
+++ gdb-head/gdb/solib-darwin.c
@@ -79,6 +79,7 @@ static void
 darwin_load_image_infos (void)
 {
   gdb_byte buf[24];
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
   int len;
 
@@ -97,11 +98,11 @@ darwin_load_image_infos (void)
     return;
 
   /* Extract the fields.  */
-  dyld_all_image.version = extract_unsigned_integer (buf, 4);
+  dyld_all_image.version = extract_unsigned_integer (buf, 4, byte_order);
   if (dyld_all_image.version != DYLD_VERSION)
     return;
 
-  dyld_all_image.count = extract_unsigned_integer (buf + 4, 4);
+  dyld_all_image.count = extract_unsigned_integer (buf + 4, 4, byte_order);
   dyld_all_image.info = extract_typed_address (buf + 8, ptr_type);
   dyld_all_image.notifier = extract_typed_address
     (buf + 8 + ptr_type->length, ptr_type);
Index: gdb-head/gdb/i386-darwin-nat.c
===================================================================
--- gdb-head.orig/gdb/i386-darwin-nat.c
+++ gdb-head/gdb/i386-darwin-nat.c
@@ -446,6 +446,7 @@ darwin_check_osabi (darwin_inferior *inf
 static int
 i386_darwin_sstep_at_sigreturn (x86_thread_state_t *regs)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   static const gdb_byte darwin_syscall[] = { 0xcd, 0x80 }; /* int 0x80 */
   gdb_byte buf[sizeof (darwin_syscall)];
 
@@ -459,8 +460,10 @@ i386_darwin_sstep_at_sigreturn (x86_thre
       ULONGEST flags_addr;
       unsigned int eflags;
 
-      uctx_addr = read_memory_unsigned_integer (regs->uts.ts32.__esp + 4, 4);
-      mctx_addr = read_memory_unsigned_integer (uctx_addr + 28, 4);
+      uctx_addr = read_memory_unsigned_integer
+		    (regs->uts.ts32.__esp + 4, 4, byte_order);
+      mctx_addr = read_memory_unsigned_integer
+		    (uctx_addr + 28, 4, byte_order);
 
       flags_addr = mctx_addr + 12 + 9 * 4;
       read_memory (flags_addr, (gdb_byte *) &eflags, 4);
@@ -475,6 +478,7 @@ i386_darwin_sstep_at_sigreturn (x86_thre
 static int
 amd64_darwin_sstep_at_sigreturn (x86_thread_state_t *regs)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
   static const gdb_byte darwin_syscall[] = { 0x0f, 0x05 }; /* syscall */
   gdb_byte buf[sizeof (darwin_syscall)];
 
@@ -487,7 +491,8 @@ amd64_darwin_sstep_at_sigreturn (x86_thr
       ULONGEST flags_addr;
       unsigned int rflags;
 
-      mctx_addr = read_memory_unsigned_integer (regs->uts.ts64.__rdi + 48, 8);
+      mctx_addr = read_memory_unsigned_integer
+		    (regs->uts.ts64.__rdi + 48, 8, byte_order);
       flags_addr = mctx_addr + 16 + 17 * 8;
 
       /* AMD64 is little endian.  */
Index: gdb-head/gdb/i386-darwin-tdep.c
===================================================================
--- gdb-head.orig/gdb/i386-darwin-tdep.c
+++ gdb-head/gdb/i386-darwin-tdep.c
@@ -107,28 +107,32 @@ const int amd64_darwin_thread_state_num_
 static CORE_ADDR
 i386_darwin_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 bp;
   CORE_ADDR si;
   gdb_byte buf[4];
 
   get_frame_register (this_frame, I386_EBP_REGNUM, buf);
-  bp = extract_unsigned_integer (buf, 4);
+  bp = extract_unsigned_integer (buf, 4, byte_order);
 
   /* A pointer to the ucontext is passed as the fourth argument
      to the signal handler.  */
   read_memory (bp + 24, buf, 4);
-  si = extract_unsigned_integer (buf, 4);
+  si = extract_unsigned_integer (buf, 4, byte_order);
 
   /* The pointer to mcontext is at offset 28.  */
   read_memory (si + 28, buf, 4);
 
   /* First register (eax) is at offset 12.  */
-  return extract_unsigned_integer (buf, 4) + 12;
+  return extract_unsigned_integer (buf, 4, byte_order) + 12;
 }
 
 static CORE_ADDR
 amd64_darwin_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 rbx;
   CORE_ADDR si;
   gdb_byte buf[8];
@@ -136,13 +140,13 @@ amd64_darwin_sigcontext_addr (struct fra
   /* A pointer to the ucontext is passed as the fourth argument
      to the signal handler, which is saved in rbx.  */
   get_frame_register (this_frame, AMD64_RBX_REGNUM, buf);
-  rbx = extract_unsigned_integer (buf, 8);
+  rbx = extract_unsigned_integer (buf, 8, byte_order);
 
   /* The pointer to mcontext is at offset 48.  */
   read_memory (rbx + 48, buf, 8);
 
   /* First register (rax) is at offset 16.  */
-  return extract_unsigned_integer (buf, 8) + 16;
+  return extract_unsigned_integer (buf, 8, byte_order) + 16;
 }
 
 /* Return true if the PC of THIS_FRAME is in a signal trampoline which

-- 
  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]