2
0
mirror of https://github.com/xcat2/xNBA.git synced 2025-01-05 19:15:05 +00:00
xNBA/src/arch/i386/core/nulltrap.c

49 lines
2.0 KiB
C
Raw Normal View History

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