bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gas/30849] New: gas x86-64: Operand size prefix incorrectly parsed


From: jwlee2217 at softsec dot kaist.ac.kr
Subject: [Bug gas/30849] New: gas x86-64: Operand size prefix incorrectly parsed as operand in `prefetch` Instruction
Date: Thu, 14 Sep 2023 04:07:59 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=30849

            Bug ID: 30849
           Summary: gas x86-64: Operand size prefix incorrectly parsed as
                    operand in `prefetch` Instruction
           Product: binutils
           Version: 2.41
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gas
          Assignee: unassigned at sourceware dot org
          Reporter: jwlee2217 at softsec dot kaist.ac.kr
  Target Milestone: ---

```
$ cat examples/bug3_1.s
.intel_syntax noprefix
prefetch WORD PTR [R11]
$ ./as examples/bug3_1.s -o bug3_1.o        
$ ./objdump -d -M intel bug3_1.o

bug3_1.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <.text>:
   0:   41 0f 0d 03             prefetch BYTE PTR [r11]
```

It seems GAS ignores memory operand prefixes for Intel `prefetch` instruction.
I guess this behavior is because `prefetch` only accepts an 8-bit width memory
operand.

```
$ cat examples/bug3_2.s
.intel_syntax noprefix
prefetch DUMMYDUMMYDUMMY [R11]
prefetch [R11] [R11]
$ ./as examples/bug3_2.s -o bug3_2.o
$ ./objdump -d -M intel bug3_2.o

bug3_2.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <.text>:
   0:   41 0f 0d 83 00 00 00    prefetch BYTE PTR [r11+0x0]
   7:   00 
   8:   43 0f 0d 04 1b          prefetch BYTE PTR [r11+r11*1]
$ ./readelf -r bug3_2.o

Relocation section '.rela.text' at offset 0xc8 contains 1 entry:
  Offset          Info           Type           Sym. Value    Sym. Name +
Addend
000000000004  00010000000b R_X86_64_32S      0000000000000000 DUMMYDUMMYDUMMY +
0
```

More interesting behaviors can be observed when we give an arbitrary token
instead of a memory operand prefix. If we put a symbol or an additional memory
operand, then two memory operands are treated as a single memory operand.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]