syscall via asm - where is the system call numbers defined?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all!

I'm looking at calling the kernel without libc, namely filling eax with 
syscall no, ebx,ecx etc with parameters and then calling int 0x80 to trigger 
it.

However, something got me stomped for a while. I'm running 64bits kernel 
(core2duo), so naturally, I thought that the numbers I'm looking for is in 
arch/x86/include/asm/unistd_64.h . 

After playing around with getpid, which is declared to be 39, or 0x27 in 
unistd_64.h I only got -14 (-EFAULT). When I tried the unistd_32.h 
equivalent, 20, I got the pid as expected.

So, my question is this: how come the values for 64 bit is declared in the 32 
bit part? Or, alternatively, why is the unistd split in 64 and 32 in the 
first place?


sample code for the interested:

int pid = -1;
/* ID of getpid is 20 */
asm("movl $20,%eax");
asm("int $0x80");

asm("movl %%eax, %0"
:"=r"(pid) /* pid is output operand */
:/* no input */
:"%eax"); /* %eax is clobbered register */

printf("From asm/int:\t%d\n", pid);

-- 
mvh Henrik Austad

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux