kfl / ebpf-tools

Experiments with eBPF bytecode
MIT License
10 stars 4 forks source link

Types of Helper are wrong?? #5

Closed Spatenheinz closed 2 years ago

Spatenheinz commented 2 years ago

I Started using the Helpers module and noticed for 64-Bit they are defined as such:

add64_i :: Reg -> Imm32 -> Instruction
add64_i dst imm = Binary B64 Add dst (Right $ fromIntegral imm)

should it not be:

add64_i :: Reg -> Imm64 -> Instruction

Or have i misunderstood something?

kfl commented 2 years ago

You have misunderstood something 😉

Due to the way that instructions are encoded, it is not possible to have imm larger than 32-bit. Except for the LoadImm instruction which has a 128 bit encoding, for this very reason.

Spatenheinz commented 2 years ago

Ah my bad!