From 2af7a3394bbbe739f309d0e55f0378aea63d8e26 Mon Sep 17 00:00:00 2001 From: siemargl Date: Wed, 23 Nov 2016 11:13:09 +0000 Subject: [PATCH] fix fopen handle leak, static build git-svn-id: svn://kolibrios.org@6744 a494cfbc-eb01-0410-851d-a64ba20cac60 --- contrib/sdk/sources/newlib/libc/Makefile | 10 +++++++--- contrib/sdk/sources/newlib/libc/sys/open.c | 3 +++ contrib/sdk/sources/newlib/static.lds | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/contrib/sdk/sources/newlib/libc/Makefile b/contrib/sdk/sources/newlib/libc/Makefile index 72628e415f..43505b8673 100644 --- a/contrib/sdk/sources/newlib/libc/Makefile +++ b/contrib/sdk/sources/newlib/libc/Makefile @@ -553,6 +553,7 @@ ifeq ($(findstring static,$(MAKECMDGOALS)),static) LIB_SRCS:= $(STATIC_SRCS) LIB_OBJS:= $(STATIC_OBJS) +CFLAGS += -DSTATIC_LIBC else @@ -582,9 +583,9 @@ shared: $(NAME).dll libdll.a $(NAME).dll: $(LIB_OBJS) $(SRC_DEP) Makefile $(LD) $(LDFLAGS) $(LIBPATH) -o $@ $(LIB_OBJS) -lgcc --version-script libc.ver - #sed -e "s/ @[^ ]*//" libc.orig.def > libc.def - #sed -f cmd2.sed libc.def > mem - #sed -f newlib.sed mem > libc.inc +#sed -e "s/ @[^ ]*//" libc.orig.def > libc.def +#sed -f cmd2.sed libc.def > mem +#sed -f newlib.sed mem > libc.inc install: libc.dll libc.dll.a libdll.a mv -f libc.dll $(SDK_DIR)/bin @@ -667,6 +668,9 @@ time/wcsftime.o: time/strftime.c %.o : %.c Makefile $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< +%.o : %.S Makefile + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< + clean: -rm -f */*.o diff --git a/contrib/sdk/sources/newlib/libc/sys/open.c b/contrib/sdk/sources/newlib/libc/sys/open.c index 8aa4ad58cf..60158b820a 100644 --- a/contrib/sdk/sources/newlib/libc/sys/open.c +++ b/contrib/sdk/sources/newlib/libc/sys/open.c @@ -115,6 +115,7 @@ int open (const char * filename, int flags, ...) if(hid < 0) { errno = EMFILE; + __io_free(hid); return (-1); }; @@ -136,6 +137,7 @@ int open (const char * filename, int flags, ...) if( !err ) { errno = EEXIST; + __io_free(hid); return (-1); }; } @@ -147,6 +149,7 @@ int open (const char * filename, int flags, ...) if( err ) { errno = EACCES; + __io_free(hid); return -1; }; }; diff --git a/contrib/sdk/sources/newlib/static.lds b/contrib/sdk/sources/newlib/static.lds index a7d1f2c3c5..7975aaba06 100644 --- a/contrib/sdk/sources/newlib/static.lds +++ b/contrib/sdk/sources/newlib/static.lds @@ -9,7 +9,7 @@ SECTIONS LONG(0x554e454D); LONG(0x32305445); LONG(1); - LONG(__start); + LONG(__crt_start); LONG(___iend); LONG(___memsize); LONG(___stacktop);