From adb81dc00dea7e2f8eef34d38d2bcad8e9751427 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Wed, 24 Apr 2019 00:45:30 +0200 Subject: [PATCH] Use the base and stack registers in the loader too --- src/arch/i386/loader.S | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/arch/i386/loader.S b/src/arch/i386/loader.S index 0ef0707..603befe 100644 --- a/src/arch/i386/loader.S +++ b/src/arch/i386/loader.S @@ -77,6 +77,9 @@ _start: add $0x4, %esp /* start the loader */ + push %ebp + mov %esp, %ebp + push $0x0 push $0x0 mov %ebx, %eax @@ -84,19 +87,25 @@ _start: push %eax push $0x1 call main - add $0x10, %esp + mov %ebp, %esp + pop %ebp jmp 2f 1: - /* start the loader */ + /* prepare the arguments */ + push %ebp + mov %esp, %ebp push $0x0 push $0x0 push $0x0 push $0x0 - call main - add $0x10, %esp 2: + /* start the loader */ + call main + mov %ebp, %esp + pop %ebp + /* exit the loader */ call _exit