From 2dc3374360cc14cb2dc8e714446187902873c3a4 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 11 Sep 2012 22:39:51 +0100 Subject: [PATCH] [build] Ensure stacks are at edges of used memory Under VMware, memory above %esp somehow gets overwritten, leading to corrupt internal data structures and unpredictable behaviour. Ensure that the protected-mode stack is at the top of our used memory, and that the real-mode stack is at the bottom. This keeps all of the important data structures nicely contained within a region of memory that is exclusively ours. Signed-off-by: Michael Brown --- callback.S | 2 +- script.lds | 5 +++++ startup.S | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/callback.S b/callback.S index 56f919f..7fa1aa2 100644 --- a/callback.S +++ b/callback.S @@ -218,7 +218,7 @@ rm_idtr: .size rm_idtr, . - rm_idtr /* Real-mode stack */ - .section ".bss16", "aw", @nobits + .section ".stack16", "aw", @nobits .align 8 _rmstack: .space 8192 diff --git a/script.lds b/script.lds index e340cf1..9037a93 100644 --- a/script.lds +++ b/script.lds @@ -16,6 +16,8 @@ SECTIONS { /* Real-mode uninitialised data section */ .bss16 ( NOLOAD ) : { _bss16 = .; + *(.stack16) + *(.stack16.*) *(.bss16) *(.bss16.*) _ebss16 = .; @@ -48,6 +50,9 @@ SECTIONS { _bss = .; *(.bss) *(.bss.*) + *(COMMON) + *(.stack) + *(.stack.*) _ebss = .; } _bss_len = ABSOLUTE ( _ebss ) - ABSOLUTE ( _bss ); diff --git a/startup.S b/startup.S index b187c78..7ebdca0 100644 --- a/startup.S +++ b/startup.S @@ -109,7 +109,7 @@ idt: .size idt, . - idt /* Stack */ - .section ".bss", "aw", @nobits + .section ".stack", "aw", @nobits .align 8 _stack: .space ( 256 * 1024 )