Skip to content

Commit 1e272a1

Browse files
committed
Make the 32-bit VDSO shared stub a function so that gdb reverse-next over VDSO functions works
1 parent a312b24 commit 1e272a1

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/Monkeypatcher.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ void patch_after_exec_arch<X86Arch>(RecordTask* t, Monkeypatcher& patcher) {
807807
uint8_t patch[X86VsyscallMonkeypatch::size];
808808
uint32_t syscall_number = syscalls_to_monkeypatch[j].syscall_number;
809809
X86VsyscallMonkeypatch::substitute(patch, syscall_number,
810-
shared_address - (absolute_address + X86VsyscallMonkeypatch::size));
810+
shared_address - (absolute_address + X86VsyscallMonkeypatch::size - 1));
811811

812812
write_and_record_bytes(t, absolute_address, patch);
813813
LOG(debug) << "monkeypatched " << syscalls_to_monkeypatch[j].name

src/assembly_templates.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,19 @@ def bytes(self):
104104
Field('syscall_hook_trampoline', 4),
105105
),
106106
'X86VsyscallMonkeypatch': AssemblyTemplate(
107-
RawBytes(0x53), # push %ebx
108107
RawBytes(0xb8), # mov $syscall_number,%eax
109108
Field('syscall_number', 4),
110-
RawBytes(0xe9), # jmp $X86VsyscallMonkeypatchShared
109+
RawBytes(0xe8), # call $X86VsyscallMonkeypatchShared
111110
Field('vsyscall_monkeypatch_shared', 4),
111+
RawBytes(0xc3),
112112
),
113113
'X86VsyscallMonkeypatchShared': AssemblyTemplate(
114114
# __vdso functions use the C calling convention, so
115115
# we have to set up the syscall parameters here.
116116
# No x86-32 __vdso functions take more than two parameters.
117-
RawBytes(0x8b, 0x5c, 0x24, 0x08), # mov 0x8(%esp),%ebx
118-
RawBytes(0x8b, 0x4c, 0x24, 0x0c), # mov 0xc(%esp),%ecx
117+
RawBytes(0x53), # push %ebx
118+
RawBytes(0x8b, 0x5c, 0x24, 0x0c), # mov 12(%esp),%ebx
119+
RawBytes(0x8b, 0x4c, 0x24, 0x10), # mov 16(%esp),%ecx
119120
RawBytes(0xcd, 0x80), # int $0x80
120121
# pad with NOPs to make room to dynamically patch the syscall
121122
# with a call to the preload library, once syscall buffering

0 commit comments

Comments
 (0)