Home |
RTTarget-32 Programming Manual Running Win32 Programs without Win32 Running a Program on the Target Running with or without Paging Installing Hardware Interrupt Handlers Catching NULL Pointer Assignments Catching Stack Overflows Running without Run-Time System Configuration for Debug and Release Builds Loading DLLs through a File System Using the MetaWINDOW Graphics Library Custom MP Floating Pointer Structure Compiling and Linking with On Time RTOS-32 |
Catching Stack OverflowsProtecting from stack overflows works in a similar way. The stack grows from high address to low address. To detect a stack overflow, the memory immediately preceding the stack should have less than read/write access. For example, the stack could be placed following the code section or in a region separated from other regions by at least one page. Example:Region FirstPage 0 4k RAM Assign Region LowMem 4k 636k RAM Assign Region HighMem 1M 3M RAM Assign Virtual ProgMem 4M // for code and data Virtual StackMem 5M // for the stack Virtual HeapMem 6M // for the heap which gets FillRAM HeapMem // all remaining memory ... Locate Stack S StackMem->LowMem 16k Locate Heap H HeapMem Both the stack and the heap are placed in separate virtual regions, completely isolating them from other program entities. Any stack overflow will cause the stack pointer to leave region StackMem and will trigger a page fault. Catching NULL Pointer Assignments Running without Run-Time System
|