diff --git a/README.adoc b/README.adoc index 7f6ca12..be31937 100644 --- a/README.adoc +++ b/README.adoc @@ -12375,6 +12375,13 @@ Bibliography: * link:userland/arch/x86_64/or.S[OR] * link:userland/arch/x86_64/xor.S[XOR] +=== x86 control transfer instructions + +<> 5.1.7 "Control Transfer Instructions" + +* link:userland/arch/x86_64/jmp.S[JMP] +** link:userland/arch/x86_64/jmp_indirect.S[JMP indirect] + === x86 SIMD History: diff --git a/userland/arch/x86_64/jmp.S b/userland/arch/x86_64/jmp.S new file mode 100644 index 0000000..7a31be3 --- /dev/null +++ b/userland/arch/x86_64/jmp.S @@ -0,0 +1,12 @@ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#x86-jmp-instruction + * + * Unconditional branch, address relative to the current address. + */ + +#include + +LKMC_PROLOGUE + jmp after_fail + LKMC_ASSERT_FAIL +after_fail: +LKMC_EPILOGUE diff --git a/userland/arch/x86_64/jmp_indirect.S b/userland/arch/x86_64/jmp_indirect.S new file mode 100644 index 0000000..f4af3e5 --- /dev/null +++ b/userland/arch/x86_64/jmp_indirect.S @@ -0,0 +1,22 @@ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#x86-jmp-instruction + * + * Unconditional branch to an absolute address stored in memory on in a register. + */ + +#include + +LKMC_PROLOGUE + /* Address in memory. */ +.section .rodata + label_address: .quad memory_label +.text + jmp *label_address + LKMC_ASSERT_FAIL +memory_label: + + /* Address in register. */ + lea register_label(%rip), %rax + jmp *%rax + LKMC_ASSERT_FAIL +register_label: +LKMC_EPILOGUE