Package: gdb
Version: 8.3.1-1
Severity: normal
Tags: upstream

I’m starting qemu-system-i386 with, for example, the MirBSD CD-ROM.
Then I attach gdb to qemu (started with -s -S), set a breakpoint at
the beginning of the bootsector, continue and disassemble.

(gdb) b *0x7c00
Breakpoint 1 at 0x7c00
(gdb) c
Continuing.

But it disassembles wrong:

(gdb) x/14i 0x7c00
=> 0x7c00:      xor    cx,cx
   0x7c03:      mov    ss,ecx
   0x7c05:      mov    esp,0x51667bfc
   0x7c0a:      popfw
   0x7c0c:      mov    es,ecx
   0x7c0e:      mov    edi,0xb1577c00
[…]
(gdb) x/14xb 0x7c00
0x7c00: 0x66    0x31    0xc9    0x8e    0xd1    0xbc    0xfc    0x7b
0x7c08: 0x66    0x51    0x66    0x9d    0x8e    0xc1
(gdb) show architecture
The target architecture is assumed to be i8086

The correct disassembly is:
        66 31 C9        XOR ECX,ECX
        8E D1           MOV SS,CX
        BC FC 7B        MOV SP,7BFCh
        66 51           PUSH ECX
        66 9D           POPFD
        8E C1           MOV ES,CX

Putting this code snippet into “objdump -d -Mintel,i8086” gets
it almost right (except for the popfd, which nasm also gets
wrong at least when assembling):

   0:   66 31 c9                xor    ecx,ecx
   3:   8e d1                   mov    ss,cx
   5:   bc fc 7b                mov    sp,0x7bfc
   8:   66 51                   push   ecx
   a:   66 9d                   popf
   c:   8e c1                   mov    es,cx

ndisasm *does* get it right:

00000000  6631C9            xor ecx,ecx
00000003  8ED1              mov ss,cx
00000005  BCFC7B            mov sp,0x7bfc
00000008  6651              push ecx
0000000A  669D              popfd
0000000C  8EC1              mov es,cx


-- System Information:
Debian Release: bullseye/sid
  APT prefers unreleased
  APT policy: (500, 'unreleased'), (500, 'buildd-unstable'), (500, 'unstable'), 
(100, 'experimental')
Architecture: x32 (x86_64)
Foreign Architectures: i386, amd64

Kernel: Linux 5.2.0-3-amd64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_FIRMWARE_WORKAROUND
Locale: LANG=C, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=C (charmap=UTF-8)
Shell: /bin/sh linked to /bin/lksh
Init: sysvinit (via /sbin/init)

Versions of packages gdb depends on:
ii  libc6         2.29-2
ii  libexpat1     2.2.9-1
ii  libgcc1       1:9.2.1-9
ii  libipt2       2.0.1-1
ii  liblzma5      5.2.4-1+b1
ii  libncursesw6  6.1+20190803-1
ii  libpython3.7  3.7.5-1
ii  libreadline8  8.0-3
ii  libstdc++6    9.2.1-9
ii  libtinfo6     6.1+20190803-1
ii  zlib1g        1:1.2.11.dfsg-1+b1

Versions of packages gdb recommends:
ii  libc6-dbg [libc-dbg]  2.29-2

Versions of packages gdb suggests:
ii  gdb-doc    8.3.1-1
pn  gdbserver  <none>

-- no debconf information

Reply via email to