From 91b78f215d081affc8e69b2790d24e71dd0d6390 Mon Sep 17 00:00:00 2001 From: Arti Zirk Date: Sun, 1 Nov 2026 00:13:45 +0200 Subject: [PATCH] lx_loader: treat the OS/2 null selector as a null pointer gspac/gspcg pass 0003:0000 (selector index 0, RPL 3) as a null far pointer; lxConvert1616to32 only special-cased addr1616 == 0 and asserted on ldt[0]. Segment index 0 is the null selector by definition, so return NULL. This unblocks the TMS340 C front end (gspac), optimizer (gspopt) and code generator (gspcg) under 2ine. --- lx_loader.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lx_loader.c b/lx_loader.c index ae6f973..e29b81e 100644 --- a/lx_loader.c +++ b/lx_loader.c @@ -542,6 +542,8 @@ static void *lxConvert1616to32(const uint32 addr1616) const uint16 selector = (uint16) (addr1616 >> 19); // slide segment down, and shift out control bits. const uint16 offset = (uint16) (addr1616 % 0x10000); // all our LDT segments start at 64k boundaries (at the moment!). + if (selector == 0) // segment 0x0000 or 0x0003: the OS/2 null selector. + return NULL; //printf("lxConvert1616to32: 0x%X -> %p\n", (uint) addr1616, (void *) (size_t) (GLoaderState.ldt[selector] + offset)); assert(GLoaderState.ldt[selector] != 0); return (void *) (size_t) (GLoaderState.ldt[selector] + offset);