aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2012-06-29 09:40:48 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2012-06-29 09:40:48 -0700
commit72842b681e7b9e8a26f683417520315595024f31 (patch)
tree7232aaaa7c656156fd61ff18f67dcb43c7f5a844
parent4678fd92a21e0139b0126bafcccda82c16404d3e (diff)
downloadsyslinux-72842b681e7b9e8a26f683417520315595024f31.tar.gz
syslinux-72842b681e7b9e8a26f683417520315595024f31.tar.xz
syslinux-72842b681e7b9e8a26f683417520315595024f31.zip
SEG(): make SEG() puke on bad pointers if DEBUG is defined
SEG() and OFFS() should only be passed on lowmem pointers. When DEBUG is defined, make SEG() abort if we pass it a non-lowmem pointer. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--com32/include/com32.h14
-rw-r--r--core/Makefile2
2 files changed, 15 insertions, 1 deletions
diff --git a/com32/include/com32.h b/com32/include/com32.h
index 6b142082..4ba7ebdc 100644
--- a/com32/include/com32.h
+++ b/com32/include/com32.h
@@ -135,10 +135,24 @@ char *lstrdup(const char *);
* specific segment. OFFS_VALID() will return whether or not the
* pointer is actually reachable from the target segment.
*/
+#if defined(DEBUG) && (defined(__COM32__) || defined(__SYSLINUX_CORE__))
+#include <dprintf.h>
+__noreturn _kaboom(void);
+
+static inline uint16_t SEG(const volatile void *__p)
+{
+ if ((uintptr_t)__p > 0xfffff) {
+ dprintf("Non-lowmem pointer passed to SEG(): %p\n", __p);
+ _kaboom();
+ }
+ return (uint16_t) (((uintptr_t) __p) >> 4);
+}
+#else
static inline uint16_t SEG(const volatile void *__p)
{
return (uint16_t) (((uintptr_t) __p) >> 4);
}
+#endif
static inline uint16_t OFFS(const volatile void *__p)
{
diff --git a/core/Makefile b/core/Makefile
index 3898b4d2..31475669 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -62,7 +62,7 @@ NASMOPT += $(NASMDEBUG)
PREPCORE = ../lzo/prepcore
-# CFLAGS += -DDEBUG=1
+CFLAGS += -DDEBUG=1 -D__SYSLINUX_CORE__
# The DATE is set on the make command line when building binaries for
# official release. Otherwise, substitute a hex string that is pretty much