Fix stack growing direction in GDT being swapped
In the GDT, the direction in which the stack grows in x86 has been ignored; for reserving space on the stack, the ESP register was added to and for cleaning up that space, ESP was subtracted from. That is obviously wrong and is fixed with this commit.
This commit is contained in:
parent
95faf0cc5a
commit
21ba34f526
|
@ -27,7 +27,7 @@ GDT_ENTRY_COUNT equ 3
|
||||||
make_regular_data_segment_in_gdt:
|
make_regular_data_segment_in_gdt:
|
||||||
.prolog:
|
.prolog:
|
||||||
push esi
|
push esi
|
||||||
add esp, 64
|
sub esp, 64
|
||||||
mov esi, esp
|
mov esi, esp
|
||||||
|
|
||||||
mov [esi + (64 - 4)], eax
|
mov [esi + (64 - 4)], eax
|
||||||
|
@ -98,7 +98,7 @@ make_regular_data_segment_in_gdt:
|
||||||
mov ebx, [esi + (64 - 8)]
|
mov ebx, [esi + (64 - 8)]
|
||||||
mov eax, [esi + (64 - 4)]
|
mov eax, [esi + (64 - 4)]
|
||||||
|
|
||||||
sub esp, 64
|
add esp, 64
|
||||||
pop esi
|
pop esi
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ make_regular_data_segment_in_gdt:
|
||||||
make_code_segment_in_gdt:
|
make_code_segment_in_gdt:
|
||||||
.prolog:
|
.prolog:
|
||||||
push esi
|
push esi
|
||||||
add esp, 64
|
sub esp, 64
|
||||||
mov esi, esp
|
mov esi, esp
|
||||||
|
|
||||||
mov [esi + (64 - 4)], eax
|
mov [esi + (64 - 4)], eax
|
||||||
|
@ -205,7 +205,7 @@ make_code_segment_in_gdt:
|
||||||
mov ebx, [esi + (64 - 8)]
|
mov ebx, [esi + (64 - 8)]
|
||||||
mov eax, [esi + (64 - 4)]
|
mov eax, [esi + (64 - 4)]
|
||||||
|
|
||||||
sub esp, 64
|
add esp, 64
|
||||||
pop esi
|
pop esi
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ make_code_segment_in_gdt:
|
||||||
load_flat_gdt:
|
load_flat_gdt:
|
||||||
.prolog:
|
.prolog:
|
||||||
push esi
|
push esi
|
||||||
add esp, 64
|
sub esp, 64
|
||||||
mov esi, esp
|
mov esi, esp
|
||||||
|
|
||||||
mov [esi + (64 - 4)], eax
|
mov [esi + (64 - 4)], eax
|
||||||
|
|
Loading…
Reference in New Issue