2
0
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:
Michael Brown 2006-06-11 01:48:29 +00:00
parent 7ce44f7480
commit df4b503a8c
2 changed files with 49 additions and 0 deletions

View 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 ) {}
}

View File

@ -117,6 +117,7 @@ SECTIONS {
.text : AT ( _textdata_load_offset + __text ) {
__text = .;
*(.text.null_trap)
*(.text)
*(.text.*)
} = 0x9090