summaryrefslogtreecommitdiffstats
path: root/syscall32_from_64.c
blob: 775cef2e1beeea579fb78395cd90d5a2b4983af7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>

extern unsigned long call32_from_64(void *stack, void (*function)(void));

asm (".pushsection .text\n\t"
     ".code32\n\t"
     "syscall32:\n\t"
     "mov $20,%eax\n\t"  // NR_getpid (32-bit)
     "syscall\n\t"
     "syscall32_ret:\n\t"
     "ret\n\t"
     ".code64");
extern void syscall32(void);

static char low_stack[4096];

int main()
{
	unsigned long ret = call32_from_64(low_stack, syscall32);
	printf("syscall return = %ld\n", (long)ret);
	return 0;
}