[llvm-bugs] [Bug 50292] New: Clang assembler does not recognize long jumps for x86 intel assembly

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 10 20:40:55 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50292

            Bug ID: 50292
           Summary: Clang assembler does not recognize long jumps for x86
                    intel assembly
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Driver
          Assignee: unassignedclangbugs at nondot.org
          Reporter: iankronquist at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

When clang is invoked on an assembly file, I expect it to be compatible with
gcc and binutils as.

When using Intel syntax, clang does not properly assemble the x86 long jump
instruction, used to reload the code segment descriptor. This happens in
.code16 and .code32 mode.

Here is an example that will assemble with gcc and binutils as, but not with
clang:

```
ian at iankhome:~/k2$ cat bug.S
.intel_syntax noprefix

.code16
.text
.global _start
_start:
        jmp 0:.canonicalized_ip
.canonicalized_ip:
        jmp 0x18:.protected
.code32
.protected:
    jmp 0x28,.long_mode
.long_mode:
ian at iankhome:~/k2$ clang-11 -c bug.S
bug.S:7:7: error: unexpected token in argument list
 jmp 0:.canonicalized_ip
      ^
bug.S:9:10: error: unexpected token in argument list
 jmp 0x18:.protected
         ^
bug.S:12:5: error: invalid operand for instruction
    jmp 0x28,.long_mode
    ^
ian at iankhome:~/k2$ gcc -c bug.S
ian at iankhome:~/k2$ as -c bug.S
ian at iankhome:~/k2$ clang-11 --version
Ubuntu clang version 11.0.0-2~ubuntu20.04.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
ian at iankhome:~/k2$ as --version
GNU assembler (GNU Binutils for Ubuntu) 2.34
Copyright (C) 2020 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
ian at iankhome:~/k2$ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

```

Adding the clang command line flags -masm=intel doesn't change clang's
behavior.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210511/39ed18cc/attachment-0001.html>


More information about the llvm-bugs mailing list