feat: test sans --fomit-frame-pointer, travail sur sysexit

This commit is contained in:
Nicolas Hordé 2018-12-04 21:57:44 +01:00
parent e87aedb02e
commit 9041832823
3 changed files with 15 additions and 35 deletions

View File

@ -9,7 +9,9 @@
static inline long syscall(long syscall) { static inline long syscall(long syscall) {
long ret; long ret;
asm volatile ( asm volatile (
"mov %%esp,%%ecx;\ "pushl %%ecx;\
pushl %%edx;\
mov %%esp,%%ecx;\
mov $1f,%%edx;\ mov $1f,%%edx;\
sysenter;\ sysenter;\
1:" : "=a" (ret) : "a" (syscall): "ecx","edx","memory"); 1:" : "=a" (ret) : "a" (syscall): "ecx","edx","memory");
@ -19,7 +21,9 @@ return ret;
static inline long syscall1(long syscall, long arg1) { static inline long syscall1(long syscall, long arg1) {
long ret; long ret;
asm volatile ( asm volatile (
"mov %%esp,%%ecx;\ "pushl %%ecx;\
pushl %%edx;\
mov %%esp,%%ecx;\
mov $1f,%%edx;\ mov $1f,%%edx;\
sysenter;\ sysenter;\
1:" : "=a" (ret) : "a" (syscall), "b" (arg1) : "ecx","edx","memory"); 1:" : "=a" (ret) : "a" (syscall), "b" (arg1) : "ecx","edx","memory");
@ -29,7 +33,9 @@ return ret;
static inline long syscall2(long syscall, long arg1, long arg2) { static inline long syscall2(long syscall, long arg1, long arg2) {
long ret; long ret;
asm volatile ( asm volatile (
"mov %%esp,%%ecx;\ "pushl %%ecx;\
pushl %%edx;\
mov %%esp,%%ecx;\
mov $1f,%%edx;\ mov $1f,%%edx;\
sysenter;\ sysenter;\
1:" : "=a" (ret) : "a" (syscall), "b" (arg1), "S" (arg2) : "ecx","edx","memory"); 1:" : "=a" (ret) : "a" (syscall), "b" (arg1), "S" (arg2) : "ecx","edx","memory");
@ -39,41 +45,15 @@ return ret;
static inline long syscall3(long syscall, long arg1, long arg2, long arg3) { static inline long syscall3(long syscall, long arg1, long arg2, long arg3) {
long ret; long ret;
asm volatile ( asm volatile (
"mov %%esp,%%ecx;\ "pushl %%ecx;\
pushl %%edx;\
mov %%esp,%%ecx;\
mov $1f,%%edx;\ mov $1f,%%edx;\
sysenter;\ sysenter;\
1:" : "=a" (ret) : "a" (syscall), "b" (arg1), "S" (arg2), "D" (arg3) : "ecx","edx","memory"); 1:" : "=a" (ret) : "a" (syscall), "b" (arg1), "S" (arg2), "D" (arg3) : "ecx","edx","memory");
return ret; return ret;
} }
/*static inline long syscall4(long syscall, long arg1, long arg2, long arg3, long arg4) { /* Vers 6 arguments maximum */
long ret;
asm volatile ("mov %%esp,%%ecx;
"mov $1f,%%edx;
"sysenter;
1:" : "=a" (ret) : "a" (syscall), "b" (arg1), "c" (arg2),
"d" (arg3), "S" (arg4) : memory);
return ret;
}
static inline long syscall5(long syscall, long arg1, long arg2, long arg3, long arg4, long arg5) {
long ret;
asm volatile ("mov %%esp,%%ecx;
"mov $1f,%%edx;
"sysenter;
1:" : "=a" (ret) : "a" (syscall), "b" (arg1), "c" (arg2),
"d" (arg3), "S" (arg4), "D" (arg5) : memory);
return ret;
}
static inline long syscall6(long syscall, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6) {
long ret;
asm volatile ("mov %%esp,%%ecx;
"mov $1f,%%edx;
"sysenter;
1:" : "=a" (ret) : "a" (syscall), "b" (arg1), "c" (arg2),
"d" (arg3), "S" (arg4), "D", (arg5), "d" (arg6) : memory);
return ret;
}*/
void initsyscall(void); void initsyscall(void);
void sysenter_handler(void); void sysenter_handler(void);

View File

@ -1,4 +1,4 @@
CC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -fomit-frame-pointer -Wall -w -m32 -F pe-i386 -I ../include CC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -m32 -F pe-i386 -I ../include
LINK=ld -m elf_i386 -r -o LINK=ld -m elf_i386 -r -o
SRCS= $(wildcard *.c) SRCS= $(wildcard *.c)
OBJS= $(SRCS:.c=.o) OBJS= $(SRCS:.c=.o)

View File

@ -1,4 +1,4 @@
GCC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -fomit-frame-pointer -Wall -w -I ../include -m32 -c -o GCC=gcc -O0 -g -nostdinc -ffreestanding -fno-builtin -Wall -w -I ../include -m32 -c -o
ASM=nasm ASM=nasm
LINK=ld -m elf_i386 -T linker.lds -n -o LINK=ld -m elf_i386 -T linker.lds -n -o