diff --git a/ueforth/Makefile b/ueforth/Makefile index dd121b8..896ac97 100644 --- a/ueforth/Makefile +++ b/ueforth/Makefile @@ -361,7 +361,7 @@ $(ESP32_SIM)/Esp32forth-sim: \ common/interp.h \ $(GEN)/esp32_boot.h \ $(GEN)/esp32_sim_opcodes.h | $(ESP32_SIM) - $(CXX) $(CFLAGS) -m32 $< -o $@ + $(CXX) $(CFLAGS) -m32 -D_FILE_OFFSET_BITS=64 $< -o $@ strip $(STRIP_ARGS) $@ sizes: $(ESP32_SIM)/Esp32forth-sim diff --git a/ueforth/common/core.h b/ueforth/common/core.h index f944e90..ce879e3 100644 --- a/ueforth/common/core.h +++ b/ueforth/common/core.h @@ -125,7 +125,9 @@ static cell_t find(const char *name, cell_t len) { static void create(const char *name, cell_t nlength, cell_t flags, void *op) { if (g_sys.latestxt) { - g_sys.latestxt[-1] |= ((g_sys.heap - &g_sys.latestxt[1]) << 16); + cell_t sz = g_sys.heap - &g_sys.latestxt[1]; + if (sz < 0 || sz > 0xffff) { sz = 0xffff; } + g_sys.latestxt[-1] |= (sz << 16); } g_sys.heap = (cell_t *) CELL_ALIGNED(g_sys.heap); char *pos = (char *) g_sys.heap;