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
0
to0x19016bc83000
for the firstmov instruction
movq $0, %rdx
change the first operand from value
0x7ffff7fc6000
to0x19016bc74000
for the secondmov instruction
movq $0x7ffff7fc6000, %rsi
change the first operand from value
0x19016bc83000
to0
for the thirdmov instruction
movq $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>