From 90418328239dc6be18b0dd6bf613ca692d6efc35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Tue, 4 Dec 2018 21:57:44 +0100 Subject: [PATCH] feat: test sans --fomit-frame-pointer, travail sur sysexit --- include/syscall.h | 46 +++++++++++++--------------------------------- lib/makefile | 2 +- system/makefile | 2 +- 3 files changed, 15 insertions(+), 35 deletions(-) diff --git a/include/syscall.h b/include/syscall.h index 4910067..a0c0e06 100644 --- a/include/syscall.h +++ b/include/syscall.h @@ -9,7 +9,9 @@ static inline long syscall(long syscall) { long ret; asm volatile ( -"mov %%esp,%%ecx;\ +"pushl %%ecx;\ +pushl %%edx;\ +mov %%esp,%%ecx;\ mov $1f,%%edx;\ sysenter;\ 1:" : "=a" (ret) : "a" (syscall): "ecx","edx","memory"); @@ -19,7 +21,9 @@ return ret; static inline long syscall1(long syscall, long arg1) { long ret; asm volatile ( -"mov %%esp,%%ecx;\ +"pushl %%ecx;\ +pushl %%edx;\ +mov %%esp,%%ecx;\ mov $1f,%%edx;\ sysenter;\ 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) { long ret; asm volatile ( -"mov %%esp,%%ecx;\ +"pushl %%ecx;\ +pushl %%edx;\ +mov %%esp,%%ecx;\ mov $1f,%%edx;\ sysenter;\ 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) { long ret; asm volatile ( -"mov %%esp,%%ecx;\ +"pushl %%ecx;\ +pushl %%edx;\ +mov %%esp,%%ecx;\ mov $1f,%%edx;\ sysenter;\ 1:" : "=a" (ret) : "a" (syscall), "b" (arg1), "S" (arg2), "D" (arg3) : "ecx","edx","memory"); return ret; } -/*static inline long syscall4(long syscall, long arg1, long arg2, long arg3, long arg4) { -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; -}*/ +/* Vers 6 arguments maximum */ void initsyscall(void); void sysenter_handler(void); diff --git a/lib/makefile b/lib/makefile index bc48e53..815b6a1 100755 --- a/lib/makefile +++ b/lib/makefile @@ -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 SRCS= $(wildcard *.c) OBJS= $(SRCS:.c=.o) diff --git a/system/makefile b/system/makefile index 642fbbf..922a303 100755 --- a/system/makefile +++ b/system/makefile @@ -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 LINK=ld -m elf_i386 -T linker.lds -n -o