llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.14k stars 12.02k forks source link

[BPF] mod32 (0x94) instruction not recognized ! #54252

Open perror opened 2 years ago

perror commented 2 years ago

I compiled the following code with bpf-gcc:

int foo (void)
{
  int n = 10, m = 100, k = -1;

  n = 10 * k + ((unsigned) m) % 7;
  k = (n ^ m) >> 2;
  return k;
}

When disassembled with bpf-objdumd if get:

  400068:   bc 01 00 00 00 00 00 00          mov32 %r1,%r0
  400070:   61 a0 f8 ff 00 00 00 00          ldxw %r0,[%fp+-8]
  400078:   94 00 00 00 07 00 00 00          mod32 %r0,7
  400080:   bc 00 00 00 00 00 00 00          mov32 %r0,%r0
  400088:   0c 01 00 00 00 00 00 00          add32 %r1,%r0

But, the exact same opcodes produce the following with llvm-objdump-13 -d:

  524301:   bc 01 00 00 00 00 00 00 w1 = w0
  524302:   61 a0 f8 ff 00 00 00 00 r0 = *(u32 *)(r10 - 8)
  524303:   94 00 00 00 07 00 00 00 <unknown>
  524304:   bc 00 00 00 00 00 00 00 w0 = w0
  524305:   0c 01 00 00 00 00 00 00 w1 += w0

So, it seems that the opcode 0x94 (mod32) is not recognized.

I may be wrong, so do not hesitate to tell me if I am wrong.

llvmbot commented 2 years ago

@llvm/issue-subscribers-tools-llvm-objdump