#943581 objdump: disassembles 16-bit code wrong (popfd as popf)

Package:
binutils
Source:
binutils
Description:
GNU assembler, linker and binary utilities
Submitter:
Thorsten Glaser
Date:
2019-10-26 20:45:04 UTC
Severity:
normal
#943581#5
Date:
2019-10-26 20:27:56 UTC
From:
To:
Found during reporting #943579:


tglase@tglase-nb:~ $ cat x.s
        .globl main
main:
        .byte   0x66, 0x31, 0xc9, 0x8e, 0xd1, 0xbc, 0xfc, 0x7b, 0x66, 0x51, 0x66, 0x9d, 0x8e, 0xc1
tglase@tglase-nb:~ $ as --32 x.s
tglase@tglase-nb:~ $ objdump -d -Mintel,i8086 a.out

a.out:     file format elf32-i386


Disassembly of section .text:

00000000 <main>:
   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


Expected is “popfd” for 66 9D in 16-bit mode (just 9D is “popf”,
and in 32-bit mode, 9D is “popfd” and 66 9D is “popfw”). While
nasm gets this wrong assembling, ndisasm gets it right.

#943581#10
Date:
2019-10-26 20:42:50 UTC
From:
To:
Control: found 943581 2.28-5
Control: notfound 943581 2.18.1~cvs20080103-7

Similar to #943579 I can reproduce it in a stretch chroot, but
the version in lenny wasn’t buggy as it produced this:

   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                      data32
   b:   9d                      popf
   c:   8e c1                   mov    es,cx

This isn’t optimal but okay.

bye,
//mirabilos