[syslinux:elflink] SEG(): centralize the bad bailout

syslinux-bot for H. Peter Anvin hpa at linux.intel.com
Fri Jun 29 09:51:02 PDT 2012


Commit-ID:  4ecc2eee96ca522e0cd4f00d2d27e3f2df90bc08
Gitweb:     http://www.syslinux.org/commit/4ecc2eee96ca522e0cd4f00d2d27e3f2df90bc08
Author:     H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Fri, 29 Jun 2012 09:50:00 -0700
Committer:  H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Fri, 29 Jun 2012 09:50:00 -0700

SEG(): centralize the bad bailout

Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>

---
 com32/include/com32.h |   10 ++++------
 core/kaboom.c         |   12 ++++++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/com32/include/com32.h b/com32/include/com32.h
index db85f77..148d08e 100644
--- a/com32/include/com32.h
+++ b/com32/include/com32.h
@@ -136,15 +136,13 @@ char *lstrdup(const char *);
  * pointer is actually reachable from the target segment.
  */
 #if defined(DEBUG) && (defined(__COM32__) || defined(__SYSLINUX_CORE__))
-#include <dprintf.h>
-__noreturn _kaboom(void);
+__noreturn __bad_SEG(const volatile void *);
 
 static inline uint16_t SEG(const volatile void *__p)
 {
-    if (__unlikely((uintptr_t)__p > 0xfffff)) {
-	dprintf("Non-lowmem pointer passed to SEG(): %p\n", __p);
-	_kaboom();
-    }
+    if (__unlikely((uintptr_t)__p > 0xfffff))
+	__bad_SEG(__p);
+
     return (uint16_t) (((uintptr_t) __p) >> 4);
 }
 #else
diff --git a/core/kaboom.c b/core/kaboom.c
index d639915..9bb3073 100644
--- a/core/kaboom.c
+++ b/core/kaboom.c
@@ -4,6 +4,18 @@
 
 #include "core.h"
 
+#ifdef DEBUG
+
+#include <dprintf.h>
+
+__noreturn __bad_SEG(const volatile void *p)
+{
+    dprintf("SEG() passed an invalid pointer: %p\n", p);
+    kaboom();
+}
+
+#endif
+
 #undef kaboom
 
 __noreturn _kaboom(void)


More information about the Syslinux-commits mailing list