diff options
68 files changed, 256 insertions, 184 deletions
@@ -62,6 +62,8 @@ endif # Make certain these contain a final "/", but no "//"s. TARGET_ARCH:=$(shell grep -s '^TARGET_ARCH' $(top_builddir)/.config | sed -e 's/^TARGET_ARCH=//' -e 's/"//g') TARGET_ARCH:=$(strip $(subst ",, $(strip $(TARGET_ARCH)))) +TARGET_SUBARCH:=$(shell grep -s '^TARGET_SUBARCH' $(top_builddir)/.config | sed -e 's/^TARGET_SUBARCH=//' -e 's/"//g') +TARGET_SUBARCH:=$(strip $(subst ",, $(strip $(TARGET_SUBARCH)))) RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX)))))) DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX)))))) KERNEL_HEADERS:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(KERNEL_HEADERS)))))) @@ -72,7 +74,11 @@ export RUNTIME_PREFIX DEVEL_PREFIX KERNEL_HEADERS MAJOR_VERSION := 0 MINOR_VERSION := 9 SUBLEVEL := 29 +EXTRAVERSION := VERSION := $(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL) +ifneq ($(EXTRAVERSION),) +VERSION := $(VERSION)$(EXTRAVERSION) +endif # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc. LC_ALL := C export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION LC_ALL @@ -146,7 +152,7 @@ endif ifeq ($(UCLIBC_FORMAT_FDPIC_ELF),y) PICFLAG:=-mfdpic else - PICFLAG:=-fPIC + PICFLAG:=-fPIC -DPIC endif PIEFLAG_NAME:=-fPIE @@ -318,6 +324,14 @@ export LDPIEFLAG:=$(shell $(LD) --help 2>/dev/null | grep -q -- -pie && echo "-W endif endif +# For NPTL we need to add the dynamic linker into the +# libc.so linker script. Required to provide __tls_get_addr +# symbol when usign TLS dynamic access model + +ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) +ASNEEDED:=AS_NEEDED ( $(UCLIBC_LDSO) ) +endif + # Check for AS_NEEDED support in linker script (binutils>=2.16.1 has it) ifndef ASNEEDED ifneq ($(UCLIBC_HAS_SSP),y) @@ -332,6 +346,7 @@ XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -fno-strict-alia ifeq ($(EXTRA_WARNINGS),y) XWARNINGS+=-Wnested-externs -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wformat=2 XWARNINGS+=-Wmissing-prototypes -Wmissing-declarations +XWARNINGS+=-Wnonnull -Wundef # works only w/ gcc-3.4 and up, can't be checked for gcc-3.x w/ check_gcc() #XWARNINGS+=-Wdeclaration-after-statement endif @@ -352,6 +367,10 @@ CFLAGS := -include $(top_builddir)include/libc-symbols.h \ $(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) \ -fno-builtin -nostdinc -I$(top_builddir)include -I. +ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"") +CFLAGS += $(subst ",, $(UCLIBC_EXTRA_CFLAGS)) +endif + LDADD_LIBFLOAT= ifeq ($(UCLIBC_HAS_SOFT_FLOAT),y) # If -msoft-float isn't supported, we want an error anyway. @@ -369,9 +388,6 @@ ifeq ($(TARGET_ARCH),arm) endif endif -# Make sure "char" behavior is the same everywhere -CFLAGS += -fsigned-char - # We need this to be checked within libc-symbols.h ifneq ($(HAVE_SHARED),y) CFLAGS += -DSTATIC @@ -392,12 +408,23 @@ ifeq ($(UCLIBC_BUILD_NOW),y) LDFLAGS_NOSTRIP+=-z now endif +ifeq ($(LDSO_GNU_HASH_SUPPORT),y) +# Be sure that binutils support it +LDFLAGS_GNUHASH:=$(call check_ld,--hash-style=gnu) +ifeq ($(LDFLAGS_GNUHASH),) +$(error Your binutils don't support --hash-style option, while you want to use it) +else +LDFLAGS_NOSTRIP += $(LDFLAGS_GNUHASH) +endif +endif + LDFLAGS:=$(LDFLAGS_NOSTRIP) -z defs + ifeq ($(DODEBUG),y) #CFLAGS += -g3 -CFLAGS += -O0 -g3 +CFLAGS += -O0 -g3 -DDEBUG else -CFLAGS += $(OPTIMIZATION) $(XARCH_CFLAGS) +CFLAGS += $(OPTIMIZATION) $(XARCH_CFLAGS) -DNDEBUG endif ifeq ($(DOSTRIP),y) LDFLAGS += -s @@ -431,9 +458,11 @@ else endif endif PTDIR := $(top_builddir)libpthread/$(PTNAME) + # set up system dependencies include dirs (NOTE: order matters!) ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) PTINC:= -I$(PTDIR) \ + -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/$(TARGET_SUBARCH) \ -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH) \ -I$(PTDIR)/sysdeps/$(TARGET_ARCH) \ -I$(PTDIR)/sysdeps/unix/sysv/linux \ diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in index c28ec640f..1573f65cd 100644 --- a/extra/Configs/Config.in +++ b/extra/Configs/Config.in @@ -7,7 +7,6 @@ mainmenu "uClibc C Library Configuration" choice prompt "Target Architecture" - default TARGET_i386 help Stuff @@ -177,6 +176,12 @@ if TARGET_x86_64 source "extra/Configs/Config.x86_64" endif +config TARGET_SUBARCH + string + default "e500" if CONFIG_E500 + default "classic" if CONFIG_CLASSIC + default "sh4" if CONFIG_SH4 + default "" source "extra/Configs/Config.in.arch" @@ -318,6 +323,21 @@ config UCLIBC_CTOR_DTOR or dtors and want your binaries to be as small as possible, then answer N. +config LDSO_GNU_HASH_SUPPORT + bool "Enable GNU hash style support" + depends on HAVE_SHARED + default n + help + Newest binutils support a new hash style named GNU-hash. The dynamic + linker will use the new GNU-hash section (.gnu.hash) for symbol lookup + if present into the ELF binaries, otherwise it will use the old SysV + hash style (.hash). This ensures that it is completely backward compatible. + Further, being the hash table implementation self-contained into each + executable and shared libraries, objects with mixed hash style can + peacefully coexist in the same process. + + If you want to use this new feature, answer Y + config HAS_NO_THREADS bool default n @@ -1440,6 +1460,12 @@ config CROSS_COMPILER_PREFIX example, if you run 'arm-linux-uclibc-gcc' to compile something, then enter 'arm-linux-uclibc-' here. +config UCLIBC_EXTRA_CFLAGS + string "Enter any extra CFLAGS to use to build uClibc" + default "" + help + Add any additional CFLAGS to be used to build uClibc. + config DODEBUG bool "Build uClibc with debugging symbols" default n diff --git a/extra/locale/Makefile.in b/extra/locale/Makefile.in index bae49417d..ec27bedb8 100644 --- a/extra/locale/Makefile.in +++ b/extra/locale/Makefile.in @@ -24,6 +24,8 @@ BUILD_CFLAGS-gen_wc8bit += -DDO_WIDE_CHAR=1 BUILD_CFLAGS-gen_ldc += -D__WCHAR_ENABLED=1 endif +BUILD_CFLAGS-gen_locale := -D_GNU_SOURCE + DEPH-locale := $(top_builddir)include/bits/sysnum.h DEPH-gen_locale := c8tables.h DEPH-gen_ldc := c8tables.h wctables.h locale_tables.h locale_collate.h @@ -44,8 +46,6 @@ CFLAGS-locale_data.c := -D__WCHAR_ENABLED -I$(locale_OUT) -I$(locale_DIR) #headers-$(UCLIBC_HAS_LOCALE) += locale_headers libc-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ) -libc-static-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ) -libc-shared-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ) libc-nomulti-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ) @@ -163,7 +163,7 @@ $(locale_SRC): $(locale_OUT)/gen_ldc $(locale_OUT)/uClibc_locale_data.h: $(locale_OUT)/lt_defines.h $(locale_OUT)/c8tables.h $(locale_OUT)/wctables.h $(locale_DIR)/locale_mmap.h | $(locale_SRC) grep -v "define __LC" $< > $@ - cat $(wordlist 2,3,4,$^) >> $@ + cat $(wordlist 2,4,$^) >> $@ endif diff --git a/libc/Makefile.in b/libc/Makefile.in index f3cd20922..12658c31f 100644 --- a/libc/Makefile.in +++ b/libc/Makefile.in @@ -16,7 +16,9 @@ VERSION_SCRIPT := --version-script $(VERSION_SCRIPT) endif LDFLAGS-libc.so := $(LDFLAGS) $(VERSION_SCRIPT) -init __uClibc_init - +ifeq ($(UCLIBC_HAS_STDIO_FUTEXES),y) +CFLAGS += -D__USE_STDIO_FUTEXES__ +endif LIBS-libc.so := $(interp) $(ldso) $(top_builddir)lib/$(NONSHARED_LIBNAME) # we have SHARED_MAJORNAME=libc.so.$(MAJOR_VERSION) defined in Rules.mak @@ -42,7 +44,7 @@ libc-a-y = $(libc-y) $(libc-static-y) endif ifeq ($(DOMULTI),n) -libc-so-y += $(libc-shared-y) +libc-so-y = $(libc-y:.o=.os) $(libc-shared-y) else all_sources = $(libc-y:.o=.c) all_sources += $(libc-shared-y:.oS=.c) diff --git a/libc/inet/Makefile.in b/libc/inet/Makefile.in index 4fc094340..66a84c06f 100644 --- a/libc/inet/Makefile.in +++ b/libc/inet/Makefile.in @@ -42,8 +42,6 @@ INET_SRC := $(patsubst %.c,$(INET_DIR)/%.c,$(CSRC)) INET_OBJ := $(patsubst %.c,$(INET_OUT)/%.o,$(CSRC)) libc-y += $(INET_OBJ) -libc-a-y += $(INET_OBJ) -libc-so-y += $(INET_OBJ:.o=.os) objclean-y += inet_objclean diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c index 1c593fc4f..23a1e988e 100644 --- a/libc/inet/getaddrinfo.c +++ b/libc/inet/getaddrinfo.c @@ -54,8 +54,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <assert.h> #include <errno.h> #include <netdb.h> -#include <resolv.h> #include <stdio.h> +#include <resolv.h> #include <stdlib.h> #include <string.h> #include <unistd.h> diff --git a/libc/inet/inet_net.c b/libc/inet/inet_net.c index f8148c274..71ed8dc88 100644 --- a/libc/inet/inet_net.c +++ b/libc/inet/inet_net.c @@ -50,55 +50,51 @@ libc_hidden_proto(__ctype_b) */ libc_hidden_proto(inet_network) in_addr_t -inet_network(const char *cp) +inet_network(cp) + register const char *cp; { - register in_addr_t val, base, n; + register u_int32_t val, base, n, i; register char c; - in_addr_t parts[4], *pp = parts; - register unsigned int i; + u_int32_t parts[4], *pp = parts; + int digit; again: - /* - * Collect number up to ``.''. - * Values are specified as for C: - * 0x=hex, 0=octal, other=decimal. - */ - val = 0; base = 10; - /* - * The 4.4BSD version of this file also accepts 'x__' as a hexa - * number. I don't think this is correct. -- Uli - */ - if (*cp == '0') { - if (*++cp == 'x' || *cp == 'X') - base = 16, cp++; - else - base = 8; - } - while ((c = *cp)) { + val = 0; base = 10; digit = 0; + if (*cp == '0') + digit = 1, base = 8, cp++; + if (*cp == 'x' || *cp == 'X') + base = 16, cp++; + while ((c = *cp) != 0) { if (isdigit(c)) { + if (base == 8 && (c == '8' || c == '9')) + return (INADDR_NONE); val = (val * base) + (c - '0'); cp++; + digit = 1; continue; } if (base == 16 && isxdigit(c)) { - val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A')); + val = (val << 4) + (tolower (c) + 10 - 'a'); cp++; + digit = 1; continue; } break; } + if (!digit) + return (INADDR_NONE); + if (pp >= parts + 4 || val > 0xff) + return (INADDR_NONE); if (*cp == '.') { - if (pp >= parts + 4) - return (INADDR_NONE); *pp++ = val, cp++; goto again; } if (*cp && !isspace(*cp)) return (INADDR_NONE); + if (pp >= parts + 4 || val > 0xff) + return (INADDR_NONE); *pp++ = val; n = pp - parts; - if (n > 4) - return (INADDR_NONE); for (val = 0, i = 0; i < n; i++) { val <<= 8; val |= parts[i] & 0xff; diff --git a/libc/inet/rpc/Makefile.in b/libc/inet/rpc/Makefile.in index c292834a0..af047c0df 100644 --- a/libc/inet/rpc/Makefile.in +++ b/libc/inet/rpc/Makefile.in @@ -32,14 +32,10 @@ INET_RPC_OBJ:=$(patsubst $(INET_RPC_DIR)/%.c,$(INET_RPC_OUT)/%.o,$(INET_RPC_SRC) libc-static-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OUT)/rpc_thread.o libc-shared-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OUT)/rpc_thread.oS -libc-a-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OUT)/rpc_thread.o -libc-so-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OUT)/rpc_thread.oS libc-nomulti-$(UCLIBC_HAS_RPC) += $(INET_RPC_OUT)/rpc_thread.o libc-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OBJ) -libc-a-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OBJ) -libc-so-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OBJ:.o=.os) objclean-y+=inet_rpc_objclean diff --git a/libc/inet/rpc/rcmd.c b/libc/inet/rpc/rcmd.c index 6009d6d31..ccab7d60a 100644 --- a/libc/inet/rpc/rcmd.c +++ b/libc/inet/rpc/rcmd.c @@ -368,7 +368,11 @@ int rresvport(int *alport) } libc_hidden_def(rresvport) -static int __check_rhosts_file = 1; +/* This needs to be exported ... while it is not a documented interface + * for rcp related apps, it's a required one that is used to control the + * rhost behavior. Legacy sucks. + */ +int __check_rhosts_file = 1; int ruserok(rhost, superuser, ruser, luser) const char *rhost, *ruser, *luser; diff --git a/libc/misc/Makefile.in b/libc/misc/Makefile.in index 104db366e..542859576 100644 --- a/libc/misc/Makefile.in +++ b/libc/misc/Makefile.in @@ -20,6 +20,7 @@ include $(top_srcdir)libc/misc/gnu/Makefile.in include $(top_srcdir)libc/misc/internals/Makefile.in include $(top_srcdir)libc/misc/locale/Makefile.in include $(top_srcdir)libc/misc/mntent/Makefile.in +include $(top_srcdir)libc/misc/pthread/Makefile.in include $(top_srcdir)libc/misc/regex/Makefile.in include $(top_srcdir)libc/misc/search/Makefile.in include $(top_srcdir)libc/misc/statfs/Makefile.in diff --git a/libc/misc/assert/Makefile.in b/libc/misc/assert/Makefile.in index 3bc3ab556..3c9111e68 100644 --- a/libc/misc/assert/Makefile.in +++ b/libc/misc/assert/Makefile.in @@ -14,8 +14,6 @@ MISC_ASSERT_SRC := $(MISC_ASSERT_DIR)/__assert.c MISC_ASSERT_OBJ := $(MISC_ASSERT_OUT)/__assert.o libc-y += $(MISC_ASSERT_OBJ) -libc-a-y += $(MISC_ASSERT_OBJ) -libc-so-y += $(MISC_ASSERT_OBJ:.o=.os) objclean-y += misc_assert_objclean diff --git a/libc/misc/ctype/Makefile.in b/libc/misc/ctype/Makefile.in index 0e64fb033..1fc768ee3 100644 --- a/libc/misc/ctype/Makefile.in +++ b/libc/misc/ctype/Makefile.in @@ -31,8 +31,6 @@ MISC_CTYPE_SRC := $(patsubst %.c,$(MISC_CTYPE_DIR)/%.c,$(CSRC)) MISC_CTYPE_OBJ := $(patsubst %.c,$(MISC_CTYPE_OUT)/%.o,$(CSRC)) libc-y += $(MISC_CTYPE_OBJ) -libc-a-y += $(MISC_CTYPE_OBJ) -libc-so-y += $(MISC_CTYPE_OBJ:.o=.os) objclean-y += misc_ctype_objclean diff --git a/libc/misc/dirent/Makefile.in b/libc/misc/dirent/Makefile.in index ba8ad393f..89a00ed5e 100644 --- a/libc/misc/dirent/Makefile.in +++ b/libc/misc/dirent/Makefile.in @@ -19,8 +19,6 @@ MISC_DIRENT_SRC := $(patsubst %.c,$(MISC_DIRENT_DIR)/%.c,$(CSRC)) MISC_DIRENT_OBJ := $(patsubst %.c,$(MISC_DIRENT_OUT)/%.o,$(CSRC)) libc-y += $(MISC_DIRENT_OBJ) -libc-a-y += $(MISC_DIRENT_OBJ) -libc-so-y += $(MISC_DIRENT_OBJ:.o=.os) objclean-y += misc_dirent_objclean diff --git a/libc/misc/error/Makefile.in b/libc/misc/error/Makefile.in index fc699e870..c529e955e 100644 --- a/libc/misc/error/Makefile.in +++ b/libc/misc/error/Makefile.in @@ -14,8 +14,6 @@ MISC_ERROR_SRC := $(patsubst %.c,$(MISC_ERROR_DIR)/%.c,$(CSRC)) MISC_ERROR_OBJ := $(patsubst %.c,$(MISC_ERROR_OUT)/%.o,$(CSRC)) libc-y += $(MISC_ERROR_OBJ) -libc-a-y += $(MISC_ERROR_OBJ) -libc-so-y += $(MISC_ERROR_OBJ:.o=.os) objclean-y += misc_error_objclean diff --git a/libc/misc/file/Makefile.in b/libc/misc/file/Makefile.in index d3947c018..721fe5ec0 100644 --- a/libc/misc/file/Makefile.in +++ b/libc/misc/file/Makefile.in @@ -15,8 +15,6 @@ endif MISC_FILE_OBJ := $(patsubst $(MISC_FILE_DIR)/%.c,$(MISC_FILE_OUT)/%.o,$(MISC_FILE_SRC)) libc-y += $(MISC_FILE_OBJ) -libc-a-y += $(MISC_FILE_OBJ) -libc-so-y += $(MISC_FILE_OBJ:.o=.os) libc-nomulti-$(UCLIBC_HAS_LFS) += $(MISC_FILE_OUT)/lockf64.o diff --git a/libc/misc/file/lockf64.c b/libc/misc/file/lockf64.c index 707b7eacb..48983d448 100644 --- a/libc/misc/file/lockf64.c +++ b/libc/misc/file/lockf64.c @@ -27,6 +27,7 @@ #ifdef __NR_fcntl64 #define flock flock64 +#define fcntl fcntl64 #undef F_GETLK #define F_GETLK F_GETLK64 #undef F_SETLK diff --git a/libc/misc/fnmatch/Makefile.in b/libc/misc/fnmatch/Makefile.in index 35748ea16..c31de9cd6 100644 --- a/libc/misc/fnmatch/Makefile.in +++ b/libc/misc/fnmatch/Makefile.in @@ -18,8 +18,6 @@ MISC_FNMATCH_SRC := $(patsubst %.c,$(MISC_FNMATCH_DIR)/%.c,$(CSRC)) MISC_FNMATCH_OBJ := $(patsubst %.c,$(MISC_FNMATCH_OUT)/%.o,$(CSRC)) libc-$(UCLIBC_HAS_FNMATCH) += $(MISC_FNMATCH_OBJ) -libc-a-$(UCLIBC_HAS_FNMATCH) += $(MISC_FNMATCH_OBJ) -libc-so-$(UCLIBC_HAS_FNMATCH) += $(MISC_FNMATCH_OBJ:.o=.os) objclean-y += misc_fnmatch_objclean diff --git a/libc/misc/ftw/Makefile.in b/libc/misc/ftw/Makefile.in index c2f249ec4..501b9084d 100644 --- a/libc/misc/ftw/Makefile.in +++ b/libc/misc/ftw/Makefile.in @@ -17,8 +17,6 @@ MISC_FTW_SRC := $(patsubst %.c,$(MISC_FTW_DIR)/%.c,$(CSRC)) MISC_FTW_OBJ := $(patsubst %.c,$(MISC_FTW_OUT)/%.o,$(CSRC)) libc-$(UCLIBC_HAS_FTW) += $(MISC_FTW_OBJ) -libc-a-$(UCLIBC_HAS_FTW) += $(MISC_FTW_OBJ) -libc-so-$(UCLIBC_HAS_FTW) += $(MISC_FTW_OBJ:.o=.os) objclean-y += misc_ftw_objclean diff --git a/libc/misc/glob/Makefile.in b/libc/misc/glob/Makefile.in index 3af0bd743..93367f41b 100644 --- a/libc/misc/glob/Makefile.in +++ b/libc/misc/glob/Makefile.in @@ -24,8 +24,6 @@ MISC_GLOB_SRC := $(patsubst %.c,$(MISC_GLOB_DIR)/%.c,$(CSRC)) MISC_GLOB_OBJ := $(patsubst %.c,$(MISC_GLOB_OUT)/%.o,$(CSRC)) libc-$(UCLIBC_HAS_GLOB) += $(MISC_GLOB_OBJ) -libc-a-$(UCLIBC_HAS_GLOB) += $(MISC_GLOB_OBJ) -libc-so-$(UCLIBC_HAS_GLOB) += $(MISC_GLOB_OBJ:.o=.os) objclean-y += misc_glob_objclean diff --git a/libc/misc/gnu/Makefile.in b/libc/misc/gnu/Makefile.in index 0aa7becb8..d64a9eed3 100644 --- a/libc/misc/gnu/Makefile.in +++ b/libc/misc/gnu/Makefile.in @@ -14,8 +14,6 @@ MISC_GNU_SRC := $(MISC_GNU_DIR)/obstack.c MISC_GNU_OBJ := $(MISC_GNU_OUT)/obstack.o libc-y += $(MISC_GNU_OBJ) -libc-a-y += $(MISC_GNU_OBJ) -libc-so-y += $(MISC_GNU_OBJ:.o=.os) objclean-y += misc_gnu_objclean diff --git a/libc/misc/internals/Makefile.in b/libc/misc/internals/Makefile.in index 4d57cf4e3..11cc7efdb 100644 --- a/libc/misc/internals/Makefile.in +++ b/libc/misc/internals/Makefile.in @@ -7,7 +7,7 @@ CFLAGS-__uClibc_main.c := $(SSP_DISABLE_FLAGS) -CSRC := tempname.c errno.c __errno_location.c __h_errno_location.c +CSRC := tempname.c __errno_location.c __h_errno_location.c MISC_INTERNALS_DIR := $(top_srcdir)libc/misc/internals MISC_INTERNALS_OUT := $(top_builddir)libc/misc/internals @@ -16,15 +16,15 @@ MISC_INTERNALS_SRC := $(patsubst %.c,$(MISC_INTERNALS_DIR)/%.c,$(CSRC)) MISC_INTERNALS_OBJ := $(patsubst %.c,$(MISC_INTERNALS_OUT)/%.o,$(CSRC)) libc-y += $(MISC_INTERNALS_OBJ) -libc-shared-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS -libc-static-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o -libc-so-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS \ - $(MISC_INTERNALS_OUT)/errno.oS $(MISC_INTERNALS_OBJ:.o=.oS) +libc-shared-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS \ + $(MISC_INTERNALS_OUT)/errno.oS +libc-static-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o \ + $(MISC_INTERNALS_OUT)/errno.o libc-static-$(UCLIBC_FORMAT_SHARED_FLAT) += \ - $(MISC_INTERNALS_OUT)/shared_flat_initfini.o \ - $(MISC_INTERNALS_OUT)/shared_flat_add_library.o -libc-nomulti-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o - + $(MISC_INTERNALS_OUT)/shared_flat_initfini.o \ + $(MISC_INTERNALS_OUT)/shared_flat_add_library.o +libc-nomulti-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o \ + $(MISC_INTERNALS_OUT)/errno.o objclean-y += misc_internals_objclean misc_internals_objclean: diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c index 85f38c521..15544790a 100644 --- a/libc/misc/internals/__uClibc_main.c +++ b/libc/misc/internals/__uClibc_main.c @@ -15,8 +15,10 @@ * avoided in the static library case. */ -#define _ERRNO_H #include <features.h> +#ifndef __UCLIBC_HAS_THREADS_NATIVE__ +#define _ERRNO_H +#endif #include <unistd.h> #include <stdlib.h> #include <string.h> @@ -30,6 +32,7 @@ #include <sys/stat.h> #include <sys/sysmacros.h> #ifdef __UCLIBC_HAS_THREADS_NATIVE__ +#include <errno.h> #include <pthread-functions.h> #include <not-cancel.h> #endif @@ -54,6 +57,8 @@ extern __typeof(fcntl) __libc_fcntl; libc_hidden_proto(__libc_fcntl) #endif +#include <pthreadP.h> + #ifndef SHARED void *__libc_stack_end=NULL; @@ -79,6 +84,11 @@ uintptr_t __guard attribute_relro; # endif # endif +/* + * Needed to initialize _dl_phdr when statically linked; + */ + +void internal_function _dl_aux_init (ElfW(auxv_t) *av); #endif /* !SHARED */ /* @@ -91,7 +101,11 @@ extern int *weak_const_function __h_errno_location(void); extern void weak_function _locale_init(void) attribute_hidden; #endif #ifdef __UCLIBC_HAS_THREADS__ +#if !defined (__UCLIBC_HAS_THREADS_NATIVE__) || defined (SHARED) extern void weak_function __pthread_initialize_minimal(void); +#else +extern void __pthread_initialize_minimal(void); +#endif #endif #ifdef __UCLIBC_CTOR_DTOR__ @@ -119,12 +133,12 @@ strong_alias (__progname_full, program_invocation_name) #endif /* - * Declare the __environ global variable and create a strong alias environ. - * Note: Apparently we must initialize __environ to ensure that the strong - * environ symbol is also included. + * Declare the __environ global variable and create a weak alias environ. + * This must be initialized; we cannot have a weak alias into bss. */ + char **__environ = 0; -strong_alias(__environ,environ) +weak_alias(__environ,environ) /* TODO: don't export __pagesize; we cant now because libpthread uses it */ size_t __pagesize = 0; @@ -209,7 +223,9 @@ void __uClibc_init(void) * __pthread_initialize_minimal so we can use pthread_locks * whenever they are needed. */ +#if !defined (__UCLIBC_HAS_THREADS_NATIVE__) || defined (SHARED) if (likely(__pthread_initialize_minimal!=NULL)) +#endif __pthread_initialize_minimal(); #endif @@ -324,6 +340,12 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc, } aux_dat += 2; } +#ifndef SHARED + /* Get the program headers (_dl_phdr) from the aux vector + It will be used into __libc_setup_tls. */ + + _dl_aux_init (auxvt); +#endif #endif /* We need to initialize uClibc. If we are dynamically linked this @@ -444,7 +466,7 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc, if (! atomic_decrement_and_test (ptr)) /* Not much left to do but to exit the thread, not the process. */ - __exit_thread (0); + __exit_thread_inline (0); } exit (result); diff --git a/libc/misc/internals/tempname.c b/libc/misc/internals/tempname.c index 26918dc16..dc125020b 100644 --- a/libc/misc/internals/tempname.c +++ b/libc/misc/internals/tempname.c @@ -206,18 +206,17 @@ int attribute_hidden __gen_tempname (char *tmpl, int kind) return -1; } - /* Get some random data. */ - if (fillrand(randomness, sizeof(randomness)) != sizeof(randomness)) { - /* if random device nodes failed us, lets use the braindamaged ver */ - brain_damaged_fillrand(randomness, sizeof(randomness)); - } - - for (i = 0; i < sizeof(randomness); ++i) - XXXXXX[i] = letters[(randomness[i]) % NUM_LETTERS]; - for (i = 0; i < TMP_MAX; ++i) { + int j; + /* Get some random data. */ + if (fillrand(randomness, sizeof(randomness)) != sizeof(randomness)) { + /* if random device nodes failed us, lets use the braindamaged ver */ + brain_damaged_fillrand(randomness, sizeof(randomness)); + } + for (j = 0; j < sizeof(randomness); ++j) + XXXXXX[j] = letters[randomness[j] % NUM_LETTERS]; - switch(kind) { + switch (kind) { case __GT_NOCREATE: { struct stat st; diff --git a/libc/misc/locale/Makefile.in b/libc/misc/locale/Makefile.in index 4a77e205f..b51fe0376 100644 --- a/libc/misc/locale/Makefile.in +++ b/libc/misc/locale/Makefile.in @@ -21,8 +21,6 @@ MISC_LOCALE_SRC := $(patsubst %.c,$(MISC_LOCALE_DIR)/%.c,$(CSRC)) MISC_LOCALE_OBJ := $(patsubst %.c,$(MISC_LOCALE_OUT)/%.o,$(CSRC)) libc-y += $(MISC_LOCALE_OBJ) -libc-a-y += $(MISC_LOCALE_OBJ) -libc-so-y += $(MISC_LOCALE_OBJ:.o=.os) objclean-y += misc_locale_objclean diff --git a/libc/misc/mntent/Makefile.in b/libc/misc/mntent/Makefile.in index 19751d498..958b119b3 100644 --- a/libc/misc/mntent/Makefile.in +++ b/libc/misc/mntent/Makefile.in @@ -14,8 +14,6 @@ MISC_MNTENT_SRC := $(MISC_MNTENT_DIR)/mntent.c MISC_MNTENT_OBJ := $(MISC_MNTENT_OUT)/mntent.o libc-y += $(MISC_MNTENT_OBJ) -libc-a-y += $(MISC_MNTENT_OBJ) -libc-so-y += $(MISC_MNTENT_OBJ:.o=.os) objclean-y += misc_mntent_objclean diff --git a/libc/misc/pthread/weaks.c b/libc/misc/pthread/weaks.c index e08812796..1d4f05d05 100644 --- a/libc/misc/pthread/weaks.c +++ b/libc/misc/pthread/weaks.c @@ -36,6 +36,10 @@ weak_alias (__pthread_return_0, __pthread_mutex_init) weak_alias (__pthread_return_0, __pthread_mutex_lock) weak_alias (__pthread_return_0, __pthread_mutex_trylock) weak_alias (__pthread_return_0, __pthread_mutex_unlock) + +weak_alias (__pthread_return_0, _pthread_cleanup_push_defer) +weak_alias (__pthread_return_0, _pthread_cleanup_pop_restore) + #ifdef __UCLIBC_HAS_THREADS_NATIVE__ weak_alias (__pthread_return_0, __pthread_mutexattr_init) weak_alias (__pthread_return_0, __pthread_mutexattr_destroy) diff --git a/libc/misc/regex/Makefile.in b/libc/misc/regex/Makefile.in index c6f2aea8b..e9d70c596 100644 --- a/libc/misc/regex/Makefile.in +++ b/libc/misc/regex/Makefile.in @@ -18,8 +18,6 @@ MISC_REGEX_SRC := $(patsubst %.c,$(MISC_REGEX_DIR)/%.c,$(CSRC)) MISC_REGEX_OBJ := $(patsubst %.c,$(MISC_REGEX_OUT)/%.o,$(CSRC)) libc-$(UCLIBC_HAS_REGEX) += $(MISC_REGEX_OBJ) -libc-a-$(UCLIBC_HAS_REGEX) += $(MISC_REGEX_OBJ) -libc-so-$(UCLIBC_HAS_REGEX) += $(MISC_REGEX_OBJ:.o=.os) objclean-y += misc_regex_objclean diff --git a/libc/misc/search/Makefile.in b/libc/misc/search/Makefile.in index 0b80328cd..2da1d6e01 100644 --- a/libc/misc/search/Makefile.in +++ b/libc/misc/search/Makefile.in @@ -26,8 +26,6 @@ MISC_SEARCH_SRC := $(patsubst %.c,$(MISC_SEARCH_DIR)/%.c,$(CSRC)) MISC_SEARCH_OBJ := $(patsubst %.c,$(MISC_SEARCH_OUT)/%.o,$(CSRC)) libc-y += $(MISC_SEARCH_OBJ) -libc-a-y += $(MISC_SEARCH_OBJ) -libc-so-y += $(MISC_SEARCH_OBJ:.o=.os) objclean-y += misc_search_objclean diff --git a/libc/misc/statfs/Makefile.in b/libc/misc/statfs/Makefile.in index 5f0850c1b..c979b2255 100644 --- a/libc/misc/statfs/Makefile.in +++ b/libc/misc/statfs/Makefile.in @@ -17,8 +17,6 @@ MISC_STATFS_SRC := $(patsubst %.c,$(MISC_STATFS_DIR)/%.c,$(CSRC)) MISC_STATFS_OBJ := $(patsubst %.c,$(MISC_STATFS_OUT)/%.o,$(CSRC)) libc-y += $(MISC_STATFS_OBJ) -libc-a-y += $(MISC_STATFS_OBJ) -libc-so-y += $(MISC_STATFS_OBJ:.o=.os) libc-nomulti-$(UCLIBC_HAS_LFS) += $(MISC_STATFS_OUT)/statvfs64.o $(MISC_STATFS_OUT)/fstatvfs64.o diff --git a/libc/misc/syslog/Makefile.in b/libc/misc/syslog/Makefile.in index 2b8b0c613..fd9ae198f 100644 --- a/libc/misc/syslog/Makefile.in +++ b/libc/misc/syslog/Makefile.in @@ -14,8 +14,6 @@ MISC_SYSLOG_SRC := $(patsubst %.c,$(MISC_SYSLOG_DIR)/%.c,$(CSRC)) MISC_SYSLOG_OBJ := $(patsubst %.c,$(MISC_SYSLOG_OUT)/%.o,$(CSRC)) libc-y += $(MISC_SYSLOG_OBJ) -libc-a-y += $(MISC_SYSLOG_OBJ) -libc-so-y += $(MISC_SYSLOG_OBJ) objclean-y += misc_syslog_objclean diff --git a/libc/misc/sysvipc/Makefile.in b/libc/misc/sysvipc/Makefile.in index 057a75568..44707d643 100644 --- a/libc/misc/sysvipc/Makefile.in +++ b/libc/misc/sysvipc/Makefile.in @@ -24,8 +24,6 @@ MISC_SYSVIPC_SRC := $(patsubst %.c,$(MISC_SYSVIPC_DIR)/%.c,$(CSRC)) MISC_SYSVIPC_OBJ := $(patsubst %.c,$(MISC_SYSVIPC_OUT)/%.o,$(CSRC)) libc-y += $(MISC_SYSVIPC_OBJ) -libc-a-y += $(MISC_SYSVIPC_OBJ) -libc-so-y += $(MISC_SYSVIPC_OBJ:.o=.os) objclean-y += misc_sysvipc_objclean diff --git a/libc/misc/time/Makefile.in b/libc/misc/time/Makefile.in index aeabcd88a..b90b9b48f 100644 --- a/libc/misc/time/Makefile.in +++ b/libc/misc/time/Makefile.in @@ -32,8 +32,6 @@ MISC_TIME_SRC := $(patsubst %.c,$(MISC_TIME_DIR)/%.c,$(CSRC)) MISC_TIME_OBJ := $(patsubst %.c,$(MISC_TIME_OUT)/%.o,$(CSRC)) libc-y += $(MISC_TIME_OBJ) -libc-a-y += $(MISC_TIME_OBJ) -libc-so-y += $(MISC_TIME_OBJ:.o=.os) objclean-y += misc_time_objclean diff --git a/libc/misc/ttyent/Makefile.in b/libc/misc/ttyent/Makefile.in index ece277609..288a4c09b 100644 --- a/libc/misc/ttyent/Makefile.in +++ b/libc/misc/ttyent/Makefile.in @@ -14,8 +14,6 @@ MISC_TTYENT_SRC := $(patsubst %.c,$(MISC_TTYENT_DIR)/%.c,$(CSRC)) MISC_TTYENT_OBJ := $(patsubst %.c,$(MISC_TTYENT_OUT)/%.o,$(CSRC)) libc-y += $(MISC_TTYENT_OBJ) -libc-a-y += $(MISC_TTYENT_OBJ) -libc-so-y += $(MISC_TTYENT_OBJ:.o=.os) objclean-y += misc_ttyent_objclean diff --git a/libc/misc/utmp/Makefile.in b/libc/misc/utmp/Makefile.in index 4a01bb20b..ff175dc64 100644 --- a/libc/misc/utmp/Makefile.in +++ b/libc/misc/utmp/Makefile.in @@ -14,8 +14,6 @@ MISC_UTMP_SRC := $(patsubst %.c,$(MISC_UTMP_DIR)/%.c,$(CSRC)) MISC_UTMP_OBJ := $(patsubst %.c,$(MISC_UTMP_OUT)/%.o,$(CSRC)) libc-y += $(MISC_UTMP_OBJ) -libc-a-y += $(MISC_UTMP_OBJ) -libc-so-y += $(MISC_UTMP_OBJ) objclean-y += misc_utmp_objclean diff --git a/libc/misc/wchar/Makefile.in b/libc/misc/wchar/Makefile.in index 7b408b3a0..db01f97cc 100644 --- a/libc/misc/wchar/Makefile.in +++ b/libc/misc/wchar/Makefile.in @@ -32,8 +32,6 @@ MISC_WCHAR_SRC := $(patsubst %.c,$(MISC_WCHAR_DIR)/%.c,$(CSRC)) MISC_WCHAR_OBJ := $(patsubst %.c,$(MISC_WCHAR_OUT)/%.o,$(CSRC)) libc-$(UCLIBC_HAS_WCHAR) += $(MISC_WCHAR_OBJ) -libc-a-$(UCLIBC_HAS_WCHAR) += $(MISC_WCHAR_OBJ) -libc-so-$(UCLIBC_HAS_WCHAR) += $(MISC_WCHAR_OBJ:.o=.os) objclean-y += misc_wchar_objclean diff --git a/libc/misc/wctype/Makefile.in b/libc/misc/wctype/Makefile.in index 1af030e7f..f4210ebb0 100644 --- a/libc/misc/wctype/Makefile.in +++ b/libc/misc/wctype/Makefile.in @@ -27,8 +27,6 @@ MISC_WCTYPE_SRC := $(patsubst %.c,$(MISC_WCTYPE_DIR)/%.c,$(CSRC)) MISC_WCTYPE_OBJ := $(patsubst %.c,$(MISC_WCTYPE_OUT)/%.o,$(CSRC)) libc-y += $(MISC_WCTYPE_OBJ) -libc-a-y += $(MISC_WCTYPE_OBJ) -libc-so-y += $(MISC_WCTYPE_OBJ:.o=.os) objclean-y += misc_wctype_objclean diff --git a/libc/misc/wordexp/Makefile.in b/libc/misc/wordexp/Makefile.in index e605715dc..526807f25 100644 --- a/libc/misc/wordexp/Makefile.in +++ b/libc/misc/wordexp/Makefile.in @@ -14,8 +14,6 @@ MISC_WORDEXP_SRC := $(patsubst %.c,$(MISC_WORDEXP_DIR)/%.c,$(CSRC)) MISC_WORDEXP_OBJ := $(patsubst %.c,$(MISC_WORDEXP_OUT)/%.o,$(CSRC)) libc-$(UCLIBC_HAS_WORDEXP) += $(MISC_WORDEXP_OBJ) -libc-a-$(UCLIBC_HAS_WORDEXP) += $(MISC_WORDEXP_OBJ) -libc-so-$(UCLIBC_HAS_WORDEXP) += $(MISC_WORDEXP_OBJ:.o=.os) objclean-y += misc_wordexp_objclean diff --git a/libc/pwd_grp/Makefile.in b/libc/pwd_grp/Makefile.in index 28d7ea075..f9c7149e7 100644 --- a/libc/pwd_grp/Makefile.in +++ b/libc/pwd_grp/Makefile.in @@ -24,8 +24,6 @@ PWDGRP_SRC := $(patsubst %.c,$(PWDGRP_DIR)/%.c,$(CSRC)) PWDGRP_OBJ := $(patsubst %.c,$(PWDGRP_OUT)/%.o,$(CSRC)) libc-y += $(PWDGRP_OBJ) -libc-a-y += $(PWDGRP_OBJ) -libc-so-y += $(PWDGRP_OBJ:.o=.os) objclean-y += pwdgrp_objclean diff --git a/libc/pwd_grp/lckpwdf.c b/libc/pwd_grp/lckpwdf.c index 2d38e89f9..964753458 100644 --- a/libc/pwd_grp/lckpwdf.c +++ b/libc/pwd_grp/lckpwdf.c @@ -49,7 +49,8 @@ static int lock_fd = -1; /* Prevent problems in multithreaded program by using mutex. */ #ifdef __UCLIBC_HAS_THREADS__ -# include <pthread.h> +#include <pthread.h> +#include <pthreadP.h> static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; #endif #define LOCK __pthread_mutex_lock(&mylock) diff --git a/libc/signal/Makefile.in b/libc/signal/Makefile.in index f272d3c28..8b09ad950 100644 --- a/libc/signal/Makefile.in +++ b/libc/signal/Makefile.in @@ -26,8 +26,6 @@ SIGNAL_SRC := $(patsubst %.c,$(SIGNAL_DIR)/%.c,$(CSRC)) SIGNAL_OBJ := $(patsubst %.c,$(SIGNAL_OUT)/%.o,$(CSRC)) libc-y += $(SIGNAL_OBJ) -libc-a-y += $(SIGNAL_OBJ) -libc-so-y += $(SIGNAL_OBJ:.o=.os) objclean-y += signal_objclean diff --git a/libc/stdio/Makefile.in b/libc/stdio/Makefile.in index 5b8e86652..d6134cb06 100644 --- a/libc/stdio/Makefile.in +++ b/libc/stdio/Makefile.in @@ -92,8 +92,6 @@ STDIO_SRC := $(patsubst %.c,$(STDIO_DIR)/%.c,$(CSRC)) STDIO_OBJ := $(patsubst %.c,$(STDIO_OUT)/%.o,$(CSRC)) libc-y += $(STDIO_OBJ) -libc-a-y += $(STDIO_OBJ) -libc-so-y += $(STDIO_OBJ:.o=.os) ifneq ($(USE_OLD_VFPRINTF),y) libc-nomulti-y += $(patsubst %.c,$(STDIO_OUT)/%.o,$(VF_CSRC)) diff --git a/libc/stdio/popen.c b/libc/stdio/popen.c index 2163d7f8c..044426abf 100644 --- a/libc/stdio/popen.c +++ b/libc/stdio/popen.c @@ -42,6 +42,7 @@ libc_hidden_proto(fork) #ifdef __UCLIBC_HAS_THREADS__ # include <pthread.h> +# include <pthreadP.h> static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; #endif #define LOCK __pthread_mutex_lock(&mylock) diff --git a/libc/stdlib/Makefile.in b/libc/stdlib/Makefile.in index f08e24795..2914d4ba6 100644 --- a/libc/stdlib/Makefile.in +++ b/libc/stdlib/Makefile.in @@ -11,7 +11,7 @@ include $(top_srcdir)libc/stdlib/malloc-standard/Makefile.in CSRC := \ abort.c getenv.c mkdtemp.c mktemp.c realpath.c mkstemp.c \ - rand.c random.c random_r.c setenv.c system.c div.c ldiv.c lldiv.c \ + rand.c random.c random_r.c setenv.c div.c ldiv.c lldiv.c \ getpt.c ptsname.c grantpt.c unlockpt.c drand48-iter.c jrand48.c \ jrand48_r.c lrand48.c lrand48_r.c mrand48.c mrand48_r.c nrand48.c \ nrand48_r.c rand_r.c srand48.c srand48_r.c seed48.c seed48_r.c \ @@ -80,9 +80,9 @@ STDLIB_SRC := $(patsubst %.c,$(STDLIB_DIR)/%.c,$(CSRC)) STDLIB_OBJ := $(patsubst %.c,$(STDLIB_OUT)/%.o,$(CSRC)) libc-y += $(STDLIB_OBJ) -libc-a-y += $(STDLIB_OBJ) -libc-so-y += $(STDLIB_OBJ:.o=.os) -libc-static-y += $(STDLIB_OUT)/atexit.o +libc-static-y += $(STDLIB_OUT)/atexit.o $(STDLIB_OUT)/system.o +libc-shared-y += $(STDLIB_OUT)/system.oS + # this should always be the PIC version, because it could be used in shared libs libc-nonshared-y += $(STDLIB_OUT)/atexit.os diff --git a/libc/stdlib/_atexit.c b/libc/stdlib/_atexit.c index 236156001..75fe41fa2 100644 --- a/libc/stdlib/_atexit.c +++ b/libc/stdlib/_atexit.c @@ -48,6 +48,7 @@ libc_hidden_proto(_exit) #ifdef __UCLIBC_HAS_THREADS__ # include <pthread.h> +# include <pthreadP.h> extern pthread_mutex_t mylock; #endif #define LOCK __pthread_mutex_lock(&mylock) diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c index e382cee55..a1c7b93c9 100644 --- a/libc/stdlib/malloc-simple/alloc.c +++ b/libc/stdlib/malloc-simple/alloc.c @@ -32,7 +32,8 @@ void *malloc(size_t size) size++; #else /* Some programs will call malloc (0). Lets be strict and return NULL */ - return 0; + __set_errno(ENOMEM); + return NULL; #endif } @@ -90,7 +91,8 @@ void *realloc(void *ptr, size_t size) newptr = malloc(size); if (newptr) { - memcpy(newptr, ptr, *((size_t *) (ptr - sizeof(size_t)))); + size_t old_size = *((size_t *) (ptr - sizeof(size_t))); + memcpy(newptr, ptr, (old_size < size ? old_size : size)); free(ptr); } return newptr; diff --git a/libc/stdlib/malloc-standard/Makefile.in b/libc/stdlib/malloc-standard/Makefile.in index e3ae73715..3bbe93e08 100644 --- a/libc/stdlib/malloc-standard/Makefile.in +++ b/libc/stdlib/malloc-standard/Makefile.in @@ -16,8 +16,6 @@ STDLIB_MALLOC_STANDARD_SRC := $(patsubst %.c,$(STDLIB_MALLOC_STANDARD_DIR)/%.c,$ STDLIB_MALLOC_STANDARD_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_STANDARD_OUT)/%.o,$(CSRC)) libc-$(MALLOC_STANDARD) += $(STDLIB_MALLOC_STANDARD_OBJ) -libc-a-$(MALLOC_STANDARD) += $(STDLIB_MALLOC_STANDARD_OBJ) -libc-so-$(MALLOC_STANDARD) += $(STDLIB_MALLOC_STANDARD_OBJ:.o=.os) objclean-y += stdlib_malloc_standard_objclean diff --git a/libc/stdlib/malloc-standard/malloc.c b/libc/stdlib/malloc-standard/malloc.c index b4b1216ed..0dc208fb6 100644 --- a/libc/stdlib/malloc-standard/malloc.c +++ b/libc/stdlib/malloc-standard/malloc.c @@ -827,7 +827,10 @@ void* malloc(size_t bytes) void * sysmem; #if !defined(__MALLOC_GLIBC_COMPAT__) - if (!bytes) return NULL; + if (!bytes) { + __set_errno(ENOMEM); + return NULL; + } #endif LOCK; @@ -902,7 +905,7 @@ void* malloc(size_t bytes) else { idx = __malloc_largebin_index(nb); - if (have_fastchunks(av)) + if (have_fastchunks(av)) __malloc_consolidate(av); } diff --git a/libc/stdlib/malloc/heap_debug.c b/libc/stdlib/malloc/heap_debug.c index 9e5b61c43..e83831d3a 100644 --- a/libc/stdlib/malloc/heap_debug.c +++ b/libc/stdlib/malloc/heap_debug.c @@ -7,7 +7,7 @@ * This file is subject to the terms and conditions of the GNU Lesser * General Public License. See the file COPYING.LIB in the main * directory of this archive for more details. - * + * * Written by Miles Bader <miles@gnu.org> */ @@ -15,9 +15,11 @@ #include <stdio.h> #include <stdarg.h> #include <string.h> +#include <unistd.h> libc_hidden_proto(vfprintf) libc_hidden_proto(fprintf) +libc_hidden_proto(_exit) #include "malloc.h" #include "heap.h" @@ -66,7 +68,7 @@ __heap_dump (struct heap *heap, const char *str) /* Output an error message to stderr, and exit. STR is printed with the failure message. */ -static void +static void attribute_noreturn __heap_check_failure (struct heap *heap, struct heap_free_area *fa, const char *str, char *fmt, ...) { @@ -81,13 +83,13 @@ __heap_check_failure (struct heap *heap, struct heap_free_area *fa, vfprintf (stderr, fmt, val); va_end (val); - __putc ('\n', stderr); + fprintf (stderr, "\n"); __malloc_debug_set_indent (0); __malloc_debug_printf (1, "heap dump:"); __heap_dump_freelist (heap); - __exit (22); + _exit (22); } /* Do some consistency checks on HEAP. If they fail, output an error diff --git a/libc/stdlib/malloc/malloc.c b/libc/stdlib/malloc/malloc.c index 2ec8b07da..770d7aea3 100644 --- a/libc/stdlib/malloc/malloc.c +++ b/libc/stdlib/malloc/malloc.c @@ -7,7 +7,7 @@ * This file is subject to the terms and conditions of the GNU Lesser * General Public License. See the file COPYING.LIB in the main * directory of this archive for more details. - * + * * Written by Miles Bader <miles@gnu.org> */ @@ -200,7 +200,7 @@ malloc (size_t size) #else /* Some programs will call malloc (0). Lets be strict and return NULL */ if (unlikely (size == 0)) - return 0; + goto oom; #endif /* Check if they are doing something dumb like malloc(-1) */ diff --git a/libc/stdlib/malloc/realloc.c b/libc/stdlib/malloc/realloc.c index 4d56565aa..ec57b874e 100644 --- a/libc/stdlib/malloc/realloc.c +++ b/libc/stdlib/malloc/realloc.c @@ -7,7 +7,7 @@ * This file is subject to the terms and conditions of the GNU Lesser * General Public License. See the file COPYING.LIB in the main * directory of this archive for more details. - * + * * Written by Miles Bader <miles@gnu.org> */ @@ -46,6 +46,11 @@ realloc (void *mem, size_t new_size) allocation unit (SIZE is already guaranteed to be so).*/ new_size = HEAP_ADJUST_SIZE (new_size + MALLOC_HEADER_SIZE); + if (new_size < sizeof (struct heap_free_area)) + /* Because we sometimes must use a freed block to hold a free-area node, + we must make sure that every allocated block can hold one. */ + new_size = HEAP_ADJUST_SIZE (sizeof (struct heap_free_area)); + MALLOC_DEBUG (1, "realloc: 0x%lx, %d (base = 0x%lx, total_size = %d)", (long)mem, new_size, (long)base_mem, size); diff --git a/libc/stdlib/mkdtemp.c b/libc/stdlib/mkdtemp.c index 20a2e16bc..6773a5bb3 100644 --- a/libc/stdlib/mkdtemp.c +++ b/libc/stdlib/mkdtemp.c @@ -30,9 +30,8 @@ char * mkdtemp (char *template) { if (__gen_tempname (template, __GT_DIR)) - /* We return the null string if we can't find a unique file name. */ - template[0] = '\0'; - + return NULL; + else return template; } #endif diff --git a/libc/stdlib/random.c b/libc/stdlib/random.c index 9f1977ee3..80df7890b 100644 --- a/libc/stdlib/random.c +++ b/libc/stdlib/random.c @@ -34,6 +34,7 @@ libc_hidden_proto(initstate_r) #ifdef __UCLIBC_HAS_THREADS__ # include <pthread.h> +# include <pthreadP.h> /* POSIX.1c requires that there is mutual exclusion for the `rand' and `srand' functions to prevent concurrent calls from modifying common data. */ diff --git a/libc/stdlib/realpath.c b/libc/stdlib/realpath.c index c3cc517de..aae8580a5 100644 --- a/libc/stdlib/realpath.c +++ b/libc/stdlib/realpath.c @@ -58,6 +58,14 @@ char resolved_path[]; int readlinks = 0; int n; + if (path == NULL) { + __set_errno(EINVAL); + return NULL; + } + if (*path == '\0') { + __set_errno(ENOENT); + return NULL; + } /* Make a copy of the source path since we may need to modify it. */ if (strlen(path) >= PATH_MAX - 2) { __set_errno(ENAMETOOLONG); @@ -66,15 +74,10 @@ char resolved_path[]; strcpy(copy_path, path); path = copy_path; max_path = copy_path + PATH_MAX - 2; - /* If it's a relative pathname use getwd for starters. */ + /* If it's a relative pathname use getcwd for starters. */ if (*path != '/') { /* Ohoo... */ -#define HAVE_GETCWD -#ifdef HAVE_GETCWD getcwd(new_path, PATH_MAX - 1); -#else - getwd(new_path); -#endif new_path += strlen(new_path); if (new_path[-1] != '/') *new_path++ = '/'; diff --git a/libc/stdlib/setenv.c b/libc/stdlib/setenv.c index fa61675fb..b2d807b50 100644 --- a/libc/stdlib/setenv.c +++ b/libc/stdlib/setenv.c @@ -34,6 +34,7 @@ libc_hidden_proto(unsetenv) #ifdef __UCLIBC_HAS_THREADS__ # include <pthread.h> +# include <pthreadP.h> static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; #endif #define LOCK __pthread_mutex_lock(&mylock) diff --git a/libc/stdlib/system.c b/libc/stdlib/system.c index 147ff5242..d1ff50f51 100644 --- a/libc/stdlib/system.c +++ b/libc/stdlib/system.c @@ -15,8 +15,8 @@ #ifdef __UCLIBC_HAS_THREADS_NATIVE__ #include <sched.h> #include <errno.h> -#include <sysdep-cancel.h> #include <bits/libc-lock.h> +#include <sysdep-cancel.h> #endif libc_hidden_proto(_exit) @@ -85,6 +85,10 @@ int __libc_system(const char *command) return. It might still be in the kernel when the cancellation request comes. Therefore we have to use the clone() calls ability to have the kernel write the PID into the user-level variable. */ + +libc_hidden_proto(sigaction) +libc_hidden_proto(waitpid) + #if defined __ia64__ # define FORK() \ INLINE_SYSCALL (clone2, 6, CLONE_PARENT_SETTID | SIGCHLD, NULL, 0, \ @@ -264,4 +268,6 @@ cancel_handler (void *arg) DO_UNLOCK (); } #endif +#ifdef IS_IN_libc weak_alias(__libc_system,system) +#endif diff --git a/libc/sysdeps/linux/Makefile.commonarch b/libc/sysdeps/linux/Makefile.commonarch index d45aa5756..ea4ba53b3 100644 --- a/libc/sysdeps/linux/Makefile.commonarch +++ b/libc/sysdeps/linux/Makefile.commonarch @@ -16,9 +16,6 @@ ARCH_SOBJ := $(patsubst %.s,$(ARCH_OUT)/%.o,$(patsubst %.S,$(ARCH_OUT)/%.o,$(SSR ARCH_OBJS := $(ARCH_COBJ) $(ARCH_SOBJ) crt-y := create -libc-a-y += $(ARCH_OBJS) -libc-so-y += $(ARCH_OBJS:.o=.os) -libc-multi-y += $(ARCH_CSRC) libc-y += $(ARCH_OBJS) libc-nomulti-y += $(ARCH_SOBJ) objclean-y += arch_objclean diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in index c2c756edc..270a2de38 100644 --- a/libc/sysdeps/linux/common/Makefile.in +++ b/libc/sysdeps/linux/common/Makefile.in @@ -30,6 +30,7 @@ CSRC := $(filter-out fork.c getpid.c raise.c pause.c open.c close.c \ lseek.c __syscall_fcntl64.c, $(CSRC)) endif + # fails for some reason ifneq ($(strip $(ARCH_OBJS)),) CSRC := $(filter-out $(notdir $(ARCH_OBJS:.o=.c)),$(CSRC)) @@ -44,9 +45,6 @@ COMMON_OBJ := $(patsubst %.c,$(COMMON_OUT)/%.o,$(CSRC)) libc-y += $(COMMON_OBJ) libc-static-$(UCLIBC_HAS_SSP) += $(COMMON_OUT)/ssp-local.o libc-nonshared-$(UCLIBC_HAS_SSP) += $(COMMON_OUT)/ssp-local.os -libc-a-y += $(COMMON_OBJ) -libc-so-y += $(COMMON_OBJ) -libc-a-$(UCLIBC_HAS_SSP) += $(COMMON_OUT)/ssp-local.o libc-nomulti-y += $(COMMON_OUT)/__syscall_rt_sigaction.o $(COMMON_OUT)/__syscall_sigaction.o libc-nomulti-$(UCLIBC_HAS_SSP) += $(COMMON_OUT)/ssp.o diff --git a/libc/sysdeps/linux/common/__rt_sigtimedwait.c b/libc/sysdeps/linux/common/__rt_sigtimedwait.c index 5d034795c..4aaebefa0 100644 --- a/libc/sysdeps/linux/common/__rt_sigtimedwait.c +++ b/libc/sysdeps/linux/common/__rt_sigtimedwait.c @@ -15,6 +15,8 @@ libc_hidden_proto(memcpy) #ifdef __NR_rt_sigtimedwait +#include <string.h> +libc_hidden_proto(memcpy) # ifdef __UCLIBC_HAS_THREADS_NATIVE__ # include <sysdep-cancel.h> @@ -87,7 +89,7 @@ int attribute_hidden __sigtimedwait(const sigset_t * set, siginfo_t * info, { return __rt_sigtimedwait(set, info, timeout, _NSIG / 8); } -# endif +# endif /* !__UCLIBC_HAS_THREADS_NATIVE__ */ #else int attribute_hidden __sigtimedwait(const sigset_t * set, siginfo_t * info, const struct timespec *timeout) diff --git a/libc/sysdeps/linux/common/__rt_sigwaitinfo.c b/libc/sysdeps/linux/common/__rt_sigwaitinfo.c index c9a497503..d7ec55402 100644 --- a/libc/sysdeps/linux/common/__rt_sigwaitinfo.c +++ b/libc/sysdeps/linux/common/__rt_sigwaitinfo.c @@ -16,6 +16,8 @@ libc_hidden_proto(memcpy) #ifdef __NR_rt_sigtimedwait +#include <string.h> + # ifdef __UCLIBC_HAS_THREADS_NATIVE__ # include <sysdep-cancel.h> @@ -95,4 +97,7 @@ int attribute_hidden __sigwaitinfo(const sigset_t * set, siginfo_t * info) return -1; } #endif -weak_alias(__sigwaitinfo,sigwaitinfo) +libc_hidden_proto(sigwaitinfo) +weak_alias (__sigwaitinfo, sigwaitinfo) +libc_hidden_weak(sigwaitinfo) + diff --git a/libc/sysdeps/linux/common/__syscall_rt_sigaction.c b/libc/sysdeps/linux/common/__syscall_rt_sigaction.c index cbf963633..da0f84dc0 100644 --- a/libc/sysdeps/linux/common/__syscall_rt_sigaction.c +++ b/libc/sysdeps/linux/common/__syscall_rt_sigaction.c @@ -12,7 +12,7 @@ #ifdef __NR_rt_sigaction #include <signal.h> -int __syscall_rt_sigaction (int __signum, const struct sigaction *__act, struct sigaction *__oldact, size_t __size) attribute_hidden; +int __syscall_rt_sigaction (int __signum, const struct sigaction *__act, struct sigaction *__oldact, size_t __size); #define __NR___syscall_rt_sigaction __NR_rt_sigaction _syscall4(int, __syscall_rt_sigaction, int, signum, const struct sigaction *, act, struct sigaction *, oldact, diff --git a/libc/sysdeps/linux/common/bits/kernel_sigaction.h b/libc/sysdeps/linux/common/bits/kernel_sigaction.h index 2fdfc897e..7af027735 100644 --- a/libc/sysdeps/linux/common/bits/kernel_sigaction.h +++ b/libc/sysdeps/linux/common/bits/kernel_sigaction.h @@ -63,6 +63,6 @@ extern int __syscall_sigaction (int, const struct old_kernel_sigaction *__unboun #endif extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *__unbounded, - struct kernel_sigaction *__unbounded, size_t) attribute_hidden; + struct kernel_sigaction *__unbounded, size_t); #endif /* _BITS_SIGACTION_STRUCT_H */ diff --git a/libc/sysdeps/linux/common/bits/posix1_lim.h b/libc/sysdeps/linux/common/bits/posix1_lim.h index 9379d46f4..71c58f760 100644 --- a/libc/sysdeps/linux/common/bits/posix1_lim.h +++ b/libc/sysdeps/linux/common/bits/posix1_lim.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-1993,96,98,2000,01,02,2003 Free Software Foundation, Inc. +/* Copyright (C) 1991-1993,96,98,2000-2003,2004 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -38,14 +38,25 @@ #define _POSIX_ARG_MAX 4096 /* Maximum simultaneous processes per real user ID. */ -#define _POSIX_CHILD_MAX 6 +#ifdef __USE_XOPEN2K +# define _POSIX_CHILD_MAX 25 +#else +# define _POSIX_CHILD_MAX 6 +#endif /* Minimal number of timer expiration overruns. */ #define _POSIX_DELAYTIMER_MAX 32 +/* Maximum length of a host name (not including the terminating null) + as returned from the GETHOSTNAME function. */ +#define _POSIX_HOST_NAME_MAX 255 + /* Maximum link count of a file. */ #define _POSIX_LINK_MAX 8 +/* Maximum length of login name. */ +#define _POSIX_LOGIN_NAME_MAX 9 + /* Number of bytes in a terminal canonical input queue. */ #define _POSIX_MAX_CANON 255 @@ -59,6 +70,9 @@ /* Maximum number of supported message priorities. */ #define _POSIX_MQ_PRIO_MAX 32 +/* Number of bytes in a filename. */ +#define _POSIX_NAME_MAX 14 + /* Number of simultaneous supplementary group IDs per process. */ #ifdef __USE_XOPEN2K # define _POSIX_NGROUPS_MAX 8 @@ -67,21 +81,26 @@ #endif /* Number of files one process can have open at once. */ -#define _POSIX_OPEN_MAX 16 +#ifdef __USE_XOPEN2K +# define _POSIX_OPEN_MAX 20 +#else +# define _POSIX_OPEN_MAX 16 +#endif /* Number of descriptors that a process may examine with `pselect' or `select'. */ #define _POSIX_FD_SETSIZE _POSIX_OPEN_MAX -/* Number of bytes in a filename. */ -#define _POSIX_NAME_MAX 14 - /* Number of bytes in a pathname. */ #define _POSIX_PATH_MAX 256 /* Number of bytes than can be written atomically to a pipe. */ #define _POSIX_PIPE_BUF 512 +/* The number of repeated occurrences of a BRE permitted by the + REGEXEC and REGCOMP functions when using the interval notation. */ +#define _POSIX_RE_DUP_MAX 255 + /* Minimal number of realtime signals reserved for the application. */ #define _POSIX_RTSIG_MAX 8 @@ -100,6 +119,19 @@ /* Number of streams a process can have open at once. */ #define _POSIX_STREAM_MAX 8 +/* The number of bytes in a symbolic link. */ +#define _POSIX_SYMLINK_MAX 255 + +/* The number of symbolic links that can be traversed in the + resolution of a pathname in the absence of a loop. */ +#define _POSIX_SYMLOOP_MAX 8 + +/* Number of timer for a process. */ +#define _POSIX_TIMER_MAX 32 + +/* Maximum number of characters in a tty name. */ +#define _POSIX_TTY_NAME_MAX 9 + /* Maximum length of a timezone name (element of `tzname'). */ #define _POSIX_TZNAME_MAX 6 @@ -113,15 +145,6 @@ /* Maximum number of elements in an `iovec' array. */ #define _POSIX_UIO_MAXIOV 16 -/* Maximum number of characters in a tty name. */ -#define _POSIX_TTY_NAME_MAX 9 - -/* Number of timer for a process. */ -#define _POSIX_TIMER_MAX 32 - -/* Maximum length of login name. */ -#define _POSIX_LOGIN_NAME_MAX 9 - /* Maximum clock resolution in nanoseconds. */ #define _POSIX_CLOCKRES_MIN 20000000 diff --git a/libc/termios/Makefile.in b/libc/termios/Makefile.in index 3e723ce04..99b1a729f 100644 --- a/libc/termios/Makefile.in +++ b/libc/termios/Makefile.in @@ -12,8 +12,6 @@ TERMIOS_SRC := $(wildcard $(TERMIOS_DIR)/*.c) TERMIOS_OBJ := $(patsubst $(TERMIOS_DIR)/%.c,$(TERMIOS_OUT)/%.o,$(TERMIOS_SRC)) libc-y += $(TERMIOS_OBJ) -libc-a-y += $(TERMIOS_OBJ) -libc-so-y += $(TERMIOS_OBJ:.o=.os) objclean-y += termios_objclean diff --git a/libc/termios/tcgetpgrp.c b/libc/termios/tcgetpgrp.c index 241670770..1ad317139 100644 --- a/libc/termios/tcgetpgrp.c +++ b/libc/termios/tcgetpgrp.c @@ -27,10 +27,10 @@ libc_hidden_proto(ioctl) /* Return the foreground process group ID of FD. */ pid_t tcgetpgrp (int fd) { - int pgrp; + pid_t pgrp; if (ioctl (fd, TIOCGPGRP, &pgrp) < 0) - return (pid_t) -1; - return (pid_t) pgrp; + return -1; + return pgrp; } libc_hidden_def (tcgetpgrp) diff --git a/libc/unistd/Makefile.in b/libc/unistd/Makefile.in index 5231ec69c..8095aa641 100644 --- a/libc/unistd/Makefile.in +++ b/libc/unistd/Makefile.in @@ -41,8 +41,6 @@ UNISTD_SRC := $(patsubst %.c,$(UNISTD_DIR)/%.c,$(CSRC)) UNISTD_OBJ := $(patsubst %.c,$(UNISTD_OUT)/%.o,$(CSRC)) libc-y += $(UNISTD_OBJ) -libc-a-y += $(UNISTD_OBJ) -libc-so-y += $(UNISTD_OBJ:.o=.os) objclean-y += unistd_objclean diff --git a/libc/unistd/sleep.c b/libc/unistd/sleep.c index 92944af18..4381c45c7 100644 --- a/libc/unistd/sleep.c +++ b/libc/unistd/sleep.c @@ -30,7 +30,7 @@ libc_hidden_proto(sigprocmask) //libc_hidden_proto(__sigaddset) //libc_hidden_proto(__sigemptyset) //libc_hidden_proto(__sigismember) -libc_hidden_proto(nanosleep) +/*libc_hidden_proto(nanosleep) need the reloc for cancellation*/ #if 0 /* This is a quick and dirty, but not 100% compliant with diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c index c02a25440..c2d2b53e2 100644 --- a/libc/unistd/sysconf.c +++ b/libc/unistd/sysconf.c @@ -908,7 +908,7 @@ long int sysconf(int name) #ifdef __UCLIBC_HAS_THREADS_NATIVE__ case _SC_THREAD_CPUTIME: -# ifdef _POSIX_THREAD_CPUTIME > 0 +# if _POSIX_THREAD_CPUTIME > 0 return _POSIX_THREAD_CPUTIME; # else RETURN_NEG_1; diff --git a/libc/unistd/usleep.c b/libc/unistd/usleep.c index 09bb09f41..91b88278d 100644 --- a/libc/unistd/usleep.c +++ b/libc/unistd/usleep.c @@ -9,7 +9,7 @@ #include <sys/types.h> #include <unistd.h> -libc_hidden_proto(nanosleep) +/*libc_hidden_proto(nanosleep) need the reloc for cancellation*/ int usleep (__useconds_t usec) { |