Linux x86_64线程/ sys_clone()的汇编示例

时间:2022-01-27 12:37:27

from the clone(2) manpage

来自clone(2)联机帮助页

http://man7.org/linux/man-pages/man2/clone.2.html

       long clone(unsigned long flags, void *child_stack,
                 void *ptid, void *ctid,
                 struct pt_regs *regs);

it's not obvious how you specify the function using the bare syscall (not libc) and also how you set up "struct pt_regs *regs" in assembly (...do you somehow include the IP as a register in a stack of registers [arranged how?] pointed to by "*regs" which thus specifies the call address?)

如何使用裸系统调用(不是libc)指定函数以及如何在汇编中设置“struct pt_regs * regs”并不明显(...您是否以某种方式将IP作为寄存器堆栈中的寄存器[已安排]如何?]指向“* regs”,从而指定了呼叫地址?)

I've searched for any pertinent examples. Can anyone point to examples or clarify?

我搜索过任何相关的例子。任何人都可以指出示例或澄清吗?

1 个解决方案

#1


1  

It is not obvious, unless you know where to look. This is for 32 bit syscalls:

这是不明显的,除非你知道在哪里看。这适用于32位系统调用:

eax = 120 (syscall number for sys_clone)
ebx = unsigned long flags
ecx = void *child_stack
edx = void *ptid
esi = void *ctid
edi = struct pt_regs *regs  

Then an int 80H

然后一个int 80H

http://syscalls.kernelgrok.com/ and search for clone

http://syscalls.kernelgrok.com/并搜索克隆

For 64bit syscalls: http://blog.rchapman.org/post/36801038863/linux-system-call-table-for-x86-64

对于64位系统调用:http://blog.rchapman.org/post/36801038863/linux-system-call-table-for-x86-64

And then look at http://lxr.free-electrons.com/source/arch/x86/include/asm/ptrace.h for the definition of the pt_regs structure

然后查看http://lxr.free-electrons.com/source/arch/x86/include/asm/ptrace.h以获取pt_regs结构的定义

Anything else, just read the man pages for clone and the info for the params are laid out.

还有其他的东西,只需阅读手册中的克隆版,并列出参数的信息。

#1


1  

It is not obvious, unless you know where to look. This is for 32 bit syscalls:

这是不明显的,除非你知道在哪里看。这适用于32位系统调用:

eax = 120 (syscall number for sys_clone)
ebx = unsigned long flags
ecx = void *child_stack
edx = void *ptid
esi = void *ctid
edi = struct pt_regs *regs  

Then an int 80H

然后一个int 80H

http://syscalls.kernelgrok.com/ and search for clone

http://syscalls.kernelgrok.com/并搜索克隆

For 64bit syscalls: http://blog.rchapman.org/post/36801038863/linux-system-call-table-for-x86-64

对于64位系统调用:http://blog.rchapman.org/post/36801038863/linux-system-call-table-for-x86-64

And then look at http://lxr.free-electrons.com/source/arch/x86/include/asm/ptrace.h for the definition of the pt_regs structure

然后查看http://lxr.free-electrons.com/source/arch/x86/include/asm/ptrace.h以获取pt_regs结构的定义

Anything else, just read the man pages for clone and the info for the params are laid out.

还有其他的东西,只需阅读手册中的克隆版,并列出参数的信息。