]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
(SWIWrite0): Catch big-endian bug when printing characters
authorNick Clifton <nickc@redhat.com>
Sun, 2 Mar 2003 10:28:29 +0000 (10:28 +0000)
committerNick Clifton <nickc@redhat.com>
Sun, 2 Mar 2003 10:28:29 +0000 (10:28 +0000)
sim/arm/ChangeLog
sim/arm/armos.c

index 90cc64fa78dff63cd688e3c3cb82f5b1132a935a..5e4b316ca863d5cf858030dbecbbc74410d841f5 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-02  Nick Clifton  <nickc@redhat.com>
+
+       * armos.c (SWIWrite0): Catch big-endian bug when printing
+       characters.
+
 2003-02-27  Andrew Cagney  <cagney@redhat.com>
 
        * wrapper.c (sim_create_inferior, sim_open): Rename _bfd to bfd.
index c4cb05175601054b38cc6fc558221a9c617fd669..04916d6ad72f20c465b10340d35a4cbc22f8402e 100644 (file)
@@ -274,7 +274,13 @@ SWIWrite0 (ARMul_State * state, ARMword addr)
   struct OSblock *OSptr = (struct OSblock *) state->OSptr;
 
   while ((temp = ARMul_SafeReadByte (state, addr++)) != 0)
-    (void) sim_callback->write_stdout (sim_callback, (char *) &temp, 1);
+    {
+      char buffer = temp;
+      /* Note - we cannot just cast 'temp' to a (char *) here,
+        since on a big-endian host the byte value will end
+        up in the wrong place and a nul character will be printed.  */
+      (void) sim_callback->write_stdout (sim_callback, & buffer, 1);
+    }
 
   OSptr->ErrorNo = sim_callback->get_errno (sim_callback);
 }