mirror of
https://github.com/xcat2/xNBA.git
synced 2024-12-14 15:21:32 +00:00
Added null trap code for debugging. (Must be included by adding
--nulltrap to the make target at the moment.)
This commit is contained in:
parent
7ce44f7480
commit
df4b503a8c
48
src/arch/i386/core/nulltrap.c
Normal file
48
src/arch/i386/core/nulltrap.c
Normal file
@ -0,0 +1,48 @@
|
||||
#include <stdint.h>
|
||||
#include <vsprintf.h>
|
||||
|
||||
__attribute__ (( noreturn, section ( ".text.null_trap" ) ))
|
||||
void null_function_trap ( void ) {
|
||||
|
||||
/* 128 bytes of NOPs; the idea of this is that if something
|
||||
* dereferences a NULL pointer and overwrites us, we at least
|
||||
* have some chance of still getting to execute the printf()
|
||||
* statement.
|
||||
*/
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
__asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
|
||||
|
||||
printf ( "NULL method called from %p\n",
|
||||
__builtin_return_address ( 0 ) );
|
||||
while ( 1 ) {}
|
||||
}
|
@ -117,6 +117,7 @@ SECTIONS {
|
||||
|
||||
.text : AT ( _textdata_load_offset + __text ) {
|
||||
__text = .;
|
||||
*(.text.null_trap)
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
} = 0x9090
|
||||
|
Loading…
Reference in New Issue
Block a user