binutils 2.9.1.0.4 bugs and a patch

H.J. Lu (hjl@lucon.org)
Tue, 26 May 1998 21:27:09 -0700 (PDT)


>
> Here's a test case:
>
> The following code isn't assembled correctly with
> binutils 2.9.1.0.4 (gas 2.9.1):
>
> movb $36, 0x4(%di)
> movw %di, %fs:(%bx)
> movw %es, %fs:2(%bx)
>
> objdump shows me that the code is assembled to:
>
> c6 46 04 24 movb $0x24,0x4(bp)
> 64 89 3f movw %di,%fs:(bx)
> 64 8c 46 02 movw %es,%fs:0x2(bp)
>
> instead of this:
>
> c6 45 04 24 movb $0x24,0x4(di)
> 64 89 3f movw %di,%fs:(bx)
> 64 8c 47 02 movw %es,%fs:0x2(bx)
>
> I ran across this while rewriting asms in Linux's arch/i386/boot to use
> as/ld instead of as86/ld86, since someone wonderful added 16-bit code
> generation to gas. =)

Thanks. Sorry for the delay.

>
> Also, I've noticed all the 'ret' instructions have extraneous prefix
> bytes, even when not needed. (ie in .code16):
>
> 66 c3 ret
> 'stead of:
> c3 ret
>
> test.S:
> --- cut ---
> .text
> .code16
>
> ret
> --- cut ---
>
> iniquity:~$ as test.S
> iniquity:~$ objdump -D a.out
>
> a.out: file format elf32-i386
>
> Disassembly of section .text:
>
> 00000000 <.text>:
> 0: 66 c3 ret
>

Please try "retw" instead of "ret" for 16bit return.

>
> I've attached a copy of the rewritten 'linux/arch/i386/boot/bootsect.S',
> with the offending instructions commented out and replaced with their
> respective opcode bytes (by way of .byte ab, cd, ef). Go ahead and remake
> it and 'objdump' the resulting binary. You'll see the instructions that
> have been improperly assembled.
>

Here is a patch for this bug. Please let me know if it works for you.
Martynas, can you double check it?

Thanks.

H.J.

--
Tue May 26 21:05:00 1998  H.J. Lu  (hjl@gnu.org)

* config/tc-i386.c (md_assemble): Fix a 16bit addressing typo.

Index: config/tc-i386.c =================================================================== RCS file: /home/work/cvs/gnu/binutils/gas/config/tc-i386.c,v retrieving revision 1.41 diff -u -p -r1.41 tc-i386.c --- tc-i386.c 1998/04/28 19:05:33 1.41 +++ tc-i386.c 1998/05/27 03:57:40 @@ -1808,7 +1808,8 @@ md_assemble (line) i.types[n] &= ~Abs32; i.types[n] |= Abs16; } - i.rm.regmem = 0x06; + if (i.rm.mode == 0) + i.rm.regmem = 0x06; } /* Add the address size prefix if we need one */

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu