From f939f14dc6c33350e0a6ed5e2fda6f8a115078a2 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Mon, 29 Jun 2026 19:06:09 +0300 Subject: [PATCH 01/13] stub: remove pre-v6 stubs support [#72] --- src/djdev64/stub/stub.c | 53 ++++++----------------------------------- 1 file changed, 7 insertions(+), 46 deletions(-) diff --git a/src/djdev64/stub/stub.c b/src/djdev64/stub/stub.c index 74431246..de46c9e8 100644 --- a/src/djdev64/stub/stub.c +++ b/src/djdev64/stub/stub.c @@ -359,11 +359,6 @@ int djstub_main(int argc, char *argv[], char *envp[], STFLAGS_OFF = 0x38; stub_debug("Found exe header %i at 0x%lx\n", cnt, coffset); memcpy(&offs, &buf[0x3c], sizeof(offs)); - /* fixup for old stubs: if they have any 32bit payload, that - * always includes the core payload. */ - if (stub_ver > 0 && stub_ver < 5 && !(buf[FLG1_OFF] & STFLG1_NO32PL)) - buf[FLG2_OFF] |= STFLG2_C32PL; - if (!(buf[FLG2_OFF] & STFLG2_C32PL)) dyn++; else @@ -384,7 +379,7 @@ int djstub_main(int argc, char *argv[], char *envp[], } memcpy(&coffsize, &buf[0x1c], sizeof(coffsize)); noffset = offs; - if (stub_ver < 6 || !(buf[FLG2_OFF] & STFLG2_EMBOV)) + if (!(buf[FLG2_OFF] & STFLG2_EMBOV)) noffset += coffsize; else emb_ov = 1; @@ -411,10 +406,6 @@ int djstub_main(int argc, char *argv[], char *envp[], 16, &rd); stubinfo.payload2_name[rd] = '\0'; } - } else if (stub_ver >= 4) { - strncpy(stubinfo.payload2_name, &buf[0x2e], 12); - stubinfo.payload2_name[12] = '\0'; - strcat(stubinfo.payload2_name, ".dbg"); } else { error("unsupported stub version %i\n", stub_ver); return -1; @@ -548,38 +539,11 @@ int djstub_main(int argc, char *argv[], char *envp[], if (dj32 && (pfile != ifile || ioops == &hops)) __dos_close(pfile); unregister_dosops(); -#define PASS_EMBOV_TO_SECOND_LDR 1 - if (dyn && pl32 && coffset -#if PASS_EMBOV_TO_SECOND_LDR - /* pass emb_ov format to another (libelf-based) loader */ - && !emb_ov -#endif - ) { - uint32_t va2; - uint32_t va_size2; - - /* dyn loaded, now pl32 */ - register_dosops(dosops); - handle = ops->read_headers(ifile); - if (!handle) - exit(EXIT_FAILURE); - stubinfo.uentry = ops->get_entry(handle); - va2 = ops->get_va(handle); - va_size2 = ops->get_length(handle); - stub_debug("va 0x%x va_size 0x%x\n", va2, va_size2); - if (va_size2 > MB) - exit(EXIT_FAILURE); - if (va2 < va + va_size || va2 + va_size2 - va > VA_SZ) - exit(EXIT_FAILURE); - if (compact_va && va2 + va_size2 - va > MB) - exit(EXIT_FAILURE); - ops->read_sections(handle, lin2ptr(mem_lin), va, ifile, coffset); - ops->close(handle); - unregister_dosops(); -#if !PASS_EMBOV_TO_SECOND_LDR - if (emb_ov) - stubinfo.flags &= ~(STFLG2_EMBOV << 8); -#endif + /* emb_ov is dealt with by another (libelf-based) loader, and non-emb_ov + * is deprecated. */ + if (dyn && pl32 && coffset && !emb_ov) { + error("deprecated non-emb_ov stub\n"); + exit(EXIT_FAILURE); } /* set base */ @@ -604,11 +568,8 @@ int djstub_main(int argc, char *argv[], char *envp[], stubinfo.self_fd = ifile; stubinfo.self_offs = coffset; -#if PASS_EMBOV_TO_SECOND_LDR + /* 0 means pass to libelf-based loader */ stubinfo.self_size = ((emb_ov && dyn && pl32) ? 0 : coffsize); -#else - stubinfo.self_size = coffsize; -#endif stubinfo.payload_offs = noffset; stubinfo.payload_size = nsize; stubinfo.payload2_offs = noffset2; From 97d5be203b1f8dcade92d287a71b584b9a9707ee Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Mon, 29 Jun 2026 20:02:20 +0300 Subject: [PATCH 02/13] stub: deprecate static crt0 in emb_ov [#72] Change condition from "stub_ver >= 6" to "stub_ver == 6". In upcoming v7 don't look into emb_ov at all. --- src/djdev64/stub/stub.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/djdev64/stub/stub.c b/src/djdev64/stub/stub.c index de46c9e8..fca5797f 100644 --- a/src/djdev64/stub/stub.c +++ b/src/djdev64/stub/stub.c @@ -372,7 +372,8 @@ int djstub_main(int argc, char *argv[], char *envp[], } else { pl32++; coffset = offs; - if (stub_ver >= 6) { + if (stub_ver == 6) { + /* static crt0 in emb_ov - deprecated */ uint32_t ooffs; memcpy(&ooffs, &buf[0x2c], sizeof(ooffs)); coffset += ooffs; From dc3c4891b39267dd5b8bd3a62fbc5064f92a92dc Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Mon, 29 Jun 2026 20:40:18 +0300 Subject: [PATCH 03/13] dj64.mk: remove support of static crt0 [#72] --- dj64.mk | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/dj64.mk b/dj64.mk index bccbc1c8..ddb31d98 100644 --- a/dj64.mk +++ b/dj64.mk @@ -136,16 +136,9 @@ GLOB_ASM ?= $(wildcard glob_asm.h) ifneq ($(AS_OBJECTS),) XLDFLAGS = -melf_i386 -static -ifeq ($(DJ64STATIC),1) -S3 := $(shell pkg-config --static --libs dj64static) -ifneq ($(.SHELLSTATUS),0) -$(error dj64-dev-static not installed) -endif -XLDFLAGS += $(S3) -DJ64_XLDFLAGS += -f 0x4000 -else XLDFLAGS += $(shell pkg-config --variable=crt0 dj64) $(XLD_IMB)=$(LOADADDR) -endif +DJ64_XLDFLAGS += -f 0x8000 + $(XELF).elf: $(AS_OBJECTS) $(PLT_O) $(XLD) $^ $(XLDFLAGS) -o $@ $(XSTRIP) $@ @@ -183,7 +176,8 @@ export script = $(_script) tmp.s: @eval "$$script" -else +endif + ifeq ($(DJ64STATIC),1) S2 := $(shell pkg-config --variable=crt0 dj64_s) ifneq ($(.SHELLSTATUS),0) @@ -191,6 +185,7 @@ $(error dj64-dev-static not installed) endif DJ64_XLDFLAGS += -l $(S2) -f 0x4000 else +ifeq ($(AS_OBJECTS),) DJ64_XLDFLAGS += -f 0x80 endif endif From 30ad5d842eb96b090f0e52206150fcd2c696bdab Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Mon, 29 Jun 2026 20:41:48 +0300 Subject: [PATCH 04/13] remove dj64static.pc.in [#72] --- configure.ac | 1 - dj64static.pc.in | 5 ----- makefile | 4 +--- 3 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 dj64static.pc.in diff --git a/configure.ac b/configure.ac index bcb46ae4..099d8f5f 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,6 @@ AC_CONFIG_FILES([ Makefile.conf dj64.pc dj64_s.pc - dj64static.pc djdev64.pc djstub64.pc dj32.pc diff --git a/dj64static.pc.in b/dj64static.pc.in deleted file mode 100644 index f4aa940a..00000000 --- a/dj64static.pc.in +++ /dev/null @@ -1,5 +0,0 @@ -Name: dj64static -Description: dj64static libs -Version: @VERSION@ -dj64prefix=@sysroot@ -Libs: --whole-archive ${dj64prefix}/lib/libc_s.a --no-whole-archive diff --git a/makefile b/makefile index 456b3a8a..9574660c 100644 --- a/makefile +++ b/makefile @@ -68,7 +68,7 @@ djdev64: djdev64.pc djstub64.pc $(MAKE) -C src/djdev64 ifeq ($(USE64),1) -DJ64PC = dj64.pc dj64_s.pc dj64static.pc +DJ64PC = dj64.pc dj64_s.pc endif DJ64PC += dj32.pc dj64: $(DJ64PC) $(DJ64DEVL) @@ -94,7 +94,6 @@ ifeq ($(USE64),1) $(INSTALL) -d $(DESTDIR)$(libdir)/pkgconfig $(INSTALL) -m 0644 dj64.pc $(DESTDIR)$(libdir)/pkgconfig $(INSTALL) -m 0644 dj64_s.pc $(DESTDIR)$(libdir)/pkgconfig - $(INSTALL) -m 0644 dj64static.pc $(DESTDIR)$(libdir)/pkgconfig ifeq ($(NCURSES),1) $(MAKE) -C $(NC_BUILD) install endif @@ -130,7 +129,6 @@ endif $(RM) -r $(DESTDIR)$(includedir)/djdev64 $(RM) $(DESTDIR)$(libdir)/pkgconfig/dj64.pc $(RM) $(DESTDIR)$(libdir)/pkgconfig/dj64_s.pc - $(RM) $(DESTDIR)$(libdir)/pkgconfig/dj64static.pc $(MAKE) -C demos src_uninstall endif From 3595b8c0f90a754c8d96633f016dc4240e6f3772 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Mon, 29 Jun 2026 20:46:38 +0300 Subject: [PATCH 05/13] make: remove libc_s.a [closes #72] --- makefile | 6 ++---- src/libc/dj64/makefile | 12 +++--------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/makefile b/makefile index 9574660c..3e399c4a 100644 --- a/makefile +++ b/makefile @@ -18,7 +18,6 @@ SHLIB_EXT = so EXTRA_NC_CONFIGURE_FLAGS = endif -DJLIBC = $(TOP)/lib/libc_s.a DJLIBC32 = $(TOP)/lib/libc32_s.a DJCRT0 = $(TOP)/lib/crt0.elf DJUCRT0 = $(TOP)/lib/uplt.o @@ -54,10 +53,10 @@ subs: # New makes have a way to avoid parallel invocation with the use of &: need = 4.3 ifneq ($(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need)))),) -$(DJ64DEVL) $(DJ32LIBS) $(DJLIBC) $(DJLIBC32) &: subs +$(DJ64DEVL) $(DJ32LIBS) $(DJLIBC32) &: subs else .NOTPARALLEL: -$(DJ64DEVL) $(DJ32LIBS) $(DJLIBC) $(DJLIBC32) : subs +$(DJ64DEVL) $(DJ32LIBS) $(DJLIBC32) : subs endif $(MAKE) -C src @@ -76,7 +75,6 @@ dj64: $(DJ64PC) $(DJ64DEVL) install_dj64: ifeq ($(USE64),1) $(INSTALL) -d $(DESTDIR)$(sysroot)/lib - $(INSTALL) -m 0644 $(DJLIBC) $(DESTDIR)$(sysroot)/lib $(INSTALL) -m 0644 $(DJCRT0) $(DESTDIR)$(sysroot)/lib $(INSTALL) -m 0644 $(DJUCRT0) $(DESTDIR)$(sysroot)/lib $(INSTALL) -d $(DESTDIR)$(sysroot)/bin diff --git a/src/libc/dj64/makefile b/src/libc/dj64/makefile index 52382875..377506ad 100644 --- a/src/libc/dj64/makefile +++ b/src/libc/dj64/makefile @@ -106,14 +106,8 @@ $(LIB)/$(LIBS): $(TOP)/makefile.rf $(ALL_OBJS) \ $(AR) cr $@ $(ALL_OBJS) $(OBJECTS) $(AR) s $@ -$(LIB)/libc_s.a: libc_tmp.a $(PLT_O) | $(LIB) - cp -f $< libctmp.a - $(CROSS_AR) q libctmp.a $(PLT_O) - $(CROSS_AR) s libctmp.a - mv -f libctmp.a $@ - -$(LIB)/crt0.elf: $(LIB)/libc_s.a - $(CROSS_LD) --whole-archive $< -melf_i386 -static $(XLD_IMB_OPT)=0x08048000 -o $@ +$(LIB)/crt0.elf: libc_tmp.a $(PLT_O) | $(LIB) + $(CROSS_LD) --whole-archive $^ -melf_i386 -static $(XLD_IMB_OPT)=0x08048000 -o $@ $(CROSS_STRIP) --strip-debug $@ chmod -x $@ @@ -124,7 +118,7 @@ $(LIB)/$(LIBNS) $(LIB)/$(LIBNV): $(LIB)/$(LIBN) | $(LIB) ln -sf $(LIBN) $@ ifeq ($(USE64),1) -final: $(LIB)/libc_s.a $(LIB)/$(LIBNS) $(LIB)/$(LIBNV) \ +final: $(LIB)/$(LIBNS) $(LIB)/$(LIBNV) \ $(LIB)/$(LIBS) $(LIB)/crt0.elf $(LIB)/uplt.o | $(LIB) else final: From 958764850bc9624a783b4362f9d2f46ff597ca0f Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Mon, 29 Jun 2026 22:26:47 +0300 Subject: [PATCH 06/13] plt: remove non-emb_ov static crt0 init [#72] This is a pure legacy, pre-v6 I think. --- src/libc/dj64/plt.S | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/libc/dj64/plt.S b/src/libc/dj64/plt.S index 2bff2af3..9fd0b1e5 100644 --- a/src/libc/dj64/plt.S +++ b/src/libc/dj64/plt.S @@ -200,13 +200,6 @@ plt_init: movl %eax, __plt_ctrl + 4 movl %esi, __plt_ctrl - movl %fs:STUBINFO_FLAGS, %ecx - testw $0xc080, %cx - jnz 111f - movl %fs:STUBINFO_UENTRY, %eax - movl $AUX_USER, %ebx - call uplt_init -111: movl %fs:STUBINFO_SELF_SIZE, %ecx orl %ecx, %ecx jz 3f From 278b74c06ff6d73f61b9e9098de9047b454dbd7a Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Tue, 30 Jun 2026 00:23:32 +0300 Subject: [PATCH 07/13] stubinfo: introduce SIFLG_SPLITPL flag [#72] It is set on stub ver >= 7 and tells dynamic linker that static crt0 is not here (payloads are split). It allows to delay the resolution of upl, which is later done by second loader. --- include/libc/stubinfo.h | 1 + src/djdev64/stub/stub.c | 2 ++ src/libc/dj64/plt.S | 8 ++++++++ src/libc/dj64/thunks.c | 23 ++++++++++++++--------- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/include/libc/stubinfo.h b/include/libc/stubinfo.h index 297c5262..8f9af495 100644 --- a/include/libc/stubinfo.h +++ b/include/libc/stubinfo.h @@ -76,5 +76,6 @@ _Static_assert(sizeof(_GO32_StubInfo) == STUBINFO_END, "size mismatch"); #define SIFLG_STATIC 0x40 #define SIFLG_ELFEXEC (1 << 16) +#define SIFLG_SPLITPL (1 << 17) #endif /* __dj_include_stub_h__ */ diff --git a/src/djdev64/stub/stub.c b/src/djdev64/stub/stub.c index fca5797f..77cb81f1 100644 --- a/src/djdev64/stub/stub.c +++ b/src/djdev64/stub/stub.c @@ -357,6 +357,8 @@ int djstub_main(int argc, char *argv[], char *envp[], stubinfo.stubinfo_ver |= stub_ver << 16; if (stub_ver >= 6) STFLAGS_OFF = 0x38; + if (stub_ver >= 7) + stubinfo.flags |= SIFLG_SPLITPL; stub_debug("Found exe header %i at 0x%lx\n", cnt, coffset); memcpy(&offs, &buf[0x3c], sizeof(offs)); if (!(buf[FLG2_OFF] & STFLG2_C32PL)) diff --git a/src/libc/dj64/plt.S b/src/libc/dj64/plt.S index 9fd0b1e5..7bf69408 100644 --- a/src/libc/dj64/plt.S +++ b/src/libc/dj64/plt.S @@ -271,6 +271,14 @@ plt_init: movw handle + 2, %si int $0x31 jc 2f + + movl %fs:STUBINFO_FLAGS, %ecx + andl $0x4000|SIFLG_SPLITPL, %ecx + cmpl $0x4000|SIFLG_SPLITPL, %ecx + jne 11f + /* upl not here so invoke second loader and get it if it exists */ + movl $0, %eax /* reserve */ + call resolve_upl 11: popl %es diff --git a/src/libc/dj64/thunks.c b/src/libc/dj64/thunks.c index 97099e61..99154bac 100644 --- a/src/libc/dj64/thunks.c +++ b/src/libc/dj64/thunks.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -281,6 +282,7 @@ static int dj64_ctrl(int handle, int libid, int fn, unsigned esi, uint8_t *sp) struct udisp *u = &udisps[handle]; uint32_t flags = regs->eax; int have_core = (flags & 0x4000); + int split_pl = (flags & SIFLG_SPLITPL); uint32_t addr = regs->ebx; uint32_t size = regs->ecx; uint32_t mem_base = regs->edx; @@ -291,6 +293,7 @@ static int dj64_ctrl(int handle, int libid, int fn, unsigned esi, uint8_t *sp) u->cs = esi; djlogprintf("addr 0x%x mem_base 0x%x\n", addr, mem_base); if (addr) { + int have_upl = (!have_core || !split_pl); char *elf = (char *)djaddr2ptr(addr); djlogprintf("data %p(%s)\n", elf, elf); eh = u->eops->open(elf, size); @@ -304,15 +307,17 @@ static int dj64_ctrl(int handle, int libid, int fn, unsigned esi, uint8_t *sp) if (ret) goto err; } - if (u->at[libid]) { - ret = process_athunks(u->at[libid], mem_base, u->eops, eh); - if (ret) - goto err; - } - if (u->pt[libid]) { - ret = process_pthunks(u->pt[libid], u->eops, eh); - if (ret) - goto err; + if (have_upl) { + if (u->at[libid]) { + ret = process_athunks(u->at[libid], mem_base, u->eops, eh); + if (ret) + goto err; + } + if (u->pt[libid]) { + ret = process_pthunks(u->pt[libid], u->eops, eh); + if (ret) + goto err; + } } u->eops->close(eh); } else if (have_core) { From 16f3a5303dc0c25b7e0b1392b2e14556a7ec23a6 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Tue, 30 Jun 2026 00:44:58 +0300 Subject: [PATCH 08/13] stub: stop passing 0 to self_size [#72] Instead check the needed flag in plt.S. --- src/djdev64/stub/stub.c | 3 +-- src/libc/dj64/plt.S | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/djdev64/stub/stub.c b/src/djdev64/stub/stub.c index 77cb81f1..827a3d5a 100644 --- a/src/djdev64/stub/stub.c +++ b/src/djdev64/stub/stub.c @@ -571,8 +571,7 @@ int djstub_main(int argc, char *argv[], char *envp[], stubinfo.self_fd = ifile; stubinfo.self_offs = coffset; - /* 0 means pass to libelf-based loader */ - stubinfo.self_size = ((emb_ov && dyn && pl32) ? 0 : coffsize); + stubinfo.self_size = coffsize; stubinfo.payload_offs = noffset; stubinfo.payload_size = nsize; stubinfo.payload2_offs = noffset2; diff --git a/src/libc/dj64/plt.S b/src/libc/dj64/plt.S index 7bf69408..7a1dad84 100644 --- a/src/libc/dj64/plt.S +++ b/src/libc/dj64/plt.S @@ -200,6 +200,9 @@ plt_init: movl %eax, __plt_ctrl + 4 movl %esi, __plt_ctrl + movl %fs:STUBINFO_FLAGS, %eax + test $0x4000, %eax /* have cpl */ + jz 3f movl %fs:STUBINFO_SELF_SIZE, %ecx orl %ecx, %ecx jz 3f From 9c3cef3f3fae6e96337ecc38f11d6dc70f3ccdc0 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Tue, 30 Jun 2026 00:47:23 +0300 Subject: [PATCH 09/13] stub: remove emb_ov [closes #72] With stub-v7 and second loader we are no longer interested in that. Second loader is libelf-based and can do many things, so we need to off-load to it as much as possible, keeping the stub simple. --- src/djdev64/stub/stub.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/djdev64/stub/stub.c b/src/djdev64/stub/stub.c index 827a3d5a..9e6ab34f 100644 --- a/src/djdev64/stub/stub.c +++ b/src/djdev64/stub/stub.c @@ -223,7 +223,6 @@ int djstub_main(int argc, char *argv[], char *envp[], struct ldops *ops = NULL; int STFLAGS_OFF = 0x2c; int compact_va = 0; - int emb_ov = 0; int dj32 = 0; struct dos_ops *ioops = dosops; uint8_t stub_ver = 0; @@ -312,7 +311,6 @@ int djstub_main(int argc, char *argv[], char *envp[], stubinfo.elfload_arg = atoi(envp[i] + l); dyn = 1; - emb_ov = 1; /* calling second ldr */ stubinfo.flags = ((STFLG2_EMBOV) << 8); stubinfo.flags |= SHM_FLAGS; @@ -382,10 +380,8 @@ int djstub_main(int argc, char *argv[], char *envp[], } memcpy(&coffsize, &buf[0x1c], sizeof(coffsize)); noffset = offs; - if (!(buf[FLG2_OFF] & STFLG2_EMBOV)) + if ((stub_ver >= 7 && !dyn) || !(buf[FLG2_OFF] & STFLG2_EMBOV)) noffset += coffsize; - else - emb_ov = 1; } if (buf[FLG1_OFF] & STFLG1_COMPACT) compact_va = 1; @@ -432,7 +428,6 @@ int djstub_main(int argc, char *argv[], char *envp[], dyn++; OPEN_DYN(); compact_va = 1; // TODO - evaluate? - emb_ov = 1; stubinfo.flags = ((STFLG2_EMBOV) << 8) | STFLG1_COMPACT; stubinfo.flags |= SHM_FLAGS; nsize = dosops->_dos_seek(ifile, 0, SEEK_END); @@ -542,12 +537,6 @@ int djstub_main(int argc, char *argv[], char *envp[], if (dj32 && (pfile != ifile || ioops == &hops)) __dos_close(pfile); unregister_dosops(); - /* emb_ov is dealt with by another (libelf-based) loader, and non-emb_ov - * is deprecated. */ - if (dyn && pl32 && coffset && !emb_ov) { - error("deprecated non-emb_ov stub\n"); - exit(EXIT_FAILURE); - } /* set base */ __dpmi_set_segment_base_address(clnt_entry.selector, mem_base); From dc95a4196c10f0fb8775971abf3621fa4088889f Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Tue, 30 Jun 2026 01:24:47 +0300 Subject: [PATCH 10/13] stub: allow 64bit ELFs as 1st pl for v7+ [#72] In v6 there was an extra field to jump to emb_ov, but it is not in v7. So we get directly to 64bit ELF and need to load dyn. --- src/djdev64/stub/stub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/djdev64/stub/stub.c b/src/djdev64/stub/stub.c index 9e6ab34f..3a522b66 100644 --- a/src/djdev64/stub/stub.c +++ b/src/djdev64/stub/stub.c @@ -438,7 +438,7 @@ int djstub_main(int argc, char *argv[], char *envp[], ops = &elf_ops; } pl32 = 1; - } else if (is_64) { + } else if (is_64 && (stub_ver < 7 || !dyn)) { error("djstub: 64bit ELF at position %lx\n", coffset); return -1; } else if (dyn) { From 86de20c2075350200bb5575119f2df4279be8431 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Tue, 30 Jun 2026 11:12:52 +0300 Subject: [PATCH 11/13] demos: fix make run for hello demo --- demos/hello/32/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/hello/32/makefile b/demos/hello/32/makefile index 4a65f9e9..28f327bd 100644 --- a/demos/hello/32/makefile +++ b/demos/hello/32/makefile @@ -21,7 +21,7 @@ info: $(TGT) djstubify -i $< run: $(TGT) - dosemu -dumb -l $(realpath $<) + dosemu -dumb -l $(realpath $<) -g 1 # hook in dj64 - make sure to not do that before defining `all:` target DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj32) From 40ce959a7de925db16cfcb8e5027bdb6a26de54c Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Tue, 30 Jun 2026 11:50:08 +0300 Subject: [PATCH 12/13] demos: add runelf targets --- demos/asmsimp/32/makefile | 3 +++ demos/asmsimp/djgpp/makefile | 4 ++++ demos/asmsimp/makefile | 3 +++ demos/file/32/makefile | 3 +++ demos/file/djgpp/makefile | 4 ++++ demos/file/makefile | 3 +++ demos/hello/32/makefile | 3 +++ demos/hello/djgpp/makefile | 4 ++++ demos/hello/makefile | 3 +++ demos/helloasm/32/makefile | 3 +++ demos/helloasm/djgpp/makefile | 4 ++++ demos/helloasm/makefile | 3 +++ demos/int86/32/makefile | 3 +++ demos/int86/djgpp/makefile | 4 ++++ demos/int86/makefile | 3 +++ demos/makefile | 5 +++++ demos/rmcb/32/makefile | 3 +++ demos/rmcb/djgpp/makefile | 4 ++++ demos/rmcb/makefile | 3 +++ 19 files changed, 65 insertions(+) diff --git a/demos/asmsimp/32/makefile b/demos/asmsimp/32/makefile index cff37154..dc019ad1 100644 --- a/demos/asmsimp/32/makefile +++ b/demos/asmsimp/32/makefile @@ -31,6 +31,9 @@ info: $(TGT) run: $(TGT) dosemu -dumb $< +runelf: tmp.elf + dosemu -dumb -l $< -g 1 + # hook in dj64 - make sure to not do that before defining `all:` target DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj32) ifeq ($(wildcard $(DJMK)),) diff --git a/demos/asmsimp/djgpp/makefile b/demos/asmsimp/djgpp/makefile index ba9beec3..31208c27 100644 --- a/demos/asmsimp/djgpp/makefile +++ b/demos/asmsimp/djgpp/makefile @@ -28,3 +28,7 @@ info: $(TGT) run: $(TGT) dosemu -t $< + +runelf: $(TGT) + djstubify $< + dosemu -dumb $< diff --git a/demos/asmsimp/makefile b/demos/asmsimp/makefile index c36f282c..e23d9b96 100644 --- a/demos/asmsimp/makefile +++ b/demos/asmsimp/makefile @@ -26,6 +26,9 @@ info: $(TGT) run: $(TGT) dosemu -dumb $< +runelf: libtmp.so + dosemu -dumb -l $< + # hook in dj64 - make sure to not do that before defining `all:` target DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj64) ifeq ($(wildcard $(DJMK)),) diff --git a/demos/file/32/makefile b/demos/file/32/makefile index 2727bbff..2eeff598 100644 --- a/demos/file/32/makefile +++ b/demos/file/32/makefile @@ -26,6 +26,9 @@ info: $(TGT) run: $(TGT) dosemu -t $< +runelf: tmp.elf + dosemu -dumb -K . -E "elfexec2 $<" + # hook in dj64 - make sure to not do that before defining `all:` target DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj32) ifeq ($(wildcard $(DJMK)),) diff --git a/demos/file/djgpp/makefile b/demos/file/djgpp/makefile index 62c7daab..85771316 100644 --- a/demos/file/djgpp/makefile +++ b/demos/file/djgpp/makefile @@ -26,3 +26,7 @@ info: $(TGT) run: $(TGT) dosemu -t $< + +runelf: $(TGT) + djstubify $< + dosemu -dumb $< diff --git a/demos/file/makefile b/demos/file/makefile index 872bb637..30921d6e 100644 --- a/demos/file/makefile +++ b/demos/file/makefile @@ -23,6 +23,9 @@ info: $(TGT) run: $(TGT) dosemu -t $< +runelf: libtmp.so + dosemu -dumb -K . -E "elfexec $<" + # hook in dj64 - make sure to not do that before defining `all:` target DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj64) ifeq ($(wildcard $(DJMK)),) diff --git a/demos/hello/32/makefile b/demos/hello/32/makefile index 28f327bd..c7f815bf 100644 --- a/demos/hello/32/makefile +++ b/demos/hello/32/makefile @@ -23,6 +23,9 @@ info: $(TGT) run: $(TGT) dosemu -dumb -l $(realpath $<) -g 1 +runelf: tmp.elf + dosemu -dumb -l $< -g 1 + # hook in dj64 - make sure to not do that before defining `all:` target DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj32) ifeq ($(wildcard $(DJMK)),) diff --git a/demos/hello/djgpp/makefile b/demos/hello/djgpp/makefile index 8435ed5d..7361eb5f 100644 --- a/demos/hello/djgpp/makefile +++ b/demos/hello/djgpp/makefile @@ -26,3 +26,7 @@ info: $(TGT) run: $(TGT) dosemu -dumb $< + +runelf: $(TGT) + djstubify $< + dosemu -dumb $< diff --git a/demos/hello/makefile b/demos/hello/makefile index cd23d23f..747954e9 100644 --- a/demos/hello/makefile +++ b/demos/hello/makefile @@ -20,6 +20,9 @@ info: $(TGT) run: $(TGT) dosemu -dumb -l $(realpath $<) +runelf: libtmp.so + dosemu -dumb -l $< + # hook in dj64 - make sure to not do that before defining `all:` target DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj64) ifeq ($(wildcard $(DJMK)),) diff --git a/demos/helloasm/32/makefile b/demos/helloasm/32/makefile index 7e7de247..f42c6d49 100644 --- a/demos/helloasm/32/makefile +++ b/demos/helloasm/32/makefile @@ -33,6 +33,9 @@ info: $(TGT) run: $(TGT) dosemu -dumb $< +runelf: tmp.elf + dosemu -dumb -l $< -g 1 + # hook in dj64 - make sure to not do that before defining `all:` target DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj32) ifeq ($(wildcard $(DJMK)),) diff --git a/demos/helloasm/djgpp/makefile b/demos/helloasm/djgpp/makefile index 4c5a964b..36896711 100644 --- a/demos/helloasm/djgpp/makefile +++ b/demos/helloasm/djgpp/makefile @@ -28,3 +28,7 @@ info: $(TGT) run: $(TGT) dosemu -dumb $< + +runelf: $(TGT) + djstubify $< + dosemu -dumb $< diff --git a/demos/helloasm/makefile b/demos/helloasm/makefile index f7687d41..75ae7582 100644 --- a/demos/helloasm/makefile +++ b/demos/helloasm/makefile @@ -27,6 +27,9 @@ info: $(TGT) run: $(TGT) dosemu -dumb $< +runelf: libtmp.so + dosemu -dumb -l $< + # hook in dj64 - make sure to not do that before defining `all:` target DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj64) ifeq ($(wildcard $(DJMK)),) diff --git a/demos/int86/32/makefile b/demos/int86/32/makefile index 2727bbff..2eeff598 100644 --- a/demos/int86/32/makefile +++ b/demos/int86/32/makefile @@ -26,6 +26,9 @@ info: $(TGT) run: $(TGT) dosemu -t $< +runelf: tmp.elf + dosemu -dumb -K . -E "elfexec2 $<" + # hook in dj64 - make sure to not do that before defining `all:` target DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj32) ifeq ($(wildcard $(DJMK)),) diff --git a/demos/int86/djgpp/makefile b/demos/int86/djgpp/makefile index 62c7daab..85771316 100644 --- a/demos/int86/djgpp/makefile +++ b/demos/int86/djgpp/makefile @@ -26,3 +26,7 @@ info: $(TGT) run: $(TGT) dosemu -t $< + +runelf: $(TGT) + djstubify $< + dosemu -dumb $< diff --git a/demos/int86/makefile b/demos/int86/makefile index 872bb637..30921d6e 100644 --- a/demos/int86/makefile +++ b/demos/int86/makefile @@ -23,6 +23,9 @@ info: $(TGT) run: $(TGT) dosemu -t $< +runelf: libtmp.so + dosemu -dumb -K . -E "elfexec $<" + # hook in dj64 - make sure to not do that before defining `all:` target DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj64) ifeq ($(wildcard $(DJMK)),) diff --git a/demos/makefile b/demos/makefile index ab928103..9cad613e 100644 --- a/demos/makefile +++ b/demos/makefile @@ -19,6 +19,11 @@ clean: $(foreach D,$(DEMOS),$(MAKE) -C $(D) clean;) $(foreach D,$(DEMOS),$(MAKE) -C $(D)/32 clean;) +run runelf: + $(foreach D,$(DEMOS),$(MAKE) -C $(D) $@;) + $(foreach D,$(DEMOS),$(MAKE) -C $(D)/32 $@;) + $(foreach D,$(DEMOS),$(MAKE) -C $(D)/djgpp $@;) + rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)) src_install: clean djgpp/clean diff --git a/demos/rmcb/32/makefile b/demos/rmcb/32/makefile index 61f533ef..51023457 100644 --- a/demos/rmcb/32/makefile +++ b/demos/rmcb/32/makefile @@ -33,6 +33,9 @@ info: $(TGT) run: $(TGT) dosemu -t $< +runelf: tmp.elf + dosemu -dumb -l $< -g 1 + # hook in dj64 - make sure to not do that before defining `all:` target DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj32) ifeq ($(wildcard $(DJMK)),) diff --git a/demos/rmcb/djgpp/makefile b/demos/rmcb/djgpp/makefile index 7903e11f..ceb4ab97 100644 --- a/demos/rmcb/djgpp/makefile +++ b/demos/rmcb/djgpp/makefile @@ -29,3 +29,7 @@ info: $(TGT) run: $(TGT) dosemu -t $< + +runelf: $(TGT) + djstubify $< + dosemu -dumb $< diff --git a/demos/rmcb/makefile b/demos/rmcb/makefile index 0132faaa..ad980552 100644 --- a/demos/rmcb/makefile +++ b/demos/rmcb/makefile @@ -27,6 +27,9 @@ info: $(TGT) run: $(TGT) dosemu -t $< +runelf: libtmp.so + dosemu -dumb -l $< + # hook in dj64 - make sure to not do that before defining `all:` target DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj64) ifeq ($(wildcard $(DJMK)),) From 272c7606cde1c3eac7bae1ccc5d2fa337f28b942 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Tue, 30 Jun 2026 12:04:24 +0300 Subject: [PATCH 13/13] deb,rpm: remove static crt0 files [#72] --- debian/dj64-dev-static.install | 2 -- dj64dev.spec.rpkg | 2 -- 2 files changed, 4 deletions(-) diff --git a/debian/dj64-dev-static.install b/debian/dj64-dev-static.install index 01d021e2..be3ecfd4 100644 --- a/debian/dj64-dev-static.install +++ b/debian/dj64-dev-static.install @@ -1,4 +1,2 @@ -usr/lib/*/i386-pc-dj64/lib/libc_s.a usr/lib/*/i386-pc-dj64/lib64/libdj64_s.a usr/lib/*/pkgconfig/dj64_s.pc -usr/lib/*/pkgconfig/dj64static.pc diff --git a/dj64dev.spec.rpkg b/dj64dev.spec.rpkg index e61a6ead..b05789d5 100644 --- a/dj64dev.spec.rpkg +++ b/dj64dev.spec.rpkg @@ -102,10 +102,8 @@ May be needed on non-glibc systems. %files dj64-devel-static %defattr(-,root,root) -%{_prefix}/i386-pc-dj64/lib/libc_s.a %{_prefix}/i386-pc-dj64/lib64/libdj64_s.a %{_libdir}/pkgconfig/dj64_s.pc -%{_libdir}/pkgconfig/dj64static.pc %end %package dj32-devel