iPXE
nulltrap.c
Go to the documentation of this file.
1 #include <stdint.h>
2 #include <stdio.h>
3 
4 __attribute__ (( noreturn, section ( ".text.null_trap" ) ))
5 void null_function_trap ( void ) {
6  void *stack;
7 
8  /* 128 bytes of NOPs; the idea of this is that if something
9  * dereferences a NULL pointer and overwrites us, we at least
10  * have some chance of still getting to execute the printf()
11  * statement.
12  */
13  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
14  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
15  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
16  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
17  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
18  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
19  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
20  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
21  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
22  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
23  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
24  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
25  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
26  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
27  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
28  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
29  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
30  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
31  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
32  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
33  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
34  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
35  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
36  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
37  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
38  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
39  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
40  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
41  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
42  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
43  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
44  __asm__ __volatile__ ( "nop ; nop ; nop ; nop" );
45 
46  __asm__ __volatile__ ( "movl %%esp, %0" : "=r" ( stack ) );
47  printf ( "NULL method called from %p (stack %p)\n",
48  __builtin_return_address ( 0 ), stack );
49  DBG_HD ( stack, 256 );
50  while ( 1 ) {}
51 }
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
#define DBG_HD(...)
Definition: compiler.h:500
struct netvsc_rx_buffer_section section[1]
Section descriptors.
Definition: netvsc.h:18
__attribute__((noreturn, section(".text.null_trap")))
Definition: nulltrap.c:4
__asm__ __volatile__("\n1:\n\t" "movb -1(%3,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %4, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c), "+m"(*value) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")