Skip to content

Commit

Permalink
[build] Ensure stacks are at edges of used memory
Browse files Browse the repository at this point in the history
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 <mbrown@fensystems.co.uk>
  • Loading branch information
mcb30 committed Sep 11, 2012
1 parent 2a7458c commit 2dc3374
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion callback.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions script.lds
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ SECTIONS {
/* Real-mode uninitialised data section */
.bss16 ( NOLOAD ) : {
_bss16 = .;
*(.stack16)
*(.stack16.*)
*(.bss16)
*(.bss16.*)
_ebss16 = .;
Expand Down Expand Up @@ -48,6 +50,9 @@ SECTIONS {
_bss = .;
*(.bss)
*(.bss.*)
*(COMMON)
*(.stack)
*(.stack.*)
_ebss = .;
}
_bss_len = ABSOLUTE ( _ebss ) - ABSOLUTE ( _bss );
Expand Down
2 changes: 1 addition & 1 deletion startup.S
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ idt:
.size idt, . - idt

/* Stack */
.section ".bss", "aw", @nobits
.section ".stack", "aw", @nobits
.align 8
_stack:
.space ( 256 * 1024 )
Expand Down

0 comments on commit 2dc3374

Please sign in to comment.