summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brown2006-06-11 03:48:29 +0200
committerMichael Brown2006-06-11 03:48:29 +0200
commitdf4b503a8c138edc0fdcfe920c7d6b6629cd2971 (patch)
tree0b32e858aa746c05b397816117ec0805f3eb80c4 /src
parentUpdate to use the generic i2c bit-bashing code. (diff)
downloadipxe-df4b503a8c138edc0fdcfe920c7d6b6629cd2971.tar.gz
ipxe-df4b503a8c138edc0fdcfe920c7d6b6629cd2971.tar.xz
ipxe-df4b503a8c138edc0fdcfe920c7d6b6629cd2971.zip
Added null trap code for debugging. (Must be included by adding
--nulltrap to the make target at the moment.)
Diffstat (limited to 'src')
-rw-r--r--src/arch/i386/core/nulltrap.c48
-rw-r--r--src/arch/i386/scripts/i386.lds1
2 files changed, 49 insertions, 0 deletions
diff --git a/src/arch/i386/core/nulltrap.c b/src/arch/i386/core/nulltrap.c
new file mode 100644
index 000000000..bd4b75774
--- /dev/null
+++ b/src/arch/i386/core/nulltrap.c
@@ -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 ) {}
+}
diff --git a/src/arch/i386/scripts/i386.lds b/src/arch/i386/scripts/i386.lds
index 4a984a956..48dd777c9 100644
--- a/src/arch/i386/scripts/i386.lds
+++ b/src/arch/i386/scripts/i386.lds
@@ -117,6 +117,7 @@ SECTIONS {
.text : AT ( _textdata_load_offset + __text ) {
__text = .;
+ *(.text.null_trap)
*(.text)
*(.text.*)
} = 0x9090