diff options
45 files changed, 544 insertions, 245 deletions
@@ -85,13 +85,6 @@ cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@) cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^ cmd_ar = $(AR) $(ARFLAGS) $@ $^ -define compile.u - $(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@)) - $(STRIPTOOL) $(STRIP_FLAGS) $@ -endef -hcompile.u = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@)) -hcompile.o = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@)) - compile.c = @$(disp_compile.c) ; $(cmd_compile.c) compile.E = $(cmd_compile.c:-c=-E) compile.s = $(cmd_compile.c:-c=-S) @@ -101,6 +94,15 @@ compile-m = @$(disp_compile-m) ; $(cmd_compile-m) do_strip = @$(disp_strip) ; $(cmd_strip) do_ar = @$(disp_ar) ; $(cmd_ar) +define compile.u + @$(disp_compile.c) + $(Q)$(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@)) + @$(disp_strip) + $(Q)$(STRIPTOOL) $(STRIP_FLAGS) $@ +endef +hcompile.u = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@)) +hcompile.o = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@)) + define link.so $(Q)$(INSTALL) -d $(dir $@) $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1) @@ -103,7 +103,7 @@ SHELL_SET_X=set +x 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:=$(shell grep -s '^TARGET_ARCH' $(top_builddir)/.config | sed -e 's/^TARGET_ARCH=//' -e 's/"//g') TARGET_ARCH:=$(strip $(subst ",, $(strip $(TARGET_ARCH)))) RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX)))))) DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX)))))) @@ -166,6 +166,8 @@ ifeq ($(TARGET_ARCH),arm) endif ifeq ($(TARGET_ARCH),mips) + CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-EL + CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-EB CPU_CFLAGS-$(CONFIG_MIPS_ISA_1)+=-mips1 CPU_CFLAGS-$(CONFIG_MIPS_ISA_2)+=-mips2 -mtune=mips2 CPU_CFLAGS-$(CONFIG_MIPS_ISA_3)+=-mips3 -mtune=mips3 @@ -174,6 +176,11 @@ ifeq ($(TARGET_ARCH),mips) CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS64)+=-mips64 -mtune=mips32 endif +ifeq ($(TARGET_ARCH),nios) + CPU_LDFLAGS-y+=-m32 + CPU_CFLAGS-y+=-m32 +endif + ifeq ($(TARGET_ARCH),sh) OPTIMIZATION+=-fstrict-aliasing OPTIMIZATION+= $(call check_gcc,-mprefergot,) @@ -223,6 +230,12 @@ ifeq ($(TARGET_ARCH),powerpc) PIEFLAG_NAME:=-fpie endif +ifeq ($(TARGET_ARCH),bfin) + # This should also work, but why bother ? ;) + #PICFLAG:=-fPIC -mid-shared-library + PICFLAG:=-fpic +endif + ifeq ($(TARGET_ARCH),frv) CPU_LDFLAGS-$(CONFIG_FRV)+=-melf32frvfd CPU_CFLAGS-$(CONFIG_FRV)+=-mfdpic @@ -279,7 +292,11 @@ ifeq ($(UCLIBC_HAS_SOFT_FLOAT),y) # If -msoft-float isn't supported, we want an error anyway. # Hmm... might need to revisit this for arm since it has 2 different # soft float encodings. +ifneq ($(TARGET_ARCH),nios) +ifneq ($(TARGET_ARCH),nios2) CPU_CFLAGS += -msoft-float +endif +endif ifeq ($(TARGET_ARCH),arm) # No longer needed with current toolchains, but leave it here for now. # If anyone is actually still using gcc 2.95 (say), they can uncomment it. @@ -400,6 +417,10 @@ ifneq ($(DOASSERTS),y) CFLAGS+=-DNDEBUG endif +ifneq ($(strip $(C_SYMBOL_PREFIX)),"") +CFLAGS+=-D__SYMBOL_PREFIX=1 +endif + # moved from ldso/{ldso,libdl} # BEWARE!!! At least mips* will die if -O0 is used!!! ifeq ($(TARGET_ARCH),mips) diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in index 16d1c07c2..46b3d55c2 100644 --- a/extra/Configs/Config.in +++ b/extra/Configs/Config.in @@ -350,7 +350,7 @@ config PTHREADS_DEBUG_SUPPORT config LINUXTHREADS_OLD bool "Use the older (stable) version of linuxthreads" default y - depends on UCLIBC_HAS_THREADS && !UCLIBC_HAS_THREADS_NATIVE + depends on UCLIBC_HAS_THREADS help There are two versions of linuxthreads. The older (stable) version has been in uClibc for quite a long time but hasn't seen too many @@ -467,6 +467,32 @@ config HAS_SHADOW Answer N if you do not need shadow password support. Most people will answer Y. +config UCLIBC_HAS_PROGRAM_INVOCATION_NAME + bool "Support for program_invocation_name" + default n + help + Support for the GNU-specific program_invocation_name and + program_invocation_short_name strings. Some GNU packages + (like tar and coreutils) utilize these for extra useful + output, but in general are not required. + + At startup, these external strings are automatically set + up based on the value of ARGV[0]. + + If unsure, just answer N. + +config UCLIBC_HAS___PROGNAME + bool "Support for __progname" + default y + help + Some packages (like openssh) like to peek into internal libc + symbols to make their output a bit more user friendly. + + At startup, __progname is automatically set up based on the + value of ARGV[0]. + + If unsure, just answer N. + config UNIX98PTY_ONLY bool "Support only Unix 98 PTYs" default y @@ -1053,7 +1079,7 @@ config UCLIBC_HAS_GNU_GETOPT config UCLIBC_HAS_STDIO_FUTEXES bool "Use futexes for multithreaded I/O locking" - default y + default n depends on UCLIBC_HAS_THREADS_NATIVE help If you want to compile uClibc to use futexes for low-level @@ -1088,8 +1114,30 @@ config UCLIBC_HAS_REGEX_OLD support, then stick with the old version (and say Y here). Otherwise, you should use the new version (and say N here). +config UCLIBC_HAS_FNMATCH + bool "fnmatch Support" + default y + help + POSIX fnmatch. + +config UCLIBC_HAS_FNMATCH_OLD + bool "Use the older (stable) fnmatch code" + depends on UCLIBC_HAS_FNMATCH + default y + help + There are two versions of fnmatch. The older (stable) version has + been in uClibc for quite a long time but hasn't seen too many + updates. It also has some known issues when dealing with uncommon + corner cases and multibyte/unicode strings. However, it is quite + a bit smaller than the newer version. + + If the older version has worked for you and you don't need unicode + support, then stick with the old version (and say Y here). + Otherwise, you should use the new version (and say N here). + config UCLIBC_HAS_WORDEXP bool "Support the wordexp() interface" + depends on UCLIBC_HAS_GLOB default n help The SuSv3 wordexp() interface performs word expansions per the Shell diff --git a/extra/Configs/Config.nios b/extra/Configs/Config.nios index 5ca9e96c4..32612d083 100644 --- a/extra/Configs/Config.nios +++ b/extra/Configs/Config.nios @@ -15,7 +15,7 @@ config HAVE_ELF config ARCH_CFLAGS string - default "-m32 -funaligned-struct-hack" + default "-funaligned-struct-hack" config LIBGCC_CFLAGS string diff --git a/extra/scripts/create_makefiles.sh b/extra/scripts/create_makefiles.sh index 89ea4a9b6..1d94b0d13 100755 --- a/extra/scripts/create_makefiles.sh +++ b/extra/scripts/create_makefiles.sh @@ -27,45 +27,45 @@ ${USE_CMD} extra/scripts/Makefile.libs.lvl0 Makefile #done for x in */Makefile.in ; do - ${RM} $(dirname ${x})/Makefile - ${USE_CMD} extra/scripts/Makefile.libs.lvl1 $(dirname ${x})/Makefile + ${RM} `dirname ${x}`/Makefile + ${USE_CMD} extra/scripts/Makefile.libs.lvl1 `dirname ${x}`/Makefile done for x in utils/Makefile.in ; do - ${RM} $(dirname ${x})/Makefile - ${USE_CMD} extra/scripts/Makefile.utils.lvl1 $(dirname ${x})/Makefile + ${RM} `dirname ${x}`/Makefile + ${USE_CMD} extra/scripts/Makefile.utils.lvl1 `dirname ${x}`/Makefile done for x in */*/Makefile.in ; do - ${RM} $(dirname ${x})/Makefile - ${USE_CMD} extra/scripts/Makefile.objs.lvl2 $(dirname ${x})/Makefile + ${RM} `dirname ${x}`/Makefile + ${USE_CMD} extra/scripts/Makefile.objs.lvl2 `dirname ${x}`/Makefile done # overwrites the earlier ones, we do not add arch specific to libm/arch for x in ldso/*/Makefile.in libpthread/*/Makefile.in ; do - ${RM} $(dirname ${x})/Makefile - ${USE_CMD} extra/scripts/Makefile.libs.lvl2 $(dirname ${x})/Makefile + ${RM} `dirname ${x}`/Makefile + ${USE_CMD} extra/scripts/Makefile.libs.lvl2 `dirname ${x}`/Makefile done for x in */*/*/Makefile.in ; do - ${RM} $(dirname ${x})/Makefile - ${USE_CMD} extra/scripts/Makefile.objs.lvl3 $(dirname ${x})/Makefile + ${RM} `dirname ${x}`/Makefile + ${USE_CMD} extra/scripts/Makefile.objs.lvl3 `dirname ${x}`/Makefile done for x in libc/*/*/Makefile.arch ; do - ${RM} $(dirname ${x})/Makefile - ${USE_CMD} extra/scripts/Makefile.arch.lvl3 $(dirname ${x})/Makefile + ${RM} `dirname ${x}`/Makefile + ${USE_CMD} extra/scripts/Makefile.arch.lvl3 `dirname ${x}`/Makefile done for x in */*/*/*/Makefile.in ; do - ${RM} $(dirname ${x})/Makefile - ${USE_CMD} extra/scripts/Makefile.objs.lvl4 $(dirname ${x})/Makefile + ${RM} `dirname ${x}`/Makefile + ${USE_CMD} extra/scripts/Makefile.objs.lvl4 `dirname ${x}`/Makefile done # we do not add these to libpthread/PTNAME/sysdeps/arch for x in libc/*/*/*/Makefile.arch ; do - ${RM} $(dirname ${x})/Makefile - ${USE_CMD} extra/scripts/Makefile.arch.lvl4 $(dirname ${x})/Makefile + ${RM} `dirname ${x}`/Makefile + ${USE_CMD} extra/scripts/Makefile.arch.lvl4 `dirname ${x}`/Makefile done exit 0 diff --git a/include/ctype.h b/include/ctype.h index e00313167..78cff7daa 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -136,18 +136,11 @@ extern const __ctype_touplow_t *__ctype_tolower; #define __isascii(c) (((c) & ~0x7f) == 0) /* If C is a 7 bit value. */ #define __toascii(c) ((c) & 0x7f) /* Mask off high bits. */ -#ifdef __USE_MISC - -/* The following are included for compatibility with older versions of - * uClibc; but now they're only visible if MISC funcctionality is requested. */ -extern int isxlower(int c) __THROW; -extern int isxupper(int c) __THROW; - +#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc) /* isdigit() is really locale-invariant, so provide some small fast macros. * These are uClibc-specific. */ #define __isdigit_char(C) (((unsigned char)((C) - '0')) <= 9) #define __isdigit_int(C) (((unsigned int)((C) - '0')) <= 9) - #endif #define __exctype(name) extern int name (int) __THROW diff --git a/include/elf.h b/include/elf.h index 691798af8..e1dae0962 100644 --- a/include/elf.h +++ b/include/elf.h @@ -181,6 +181,7 @@ typedef struct #define EM_386 3 /* Intel 80386 */ #define EM_68K 4 /* Motorola m68k family */ #define EM_88K 5 /* Motorola m88k family */ +#define EM_486 6 /* Intel 80486 *//* Reserved for future use */ #define EM_860 7 /* Intel 80860 */ #define EM_MIPS 8 /* MIPS R3000 big-endian */ #define EM_S370 9 /* IBM System/370 */ @@ -197,7 +198,8 @@ typedef struct #define EM_V800 36 /* NEC V800 series */ #define EM_FR20 37 /* Fujitsu FR20 */ #define EM_RH32 38 /* TRW RH-32 */ -#define EM_RCE 39 /* Motorola RCE */ +#define EM_MCORE 39 /* Motorola M*Core */ /* May also be taken by Fujitsu MMA */ +#define EM_RCE 39 /* Old name for MCore */ #define EM_ARM 40 /* ARM */ #define EM_FAKE_ALPHA 41 /* Digital Alpha */ #define EM_SH 42 /* Renesas SH */ @@ -252,18 +254,105 @@ typedef struct #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ +#define EM_IP2K 101 /* Ubicom IP2022 micro controller */ +#define EM_CR 103 /* National Semiconductor CompactRISC */ +#define EM_MSP430 105 /* TI msp430 micro controller */ +#define EM_BLACKFIN 106 /* Analog Devices Blackfin */ +#define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */ +#define EM_CRX 114 /* National Semiconductor CRX */ #define EM_NUM 95 -/* If it is necessary to assign new unofficial EM_* values, please - pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the - chances of collision with official or non-GNU unofficial values. */ +/* If it is necessary to assign new unofficial EM_* values, please pick large + random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision + with official or non-GNU unofficial values. -/* Fujitsu FR-V. */ + NOTE: Do not just increment the most recent number by one. + Somebody else somewhere will do exactly the same thing, and you + will have a collision. Instead, pick a random number. + + Normally, each entity or maintainer responsible for a machine with an + unofficial e_machine number should eventually ask registry@caldera.com for + an officially blessed number to be added to the list above. */ + +/* picoJava */ +#define EM_PJ_OLD 99 + +/* Cygnus PowerPC ELF backend. Written in the absence of an ABI. */ +#define EM_CYGNUS_POWERPC 0x9025 + +/* Old version of Sparc v9, from before the ABI; this should be + removed shortly. */ +#define EM_OLD_SPARCV9 11 + +/* Old version of PowerPC, this should be removed shortly. */ +#define EM_PPC_OLD 17 + +/* (Deprecated) Temporary number for the OpenRISC processor. */ +#define EM_OR32 0x8472 + +/* Renesas M32C and M16C. */ +#define EM_M32C 0xFEB0 + +/* Cygnus M32R ELF backend. Written in the absence of an ABI. */ +#define EM_CYGNUS_M32R 0x9041 + +/* old S/390 backend magic number. Written in the absence of an ABI. */ +#define EM_S390_OLD 0xa390 + +/* D10V backend magic number. Written in the absence of an ABI. */ +#define EM_CYGNUS_D10V 0x7650 + +/* D30V backend magic number. Written in the absence of an ABI. */ +#define EM_CYGNUS_D30V 0x7676 + +/* V850 backend magic number. Written in the absense of an ABI. */ +#define EM_CYGNUS_V850 0x9080 + +/* mn10200 and mn10300 backend magic numbers. + Written in the absense of an ABI. */ +#define EM_CYGNUS_MN10200 0xdead +#define EM_CYGNUS_MN10300 0xbeef + +/* FR30 magic number - no EABI available. */ +#define EM_CYGNUS_FR30 0x3330 + +/* AVR magic number + Written in the absense of an ABI. */ +#define EM_AVR_OLD 0x1057 + +/* OpenRISC magic number + Written in the absense of an ABI. */ +#define EM_OPENRISC_OLD 0x3426 + +/* DLX magic number + Written in the absense of an ABI. */ +#define EM_DLX 0x5aa5 + +#define EM_XSTORMY16 0xad45 + +/* FRV magic number - no EABI available??. */ #define EM_CYGNUS_FRV 0x5441 +/* Ubicom IP2xxx; no ABI */ +#define EM_IP2K_OLD 0x8217 + +#define EM_MT 0x2530 /* Morpho MT; no ABI */ + +/* MSP430 magic number + Written in the absense everything. */ +#define EM_MSP430_OLD 0x1059 + +/* Vitesse IQ2000. */ +#define EM_IQ2000 0xFEBA + +/* Old, unofficial value for Xtensa. */ +#define EM_XTENSA_OLD 0xabc7 + +/* Alpha backend magic number. Written in the absence of an ABI. */ #define EM_ALPHA 0x9026 -#define EM_NIOS32 0xfebb /* Altera Nios 32 */ -#define EM_ALTERA_NIOS2 0x9ee5 /* Altera Nios II */ + +/* NIOS magic number - no EABI available. */ +#define EM_NIOS32 0xFEBB /* V850 backend magic number. Written in the absense of an ABI. */ #define EM_CYGNUS_V850 0x9080 @@ -2692,6 +2781,7 @@ typedef Elf32_Addr Elf32_Conflict; #define R_V850_NUM 25 +/* Renesas H8/300 Relocations */ #define R_H8_NONE 0 #define R_H8_DIR32 1 #define R_H8_DIR32_28 2 @@ -2735,8 +2825,7 @@ typedef Elf32_Addr Elf32_Conflict; #define R_H8_DIR32A16 63 #define R_H8_ABS32 65 #define R_H8_ABS32A16 127 - -/* Altera NIOS specific definitions. */ +#define R_H8_NUM 128 /* NIOS relocations. */ #define R_NIOS_NONE 0 diff --git a/include/errno.h b/include/errno.h index bd363a258..527326b17 100644 --- a/include/errno.h +++ b/include/errno.h @@ -47,7 +47,7 @@ __BEGIN_DECLS extern int errno; #endif -#if 0 /*def __USE_GNU uClibc note: not supported */ +#if defined __USE_GNU && defined __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__ /* The full and simple forms of the name with which the program was invoked. These variables are set up automatically at startup based on diff --git a/include/ftw.h b/include/ftw.h index b1f7e09cb..4bdff88c6 100644 --- a/include/ftw.h +++ b/include/ftw.h @@ -74,7 +74,7 @@ enum # define FTW_CHDIR FTW_CHDIR FTW_DEPTH = 8 /* Report files in directory before directory itself.*/ # define FTW_DEPTH FTW_DEPTH -# if 0 /* def __USE_GNU */ +# ifdef __USE_GNU , FTW_ACTIONRETVAL = 16 /* Assume callback to return FTW_* values instead of zero to continue and non-zero to terminate. */ @@ -82,7 +82,7 @@ enum # endif }; -#if 0 /* def __USE_GNU */ +#ifdef __USE_GNU /* Return values from callback functions. */ enum { diff --git a/include/glob.h b/include/glob.h index 1dbf99ff6..3d401f082 100644 --- a/include/glob.h +++ b/include/glob.h @@ -163,11 +163,12 @@ extern int glob (__const char *__restrict __pattern, int __flags, /* Free storage allocated in PGLOB by a previous `glob' call. */ extern void globfree (glob_t *__pglob) __THROW; #else -extern int glob __P ((__const char *__restrict __pattern, int __flags, - int (*__errfunc) (__const char *, int), - glob_t *__restrict __pglob)) __asm__ ("glob64"); +extern int __REDIRECT_NTH (glob, (__const char *__restrict __pattern, + int __flags, + int (*__errfunc) (__const char *, int), + glob_t *__restrict __pglob), glob64); -extern void globfree __P ((glob_t *__pglob)) __asm__ ("globfree64"); +extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64); #endif #ifdef __USE_LARGEFILE64 diff --git a/include/locale.h b/include/locale.h index d7f90c969..02d33a0d4 100644 --- a/include/locale.h +++ b/include/locale.h @@ -218,12 +218,6 @@ extern __locale_t uselocale (__locale_t __dataset) __THROW; Passing this value to any other function has undefined behavior. */ # define LC_GLOBAL_LOCALE ((__locale_t) -1L) -extern __locale_t __newlocale (int __category_mask, __const char *__locale, - __locale_t __base) __THROW; -extern __locale_t __duplocale (__locale_t __dataset) __THROW; -extern void __freelocale (__locale_t __dataset) __THROW; -extern __locale_t __uselocale (__locale_t __dataset) __THROW; - #endif __END_DECLS diff --git a/include/sys/stat.h b/include/sys/stat.h index 1f758d30c..b3dbe4f92 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1992,1995-2002,2003,2004 Free Software Foundation, Inc. +/* Copyright (C) 1991,1992,1995-2004,2005 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 @@ -211,11 +211,11 @@ extern int stat (__const char *__restrict __file, that file descriptor FD is open on and put them in BUF. */ extern int fstat (int __fd, struct stat *__buf) __THROW __nonnull ((2)); #else -# ifdef __REDIRECT -extern int __REDIRECT (stat, (__const char *__restrict __file, +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (stat, (__const char *__restrict __file, struct stat *__restrict __buf), stat64) __nonnull ((1, 2)); -extern int __REDIRECT (fstat, (int __fd, struct stat *__buf), fstat64) +extern int __REDIRECT_NTH (fstat, (int __fd, struct stat *__buf), fstat64) __nonnull ((2)); # else # define stat stat64 @@ -228,6 +228,27 @@ extern int stat64 (__const char *__restrict __file, extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2)); #endif +#if 0 /*def __USE_GNU*/ +/* Similar to stat, get the attributes for FILE and put them in BUF. + Relative path names are interpreted relative to FD unless FD is + AT_FDCWD. */ +# ifndef __USE_FILE_OFFSET64 +extern int fstatat (int __fd, __const char *__file, struct stat *__buf, + int __flag) __THROW __nonnull ((2, 3)); +# else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (fstatat, (int __fd, __const char *__file, + struct stat *__buf, int __flag), + fstatat64) __nonnull ((2, 3)); +# else +# define fstatat fstatat64 +# endif +# endif + +extern int fstatat64 (int __fd, __const char *__file, struct stat64 *__buf, + int __flag) __THROW __nonnull ((2, 3)); +#endif + #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED # ifndef __USE_FILE_OFFSET64 /* Get file attributes about FILE and put them in BUF. @@ -235,8 +256,8 @@ extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2)); extern int lstat (__const char *__restrict __file, struct stat *__restrict __buf) __THROW __nonnull ((1, 2)); # else -# ifdef __REDIRECT -extern int __REDIRECT (lstat, +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (lstat, (__const char *__restrict __file, struct stat *__restrict __buf), lstat64) __nonnull ((1, 2)); @@ -256,7 +277,7 @@ extern int lstat64 (__const char *__restrict __file, extern int chmod (__const char *__file, __mode_t __mode) __THROW __nonnull ((1)); -#if 0 /* def __USE_BSD */ +#if 0 /*def __USE_BSD*/ /* Set file access permissions for FILE to MODE. If FILE is a symbolic link, this affects the link itself rather than its target. */ @@ -274,7 +295,7 @@ extern int fchmod (int __fd, __mode_t __mode) __THROW; and return the old creation mask. */ extern __mode_t umask (__mode_t __mask) __THROW; -#ifdef __USE_GNU +#if 0 /*def __USE_GNU*/ /* Get the current `umask' value without changing it. This function is only available under the GNU Hurd. */ extern __mode_t getumask (void) __THROW; @@ -284,6 +305,14 @@ extern __mode_t getumask (void) __THROW; extern int mkdir (__const char *__path, __mode_t __mode) __THROW __nonnull ((1)); +#if 0 /*def __USE_GNU*/ +/* Like mkdir, create a new directory with permission bits MODE. But + interpret relative PATH names relative to the directory associated + with FD. */ +extern int mkdirat (int __fd, __const char *__path, __mode_t __mode) + __THROW __nonnull ((2)); +#endif + /* Create a device file named PATH, with permission and special bits MODE and device number DEV (which can be constructed from major and minor device numbers with the `makedev' macro above). */ @@ -292,11 +321,27 @@ extern int mknod (__const char *__path, __mode_t __mode, __dev_t __dev) __THROW __nonnull ((1)); #endif +#if 0 /*def __USE_GNU*/ +/* Like mknod, create a new device file with permission bits MODE and + device number DEV. But interpret relative PATH names relative to + the directory associated with FD. */ +extern int mknodat (int __fd, __const char *__path, __mode_t __mode, + __dev_t __dev) __THROW __nonnull ((2)); +#endif + /* Create a new FIFO named PATH, with permission bits MODE. */ extern int mkfifo (__const char *__path, __mode_t __mode) __THROW __nonnull ((1)); +#if 0 /*def __USE_GNU*/ +/* Like mkfifo, create a new FIFO with permission bits MODE. But + interpret relative PATH names relative to the directory associated + with FD. */ +extern int mkfifoat (int __fd, __const char *__path, __mode_t __mode) + __THROW __nonnull ((2)); +#endif + __END_DECLS diff --git a/include/sys/statfs.h b/include/sys/statfs.h index 2ac877245..3b2226b41 100644 --- a/include/sys/statfs.h +++ b/include/sys/statfs.h @@ -32,8 +32,8 @@ __BEGIN_DECLS extern int statfs (__const char *__file, struct statfs *__buf) __THROW __nonnull ((1, 2)); #else -# ifdef __REDIRECT -extern int __REDIRECT (statfs, +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (statfs, (__const char *__file, struct statfs *__buf), statfs64) __nonnull ((1, 2)); # else @@ -51,8 +51,8 @@ extern int statfs64 (__const char *__file, struct statfs64 *__buf) extern int fstatfs (int __fildes, struct statfs *__buf) __THROW __nonnull ((2)); #else -# ifdef __REDIRECT -extern int __REDIRECT (fstatfs, (int __fildes, struct statfs *__buf), +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (fstatfs, (int __fildes, struct statfs *__buf), fstatfs64) __nonnull ((2)); # else # define fstatfs fstatfs64 diff --git a/include/sys/syscall.h b/include/sys/syscall.h index 3b82571a3..703188683 100644 --- a/include/sys/syscall.h +++ b/include/sys/syscall.h @@ -20,6 +20,11 @@ #define _SYSCALL_H 1 /* This file provides us with the nicely useful _syscall[0-5] macros. */ -#include <bits/syscalls.h> +#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc) +# include <bits/syscalls.h> +#else +# include <asm/unistd.h> +# include <bits/sysnum.h> +#endif #endif diff --git a/include/sys/wait.h b/include/sys/wait.h index ec53808db..81a54fc3d 100644 --- a/include/sys/wait.h +++ b/include/sys/wait.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1991-1994,1996-2001,2003,2004 Free Software Foundation, Inc. +/* Copyright (C) 1991-1994,1996-2001,2003,2004,2005 + 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 @@ -42,11 +43,11 @@ __BEGIN_DECLS as well as POSIX.1 use of `int' for the status word. */ # if defined __GNUC__ && !defined __cplusplus -# define __WAIT_INT(status) \ - (__extension__ ({ union { __typeof(status) __in; int __i; } __u; \ - __u.__in = (status); __u.__i; })) +# define __WAIT_INT(status) \ + (__extension__ (((union { __typeof(status) __in; int __i; }) \ + { .__in = (status) }).__i)) # else -# define __WAIT_INT(status) (*(int *) &(status)) +# define __WAIT_INT(status) (*(__const int *) &(status)) # endif /* This is the type of the argument to `wait'. The funky union @@ -84,7 +85,7 @@ typedef union # define WIFEXITED(status) __WIFEXITED(__WAIT_INT(status)) # define WIFSIGNALED(status) __WIFSIGNALED(__WAIT_INT(status)) # define WIFSTOPPED(status) __WIFSTOPPED(__WAIT_INT(status)) -# if 0 /* def __WIFCONTINUED */ +# if 0 /*def __WIFCONTINUED*/ # define WIFCONTINUED(status) __WIFCONTINUED(__WAIT_INT(status)) # endif #endif /* <stdlib.h> not included. */ diff --git a/include/unistd.h b/include/unistd.h index 1ca923130..9ccb0e80f 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1991-2002,2003,2004,2005,2006 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 @@ -255,7 +255,7 @@ typedef __socklen_t socklen_t; /* Test for access to NAME using the real UID and real GID. */ extern int access (__const char *__name, int __type) __THROW __nonnull ((1)); -#if 0 /* def __USE_GNU */ +#if 0 /*def __USE_GNU*/ /* Test for access to NAME using the effective UID and GID (as normal file operations use). */ extern int euidaccess (__const char *__name, int __type) @@ -286,8 +286,8 @@ extern int euidaccess (__const char *__name, int __type) #ifndef __USE_FILE_OFFSET64 extern __off_t lseek (int __fd, __off_t __offset, int __whence) __THROW; #else -# ifdef __REDIRECT -extern __off64_t __REDIRECT (lseek, +# ifdef __REDIRECT_NTH +extern __off64_t __REDIRECT_NTH (lseek, (int __fd, __off64_t __offset, int __whence), lseek64); # else @@ -295,7 +295,8 @@ extern __off64_t __REDIRECT (lseek, # endif #endif #ifdef __USE_LARGEFILE64 -extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence) __THROW; +extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence) + __THROW; #endif /* Close the file descriptor FD. @@ -309,13 +310,13 @@ extern int close (int __fd); This function is a cancellation point and therefore not marked with __THROW. */ -extern ssize_t read (int __fd, void *__buf, size_t __nbytes); +extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur; /* Write N bytes of BUF to FD. Return the number written, or -1. This function is a cancellation point and therefore not marked with __THROW. */ -extern ssize_t write (int __fd, __const void *__buf, size_t __n); +extern ssize_t write (int __fd, __const void *__buf, size_t __n) __wur; #ifdef __USE_UNIX98 # ifndef __USE_FILE_OFFSET64 @@ -326,7 +327,7 @@ extern ssize_t write (int __fd, __const void *__buf, size_t __n); This function is a cancellation point and therefore not marked with __THROW. */ extern ssize_t pread (int __fd, void *__buf, size_t __nbytes, - __off_t __offset); + __off_t __offset) __wur; /* Write N bytes of BUF to FD at the given position OFFSET without changing the file pointer. Return the number written, or -1. @@ -334,15 +335,15 @@ extern ssize_t pread (int __fd, void *__buf, size_t __nbytes, This function is a cancellation point and therefore not marked with __THROW. */ extern ssize_t pwrite (int __fd, __const void *__buf, size_t __n, - __off_t __offset); + __off_t __offset) __wur; # else # ifdef __REDIRECT extern ssize_t __REDIRECT (pread, (int __fd, void *__buf, size_t __nbytes, __off64_t __offset), - pread64); + pread64) __wur; extern ssize_t __REDIRECT (pwrite, (int __fd, __const void *__buf, size_t __nbytes, __off64_t __offset), - pwrite64); + pwrite64) __wur; # else # define pread pread64 # define pwrite pwrite64 @@ -354,11 +355,11 @@ extern ssize_t __REDIRECT (pwrite, (int __fd, __const void *__buf, changing the file pointer. Return the number read, -1 for errors or 0 for EOF. */ extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes, - __off64_t __offset); + __off64_t __offset) __wur; /* Write N bytes of BUF to FD at the given position OFFSET without changing the file pointer. Return the number written, or -1. */ extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n, - __off64_t __offset); + __off64_t __offset) __wur; # endif #endif @@ -366,7 +367,7 @@ extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n, If successful, two file descriptors are stored in PIPEDES; bytes written on PIPEDES[1] can be read from PIPEDES[0]. Returns 0 if successful, -1 if not. */ -extern int pipe (int __pipedes[2]) __THROW; +extern int pipe (int __pipedes[2]) __THROW __wur; /* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM. If SECONDS is zero, any currently scheduled alarm will be cancelled. @@ -416,26 +417,34 @@ extern int pause (void); /* Change the owner and group of FILE. */ extern int chown (__const char *__file, __uid_t __owner, __gid_t __group) - __THROW __nonnull ((1)); + __THROW __nonnull ((1)) __wur; #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED /* Change the owner and group of the file that FD is open on. */ -extern int fchown (int __fd, __uid_t __owner, __gid_t __group) __THROW; +extern int fchown (int __fd, __uid_t __owner, __gid_t __group) __THROW __wur; /* Change owner and group of FILE, if it is a symbolic link the ownership of the symbolic link is changed. */ extern int lchown (__const char *__file, __uid_t __owner, __gid_t __group) - __THROW __nonnull ((1)); + __THROW __nonnull ((1)) __wur; #endif /* Use BSD || X/Open Unix. */ +#if 0 /*def __USE_GNU*/ +/* Change the owner and group of FILE relative to the directory FD is open + on. */ +extern int fchownat (int __fd, __const char *__file, __uid_t __owner, + __gid_t __group, int __flag) + __THROW __nonnull ((2)) __wur; +#endif /* Use GNU. */ + /* Change the process's working directory to PATH. */ -extern int chdir (__const char *__path) __THROW __nonnull ((1)); +extern int chdir (__const char *__path) __THROW __nonnull ((1)) __wur; #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED /* Change the process's working directory to the one FD is open on. */ -extern int fchdir (int __fd) __THROW; +extern int fchdir (int __fd) __THROW __wur; #endif /* Get the pathname of the current working directory, @@ -445,7 +454,7 @@ extern int fchdir (int __fd) __THROW; an array is allocated with `malloc'; the array is SIZE bytes long, unless SIZE == 0, in which case it is as big as necessary. */ -extern char *getcwd (char *__buf, size_t __size) __THROW; +extern char *getcwd (char *__buf, size_t __size) __THROW __wur; #ifdef __USE_GNU /* Return a malloc'd string containing the current directory name. @@ -454,16 +463,17 @@ extern char *getcwd (char *__buf, size_t __size) __THROW; extern char *get_current_dir_name (void) __THROW; #endif -#if 0 /* defined __USE_BSD || defined __USE_XOPEN_EXTENDED */ +#if 0 /*defined __USE_BSD || defined __USE_XOPEN_EXTENDED*/ /* Put the absolute pathname of the current working directory in BUF. If successful, return BUF. If not, put an error message in BUF and return NULL. BUF should be at least PATH_MAX bytes long. */ -extern char *getwd (char *__buf) __THROW __nonnull ((1)); +extern char *getwd (char *__buf) + __THROW __nonnull ((1)) __attribute_deprecated__ __wur; #endif /* Duplicate FD, returning a new file descriptor on the same file. */ -extern int dup (int __fd) __THROW; +extern int dup (int __fd) __THROW __wur; /* Duplicate FD to FD2, closing FD2 and making it open on the same file. */ extern int dup2 (int __fd, int __fd2) __THROW; @@ -480,7 +490,7 @@ extern char **environ; extern int execve (__const char *__path, char *__const __argv[], char *__const __envp[]) __THROW __nonnull ((1)); -#if 0 /* def __USE_GNU */ +#if 0 /*def __USE_GNU*/ /* Execute the file FD refers to, overlaying the running program image. ARGV and ENVP are passed to the new program, as for `execve'. */ extern int fexecve (int __fd, char *__const __argv[], char *__const __envp[]) @@ -516,7 +526,7 @@ extern int execlp (__const char *__file, __const char *__arg, ...) #if defined __USE_MISC || defined __USE_XOPEN /* Add INC to priority of the current process. */ -extern int nice (int __inc) __THROW; +extern int nice (int __inc) __THROW __wur; #endif @@ -556,8 +566,8 @@ extern __pid_t getppid (void) __THROW; #ifndef __FAVOR_BSD extern __pid_t getpgrp (void) __THROW; #else -# ifdef __REDIRECT -extern __pid_t __REDIRECT (getpgrp, (__pid_t __pid), __getpgid); +# ifdef __REDIRECT_NTH +extern __pid_t __REDIRECT_NTH (getpgrp, (__pid_t __pid), __getpgid); # else # define getpgrp __getpgid # endif @@ -595,8 +605,8 @@ extern int setpgrp (void) __THROW; # else /* Another name for `setpgid' (above). */ -# ifdef __REDIRECT -extern int __REDIRECT (setpgrp, (__pid_t __pid, __pid_t __pgrp), setpgid); +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (setpgrp, (__pid_t __pid, __pid_t __pgrp), setpgid); # else # define setpgrp setpgid # endif @@ -629,9 +639,9 @@ extern __gid_t getegid (void) __THROW; /* If SIZE is zero, return the number of supplementary groups the calling process is in. Otherwise, fill in the group IDs of its supplementary groups in LIST and return the number written. */ -extern int getgroups (int __size, __gid_t __list[]) __THROW; +extern int getgroups (int __size, __gid_t __list[]) __THROW __wur; -#if 0 /* def __USE_GNU */ +#if 0 /*def __USE_GNU*/ /* Return nonzero iff the calling process is in group GID. */ extern int group_member (__gid_t __gid) __THROW; #endif @@ -673,19 +683,23 @@ extern int setegid (__gid_t __gid) __THROW; #ifdef __USE_GNU /* Fetch the effective user ID, real user ID, and saved-set user ID, of the calling process. */ -extern int getresuid (__uid_t *__euid, __uid_t *__ruid, __uid_t *__suid); +extern int getresuid (__uid_t *__euid, __uid_t *__ruid, __uid_t *__suid) + __THROW; /* Fetch the effective group ID, real group ID, and saved-set group ID, of the calling process. */ -extern int getresgid (__gid_t *__egid, __gid_t *__rgid, __gid_t *__sgid); +extern int getresgid (__gid_t *__egid, __gid_t *__rgid, __gid_t *__sgid) + __THROW; /* Set the effective user ID, real user ID, and saved-set user ID, of the calling process to EUID, RUID, and SUID, respectively. */ -extern int setresuid (__uid_t __euid, __uid_t __ruid, __uid_t __suid); +extern int setresuid (__uid_t __euid, __uid_t __ruid, __uid_t __suid) + __THROW; /* Set the effective group ID, real group ID, and saved-set group ID, of the calling process to EGID, RGID, and SGID, respectively. */ -extern int setresgid (__gid_t __egid, __gid_t __rgid, __gid_t __sgid); +extern int setresgid (__gid_t __egid, __gid_t __rgid, __gid_t __sgid) + __THROW; #endif @@ -712,14 +726,14 @@ extern char *ttyname (int __fd) __THROW; /* Store at most BUFLEN characters of the pathname of the terminal FD is open on in BUF. Return 0 on success, otherwise an error number. */ extern int ttyname_r (int __fd, char *__buf, size_t __buflen) - __THROW __nonnull ((2)); + __THROW __nonnull ((2)) __wur; /* Return 1 if FD is a valid descriptor associated with a terminal, zero if not. */ extern int isatty (int __fd) __THROW; -#if 0 /* defined __USE_BSD \ - || (defined __USE_XOPEN_EXTENDED && !defined __USE_UNIX98) */ +#if 0 /*defined __USE_BSD \ + || (defined __USE_XOPEN_EXTENDED && !defined __USE_UNIX98)*/ /* Return the index into the active-logins file (utmp) for the controlling terminal. */ extern int ttyslot (void) __THROW; @@ -728,23 +742,47 @@ extern int ttyslot (void) __THROW; /* Make a link to FROM named TO. */ extern int link (__const char *__from, __const char *__to) - __THROW __nonnull ((1, 2)); + __THROW __nonnull ((1, 2)) __wur; + +#if 0 /*def __USE_GNU*/ +/* Like link but relative paths in TO and FROM are interpreted relative + to FROMFD and TOFD respectively. */ +extern int linkat (int __fromfd, __const char *__from, int __tofd, + __const char *__to) __THROW __nonnull ((2, 4)) __wur; +#endif #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K /* Make a symbolic link to FROM named TO. */ extern int symlink (__const char *__from, __const char *__to) - __THROW __nonnull ((1, 2)); + __THROW __nonnull ((1, 2)) __wur; /* Read the contents of the symbolic link PATH into no more than LEN bytes of BUF. The contents are not null-terminated. Returns the number of characters read, or -1 for errors. */ extern int readlink (__const char *__restrict __path, char *__restrict __buf, - size_t __len) __THROW __nonnull ((1, 2)); + size_t __len) __THROW __nonnull ((1, 2)) __wur; #endif /* Use BSD. */ +#if 0 /*def __USE_GNU*/ +/* Like symlink but a relative path in TO is interpreted relative to TOFD. */ +extern int symlinkat (__const char *__from, int __tofd, + __const char *__to) __THROW __nonnull ((1, 3)) __wur; + +/* Like readlink but a relative PATH is interpreted relative to FD. */ +extern int readlinkat (int __fd, __const char *__restrict __path, + char *__restrict __buf, size_t __len) + __THROW __nonnull ((2, 3)) __wur; +#endif + /* Remove the link NAME. */ extern int unlink (__const char *__name) __THROW __nonnull ((1)); +#if 0 /*def __USE_GNU*/ +/* Remove the link NAME relative to FD. */ +extern int unlinkat (int __fd, __const char *__name, int __flag) + __THROW __nonnull ((2)); +#endif + /* Remove the directory PATH. */ extern int rmdir (__const char *__path) __THROW __nonnull ((1)); @@ -771,7 +809,7 @@ extern char *getlogin (void); extern int getlogin_r (char *__name, size_t __name_len) __nonnull ((1)); #endif -#if 0 /* def __USE_BSD */ +#if 0 /*def __USE_BSD*/ /* Set the login name returned by `getlogin'. */ extern int setlogin (__const char *__name) __THROW __nonnull ((1)); #endif @@ -798,20 +836,20 @@ extern int gethostname (char *__name, size_t __len) __THROW __nonnull ((1)); /* Set the name of the current host to NAME, which is LEN bytes long. This call is restricted to the super-user. */ extern int sethostname (__const char *__name, size_t __len) - __THROW __nonnull ((1)); + __THROW __nonnull ((1)) __wur; /* Set the current machine's Internet number to ID. This call is restricted to the super-user. */ -extern int sethostid (long int __id) __THROW; +extern int sethostid (long int __id) __THROW __wur; /* Get and set the NIS (aka YP) domain name, if any. Called just like `gethostname' and `sethostname'. The NIS domain name is usually the empty string when not using NIS. */ extern int getdomainname (char *__name, size_t __len) - __THROW __nonnull ((1)); + __THROW __nonnull ((1)) __wur; extern int setdomainname (__const char *__name, size_t __len) - __THROW __nonnull ((1)); + __THROW __nonnull ((1)) __wur; /* Revoke access permissions to all processes currently communicating @@ -821,7 +859,7 @@ extern int vhangup (void) __THROW; #if 0 /* Revoke the access of all descriptors currently open on FILE. */ -extern int revoke (__const char *__file) __THROW __nonnull ((1)); +extern int revoke (__const char *__file) __THROW __nonnull ((1)) __wur; /* Enable statistical profiling, writing samples of the PC into at most @@ -838,7 +876,7 @@ extern int profil (unsigned short int *__sample_buffer, size_t __size, /* Turn accounting on if NAME is an existing file. The system will then write a record for each process as it terminates, to this file. If NAME is NULL, turn accounting off. This call is restricted to the super-user. */ -extern int acct (__const char *__name) __THROW __nonnull ((1)); +extern int acct (__const char *__name) __THROW; /* Successive calls return the shells listed in `/etc/shells'. */ @@ -851,7 +889,7 @@ extern void setusershell (void) __THROW; /* Rewind and re-read the file. */ /* Put the program in the background, and dissociate from the controlling terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero, redirects stdin, stdout, and stderr to /dev/null. */ -extern int daemon (int __nochdir, int __noclose) __THROW; +extern int daemon (int __nochdir, int __noclose) __THROW __wur; #endif #endif /* Use BSD || X/Open. */ @@ -859,7 +897,7 @@ extern int daemon (int __nochdir, int __noclose) __THROW; #if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_XOPEN2K) /* Make PATH be the root directory (the starting point for absolute paths). This call is restricted to the super-user. */ -extern int chroot (__const char *__path) __THROW __nonnull ((1)); +extern int chroot (__const char *__path) __THROW __nonnull ((1)) __wur; /* Prompt with PROMPT and read a string from the terminal without echoing. Uses /dev/tty if possible; otherwise stderr and stdin. */ @@ -898,19 +936,19 @@ extern int getdtablesize (void) __THROW; /* Truncate FILE to LENGTH bytes. */ # ifndef __USE_FILE_OFFSET64 extern int truncate (__const char *__file, __off_t __length) - __THROW __nonnull ((1)); + __THROW __nonnull ((1)) __wur; # else -# ifdef __REDIRECT -extern int __REDIRECT (truncate, +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (truncate, (__const char *__file, __off64_t __length), - truncate64) __nonnull ((1)); + truncate64) __nonnull ((1)) __wur; # else # define truncate truncate64 # endif # endif # ifdef __USE_LARGEFILE64 extern int truncate64 (__const char *__file, __off64_t __length) - __THROW __nonnull ((1)); + __THROW __nonnull ((1)) __wur; # endif #endif /* Use BSD || X/Open Unix. */ @@ -919,17 +957,17 @@ extern int truncate64 (__const char *__file, __off64_t __length) /* Truncate the file FD is open on to LENGTH bytes. */ # ifndef __USE_FILE_OFFSET64 -extern int ftruncate (int __fd, __off_t __length) __THROW; +extern int ftruncate (int __fd, __off_t __length) __THROW __wur; # else -# ifdef __REDIRECT -extern int __REDIRECT (ftruncate, (int __fd, __off64_t __length), - ftruncate64); +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (ftruncate, (int __fd, __off64_t __length), + ftruncate64) __wur; # else # define ftruncate ftruncate64 # endif # endif # ifdef __USE_LARGEFILE64 -extern int ftruncate64 (int __fd, __off64_t __length) __THROW; +extern int ftruncate64 (int __fd, __off64_t __length) __THROW __wur; # endif #endif /* Use BSD || X/Open Unix || POSIX 2003. */ @@ -939,7 +977,7 @@ extern int ftruncate64 (int __fd, __off64_t __length) __THROW; /* Set the end of accessible data space (aka "the break") to ADDR. Returns zero on success and -1 for errors (with errno set). */ -extern int brk (void *__addr) __THROW; +extern int brk (void *__addr) __THROW __wur; /* Increase or decrease the end of accessible data space by DELTA bytes. If successful, returns the address the previous end of data space @@ -983,17 +1021,17 @@ extern long int syscall (long int __sysno, ...) __THROW; # define F_TEST 3 /* Test a region for other processes locks. */ # ifndef __USE_FILE_OFFSET64 -extern int lockf (int __fd, int __cmd, __off_t __len); +extern int lockf (int __fd, int __cmd, __off_t __len) __wur; # else # ifdef __REDIRECT extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), - lockf64); + lockf64) __wur; # else # define lockf lockf64 # endif # endif # ifdef __USE_LARGEFILE64 -extern int lockf64 (int __fd, int __cmd, __off64_t __len); +extern int lockf64 (int __fd, int __cmd, __off64_t __len) __wur; # endif #endif /* Use misc and F_LOCK not already defined. */ @@ -1043,7 +1081,13 @@ extern void swab (__const void *__restrict __from, void *__restrict __to, It is also found in <stdio.h>. */ #ifdef __USE_XOPEN /* Return the name of the controlling terminal. */ -extern char *ctermid (char *__s) __THROW __nonnull ((1)); +extern char *ctermid (char *__s) __THROW; +#endif + + +/* Define some macros helping to catch buffer overflows. */ +#if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus +# include <bits/unistd.h> #endif __END_DECLS diff --git a/ldso/ldso/Makefile.in b/ldso/ldso/Makefile.in index 903a1fd3a..c5273bcc8 100644 --- a/ldso/ldso/Makefile.in +++ b/ldso/ldso/Makefile.in @@ -66,4 +66,4 @@ $(ld-uClibc_OUT)/ld-uClibc_so.a: $(ld-uClibc-so-y) $(do_ar) ld-uClibc_clean: - $(RM) $(ld-uClibc_OUT)/*.{o,os,a} $(ld-uClibc_OUT)/*/*.{o,os} + $(RM) $(ld-uClibc_OUT)/*.{o,os,oS,a} $(ld-uClibc_OUT)/*/*.{o,os} diff --git a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c index e06aa343c..f536f7446 100644 --- a/ldso/ldso/dl-startup.c +++ b/ldso/ldso/dl-startup.c @@ -98,7 +98,7 @@ int (*_dl_elf_main) (int, char **, char **); static void* __rtld_stack_end; /* Points to argc on stack, e.g *((long *)__rtld_stackend) == argc */ -strong_alias(__rtld_stack_end, __libc_stack_end); /* Exported version of __rtld_stack_end */ +strong_alias(__rtld_stack_end, __libc_stack_end) /* Exported version of __rtld_stack_end */ /* When we enter this piece of code, the program stack looks like this: argc argument counter (integer) diff --git a/ldso/ldso/i386/dl-startup.h b/ldso/ldso/i386/dl-startup.h index 95609bbb3..cfa412621 100644 --- a/ldso/ldso/i386/dl-startup.h +++ b/ldso/ldso/i386/dl-startup.h @@ -41,9 +41,9 @@ asm( #define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) & ARGS)+1) /* Handle relocation of the symbols in the dynamic loader. */ -static inline +static __always_inline void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr, - unsigned long symbol_addr, unsigned long load_addr, Elf32_Sym *symtab) + unsigned long symbol_addr, unsigned long load_addr, attribute_unused Elf32_Sym *symtab) { switch (ELF32_R_TYPE(rpnt->r_info)) { diff --git a/ldso/ldso/powerpc/dl-startup.h b/ldso/ldso/powerpc/dl-startup.h index 6fdf74301..e6fd814e5 100644 --- a/ldso/ldso/powerpc/dl-startup.h +++ b/ldso/ldso/powerpc/dl-startup.h @@ -42,8 +42,10 @@ asm( " bne 2b\n" " addi 6,6,4\n" #endif - /* Pass a termination function pointer (in this case _dl_fini) in r7. */ - " lwz 7,_dl_fini@got(31)\n" + /* Pass a termination function pointer (in this case _dl_fini) in r3. */ + /* Paulus promized he would keep r3 zero in the exec ABI. */ + " lwz 3,_dl_fini@got(31)\n" + " mr 7,3\n" /* Pass _dl_fini in r7 to maintain compat */ " bctr\n" /* Jump to entry point */ " .size _start,.-_start\n" " .previous\n" diff --git a/libc/sysdeps/linux/mips/clone.S b/libc/sysdeps/linux/mips/clone.S index aba2f7cbb..65ac8b16a 100644 --- a/libc/sysdeps/linux/mips/clone.S +++ b/libc/sysdeps/linux/mips/clone.S @@ -20,9 +20,6 @@ /* clone() is even more special than fork() as it mucks with stacks and invokes a function in the right context after its all over. */ -#ifdef __UCLIBC_HAS_THREADS_NATIVE__ -#define RESET_PID -#endif #include <sys/asm.h> #include <sysdep.h> #define _ERRNO_H 1 diff --git a/libcrypt/crypt.c b/libcrypt/crypt.c index a7dd35458..a1bba6ebd 100644 --- a/libcrypt/crypt.c +++ b/libcrypt/crypt.c @@ -26,8 +26,8 @@ #include <crypt.h> #include <unistd.h> -extern char * __md5_crypt( const char *pw, const char *salt); -extern char * __des_crypt( const char *pw, const char *salt); +extern char * __md5_crypt( const char *pw, const char *salt) attribute_hidden; +extern char * __des_crypt( const char *pw, const char *salt) attribute_hidden; extern char * crypt(const char *key, const char *salt) { diff --git a/libcrypt/des.c b/libcrypt/des.c index 5966da0b9..80e513183 100644 --- a/libcrypt/des.c +++ b/libcrypt/des.c @@ -349,7 +349,7 @@ des_init(void) static void -setup_salt(long salt) +setup_salt(u_int32_t salt) { u_int32_t obit, saltbit; int i; diff --git a/libm/fp_private.h b/libm/fp_private.h index 505400e33..0ddb616c4 100644 --- a/libm/fp_private.h +++ b/libm/fp_private.h @@ -70,10 +70,11 @@ *******************************************************************************/ #include <stdint.h> +#include <endian.h> typedef struct /* Hex representation of a double. */ { -#if defined(__BIG_ENDIAN__) +#if (__BYTE_ORDER == __BIG_ENDIAN) uint32_t high; uint32_t low; #else diff --git a/libm/fpmacros.c b/libm/fpmacros.c index 57c6b5a7a..2624054d0 100644 --- a/libm/fpmacros.c +++ b/libm/fpmacros.c @@ -248,7 +248,7 @@ int __isinfl ( long double x ) } return 0; } -weak_alias (__isinfl, isinfl); +weak_alias (__isinfl, isinfl) #endif /*********************************************************************** @@ -271,14 +271,14 @@ int __isnanf ( float x ) z.fval = x; return (((z.lval&FEXP_MASK) == FEXP_MASK) && ((z.lval&FFRAC_MASK) != 0)); } -weak_alias (__isnanf, isnanf); +weak_alias (__isnanf, isnanf) int __isnan ( double x ) { int class = __fpclassify(x); return ( class == FP_NAN ); } -weak_alias (__isnan, isnan); +weak_alias (__isnan, isnan) #if 0 int __isnanl ( long double x ) @@ -286,6 +286,6 @@ int __isnanl ( long double x ) int class = __fpclassify(x); return ( class == FP_NAN ); } -weak_alias (__isnanl, isnanl); +weak_alias (__isnanl, isnanl) #endif diff --git a/libm/math_private.h b/libm/math_private.h index 2f6ebb0d9..c4f513fb2 100644 --- a/libm/math_private.h +++ b/libm/math_private.h @@ -186,11 +186,11 @@ extern double __ieee754_scalb __P((double,double)); #endif /* fdlibm kernel function */ -extern double __kernel_standard __P((double,double,int)); -extern double __kernel_sin __P((double,double,int)); -extern double __kernel_cos __P((double,double)); -extern double __kernel_tan __P((double,double,int)); -extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*)); +extern double __kernel_standard __P((double,double,int)) attribute_hidden; +extern double __kernel_sin __P((double,double,int)) attribute_hidden; +extern double __kernel_cos __P((double,double)) attribute_hidden; +extern double __kernel_tan __P((double,double,int)) attribute_hidden; +extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*)) attribute_hidden; /* ieee style elementary float functions */ diff --git a/libm/powerpc/Makefile.arch b/libm/powerpc/Makefile.arch index c6d39676a..7eb68bb59 100644 --- a/libm/powerpc/Makefile.arch +++ b/libm/powerpc/Makefile.arch @@ -13,7 +13,11 @@ libm_ARCH_OBJ:=$(patsubst $(libm_ARCH_DIR)/%.c,$(libm_ARCH_OUT)/%.o,$(libm_ARCH_ libm_ARCH_OBJS:=$(libm_ARCH_OBJ) +ifeq ($(DOPIC),y) +libm-a-$(DO_C99_MATH)+=$(libm_ARCH_OBJS:.o=.os) +else libm-a-$(DO_C99_MATH)+=$(libm_ARCH_OBJS) +endif libm-so-$(DO_C99_MATH)+=$(libm_ARCH_OBJS:.o=.os) libm-multi-$(DO_C99_MATH)+=$(libm_ARCH_SRC) diff --git a/libm/powerpc/s_ceil.c b/libm/powerpc/s_ceil.c index fd073de7b..f6680eedf 100644 --- a/libm/powerpc/s_ceil.c +++ b/libm/powerpc/s_ceil.c @@ -21,13 +21,15 @@ * * *******************************************************************************/ +#include <endian.h> + static const double twoTo52 = 4503599627370496.0; static const unsigned long signMask = 0x80000000ul; typedef union { struct { -#if defined(__BIG_ENDIAN__) +#if (__BYTE_ORDER == __BIG_ENDIAN) unsigned long int hi; unsigned long int lo; #else diff --git a/libm/powerpc/s_floor.c b/libm/powerpc/s_floor.c index 94677b4d2..0ddbb9b66 100644 --- a/libm/powerpc/s_floor.c +++ b/libm/powerpc/s_floor.c @@ -21,13 +21,15 @@ * * *******************************************************************************/ +#include <endian.h> + static const double twoTo52 = 4503599627370496.0; static const unsigned long signMask = 0x80000000ul; typedef union { struct { -#if defined(__BIG_ENDIAN__) +#if (__BYTE_ORDER == __BIG_ENDIAN) unsigned long int hi; unsigned long int lo; #else diff --git a/libm/powerpc/s_frexp.c b/libm/powerpc/s_frexp.c index 9909f2ce7..7c998f81a 100644 --- a/libm/powerpc/s_frexp.c +++ b/libm/powerpc/s_frexp.c @@ -21,13 +21,14 @@ #include <limits.h> #include <math.h> +#include <endian.h> static const double two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */ typedef union { struct { -#if defined(__BIG_ENDIAN__) +#if (__BYTE_ORDER == __BIG_ENDIAN) unsigned long int hi; unsigned long int lo; #else diff --git a/libm/powerpc/s_ldexp.c b/libm/powerpc/s_ldexp.c index ce9ec8b1b..7e52352ae 100644 --- a/libm/powerpc/s_ldexp.c +++ b/libm/powerpc/s_ldexp.c @@ -21,11 +21,12 @@ #include <limits.h> #include <math.h> +#include <endian.h> typedef union { struct { -#if defined(__BIG_ENDIAN__) +#if (__BYTE_ORDER == __BIG_ENDIAN) unsigned long int hi; unsigned long int lo; #else diff --git a/libm/powerpc/s_logb.c b/libm/powerpc/s_logb.c index 23c7270f9..3caecd95f 100644 --- a/libm/powerpc/s_logb.c +++ b/libm/powerpc/s_logb.c @@ -32,10 +32,12 @@ * Standard 754. * *******************************************************************************/ +#include <endian.h> + typedef union { struct { -#if defined(__BIG_ENDIAN__) +#if (__BYTE_ORDER == __BIG_ENDIAN) unsigned long int hi; unsigned long int lo; #else diff --git a/libm/powerpc/s_modf.c b/libm/powerpc/s_modf.c index f4344bda8..cb8338a90 100644 --- a/libm/powerpc/s_modf.c +++ b/libm/powerpc/s_modf.c @@ -45,13 +45,14 @@ #include <limits.h> #include <math.h> +#include <endian.h> #define SET_INVALID 0x01000000UL typedef union { struct { -#if defined(__BIG_ENDIAN__) +#if (__BYTE_ORDER == __BIG_ENDIAN) unsigned long int hi; unsigned long int lo; #else diff --git a/libm/powerpc/s_rint.c b/libm/powerpc/s_rint.c index 72c4834d0..c229515c4 100644 --- a/libm/powerpc/s_rint.c +++ b/libm/powerpc/s_rint.c @@ -46,13 +46,14 @@ #include <limits.h> #include <math.h> +#include <endian.h> #define SET_INVALID 0x01000000UL typedef union { struct { -#if defined(__BIG_ENDIAN__) +#if (__BYTE_ORDER == __BIG_ENDIAN) unsigned long int hi; unsigned long int lo; #else diff --git a/libm/powerpc/s_round.c b/libm/powerpc/s_round.c index 81f4d0fec..a0f72ebe3 100644 --- a/libm/powerpc/s_round.c +++ b/libm/powerpc/s_round.c @@ -1,10 +1,11 @@ #include <limits.h> #include <math.h> +#include <endian.h> typedef union { struct { -#if defined(__BIG_ENDIAN__) +#if (__BYTE_ORDER == __BIG_ENDIAN) unsigned long int hi; unsigned long int lo; #else diff --git a/libm/powerpc/s_trunc.c b/libm/powerpc/s_trunc.c index 4b61355ea..7db7606b6 100644 --- a/libm/powerpc/s_trunc.c +++ b/libm/powerpc/s_trunc.c @@ -1,10 +1,11 @@ #include <limits.h> #include <math.h> +#include <endian.h> typedef union { struct { -#if defined(__BIG_ENDIAN__) +#if (__BYTE_ORDER == __BIG_ENDIAN) unsigned long int hi; unsigned long int lo; #else diff --git a/libm/powerpc/w_scalb.c b/libm/powerpc/w_scalb.c index c93c74b68..fe23ece53 100644 --- a/libm/powerpc/w_scalb.c +++ b/libm/powerpc/w_scalb.c @@ -19,10 +19,12 @@ ** ***********************************************************************/ +#include <endian.h> + typedef union { struct { -#if defined(__BIG_ENDIAN__) +#if (__BYTE_ORDER == __BIG_ENDIAN) unsigned long int hi; unsigned long int lo; #else diff --git a/libpthread/nptl/sysdeps/pthread/bits/libc-lock.h b/libpthread/nptl/sysdeps/pthread/bits/libc-lock.h index 795caa713..d043a0d2e 100644 --- a/libpthread/nptl/sysdeps/pthread/bits/libc-lock.h +++ b/libpthread/nptl/sysdeps/pthread/bits/libc-lock.h @@ -509,35 +509,30 @@ extern int __pthread_atfork (void (*__prepare) (void), single-threaded processes. */ #ifndef __NO_WEAK_PTHREAD_ALIASES # ifdef weak_extern -# if _LIBC -# include <bp-sym.h> -# else -# define BP_SYM (sym) sym -# endif -weak_extern (BP_SYM (__pthread_mutex_init)) -weak_extern (BP_SYM (__pthread_mutex_destroy)) -weak_extern (BP_SYM (__pthread_mutex_lock)) -weak_extern (BP_SYM (__pthread_mutex_trylock)) -weak_extern (BP_SYM (__pthread_mutex_unlock)) -weak_extern (BP_SYM (__pthread_mutexattr_init)) -weak_extern (BP_SYM (__pthread_mutexattr_destroy)) -weak_extern (BP_SYM (__pthread_mutexattr_settype)) -weak_extern (BP_SYM (__pthread_rwlock_init)) -weak_extern (BP_SYM (__pthread_rwlock_destroy)) -weak_extern (BP_SYM (__pthread_rwlock_rdlock)) -weak_extern (BP_SYM (__pthread_rwlock_tryrdlock)) -weak_extern (BP_SYM (__pthread_rwlock_wrlock)) -weak_extern (BP_SYM (__pthread_rwlock_trywrlock)) -weak_extern (BP_SYM (__pthread_rwlock_unlock)) -weak_extern (BP_SYM (__pthread_key_create)) -weak_extern (BP_SYM (__pthread_setspecific)) -weak_extern (BP_SYM (__pthread_getspecific)) -weak_extern (BP_SYM (__pthread_once)) +weak_extern (__pthread_mutex_init) +weak_extern (__pthread_mutex_destroy) +weak_extern (__pthread_mutex_lock) +weak_extern (__pthread_mutex_trylock) +weak_extern (__pthread_mutex_unlock) +weak_extern (__pthread_mutexattr_init) +weak_extern (__pthread_mutexattr_destroy) +weak_extern (__pthread_mutexattr_settype) +weak_extern (__pthread_rwlock_init) +weak_extern (__pthread_rwlock_destroy) +weak_extern (__pthread_rwlock_rdlock) +weak_extern (__pthread_rwlock_tryrdlock) +weak_extern (__pthread_rwlock_wrlock) +weak_extern (__pthread_rwlock_trywrlock) +weak_extern (__pthread_rwlock_unlock) +weak_extern (__pthread_key_create) +weak_extern (__pthread_setspecific) +weak_extern (__pthread_getspecific) +weak_extern (__pthread_once) weak_extern (__pthread_initialize) weak_extern (__pthread_atfork) -weak_extern (BP_SYM (_pthread_cleanup_push_defer)) -weak_extern (BP_SYM (_pthread_cleanup_pop_restore)) -weak_extern (BP_SYM (pthread_setcancelstate)) +weak_extern (_pthread_cleanup_push_defer) +weak_extern (_pthread_cleanup_pop_restore) +weak_extern (pthread_setcancelstate) # else # pragma weak __pthread_mutex_init # pragma weak __pthread_mutex_destroy diff --git a/librt/mq_getsetattr.c b/librt/mq_getsetattr.c index 4ffda26ca..d412beebb 100644 --- a/librt/mq_getsetattr.c +++ b/librt/mq_getsetattr.c @@ -18,16 +18,18 @@ static inline _syscall3(int, __syscall_mq_getsetattr, int, mqdes, * Set attributes associated with message queue (and possibly also get * its old attributes) */ -int mq_setattr(mqd_t mqdes, const struct mq_attr *mqstat, +attribute_hidden +int __mq_setattr(mqd_t mqdes, const struct mq_attr *mqstat, struct mq_attr *omqstat) { return __syscall_mq_getsetattr(mqdes, mqstat, omqstat); } +strong_alias(__mq_setattr,mq_setattr) /* Query status and attributes of message queue */ int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat) { - return mq_setattr(mqdes, NULL, mqstat); + return __mq_setattr(mqdes, NULL, mqstat); } #endif diff --git a/librt/mq_receive.c b/librt/mq_receive.c index 4dd81f5e7..25e3bd25b 100644 --- a/librt/mq_receive.c +++ b/librt/mq_receive.c @@ -9,28 +9,33 @@ #include <mqueue.h> #ifdef __NR_mq_timedreceive - #define __NR___syscall_mq_timedreceive __NR_mq_timedreceive static inline _syscall5(int, __syscall_mq_timedreceive, int, mqdes, char *, msg_ptr, size_t, msg_len, unsigned int *, msg_prio, const void *, abs_timeout); +#endif /* * Receive the oldest from highest priority messages. * Stop waiting if abs_timeout expires. */ -ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, +attribute_hidden +ssize_t __mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio, const struct timespec *abs_timeout) { - return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); +#ifdef __NR_mq_timedreceive + return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); +#else + errno = ENOSYS; + return -1; +#endif } +strong_alias(__mq_timedreceive,mq_timedreceive) /* Receive the oldest from highest priority messages */ ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio) { - return mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL); + return __mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL); } - -#endif diff --git a/librt/mq_send.c b/librt/mq_send.c index 947e9fe72..642575915 100644 --- a/librt/mq_send.c +++ b/librt/mq_send.c @@ -9,28 +9,33 @@ #include <mqueue.h> #ifdef __NR_mq_timedsend - #define __NR___syscall_mq_timedsend __NR_mq_timedsend static inline _syscall5(int, __syscall_mq_timedsend, int, mqdes, const char *, msg_ptr, size_t, msg_len, unsigned int, msg_prio, const void *, abs_timeout); +#endif /* * Add a message to queue. If O_NONBLOCK is set and queue is full, wait * for sufficient room in the queue until abs_timeout expires. */ -int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, +attribute_hidden +int __mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout) { - return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); +#ifdef __NR_mq_timedsend + return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); +#else + errno = ENOSYS; + return -1; +#endif } +strong_alias(__mq_timedsend,mq_timedsend) /* Add a message to queue */ int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio) { - return mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL); + return __mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL); } - -#endif diff --git a/utils/ldconfig.c b/utils/ldconfig.c index 85ce015d5..f54eadd27 100644 --- a/utils/ldconfig.c +++ b/utils/ldconfig.c @@ -779,10 +779,10 @@ void cache_write(void) for (cur_lib = lib_head; cur_lib != NULL; cur_lib = cur_lib->next) { - if (write(cachefd, cur_lib->soname, strlen(cur_lib->soname) + 1) + if ((size_t)write(cachefd, cur_lib->soname, strlen(cur_lib->soname) + 1) != strlen(cur_lib->soname) + 1) err(EXIT_FATAL,"can't write %s~ (%s)", cachefile, strerror(errno)); - if (write(cachefd, cur_lib->libname, strlen(cur_lib->libname) + 1) + if ((size_t)write(cachefd, cur_lib->libname, strlen(cur_lib->libname) + 1) != strlen(cur_lib->libname) + 1) err(EXIT_FATAL,"can't write %s~ (%s)", cachefile, strerror(errno)); } diff --git a/utils/ldd.c b/utils/ldd.c index dbd2f6de8..4545cf328 100644 --- a/utils/ldd.c +++ b/utils/ldd.c @@ -191,7 +191,7 @@ inline uint64_t byteswap64_to_host(uint64_t value) # define byteswap_to_host(x) byteswap64_to_host(x) #endif -ElfW(Shdr) * elf_find_section_type( int key, ElfW(Ehdr) *ehdr) +ElfW(Shdr) * elf_find_section_type( uint32_t key, ElfW(Ehdr) *ehdr) { int j; ElfW(Shdr) *shdr; @@ -204,7 +204,7 @@ ElfW(Shdr) * elf_find_section_type( int key, ElfW(Ehdr) *ehdr) return NULL; } -ElfW(Phdr) * elf_find_phdr_type( int type, ElfW(Ehdr) *ehdr) +ElfW(Phdr) * elf_find_phdr_type( uint32_t type, ElfW(Ehdr) *ehdr) { int j; ElfW(Phdr) *phdr = (ElfW(Phdr) *)(ehdr->e_phoff + (char *)ehdr); @@ -217,7 +217,7 @@ ElfW(Phdr) * elf_find_phdr_type( int type, ElfW(Ehdr) *ehdr) } /* Returns value if return_val==1, ptr otherwise */ -void * elf_find_dynamic(int const key, ElfW(Dyn) *dynp, +void * elf_find_dynamic( int64_t const key, ElfW(Dyn) *dynp, ElfW(Ehdr) *ehdr, int return_val) { ElfW(Phdr) *pt_text = elf_find_phdr_type(PT_LOAD, ehdr); @@ -648,6 +648,7 @@ static struct library * find_elf_interpreter(ElfW(Ehdr)* ehdr) } /* map the .so, and locate interesting pieces */ +#warning "There may be two warnings here about vfork() clobbering, ignore them" int find_dependancies(char* filename) { int is_suid = 0; diff --git a/utils/readelf.c b/utils/readelf.c index c7516ef4f..0aaf2de65 100644 --- a/utils/readelf.c +++ b/utils/readelf.c @@ -64,7 +64,7 @@ inline uint64_t byteswap64_to_host(uint64_t value) # define byteswap_to_host(x) byteswap32_to_host(x) #endif -ElfW(Shdr) * elf_find_section_type( int key, ElfW(Ehdr) *ehdr) +ElfW(Shdr) * elf_find_section_type( uint32_t key, ElfW(Ehdr) *ehdr) { int j; ElfW(Shdr) *shdr = (ElfW(Shdr) *)(ehdr->e_shoff + (char *)ehdr); @@ -76,7 +76,7 @@ ElfW(Shdr) * elf_find_section_type( int key, ElfW(Ehdr) *ehdr) return NULL; } -ElfW(Phdr) * elf_find_phdr_type( int type, ElfW(Ehdr) *ehdr) +ElfW(Phdr) * elf_find_phdr_type( uint32_t type, ElfW(Ehdr) *ehdr) { int j; ElfW(Phdr) *phdr = (ElfW(Phdr) *)(ehdr->e_phoff + (char *)ehdr); @@ -89,7 +89,7 @@ ElfW(Phdr) * elf_find_phdr_type( int type, ElfW(Ehdr) *ehdr) } /* Returns value if return_val==1, ptr otherwise */ -void * elf_find_dynamic(int const key, ElfW(Dyn) *dynp, +void * elf_find_dynamic( int64_t const key, ElfW(Dyn) *dynp, ElfW(Ehdr) *ehdr, int return_val) { ElfW(Phdr) *pt_text = elf_find_phdr_type(PT_LOAD, ehdr); @@ -164,21 +164,22 @@ static void describe_elf_hdr(ElfW(Ehdr)* ehdr) case EM_386: tmp="Intel 80386"; break; case EM_68K: tmp="Motorola m68k family"; break; case EM_88K: tmp="Motorola m88k family"; break; + case EM_486: tmp="Intel 80486"; break; case EM_860: tmp="Intel 80860"; break; case EM_MIPS: tmp="MIPS R3000 big-endian"; break; case EM_S370: tmp="IBM System/370"; break; case EM_MIPS_RS3_LE: tmp="MIPS R3000 little-endian"; break; + case EM_OLD_SPARCV9: tmp="Sparc v9 (old)"; break; case EM_PARISC: tmp="HPPA"; break; - case EM_VPP500: tmp="Fujitsu VPP500"; break; + /*case EM_PPC_OLD: tmp="Power PC (old)"; break; conflicts with EM_VPP500 */ case EM_SPARC32PLUS: tmp="Sun's v8plus"; break; case EM_960: tmp="Intel 80960"; break; case EM_PPC: tmp="PowerPC"; break; case EM_PPC64: tmp="PowerPC 64-bit"; break; - case EM_S390: tmp="IBM S390"; break; case EM_V800: tmp="NEC V800 series"; break; case EM_FR20: tmp="Fujitsu FR20"; break; case EM_RH32: tmp="TRW RH-32"; break; - case EM_RCE: tmp="Motorola RCE"; break; + case EM_MCORE: tmp="MCORE"; break; case EM_ARM: tmp="ARM"; break; case EM_FAKE_ALPHA: tmp="Digital Alpha"; break; case EM_SH: tmp="Renesas SH"; break; @@ -193,6 +194,24 @@ static void describe_elf_hdr(ElfW(Ehdr)* ehdr) case EM_MIPS_X: tmp="Stanford MIPS-X"; break; case EM_COLDFIRE: tmp="Motorola Coldfire"; break; case EM_68HC12: tmp="Motorola M68HC12"; break; + case EM_ALPHA: tmp="Alpha"; break; + case EM_CYGNUS_D10V: + case EM_D10V: tmp="Mitsubishi D10V"; break; + case EM_CYGNUS_D30V: + case EM_D30V: tmp="Mitsubishi D30V"; break; + case EM_CYGNUS_M32R: + case EM_M32R: tmp="Renesas M32R (formerly Mitsubishi M32r)"; break; + case EM_CYGNUS_V850: + case EM_V850: tmp="NEC v850"; break; + case EM_CYGNUS_MN10300: + case EM_MN10300: tmp="Matsushita MN10300"; break; + case EM_CYGNUS_MN10200: + case EM_MN10200: tmp="Matsushita MN10200"; break; + case EM_CYGNUS_FR30: + case EM_FR30: tmp="Fujitsu FR30"; break; + case EM_CYGNUS_FRV: + case EM_PJ_OLD: + case EM_PJ: tmp="picoJava"; break; case EM_MMA: tmp="Fujitsu MMA Multimedia Accelerator"; break; case EM_PCP: tmp="Siemens PCP"; break; case EM_NCPU: tmp="Sony nCPU embeeded RISC"; break; @@ -201,8 +220,6 @@ static void describe_elf_hdr(ElfW(Ehdr)* ehdr) case EM_ME16: tmp="Toyota ME16 processor"; break; case EM_ST100: tmp="STMicroelectronic ST100 processor"; break; case EM_TINYJ: tmp="Advanced Logic Corp. Tinyj emb.fam"; break; - case EM_X86_64: tmp="AMD x86-64 architecture"; break; - case EM_PDSP: tmp="Sony DSP Processor"; break; case EM_FX66: tmp="Siemens FX66 microcontroller"; break; case EM_ST9PLUS: tmp="STMicroelectronics ST9+ 8/16 mc"; break; case EM_ST7: tmp="STmicroelectronics ST7 8 bit mc"; break; @@ -213,6 +230,8 @@ static void describe_elf_hdr(ElfW(Ehdr)* ehdr) case EM_SVX: tmp="Silicon Graphics SVx"; break; case EM_ST19: tmp="STMicroelectronics ST19 8 bit mc"; break; case EM_VAX: tmp="Digital VAX"; break; + case EM_AVR_OLD: + case EM_AVR: tmp="Atmel AVR 8-bit microcontroller"; break; case EM_CRIS: tmp="Axis Communications 32-bit embedded processor"; break; case EM_JAVELIN: tmp="Infineon Technologies 32-bit embedded processor"; break; case EM_FIREPATH: tmp="Element 14 64-bit DSP Processor"; break; @@ -220,15 +239,26 @@ static void describe_elf_hdr(ElfW(Ehdr)* ehdr) case EM_MMIX: tmp="Donald Knuth's educational 64-bit processor"; break; case EM_HUANY: tmp="Harvard University machine-independent object files"; break; case EM_PRISM: tmp="SiTera Prism"; break; - case EM_AVR: tmp="Atmel AVR 8-bit microcontroller"; break; - case EM_FR30: tmp="Fujitsu FR30"; break; - case EM_D10V: tmp="Mitsubishi D10V"; break; - case EM_D30V: tmp="Mitsubishi D30V"; break; - case EM_V850: tmp="NEC v850"; break; - case EM_M32R: tmp="Renesas M32R"; break; - case EM_MN10300: tmp="Matsushita MN10300"; break; - case EM_MN10200: tmp="Matsushita MN10200"; break; - case EM_PJ: tmp="picoJava"; break; + case EM_X86_64: tmp="AMD x86-64 architecture"; break; + case EM_S390_OLD: + case EM_S390: tmp="IBM S390"; break; + case EM_XSTORMY16: tmp="Sanyo Xstormy16 CPU core"; break; + case EM_OPENRISC: + case EM_OR32: tmp="OpenRISC"; break; + case EM_CRX: tmp="National Semiconductor CRX microprocessor"; break; + case EM_DLX: tmp="OpenDLX"; break; + case EM_IP2K_OLD: + case EM_IP2K: tmp="Ubicom IP2xxx 8-bit microcontrollers"; break; + case EM_IQ2000: tmp="Vitesse IQ2000"; break; + case EM_XTENSA_OLD: + case EM_XTENSA: tmp="Tensilica Xtensa Processor"; break; + case EM_M32C: tmp="Renesas M32c"; break; + case EM_MT: tmp="Morpho Techologies MT processor"; break; + case EM_BLACKFIN: tmp="Analog Devices Blackfin"; break; + case EM_NIOS32: tmp="Altera Nios 32"; break; + case EM_ALTERA_NIOS2: tmp="Altera Nios II"; break; + case EM_VPP500: tmp="Fujitsu VPP500"; break; + case EM_PDSP: tmp="Sony DSP Processor"; break; default: tmp="unknown"; } printf( "Machine:\t%s\n", tmp); diff --git a/utils/readsoname2.c b/utils/readsoname2.c index 9452c0c4d..029a2bbc1 100644 --- a/utils/readsoname2.c +++ b/utils/readsoname2.c @@ -2,14 +2,14 @@ char *readsonameXX(char *name, FILE *infile, int expected_type, int *type) { ElfW(Ehdr) *epnt; ElfW(Phdr) *ppnt; - int i, j; + unsigned int i, j; char *header; - ElfW(Word) dynamic_addr = 0; - ElfW(Word) dynamic_size = 0; + ElfW(Addr) dynamic_addr = 0; + ElfW(Addr) dynamic_size = 0; unsigned long page_size = getpagesize(); - ElfW(Word) strtab_val = 0; - ElfW(Word) needed_val; - ElfW(Sword) loadaddr = -1; + ElfW(Addr) strtab_val = 0; + ElfW(Addr) needed_val; + ElfW(Addr) loadaddr = -1; ElfW(Dyn) *dpnt; struct stat st; char *needed; @@ -62,7 +62,7 @@ char *readsonameXX(char *name, FILE *infile, int expected_type, int *type) ppnt->p_filesz=bswap_32(ppnt->p_filesz); } - if (loadaddr == -1 && ppnt->p_type == PT_LOAD) + if (loadaddr == (ElfW(Addr))-1 && ppnt->p_type == PT_LOAD) loadaddr = (ppnt->p_vaddr & ~(page_size-1)) - (ppnt->p_offset & ~(page_size-1)); if(ppnt->p_type == 2) @@ -104,8 +104,8 @@ char *readsonameXX(char *name, FILE *infile, int expected_type, int *type) if (dpnt->d_tag == DT_SONAME || dpnt->d_tag == DT_NEEDED) { needed_val = dpnt->d_un.d_val; - if (needed_val + strtab_val - loadaddr >= 0 || - needed_val + strtab_val - loadaddr < st.st_size) + if (needed_val + strtab_val >= loadaddr || + needed_val + strtab_val < st.st_size - loadaddr) { needed = (char *) (header - loadaddr + strtab_val + needed_val); |