[BUG] Mismatch between assembler & disassembler of X86 RIP-relative instruction


I found a mismatch between assembler & disassembler of X86: I assembled an instruction, then disassembled the output, but the result is not the same as the first original code: “add qword ptr [205163983024656], 1” vs " add qword ptr [1985229328], 1"

Anybody knows what is wrong?


$ echo “ADD QWORD PTR [0xba9876543210], 0x1”|llvm-mc -assemble -triple=x86_64 -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding
add qword ptr [205163983024656], 1 # encoding:[0x48,0x83,0x04,0x25,0x10,0x32,0x54,0x76,0x01]

$ echo “0x48,0x83,0x04,0x25,0x10,0x32,0x54,0x76,0x01”|llvm-mc -disassemble -triple=x86_64 -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding
add qword ptr [1985229328], 1 # encoding: [0x48,0x83,0x04,0x25,0x10,0x32,0x54,0x76,0x01]

To make it more clear, here is the same thing again, but with hexa
immediate. You can see the difference in memory address: 0xba9876543210 vs

$ echo "ADD QWORD PTR [0xba9876543210], 0x1"|llvm-mc -assemble
-triple=x86_64 -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding
    add qword ptr [0xba9876543210], 0x1 # encoding:

$ echo "0x48,0x83,0x04,0x25,0x10,0x32,0x54,0x76,0x01"|llvm-mc -disassemble
-triple=x86_64 -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding
    add qword ptr [0x76543210], 0x1 # encoding:

Hi Jun,

Could you file a PR please?