diff --git a/contrib/toolchain/gcc/5x/libgcc/Makefile b/contrib/toolchain/gcc/5x/libgcc/Makefile index 567709ca7b..c394a8ced3 100644 --- a/contrib/toolchain/gcc/5x/libgcc/Makefile +++ b/contrib/toolchain/gcc/5x/libgcc/Makefile @@ -72,34 +72,33 @@ EH_MODEL = dw2 CUSTOM_CRTSTUFF = yes -crtbegin.o: $(srcdir)/config/i386/cygming-crtbegin.c +#crtbegin.o: config/i386/cygming-crtbegin.c - $(crt_compile) -fno-omit-frame-pointer -c $< +# $(crt_compile) -fno-omit-frame-pointer -c $< -crtbeginS.o: $(srcdir)/config/i386/cygming-crtbegin.c +#crtbeginS.o: config/i386/cygming-crtbegin.c - $(crt_compile) -fno-omit-frame-pointer -c $< -DCRTSTUFFS_O +# $(crt_compile) -fno-omit-frame-pointer -c $< -DCRTSTUFFS_O # We intentionally use a implementation-reserved init priority of 0, # so allow the warning. -crtend.o: $(srcdir)/config/i386/cygming-crtend.c +#crtend.o: config/i386/cygming-crtend.c - $(crt_compile) -fno-omit-frame-pointer -Wno-error -c $< +# $(crt_compile) -fno-omit-frame-pointer -Wno-error -c $< # This is an endfile, Use -minline-all-stringops to ensure # that __builtin_memset doesn't refer to the lib function memset(). -crtfastmath.o: $(srcdir)/config/i386/crtfastmath.c +crtfastmath.o: config/i386/crtfastmath.c $(gcc_compile) -mfxsr -msse -c $< -LIB1ASMSRC = i386/cygwin.S - +LIB1ASMSRC = i386/chkstk.S LIB1ASMFUNCS = _chkstk _chkstk_ms DFP_ENABLE = true @@ -217,6 +216,14 @@ lib2funcs := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS),$(lib2funcs)) LIB2_DIVMOD_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS), \ $(LIB2_DIVMOD_FUNCS)) +# Build "libgcc1" (assembly) components. + +lib1asmfuncs-o = $(patsubst %,%$(objext),$(LIB1ASMFUNCS)) +$(lib1asmfuncs-o): %$(objext): config/$(LIB1ASMSRC) + $(gcc_compile) -DL$* -xassembler-with-cpp -c $< -o $@ +libgcc-objects += $(lib1asmfuncs-o) + + # Build lib2funcs. For the static library also include LIB2FUNCS_ST. lib2funcs-o = $(patsubst %,%$(objext),$(lib2funcs) $(LIB2FUNCS_ST)) diff --git a/contrib/toolchain/gcc/5x/libgcc/config/i386/chkstk.S b/contrib/toolchain/gcc/5x/libgcc/config/i386/chkstk.S new file mode 100644 index 0000000000..f2029cce7d --- /dev/null +++ b/contrib/toolchain/gcc/5x/libgcc/config/i386/chkstk.S @@ -0,0 +1,60 @@ + +.section .text + +#ifdef L_chkstk + .global ___chkstk + .global __alloca + +___chkstk: +__alloca: + pushl %ecx /* save temp */ + leal 8(%esp), %ecx /* point past return addr */ + subl %eax, %ecx + cmpl %fs:8, %ecx # check low stack limit + jb 1f + + movl %esp, %eax /* save old stack pointer */ + movl %ecx, %esp /* decrement stack */ + movl (%eax), %ecx /* recover saved temp */ + movl 4(%eax), %eax /* recover return address */ + + /* Push the return value back. Doing this instead of just + jumping to %eax preserves the cached call-return stack + used by most modern processors. */ + pushl %eax + ret +1: + int3 #trap to debugger + .ascii "Stack overflow" +#endif + +#ifdef L_chkstk_ms + .global ___chkstk_ms + +___chkstk_ms: + pushl %ecx /* save temp */ + pushl %eax + cmpl $0x1000, %eax /* > 4k ?*/ + leal 12(%esp), %ecx /* point past return addr */ + jb 2f +1: + subl $0x1000, %ecx /* yes, move pointer down 4k*/ + cmpl %fs:8, %ecx /* check low stack limit */ + jb 3f + + orl $0x0, (%ecx) /* probe there */ + subl $0x1000, %eax /* decrement count */ + cmpl $0x1000, %eax + ja 1b /* and do it again */ + +2: + subl %eax, %ecx + orl $0x0, (%ecx) /* less than 4k, just peek here */ + + popl %eax + popl %ecx + ret +3: + int3 #trap to debugger + .ascii "Stack overflow" +#endif