Skip to content

Commit 5e5df87

Browse files
committed
Fix code patching scenario on Linux
1 parent df3dcc9 commit 5e5df87

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

qiling/loader/elf.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,14 @@ def __init__(self, ql: Qiling):
6868
def run(self):
6969
if self.ql.code:
7070
self.ql.mem.map(self.ql.os.entry_point, self.ql.os.code_ram_size, info="[shellcode_stack]")
71-
self.ql.os.entry_point = (self.ql.os.entry_point + 0x200000 - 0x1000)
72-
self.ql.mem.write(self.ql.os.entry_point, self.ql.code)
73-
self.ql.arch.regs.arch_sp = self.ql.os.entry_point
71+
72+
shellcode_base = self.ql.os.entry_point + 0x200000 - 0x1000
73+
self.ql.mem.write(shellcode_base, self.ql.code)
74+
75+
self.ql.arch.regs.arch_sp = shellcode_base
76+
self.ql.os.entry_point = shellcode_base
77+
self.load_address = shellcode_base
78+
7479
return
7580

7681
section = {

0 commit comments

Comments
 (0)