Byte-order problems with GDB and BDM driver

Dario Alcocer dalcocer at
Tue Jun 20 20:08:16 UTC 2000


Are any of you using gdb with the Linux BDM driver on an Intel x86
host?  I'm experiencing byte ordering problems when reading and
writing target memory using the BDM interface.  [I'm suspecting that
the library has been tested on non-Intel (i.e. big-endian) machines,
but I'm not sure.  At least, that's the way gdb seems to be behaving.]

Specifically, when I download hello.exe to the target, the program
bytes are being written incorrectly to the target.  Running 'objdump
--disassemble hello.exe' shows the correct byte order:

    00020000 <start-0x4>:
       20000:       0000 0000       orib #0,%d0

    00020004 <start>:
       20004:       2e7c 0003 3430  moveal #209968,%sp
       2000a:       4ef9 0002 0c70  jmp 20c70 <_Init5307>

However, when I dump the target bytes in 'gdb' (after loading
hello.exe via the gdb 'load' command), I see the following incorrect
byte order:

    (gdb) x/16bx 0x20000
    0x20000: 0x00 0x00 0x00 0x00 0x00 0x7c 0x00 0x03
    0x20008: 0x2e 0x30 0x4e 0xf9 0x34 0x02 0x0c 0x70
    (gdb) x/4i 0x20000
    0x20000:	orib #0,%d0
    0x20004 <start>:	oriw #3,%sr
    0x20008 <start+4>:	movel %a0@(fffffff9,%d4:l:8),%d7
    0x2000c <start+8>:	movew %d2,%d2

Notice that the code has been incorrectly disassembled by gdb, due to
the bytes being written incorrectly.

I've looked at bdmIO.c (part of libBDM.a), and bdmReadMemory() is
performing byte-reordering.  Before I go and rewrite this routine, I
was curious if anyone else was having the same problems.  In case it
matters, I'm running Red Hat 6.1 on a Pentium II laptop.

Dario Alcocer // dalcocer at

More information about the users mailing list