Permalink
Checking mergeability…
Don’t worry, you can still create the pull request.
Comparing changes
Choose two branches to see what’s changed or to start a new pull request.
If you need to, you can also .
Open a pull request
Create a new pull request by comparing changes across two branches. If you need to, you can also .
2
contributors
Commits on Jul 12, 2019
Commits on Jul 13, 2019
Commits on Jul 14, 2019
Commits on Jul 17, 2019
Commits on Feb 02, 2020
Commits on Feb 04, 2020
This patch adds the __spawn_flags variable and __spawn_leak_workaround flag to allow the software to control the leak work-around. Previous behaviour was to always enable the work-around unless the DPMI host is cwsdpmi. Without this patch it is not possible to spawn a prot-mode TSR program like 32rtm. djgpp treats it as a leak and wipes out of memory. With this patch things work properly if the DPMI server is smart enough to direct the control to prev client after 32rtm TSRed. The problem is that 32rtm just jumps to the realmode exit addr, so the DPMI server doesn't see the exit and may get confused unless the special logic is implemented for that case (i.e. not all DPMI servers treat that correctly even after that patch).
Currently if the DOS environment is empty (can happen when starting command.com), djgpp startup produces the corrupted environment. This patch fixes it by checking the loop end condition before loop action. Another problematic case is the missing environment segment. In this case there is no work-around, so the error msg is printed and the program terminates.
Commits on Feb 10, 2020
Commits on Mar 16, 2020
Commits on Mar 26, 2020
Commits on Apr 29, 2020
Commits on May 05, 2020
Commits on May 09, 2020
GCC 10 now defaults to -fno-common, which causes multiple definition errors during linking. In libc, __stdio_cleanup_hook is defined twice, and in fsdb, several variables are defined in a header, which is included in multiple source files. To solve this, __stdio_cleanup_hook is declared extern and fsdb can be compiled with -fcommon.
Commits on Jul 27, 2020
Commits on Dec 13, 2020
Commits on Jan 10, 2021
Commits on Jan 17, 2021
Unified
Split
Showing
with
54 additions
and 21 deletions.
- +4 −0 include/process.h
- +1 −4 lib/djgpp.djl
- +5 −1 src/dxe/makefile
- +8 −6 src/libc/crt0/crt1.c
- +3 −1 src/libc/dos/process/dosexec.c
- +1 −1 src/libc/posix/regex/makefile
- +1 −1 src/makefile
- +2 −0 src/makefile.cfg
- +2 −1 src/makefile.inc
- +1 −0 src/makefile.lib
- +4 −0 src/misc.c
- +3 −1 src/stub/exe2coff.c
- +6 −2 src/stub/makefile
- +13 −3 src/stub/stub.asm
| @@ -52,6 +52,10 @@ int __djgpp_spawn(int _mode, const char *_path, char *const _argv[], char *const | ||
| #define SPAWN_EXTENSION_SRCH 1 | ||
| #define SPAWN_NO_EXTENSION_SRCH 2 | ||
|
|
||
| #define __spawn_leak_workaround 0x0001 /* free descriptor leaks */ | ||
|
|
||
| extern int __spawn_flags; | ||
|
|
||
| #endif /* !_POSIX_SOURCE */ | ||
| #endif /* !__STRICT_ANSI__ */ | ||
| #endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ | ||
| @@ -33,9 +33,6 @@ SECTIONS | ||
| LONG(0) ; | ||
| *(.data) | ||
| *(.data.*) | ||
| /* Ugly workaround to prevent entire .bss to have attribute CONTENT */ | ||
| /* for C++ executables. */ | ||
| *( .bss.*) | ||
| *(.gcc_exc*) | ||
| ___EH_FRAME_BEGIN__ = . ; | ||
| *(.eh_fram*) | ||
| @@ -47,7 +44,7 @@ SECTIONS | ||
| } | ||
| .bss SIZEOF(.data) + ADDR(.data) : | ||
| { | ||
| *(.bss .gnu.linkonce.b.*) | ||
| *(.bss .bss.* .gnu.linkonce.b.*) | ||
| *(COMMON) | ||
| end = . ; PROVIDE(_end = .) ; | ||
| . = ALIGN(0x200); | ||
| @@ -13,7 +13,8 @@ all :: native \ | ||
| $(BIN)/dxe3res.exe \ | ||
| $E | ||
|
|
||
| native :: $(HOSTBIN)/dxegen.exe | ||
| native :: $(HOSTBIN)/dxegen.exe \ | ||
| $(HOSTBIN)/dxe3res.exe | ||
| $(NOP) | ||
|
|
||
| .o.h: | ||
| @@ -36,5 +37,8 @@ CROSS_CC = $(word 1,$(CROSS_GCC)) | ||
| $(HOSTBIN)/dxegen.exe : dxe3gen.c init1.h init2.h init3.h init4.h init5.h fini1.h fini2.h fini3.h fini4.h fini5.h | ||
| $(GCC) -DDXE_LD=\"$(CROSS_LD)\" -DDXE_CC=\"$(CROSS_CC)\" -DDXE_AR=\"$(CROSS_AR)\" -DDXE_AS=\"$(CROSS_AS)\" dxe3gen.c -o $@ | ||
|
|
||
| $(HOSTBIN)/dxe3res.exe: dxe3res.c | ||
| $(GCC) -O2 -Wall dxe3res.c -o $@ | ||
|
|
||
| clean :: | ||
| @-$(MISC) rm *.o *.h $(HOSTBIN)/dxegen.exe | ||
| @@ -128,31 +128,33 @@ char *__dos_argv0; | ||
| static void | ||
| setup_environment(void) | ||
| { | ||
| char *dos_environ = alloca(_stubinfo->env_size), *cp; | ||
| char *dos_environ, *cp; | ||
| short env_selector; | ||
| int env_count=0; | ||
|
|
||
| dos_environ = alloca(_stubinfo->env_size); | ||
| movedata(_stubinfo->psp_selector, 0x2c, ds, (int)&env_selector, 2); | ||
| movedata(env_selector, 0, ds, (int)dos_environ, _stubinfo->env_size); | ||
| cp = dos_environ; | ||
| do { | ||
| while (*cp) { /* repeat until two NULs */ | ||
| env_count++; | ||
| while (*cp) cp++; /* skip to NUL */ | ||
| cp++; /* skip to next character */ | ||
| } while (*cp); /* repeat until two NULs */ | ||
| } | ||
| _environ = (char **)malloc((env_count+1) * sizeof(char *)); | ||
| if (_environ == 0) | ||
| return; | ||
|
|
||
| cp = dos_environ; | ||
| env_count = 0; | ||
| do { | ||
| while (*cp) { /* repeat until two NULs */ | ||
| /* putenv assumes each string is malloc'd */ | ||
| _environ[env_count] = (char *)malloc(strlen(cp)+1); | ||
| strcpy(_environ[env_count], cp); | ||
| env_count++; | ||
| while (*cp) cp++; /* skip to NUL */ | ||
| cp++; /* skip to next character */ | ||
| } while (*cp); /* repeat until two NULs */ | ||
| } | ||
| _environ[env_count] = 0; | ||
|
|
||
| /* | ||
| @@ -208,7 +210,7 @@ setup_os_version(void) | ||
| _osminor = v & 0xff; | ||
| } | ||
|
|
||
|
|
||
| __attribute__((force_align_arg_pointer)) | ||
| void | ||
| __crt1_startup(void) | ||
| { | ||
| @@ -45,6 +45,7 @@ | ||
| extern char **_environ; | ||
|
|
||
| int __dosexec_in_system = 0; | ||
| int __spawn_flags = __spawn_leak_workaround; | ||
|
|
||
| typedef struct { | ||
| unsigned short eseg; | ||
| @@ -492,7 +493,8 @@ static int direct_exec_tail (const char *program, const char *args, | ||
| /* r5 as corresponding DPMI call is supported beginning with v5. */ | ||
|
|
||
| ret = __dpmi_get_capabilities(&flags, dpmi_vendor); | ||
| if (ret == 0 && strcmp(dpmi_vendor + 2, "CWSDPMI") == 0) | ||
| if ((ret == 0 && strcmp(dpmi_vendor + 2, "CWSDPMI") == 0) | ||
| || (__spawn_flags & __spawn_leak_workaround) == 0) | ||
| workaround_descriptor_leaks = 0; | ||
| else | ||
| { | ||
| @@ -4,7 +4,7 @@ | ||
| TOP=../.. | ||
|
|
||
| # supress all warnings here | ||
| CFLAGS = -w | ||
| CFLAGS += -w | ||
|
|
||
| SRC += regcomp.c | ||
| SRC += regerror.c | ||
| @@ -21,7 +21,7 @@ DIRS = \ | ||
| ../info \ | ||
| ../lib | ||
|
|
||
| all : misc.exe config $(DIRS) makemake.exe subs ../lib/libg.a ../lib/libpc.a | ||
| all : misc.exe config $(DIRS) makemake.exe subs | ||
|
|
||
| misc.exe : misc.c | ||
| gcc -O2 -Wall misc.c -o misc.exe | ||
| @@ -55,6 +55,7 @@ gcc.opt: makefile.cfg | ||
| @./misc.exe echo - "-Wsign-compare" >>gcc.opt | ||
| @./misc.exe echo - "-nostdinc" >>gcc.opt | ||
| @./misc.exe echo - "$(IQUOTE)" >>gcc.opt | ||
| @./misc.exe echo - "-mpreferred-stack-boundary=4" >>gcc.opt | ||
|
|
||
|
|
||
| gcc-l.opt: makefile.cfg | ||
| @@ -65,6 +66,7 @@ gcc-l.opt: makefile.cfg | ||
| @./misc.exe echo - "-Wall" >>gcc-l.opt | ||
| @./misc.exe echo - "-nostdinc" >>gcc-l.opt | ||
| @./misc.exe echo - "$(IQUOTE)" >>gcc-l.opt | ||
| @./misc.exe echo - "-mpreferred-stack-boundary=4" >>gcc-l.opt | ||
|
|
||
| gpp.opt: gcc.opt | ||
| sed -f gpp.sed $< > $@ | ||
| @@ -165,7 +165,8 @@ ifneq ($(MAKEFILE_LIB),1) | ||
| all :: makefile.oh | ||
| makefile.oh : makefile | ||
| @$(MISC) echo - building new response file | ||
| @$(MISC) echo makefile.oh $(addprefix \&/,$(OBJS)) | ||
| #@echo " $(addprefix $(subst $(abspath $(CURDIR)/$(TOP))/,,$(CURDIR)/),$(OBJS))" > makefile.oh | ||
| @echo "$(addprefix &/,$(OBJS))" > makefile.oh | ||
| endif | ||
|
|
||
| clean :: | ||
| @@ -23,6 +23,7 @@ $(LIB)/lib$(LIBNAME).a : $(OBJS) makefile.rf $(TOP)/../ident.c | ||
| ifeq ($(CROSS_BUILD),0) | ||
| $(CROSS_AR) q $(LIB)/lib$(LIBNAME).a @makefile.rf id_$(LIBNAME).o | ||
| else | ||
| dos2unix makefile.rf | ||
| $(CROSS_AR) q $(LIB)/lib$(LIBNAME).a `cat makefile.rf` id_$(LIBNAME).o | ||
| endif | ||
| $(CROSS_AR) s $(LIB)/lib$(LIBNAME).a | ||
| @@ -14,7 +14,11 @@ main(int argc, char **argv) | ||
| { | ||
| /* MS-DOS uses \, unix uses / */ | ||
| if (argc > 2 && strcmp(argv[1], "mkdir") == 0) | ||
| #if defined(__MINGW32__) || defined(__MINGW64__) | ||
| mkdir(argv[2]); | ||
| #else | ||
| mkdir(argv[2], 0777); | ||
| #endif | ||
|
|
||
| /* redirection and long command lines don't always | ||
| mix well under MS-DOS */ | ||
| @@ -5,10 +5,12 @@ | ||
| #include <fcntl.h> | ||
| #include <sys/stat.h> | ||
| #include <string.h> | ||
| #include <io.h> | ||
| #include <unistd.h> | ||
| #include <ctype.h> | ||
|
|
||
| #if !defined(O_BINARY) | ||
| #define O_BINARY 0 | ||
| #endif | ||
|
|
||
| static void | ||
| exe2aout(char *fname) | ||
| @@ -22,6 +22,7 @@ all :: native \ | ||
| native :: \ | ||
| $(HOSTBIN)/stubedit.exe \ | ||
| $(HOSTBIN)/stubify.exe \ | ||
| $(HOSTBIN)/exe2coff.exe \ | ||
| $(INC)/stubinfo.h \ | ||
| $E | ||
| $(NOP) | ||
| @@ -63,10 +64,13 @@ $(BIN)/stubedit.exe : $(C) stubedit.o $(L) | ||
|
|
||
|
|
||
| $(HOSTBIN)/stubify.exe : stubify.c stub.h | ||
| $(GCC) stubify.c -o $@ | ||
| $(GCC) -O2 stubify.c -o $@ | ||
|
|
||
| $(HOSTBIN)/stubedit.exe : stubedit.c $(INC)/stubinfo.h | ||
| $(GCC) stubedit.c -o $@ | ||
| $(GCC) -O2 stubedit.c -o $@ | ||
|
|
||
| $(HOSTBIN)/exe2coff.exe : exe2coff.c | ||
| $(GCC) -O2 $< -o $@ | ||
|
|
||
| ./stub2inc.exe : stub2inc.c | ||
| $(GCC) stub2inc.c -o $@ | ||
| @@ -160,13 +160,21 @@ resize_again: | ||
| ; Scan environment for "PATH=" and the stub's full name after environment | ||
|
|
||
| mov es, es:[0x2c] ; get environment segment | ||
| mov di, es | ||
| or di, di ; check if no env | ||
| jnz @f1 | ||
| mov al, 111 | ||
| mov dx, msg_no_env | ||
| jmpl error | ||
| @f1: | ||
| xor di, di ; begin search for NUL/NUL (di = 0) | ||
| ; mov cx, 0xff04 ; effectively `infinite' loop | ||
| xor al, al | ||
| .db 0xa9 ; "test ax,...." -- skip 2 bytes | ||
| jmp @f1 | ||
| scan_environment: | ||
| repne | ||
| scasb ; search for NUL | ||
| @f1: | ||
| cmpw es:[di], 0x4150 ; "PA" | ||
| jne not_path | ||
| scasw | ||
| @@ -182,6 +190,8 @@ not_path: | ||
| scasb | ||
| jne scan_environment ; no, still environment | ||
| scasw ; adjust pointer to point to prog name | ||
| push es | ||
| push di | ||
|
|
||
| ;; When we are spawned from a program which has more than 20 handles in use, | ||
| ;; all the handles passed to us by DOS are taken (since only the first 20 | ||
| @@ -199,8 +209,6 @@ not_path: | ||
| ;----------------------------------------------------------------------------- | ||
| ; Get DPMI information before doing anything 386-specific | ||
|
|
||
| push es | ||
| push di | ||
| xor cx, cx ; flag for load attempt set cx = 0 | ||
| jz @f2 ; We always jump, shorter than jmp | ||
| @b1: | ||
| @@ -828,6 +836,8 @@ msg_not_exe: | ||
| .db ": not EXE$" | ||
| msg_not_coff: | ||
| .db ": not COFF (Check for viruses)$" | ||
| msg_no_env: | ||
| .db "no envseg$" | ||
| msg_no_dpmi: | ||
| .db "no DPMI - Get csdpmi*b.zip$" | ||
| msg_no_dos_memory: | ||