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/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/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 4a65f9e9..c7f815bf 100644 --- a/demos/hello/32/makefile +++ b/demos/hello/32/makefile @@ -21,7 +21,10 @@ info: $(TGT) djstubify -i $< run: $(TGT) - dosemu -dumb -l $(realpath $<) + 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) 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)),) 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 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 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/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/makefile b/makefile index 456b3a8a..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 @@ -68,7 +67,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) @@ -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 @@ -94,7 +92,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 +127,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 diff --git a/src/djdev64/stub/stub.c b/src/djdev64/stub/stub.c index 74431246..3a522b66 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; @@ -357,13 +355,10 @@ 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)); - /* 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 @@ -377,17 +372,16 @@ 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; } memcpy(&coffsize, &buf[0x1c], sizeof(coffsize)); noffset = offs; - if (stub_ver < 6 || !(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; @@ -411,10 +405,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; @@ -438,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); @@ -449,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) { @@ -548,39 +537,6 @@ 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 - } /* set base */ __dpmi_set_segment_base_address(clnt_entry.selector, mem_base); @@ -604,11 +560,7 @@ int djstub_main(int argc, char *argv[], char *envp[], stubinfo.self_fd = ifile; stubinfo.self_offs = coffset; -#if PASS_EMBOV_TO_SECOND_LDR - 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; 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: diff --git a/src/libc/dj64/plt.S b/src/libc/dj64/plt.S index 2bff2af3..7a1dad84 100644 --- a/src/libc/dj64/plt.S +++ b/src/libc/dj64/plt.S @@ -200,13 +200,9 @@ 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_FLAGS, %eax + test $0x4000, %eax /* have cpl */ + jz 3f movl %fs:STUBINFO_SELF_SIZE, %ecx orl %ecx, %ecx jz 3f @@ -278,6 +274,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) {