0
我成功地從程序集中調用了exit syscall,但我正努力調用_getpid系統調用並使用它的返回值。下面是我使用getpid從syscall與32位應用程序和雪豹上的內核
.text
.globl _getpiddirect
_getpiddirect:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
movl $39, %eax
int $0x80
addl $8, %esp
popl %ebp
ret
和
#include <stdio.h>
#include <unistd.h>
extern unsigned long getpiddirect();
int main(int argc, const char *argv[])
{
printf("%lu\n", getpiddirect());
printf("%lu\n", (unsigned long) getpid());
return 0;
}
getpiddirect保持返回4056
謝謝你的回答是正確的。我誤以爲getpid與getpid。 額外的8個字節是必要的,以保持堆棧對齊mac os ABI的要求。 – 2010-05-31 12:18:51