Currently I have written a code segment using assembly on one page pageA in linux kernel.The code is
SYM_CODE_START(sr_function)
movq $0, %rdx
movq $0x7ffff7fc6000, %rsi
movq $0x19016bc83000, %rcx
movq $9, %rdx
movq $0, %rdx
jmp goto_fce_func
SYM_CODE_END(sr_function)
At run time , I would like to overwrite the first operad of mov instruction via c pointer, For example, I map the page pageA to kernel space using kmap(pageA).
That means, Now the first instruction movq $0, %rdx has the address for example 0x1000.
I would like to use C pointer to:
change the first operand from value
0to0x19016bc83000for the firstmov instructionmovq $0, %rdxchange the first operand from value
0x7ffff7fc6000to0x19016bc74000for the secondmov instructionmovq $0x7ffff7fc6000, %rsichange the first operand from value
0x19016bc83000to0for the thirdmov instructionmovq $0x19016bc83000, %rcx
Do you know how could i do this?
the Disassembly of this code segment by using objdump -D shows
0000000000001000 <sr_function>:
1000: 48 c7 c2 00 00 00 00 mov $0x0,%rdx
1007: 48 be 00 60 fc f7 ff movabs $0x7ffff7fc6000,%rsi
100e: 7f 00 00
1011: 48 b9 00 30 c8 6b 01 movabs $0x19016bc83000,%rcx
1018: 19 00 00
101b: 48 c7 c2 09 00 00 00 mov $0x9,%rdx
1022: 48 c7 c2 00 00 00 00 mov $0x0,%rdx
1029: e9 de ef ff ff jmpq c <goto_fce_func>