Browse Source

Merge remote-tracking branch 'origin/master' into prelink

* origin/master: (137 commits)
  utils/ldd: Check for returned pointer from strrchr not the value it holds
  cris: add provide arch-specific vfork implementation
  lutimes.c, stubs.c: fix compiling lutimes, if __NR_utimensat is not defined
  bump version to 0.9.32-rc3-git
  release 0.9.32-rc3
  memalign: include sys/param.h for MAX
  arm/bits/atomic.h: Include common/bit/atomic.h for thumb1
  wctype.h: fix libc_hidden_proto for iswupper and add it for iswspace
  add libc_hidden_proto for wcs[n]casecmp_l
  really fix missing __libc_drand48_data
  Revert "missing prototype of __libc_drand48_data fixed"
  missing prototype of __libc_drand48_data fixed
  time.c, time.h: remove unused hidden strftime/strptime
  nanosleep.c: remove duplicated libc_hidden_proto
  ctype.c, ctype.h: remove commented parts that were banned for removal after 0.9.31
  _wctype.c, wctype.h: remove unused isw* and wctype_l hidden functions
  time.c, wchar.h: remove unused hidden wcsftime
  str[n]casecmp.c: fix hidden usage
  remove unused hidden functions
  frv/memset.S: add missing libc_hidden_def
  ...

Conflicts:
	ldso/ldso/ldso.c

Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Carmelo Amoroso 13 years ago
parent
commit
3b3285b1b7
100 changed files with 1449 additions and 310 deletions
  1. 10 6
      Makefile.in
  2. 8 1
      Makerules
  3. 13 1
      Rules.mak
  4. 31 38
      TODO
  5. 1 1
      extra/Configs/Config.arm
  6. 29 0
      extra/Configs/Config.c6x
  7. 19 9
      extra/Configs/Config.in
  8. 5 1
      extra/Configs/Config.in.arch
  9. 0 1
      extra/Configs/Config.sh
  10. 2 0
      include/alloca.h
  11. 0 7
      include/ctype.h
  12. 45 0
      include/elf.h
  13. 7 5
      include/errno.h
  14. 3 0
      include/fcntl.h
  15. 5 2
      include/features.h
  16. 2 2
      include/ftw.h
  17. 4 3
      include/langinfo.h
  18. 5 0
      include/libc-internal.h
  19. 0 5
      include/libintl.h
  20. 12 1
      include/link.h
  21. 3 6
      include/locale.h
  22. 3 1
      include/net/if_arp.h
  23. 4 0
      include/net/route.h
  24. 0 1
      include/netinet/ether.h
  25. 2 2
      include/netinet/icmp6.h
  26. 25 6
      include/netinet/in.h
  27. 37 1
      include/netinet/ip.h
  28. 11 1
      include/netinet/udp.h
  29. 4 0
      include/nl_types.h
  30. 1 0
      include/paths.h
  31. 1 0
      include/protocols/timed.h
  32. 20 0
      include/resolv.h
  33. 6 0
      include/sgtty.h
  34. 10 1
      include/signal.h
  35. 1 0
      include/stdint.h
  36. 0 1
      include/stdio.h
  37. 36 19
      include/stdlib.h
  38. 1 4
      include/string.h
  39. 13 17
      include/sys/wait.h
  40. 0 2
      include/time.h
  41. 2 0
      include/unistd.h
  42. 0 1
      include/wchar-stub.h
  43. 5 7
      include/wchar.h
  44. 2 2
      include/wctype.h
  45. 9 22
      include/xlocale.h
  46. 1 1
      ldso/include/dl-defs.h
  47. 16 2
      ldso/include/dl-elf.h
  48. 1 1
      ldso/include/dl-syscall.h
  49. 1 0
      ldso/ldso/Makefile.in
  50. 6 6
      ldso/ldso/bfin/dl-syscalls.h
  51. 49 0
      ldso/ldso/c6x/dl-debug.h
  52. 91 0
      ldso/ldso/c6x/dl-inlines.h
  53. 122 0
      ldso/ldso/c6x/dl-startup.h
  54. 25 0
      ldso/ldso/c6x/dl-syscalls.h
  55. 209 0
      ldso/ldso/c6x/dl-sysdep.h
  56. 296 0
      ldso/ldso/c6x/elfinterp.c
  57. 68 0
      ldso/ldso/c6x/resolve.S
  58. 49 1
      ldso/ldso/dl-elf.c
  59. 1 1
      ldso/ldso/i386/elfinterp.c
  60. 6 8
      ldso/ldso/ldso.c
  61. 1 1
      ldso/ldso/sparc/elfinterp.c
  62. 1 1
      ldso/ldso/x86_64/elfinterp.c
  63. 1 0
      ldso/libdl/Makefile.in
  64. 4 1
      ldso/libdl/libdl.c
  65. 1 0
      libc/Makefile.in
  66. 4 0
      libc/inet/getaddrinfo.c
  67. 10 0
      libc/inet/ifaddrs.c
  68. 1 0
      libc/inet/rpc/clnt_tcp.c
  69. 1 0
      libc/inet/rpc/clnt_udp.c
  70. 1 0
      libc/inet/rpc/clnt_unix.c
  71. 4 0
      libc/inet/rpc/sa_len.c
  72. 1 0
      libc/inet/rpc/svc.c
  73. 0 5
      libc/misc/ctype/ctype.c
  74. 3 1
      libc/misc/elf/dl-iterate-phdr.c
  75. 0 5
      libc/misc/fnmatch/fnmatch.c
  76. 2 2
      libc/misc/ftw/ftw.c
  77. 12 20
      libc/misc/internals/__uClibc_main.c
  78. 4 1
      libc/misc/internals/tempname.c
  79. 3 1
      libc/misc/locale/locale.c
  80. 1 0
      libc/misc/pthread/tsd.c
  81. 0 4
      libc/misc/regex/regcomp.c
  82. 1 3
      libc/misc/regex/regex_internal.c
  83. 1 1
      libc/misc/sysvipc/msgq.c
  84. 1 1
      libc/misc/sysvipc/sem.c
  85. 1 1
      libc/misc/sysvipc/shm.c
  86. 10 10
      libc/misc/time/time.c
  87. 1 1
      libc/misc/utmp/utent.c
  88. 16 7
      libc/misc/wctype/_wctype.c
  89. 0 1
      libc/stdio/_scanf.c
  90. 10 0
      libc/stdio/_vfprintf.c
  91. 0 1
      libc/stdio/fwprintf.c
  92. 3 4
      libc/stdlib/_strtod.c
  93. 10 17
      libc/stdlib/arc4random.c
  94. 2 2
      libc/stdlib/drand48-iter.c
  95. 0 4
      libc/stdlib/drand48.c
  96. 0 4
      libc/stdlib/erand48.c
  97. 0 3
      libc/stdlib/erand48_r.c
  98. 0 4
      libc/stdlib/jrand48.c
  99. 0 3
      libc/stdlib/jrand48_r.c
  100. 0 4
      libc/stdlib/lrand48.c

+ 10 - 6
Makefile.in

@@ -206,8 +206,8 @@ $(top_builddir)extra/scripts/unifdef: $(top_srcdir)extra/scripts/unifdef.c
 # a "y" here means the feature is enabled and so we should *not* rm it.
 # if the option expands to nothing though, we can punt the headers.
 HEADERS_RM- := \
-	internal \
 	dl-osinfo.h \
+	hp-timing.h \
 	_lfs_64.h \
 	bits/uClibc_arch_features.h \
 	bits/kernel_sigaction.h \
@@ -215,14 +215,19 @@ HEADERS_RM- := \
 	bits/kernel_types.h \
 	bits/syscalls.h \
 	bits/syscalls-common.h \
-	bits/uClibc_errno.h \
+	bits/uClibc_fpmax.h \
 	bits/uClibc_uintmaxtostr.h \
+	bits/uClibc_uwchar.h \
+	bits/uClibc_va_copy.h \
 	bits/sigcontextinfo.h \
 	bits/stackinfo.h \
 	tls.h \
 	rpc/des_crypt.h \
 	rpc/key_prot.h \
 	rpc/rpc_des.h
+ifeq ($(UCLIBC_STRICT_HEADERS),y)
+HEADERS_RM- += sgtty.h
+endif
 HEADERS_RM-$(HAVE_SHARED)                    += dlfcn.h bits/dlfcn.h
 HEADERS_RM-$(PTHREADS_DEBUG_SUPPORT)         += thread_db.h
 HEADERS_RM-$(UCLIBC_HAS_BSD_ERR)             += err.h
@@ -232,7 +237,6 @@ HEADERS_RM-$(UCLIBC_HAS_FENV)                += fenv.h bits/fenv.h bits/fenvinli
 HEADERS_RM-$(UCLIBC_HAS_FLOATS)              += complex.h fpu_control.h ieee754.h \
 	math.h \
 	tgmath.h \
-	bits/uClibc_fpmax.h \
 	bits/math*.h
 HEADERS_RM-$(findstring y,$(UCLIBC_HAS_FTW)$(UCLIBC_HAS_NFTW))  += ftw.h
 HEADERS_RM-$(UCLIBC_HAS_GETTEXT_AWARENESS)   += libintl.h
@@ -276,9 +280,7 @@ HEADERS_RM-$(UCLIBC_LINUX_SPECIFIC)          += sys/fsuid.h sys/inotify.h sys/pe
 HEADERS_RM-$(UCLIBC_SUPPORT_AI_ADDRCONFIG)   += ifaddrs.h
 HEADERS_RM-$(UCLIBC_SV4_DEPRECATED)          += ustat.h sys/ustat.h bits/ustat.h
 HEADERS_RM-$(UCLIBC_SUSV3_LEGACY)            += sys/timeb.h regexp.h
-HEADERS_RM-$(UCLIBC_SUSV4_LEGACY)            += utime.h
-	# BREAKAGE: include/signal.h uses it, this rm broke bbox compile:
-	### ucontext.h
+HEADERS_RM-$(UCLIBC_SUSV4_LEGACY)            += utime.h ucontext.h
 
 ifneq ($(findstring install,$(MAKECMDGOALS)),)
 $(addprefix $(PREFIX)$(DEVEL_PREFIX),include $(MULTILIB_DIR)):
@@ -327,6 +329,7 @@ ifeq ($(HARDWIRED_ABSPATH),y)
 		    -e 's:$(SHARED_LIBNAME):$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(SHARED_LIBNAME):' \
 		    -e 's:$(UCLIBC_LDSO):$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(UCLIBC_LDSO):' \
 		    $(top_builddir)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so; \
+		$(SED) -i -e 's://:/:g' $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so; \
 	fi
 else
 	-$(INSTALL) -m 755 $(top_builddir)lib/libc.so $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/
@@ -345,6 +348,7 @@ ifeq ($(HARDWIRED_ABSPATH),y)
 		cp $(top_srcdir)extra/scripts/format.lds $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread.so; \
 		echo "GROUP ( $(RUNTIME_PREFIX)$(MULTILIB_DIR)/libpthread.so.$(ABI_VERSION) $(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread_nonshared.a )" \
 			>> $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread.so; \
+		$(SED) -i -e 's://:/:g' $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread.so; \
 	fi
 else
 	-$(INSTALL) -m 755 $(top_builddir)lib/libpthread.so $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/

+ 8 - 1
Makerules

@@ -306,7 +306,8 @@ endef
 define link.so
 	$(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
 	@$(disp_ld)
-	$(Q)$(CC) $(LDFLAGS-$(notdir $@)) -Wl,-soname=$(notdir $@).$(2) \
+	$(Q)$(CC) $(LDFLAGS-$(notdir $@)) $(LDFLAGS-y-$(@F)) \
+		-Wl,-soname=$(notdir $@).$(2) \
 		$(NOSTDLIB_CFLAGS) -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
 		-Wl,--whole-archive $(firstword $^) -Wl,--no-whole-archive \
 		$(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
@@ -372,8 +373,14 @@ $(top_builddir)%.dep:
 $(top_builddir)lib/interp.c: | $(top_builddir)lib
 	$(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@.tmp
 	$(Q)echo "#include <features.h>" >> $@.tmp
+ifeq ($(HARDWIRED_ABSPATH),y)
 	$(Q)echo "const char __dl_ldso__[] attribute_hidden __attribute__ ((weak)) __attribute__ ((section " \
 		"(\".interp\"))) =\""$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(UCLIBC_LDSO)"\";" >> $@.tmp
+	$(Q)$(SED) -i -e 's://:/:g' $@.tmp
+else
+	$(Q)echo "const char __dl_ldso__[] attribute_hidden __attribute__ ((weak)) __attribute__ ((section " \
+		"(\".interp\"))) =\""$(UCLIBC_LDSO)"\";" >> $@.tmp
+endif
 	$(Q)mv $@.tmp $@
 
 $(interp): $(top_builddir)lib/interp.c | $(sub_headers)

+ 13 - 1
Rules.mak

@@ -106,7 +106,7 @@ export RUNTIME_PREFIX DEVEL_PREFIX KERNEL_HEADERS MULTILIB_DIR
 MAJOR_VERSION := 0
 MINOR_VERSION := 9
 SUBLEVEL      := 32
-EXTRAVERSION  :=-rc2-git
+EXTRAVERSION  :=-rc3-git
 VERSION       := $(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL)
 ABI_VERSION   := $(MAJOR_VERSION)
 ifneq ($(EXTRAVERSION),)
@@ -218,10 +218,12 @@ ifeq ($(UCLIBC_HAS_SOFT_FLOAT),y)
 ifneq ($(TARGET_ARCH),nios)
 ifneq ($(TARGET_ARCH),nios2)
 ifneq ($(TARGET_ARCH),sh)
+ifneq ($(TARGET_ARCH),c6x)
 CPU_CFLAGS-y += -msoft-float
 endif
 endif
 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.
@@ -239,6 +241,7 @@ CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)    += -Wl,-EB
 
 PICFLAG-y := -fPIC
 PICFLAG-$(UCLIBC_FORMAT_FDPIC_ELF) := -mfdpic
+PICFLAG-$(UCLIBC_FORMAT_DSBT_ELF)  := -mdsbt -fpic
 PICFLAG := $(PICFLAG-y)
 PIEFLAG_NAME:=-fPIE
 
@@ -485,6 +488,15 @@ ifeq ($(TARGET_ARCH),v850)
       SYMBOL_PREFIX=_
 endif
 
+ifeq ($(TARGET_ARCH),c6x)
+	PIEFLAG:=
+	CPU_CFLAGS-$(CONFIG_TMS320C64X) += -march=c64x
+	CPU_CFLAGS-$(CONFIG_TMS320C64XPLUS) += -march=c64x+
+	CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-mlittle-endian
+	CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mbig-endian
+	CPU_LDFLAGS-y += $(CPU_CFLAGS)
+endif
+
 # Keep the check_gcc from being needlessly executed
 ifndef PIEFLAG
 export PIEFLAG:=$(call check_gcc,$(PIEFLAG_NAME),$(PICFLAG))

+ 31 - 38
TODO

@@ -9,49 +9,42 @@ TODO list for every uClibc release:
 	them in the include files as well by checking for the proper
 	define from include/bits/uClibc_config.h (pulled in from features.h)
 
-TODO list for the uClibc 0.9.31 release:
+TODO list for the uClibc 1.0.0 release:
 -------------------------------------------------
-    *) merge NPTL
-       Settle cancellation
-       support arches: (- todo; + done)
-       + arm
-       + sh
-       + mips
-       - i386
-       - x86_64
-       - ...
+    *) NPTL
+       support arches: (o todo; + done)
+	o alpha
+	+ arm
+	o avr32
+	o bfin
+	o cris
+	o e1
+	o frv
+	o h8300
+	o hppa
+	+ i386
+	o i960
+	o ia64
+	o m68k
+	o microblaze
+	+ mips
+	o nios
+	o nios2
+	+ powerpc
+	+ sh
+	+ sh64
+	o sparc
+	o v850
+	o vax
+	o x86_64
+	o xtensa
+	o ...
     *) Go through SUSv4
        TOC: http://www.opengroup.org/onlinepubs/9699919799/xrat/contents.html
        shell (busybox): http://www.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap01.html#tag_22_01_01
        interface:
          http://www.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap13.html#tag_21_13_02
          http://www.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap01.html#tag_23_01_01
-
-
-TODO list for the uClibc 0.9.29 release:
--------------------------------------------------
-    *) as many of the arch-specific issues as possible
-    *) Remove N instances of libc_hidden_proto() from uClibc internals.
-	Instead add internal only header(s) defining all hidden prototypes.
-	This will avoid clutter and guarantee prototype consistancy.
-    *) The __is*_l() functions were all removed, such that we now only export
-	the is*_l() functions (no prefix).  Before, we had the prefixed versions
-	for use by libstdc++ and weak versions without prefixes exported because
-	those functions belong to no std (unless you call glibc a std).  This should
-	be fixed.  Similar problems likely were created elsewhere.
-    *) misc stdio bugs:
-	http://bugs.uclibc.org/view.php?id=420
-	http://bugs.uclibc.org/view.php?id=539
-    *) bug in getopt handling:
-	http://bugs.uclibc.org/view.php?id=61
-	http://www.uclibc.org/lists/uclibc/2006-January/013851.html
-    *) Should integrate test subdir better ... need to propagate CPU
-	CFLAGS/LDFLAGS to the build/link for target binaries so that when we have
-	a multilib toolchain, the proper ABI is selected.
-
-
-TODO list for the uClibc 1.0.0 release:
--------------------------------------------------
     *) glob / fnmatch tests fail
     *) regex should pass AT&T conformance tests
     *) Finish hiding uClibc internal symbols from our exported namespace
@@ -80,8 +73,8 @@ TODO list for the uClibc 1.0.0 release:
 	and perhaps others (finalize list) produce a lib with a differing
 	ABI.  Make it so apps cannot use an ABI mis-matched uClibc.
 	This is most easily done using symbol versioning...
-    *) Implement the long double versions of math funcs
-	using wrappers on top of the double versions (size / precision
+    *) Implement the long double versions of math funcs on interrested
+        arches using wrappers on top of the double versions (size / precision
 	trade off where size clearly wins).
     *) Make all small objects (>~50 bytes) into either inlines or
 	into a static library

+ 1 - 1
extra/Configs/Config.arm

@@ -14,7 +14,7 @@ config FORCE_OPTIONS_FOR_ARCH
 
 choice
 	prompt "Target ABI"
-	default CONFIG_ARM_OABI
+	default CONFIG_ARM_EABI
 	help
 	  If you choose "EABI" here, functions and constants required by the
 	  ARM EABI will be built into the library.  You should choose "EABI"

+ 29 - 0
extra/Configs/Config.c6x

@@ -0,0 +1,29 @@
+#
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+
+config TARGET_ARCH
+	default "c6x"
+
+config FORCE_OPTIONS_FOR_ARCH
+	bool
+	default y
+	select ARCH_ANY_ENDIAN
+	select ARCH_HAS_NO_MMU
+
+choice
+	prompt "Target Processor Type"
+	default CONFIG_GENERIC_C6X
+
+config CONFIG_GENERIC_C6X
+	bool "Generic C6X DSP"
+
+config CONFIG_TMS320C64X
+	bool "TMS320C64X"
+
+config CONFIG_TMS320C64XPLUS
+	bool "TMS320C64X+"
+
+endchoice
+

+ 19 - 9
extra/Configs/Config.in

@@ -114,6 +114,9 @@ config TARGET_x86_64
 config TARGET_xtensa
 	bool "xtensa"
 
+config TARGET_c6x
+	bool "c6x"
+
 endchoice
 
 
@@ -219,6 +222,10 @@ if TARGET_xtensa
 source "extra/Configs/Config.xtensa"
 endif
 
+if TARGET_c6x
+source "extra/Configs/Config.c6x"
+endif
+
 config TARGET_SUBARCH
 	string
 	default "e500" if CONFIG_E500
@@ -685,6 +692,17 @@ config UCLIBC_SUSV4_LEGACY
 
 	  WARNING! ABI incompatibility.
 
+config UCLIBC_STRICT_HEADERS
+	bool "Enable structures and constants for unsupported features"
+	default n
+	help
+	  Enable structures and constants in headers that should not be used,
+	  because the respective feature is disabled.
+
+	  WARNING! enabling this option requires to patch many faulty apps,
+	  since they make (wrongly) use of these structures/constants,
+	  although the feature was disabled.
+
 config UCLIBC_HAS_STUBS
 	bool "Provide stubs for unavailable functionality"
 	default n
@@ -693,15 +711,6 @@ config UCLIBC_HAS_STUBS
 	  functions which are impossible to implement on the target
 	  architecture. Otherwise, such functions are simply omitted.
 
-	  As of 2008-07, this option makes uClibc provide fork() stub
-	  on NOMMU targets. It always sets errno to ENOSYS and returns -1.
-
-	  This may be useful if you port a lot of software and cannot
-	  audit all of it and replace or disable fork() usage.
-	  With this option, a program which uses fork() will build
-	  successfully. Of course, it may be useless if fork()
-	  is essential for its operation.
-
 config UCLIBC_HAS_SHADOW
 	bool "Shadow Password Support"
 	default y
@@ -1525,6 +1534,7 @@ config UCLIBC_HAS_GLIBC_CUSTOM_PRINTF
 	help
 	  Answer Y to support glibc's register_printf_function() to allow an
 	  application to add its own printf conversion specifiers.
+	  parse_printf_format() is also enabled.
 
 	  NOTE: Limits the number or registered specifiers to 10.
 	  NOTE: Requires new conversion specifiers to be ASCII

+ 5 - 1
extra/Configs/Config.in.arch

@@ -15,7 +15,11 @@ config UCLIBC_FORMAT_ELF
 	depends on ARCH_USE_MMU
 config UCLIBC_FORMAT_FDPIC_ELF
 	bool "FDPIC ELF"
-	depends on !ARCH_USE_MMU
+	depends on !ARCH_USE_MMU && (TARGET_bfin || TARGET_frv)
+	select DOPIC
+config UCLIBC_FORMAT_DSBT_ELF
+	bool "DBST ELF"
+	depends on !ARCH_USE_MMU && TARGET_c6x
 	select DOPIC
 config UCLIBC_FORMAT_FLAT
 	bool "STATIC FLAT"

+ 0 - 1
extra/Configs/Config.sh

@@ -41,7 +41,6 @@ config CONFIG_SH3
 	bool "SH3"
 
 config CONFIG_SH4
-	select FORCE_SHAREABLE_TEXT_SEGMENTS
 	bool "SH4"
 
 endchoice

+ 2 - 0
include/alloca.h

@@ -67,6 +67,8 @@ extern void *alloca (size_t __size) __THROW;
 #  define extend_alloca(buf, len, newlen) \
    alloca (((len) = (newlen)))
 # endif
+
+extern int __libc_alloca_cutoff (size_t size);
 #endif
 
 __END_DECLS

+ 0 - 7
include/ctype.h

@@ -345,22 +345,15 @@ libc_hidden_proto(isascii_l)
 # endif
 
 /* Return the lowercase version of C in locale L.  */
-/* "ordinary" ctype.h has no __tolower, why we try to have it?
- * remove after 0.9.31
- *extern int __tolower_l (int __c, __locale_t __l) __THROW; */
 extern int tolower_l (int __c, __locale_t __l) __THROW;
 libc_hidden_proto(tolower_l)
 
 /* Return the uppercase version of C.  */
-/*extern int __toupper_l (int __c, __locale_t __l) __THROW; */
 extern int toupper_l (int __c, __locale_t __l) __THROW;
-libc_hidden_proto(toupper_l)
 
 # if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
 #  define tolower_l(c, locale) __tobody(c, tolower_l, (locale)->__ctype_tolower, (c, locale))
 #  define toupper_l(c, locale) __tobody(c, toupper_l, (locale)->__ctype_toupper, (c, locale))
-/*#  define __tolower_l(c, locale) tolower_l((c), (locale)) */
-/*#  define __toupper_l(c, locale) toupper_l((c), (locale)) */
 # endif	/* Optimizing gcc */
 
 

+ 45 - 0
include/elf.h

@@ -268,6 +268,7 @@ typedef struct
 #define EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
 #define EM_CRX		114		/* National Semiconductor CRX */
 #define EM_NUM		95
+#define EM_TI_C6000	140
 
 /* If it is necessary to assign new unofficial EM_* values, please pick large
    random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision
@@ -3063,6 +3064,50 @@ typedef Elf32_Addr Elf32_Conflict;
 /* Keep this the last entry.  */
 #define R_XTENSA_NUM		50
 
+/* C6X specific relocs */
+#define R_C6000_NONE		0
+#define R_C6000_ABS32		1
+#define R_C6000_ABS16		2
+#define R_C6000_ABS8		3
+#define R_C6000_PCR_S21		4
+#define R_C6000_PCR_S12		5
+#define R_C6000_PCR_S10		6
+#define R_C6000_PCR_S7		7
+#define R_C6000_ABS_S16		8
+#define R_C6000_ABS_L16		9
+#define R_C6000_ABS_H16		10
+#define R_C6000_SBR_U15_B	11
+#define R_C6000_SBR_U15_H	12
+#define R_C6000_SBR_U15_W	13
+#define R_C6000_SBR_S16		14
+#define R_C6000_SBR_L16_B	15
+#define R_C6000_SBR_L16_H	16
+#define R_C6000_SBR_L16_W	17
+#define R_C6000_SBR_H16_B	18
+#define R_C6000_SBR_H16_H	19
+#define R_C6000_SBR_H16_W	20
+#define R_C6000_SBR_GOT_U15_W	21
+#define R_C6000_SBR_GOT_L16_W	22
+#define R_C6000_SBR_GOT_H16_W	23
+#define R_C6000_DSBT_INDEX	24
+#define R_C6000_PREL31		25
+#define R_C6000_COPY		26
+#define R_C6000_JUMP_SLOT	27
+#define R_C6000_SBR_GOT32	28
+#define R_C6000_PCR_H16		29
+#define R_C6000_PCR_L16		30
+#define R_C6000_ALIGN		253
+#define R_C6000_FPHEAD		254
+#define R_C6000_NOCMP		255
+
+/* C6x specific values for the Dyn d_tag field.  */
+#define DT_C6000_DSBT_BASE	(DT_LOPROC + 0)
+#define DT_C6000_DSBT_SIZE	(DT_LOPROC + 1)
+#define DT_C6000_PREEMPTMAP	(DT_LOPROC + 2)
+#define DT_C6000_DSBT_INDEX	(DT_LOPROC + 3)
+
+#define DT_C6000_NUM    4
+
 #ifdef	__cplusplus
 }
 #endif

+ 7 - 5
include/errno.h

@@ -58,7 +58,12 @@ extern const char *program_invocation_name, *program_invocation_short_name;
 
 __END_DECLS
 
-#if defined _LIBC && defined __UCLIBC_HAS_TLS__
+#ifdef _LIBC
+#ifdef IS_IN_rtld
+# undef errno
+# define errno _dl_errno
+extern int _dl_errno; /* attribute_hidden */
+#elif defined __UCLIBC_HAS_TLS__
 # if !defined NOT_IN_libc || defined IS_IN_libpthread
 #  undef errno
 #  ifndef NOT_IN_libc
@@ -73,10 +78,7 @@ extern __thread int errno attribute_tls_model_ie;
 #ifndef __set_errno
 #define __set_errno(val) (errno = (val))
 #endif
-
-#ifndef __ASSEMBLER__
-extern int *__errno_location (void) __THROW __attribute__ ((__const__));
-#endif
+#endif /* _LIBC */
 
 #endif /* _ERRNO_H */
 

+ 3 - 0
include/fcntl.h

@@ -234,7 +234,10 @@ extern int posix_fallocate64 (int __fd, __off64_t __offset, __off64_t __len);
 # endif
 #endif
 
+#ifdef _LIBC
 extern int __fcntl_nocancel (int fd, int cmd, ...);
+libc_hidden_proto(__fcntl_nocancel)
+#endif
 
 __END_DECLS
 

+ 5 - 2
include/features.h

@@ -198,9 +198,12 @@
 # define __OPTIMIZE_SIZE__   1
 
 /* disable unsupported features */
-# undef _FORTIFY_SOURCE
 # undef __LDBL_COMPAT
 
+# ifndef __UCLIBC_HAS_FORTIFY__
+#  undef _FORTIFY_SOURCE
+# endif
+
 # ifndef __UCLIBC_HAS_THREADS__
 #  if defined _REENTRANT || defined _THREAD_SAFE
 #   warning requested reentrant code, but thread support was disabled
@@ -433,7 +436,7 @@ uClibc was built without large file support enabled.
  */
 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
     && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \
-    && (defined __extern_inline || defined __GNUC_GNU_INLINE__)
+    && (defined __extern_inline || defined __GNUC_GNU_INLINE__ || defined __GNUC_STDC_INLINE__)
 # define __USE_EXTERN_INLINES	1
 #endif
 

+ 2 - 2
include/ftw.h

@@ -129,7 +129,7 @@ typedef int (*__nftw64_func_t) (__const char *__filename,
 # endif
 #endif
 
-#if __UCLIBC_HAS_FTW__
+#ifdef __UCLIBC_HAS_FTW__
 /* Call a function on every element in a directory tree.
 
    This function is a possible cancellation point and therefore not
@@ -151,7 +151,7 @@ extern int ftw64 (__const char *__dir, __ftw64_func_t __func,
 # endif
 #endif
 
-#if __UCLIBC_HAS_NFTW__ && defined __USE_XOPEN_EXTENDED
+#if defined __UCLIBC_HAS_NFTW__ && defined __USE_XOPEN_EXTENDED
 /* Call a function on every element in a directory tree.  FLAG allows
    to specify the behaviour more detailed.
 

+ 4 - 3
include/langinfo.h

@@ -1,5 +1,5 @@
 /* Access to locale-dependent parameters.
-   Copyright (C) 1995-2002,2003,2004,2005 Free Software Foundation, Inc.
+   Copyright (C) 1995-2002,2003,2004,2005,2009 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
@@ -352,6 +352,7 @@ enum
   _NL_CTYPE_TRANSLIT_IGNORE_LEN,
   _NL_CTYPE_TRANSLIT_IGNORE,
   _NL_CTYPE_MAP_TO_NONASCII,
+  _NL_CTYPE_NONASCII_CASE,
   _NL_CTYPE_EXTRA_MAP_1,
   _NL_CTYPE_EXTRA_MAP_2,
   _NL_CTYPE_EXTRA_MAP_3,
@@ -620,7 +621,7 @@ extern char *nl_langinfo (nl_item __item) __THROW;
 libc_hidden_proto(nl_langinfo)
 
 
-#if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
+#if defined __USE_XOPEN2K && defined __UCLIBC_HAS_XLOCALE__
 /* This interface is for the extended locale model.  See <locale.h> for
    more information.  */
 
@@ -628,7 +629,7 @@ libc_hidden_proto(nl_langinfo)
 # include <xlocale.h>
 
 /* Just like nl_langinfo but get the information from the locale object L.  */
-extern char *nl_langinfo_l (nl_item __item, __locale_t l);
+extern char *nl_langinfo_l (nl_item __item, __locale_t __l);
 libc_hidden_proto(nl_langinfo_l)
 #endif
 

+ 5 - 0
include/libc-internal.h

@@ -65,6 +65,11 @@ libc_hidden_proto(__glibc_strerror_r)
 /* internal access to program name */
 extern const char *__uclibc_progname attribute_hidden;
 
+#  ifdef __UCLIBC_HAS_FORTIFY__
+extern void __chk_fail(void) attribute_noreturn;
+libc_hidden_proto(__chk_fail)
+#  endif
+
 # endif /* IS_IN_libc */
 
 #endif /* __ASSEMBLER__ */

+ 0 - 5
include/libintl.h

@@ -34,11 +34,6 @@
 
 __BEGIN_DECLS
 
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning "mjn3 FIXME: gettext has a prototype but isn't defined."
-#warning "mjn3 FIXME: __OPTIMIZE__ is never defined."
-#endif
-
 /* Look up MSGID in the current default message catalog for the current
    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
    text).  */

+ 12 - 1
include/link.h

@@ -1,6 +1,6 @@
 /* Data structure for communication from the run-time dynamic linker for
    loaded ELF shared objects.
-   Copyright (C) 1995-2001, 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1995-2001, 2004, 2005, 2006, 2010 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
@@ -83,6 +83,9 @@ extern ElfW(Dyn) _DYNAMIC[];
 #ifdef __FDPIC__
 # include <bits/elf-fdpic.h>
 #endif
+#ifdef __DSBT__
+# include <bits/elf-dsbt.h>
+#endif
 
 /* Structure describing a loaded shared object.  The `l_next' and `l_prev'
    members form a chain of all the shared objects loaded at startup.
@@ -97,8 +100,12 @@ struct link_map
 
 #ifdef __FDPIC__
     struct elf32_fdpic_loadaddr l_addr;
+#else
+#ifdef __DSBT__
+    struct elf32_dsbt_loadaddr l_addr;
 #else
     ElfW(Addr) l_addr;		/* Base address shared object is loaded at.  */
+#endif
 #endif
     char *l_name;		/* Absolute file name object was found in.  */
     ElfW(Dyn) *l_ld;		/* Dynamic section of the shared object.  */
@@ -177,8 +184,12 @@ struct dl_phdr_info
   {
 #ifdef __FDPIC__
     struct elf32_fdpic_loadaddr dlpi_addr;
+#else
+#ifdef __DSBT__
+    struct elf32_dsbt_loadaddr dlpi_addr;
 #else
     ElfW(Addr) dlpi_addr;
+#endif
 #endif
     const char *dlpi_name;
     const ElfW(Phdr) *dlpi_phdr;

+ 3 - 6
include/locale.h

@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,92,95-99,2000,01,02 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1992,1995-2002,2007,2009 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
@@ -133,7 +133,7 @@ libc_hidden_proto(localeconv)
 __END_NAMESPACE_STD
 
 
-#if defined __USE_GNU && defined __UCLIBC_HAS_LOCALE__
+#if defined __USE_XOPEN2K8 && defined __UCLIBC_HAS_LOCALE__
 /* The concept of one static locale per category is not very well
    thought out.  Many applications will need to process its data using
    information from several different locales.  Another application is
@@ -150,6 +150,7 @@ __END_NAMESPACE_STD
 # include <xlocale.h>
 #endif
 
+/* POSIX 2008 makes locale_t official.  */
 typedef __locale_t locale_t;
 
 /* Return a reference to a data structure representing a set of locale
@@ -170,9 +171,6 @@ libc_hidden_proto(newlocale)
 # define LC_COLLATE_MASK	(1 << __LC_COLLATE)
 # define LC_MONETARY_MASK	(1 << __LC_MONETARY)
 # define LC_MESSAGES_MASK	(1 << __LC_MESSAGES)
-#ifdef L_newlocale
-#warning mask defines for extra locale categories
-#endif /* L_newlocale - uClibc note */
 #ifdef LC_PAPER
 # define LC_PAPER_MASK		(1 << __LC_PAPER)
 # define LC_NAME_MASK		(1 << __LC_NAME)
@@ -206,7 +204,6 @@ libc_hidden_proto(newlocale)
 /* Return a duplicate of the set of locale in DATASET.  All usage
    counters are increased if necessary.  */
 extern __locale_t duplocale (__locale_t __dataset) __THROW;
-libc_hidden_proto(duplocale)
 
 /* Free the data associated with a locale dataset previously returned
    by a call to `setlocale_r'.  */

+ 3 - 1
include/net/if_arp.h

@@ -1,5 +1,5 @@
 /* Definitions for Address Resolution Protocol.
-   Copyright (C) 1997,1999,2001,2006 Free Software Foundation, Inc.
+   Copyright (C) 1997,1999,2001,2006,2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -128,6 +128,8 @@ struct arphdr
 #define ARPHRD_IEEE80211 801		/* IEEE 802.11.  */
 #define ARPHRD_IEEE80211_PRISM 802	/* IEEE 802.11 + Prism2 header.  */
 #define ARPHRD_IEEE80211_RADIOTAP 803	/* IEEE 802.11 + radiotap header.  */
+#define ARPHRD_IEEE802154 804		/* IEEE 802.15.4 header.  */
+#define ARPHRD_IEEE802154_PHY 805	/* IEEE 802.15.4 PHY header.  */
 
 #define ARPHRD_VOID	  0xFFFF	/* Void type, nothing is known.  */
 #define ARPHRD_NONE	  0xFFFE	/* Zero header length.  */

+ 4 - 0
include/net/route.h

@@ -55,6 +55,7 @@ struct rtentry
 #define rt_mss	rt_mtu
 
 
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
 struct in6_rtmsg
   {
     struct in6_addr rtmsg_dst;
@@ -68,6 +69,7 @@ struct in6_rtmsg
     u_int32_t rtmsg_flags;
     int rtmsg_ifindex;
   };
+#endif
 
 
 #define	RTF_UP		0x0001		/* Route usable.  */
@@ -129,6 +131,7 @@ struct in6_rtmsg
 #define RT_CLASS_MAX		255
 
 
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
 #define RTMSG_ACK		NLMSG_ACK
 #define RTMSG_OVERRUN		NLMSG_OVERRUN
 
@@ -141,5 +144,6 @@ struct in6_rtmsg
 #define RTMSG_CONTROL		0x40
 
 #define RTMSG_AR_FAILED		0x51	/* Address Resolution failed.  */
+#endif
 
 #endif /* net/route.h */

+ 0 - 1
include/netinet/ether.h

@@ -45,7 +45,6 @@ extern struct ether_addr *ether_aton_r (__const char *__asc,
 					struct ether_addr *__addr) __THROW;
 libc_hidden_proto(ether_aton_r)
 
-
 /* Map 48 bit Ethernet number ADDR to HOSTNAME.  */
 extern int ether_ntohost (char *__hostname, __const struct ether_addr *__addr)
      __THROW;

+ 2 - 2
include/netinet/icmp6.h

@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1997,2000,2006 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1997,2000,2006,2009 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
@@ -339,7 +339,7 @@ struct nd_opt_home_agent_info
     uint8_t   nd_opt_home_agent_info_type;
     uint8_t   nd_opt_home_agent_info_len;
     uint16_t  nd_opt_home_agent_info_reserved;
-    int16_t   nd_opt_home_agent_info_preference;
+    uint16_t  nd_opt_home_agent_info_preference;
     uint16_t  nd_opt_home_agent_info_lifetime;
   };
 

+ 25 - 6
include/netinet/in.h

@@ -194,6 +194,7 @@ struct in_addr
 #define INADDR_MAX_LOCAL_GROUP  ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */
 
 
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
 /* IPv6 address */
 struct in6_addr
   {
@@ -212,14 +213,19 @@ struct in6_addr
 #endif
   };
 
+#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
+#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
+
+#define INET6_ADDRSTRLEN 46
+#endif
+
+#ifdef __UCLIBC_HAS_IPV6__
 extern const struct in6_addr in6addr_any;        /* :: */
 extern const struct in6_addr in6addr_loopback;   /* ::1 */
 libc_hidden_proto(in6addr_loopback)
-#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
-#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
+#endif
 
 #define INET_ADDRSTRLEN 16
-#define INET6_ADDRSTRLEN 46
 
 
 #if 1 /*def __UCLIBC_HAS_IPV4__*/
@@ -238,6 +244,7 @@ struct sockaddr_in
   };
 #endif
 
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
 /* Ditto, for IPv6.  */
 struct sockaddr_in6
   {
@@ -247,6 +254,7 @@ struct sockaddr_in6
     struct in6_addr sin6_addr;	/* IPv6 address */
     uint32_t sin6_scope_id;	/* IPv6 scope-id */
   };
+#endif
 
 
 #if defined __USE_MISC || defined __USE_GNU
@@ -274,6 +282,7 @@ struct ip_mreq_source
 #endif
 
 
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
 /* Likewise, for IPv6.  */
 struct ipv6_mreq
   {
@@ -283,6 +292,7 @@ struct ipv6_mreq
     /* local interface */
     unsigned int ipv6mr_interface;
   };
+#endif
 
 
 #if defined __USE_MISC || defined __USE_GNU
@@ -403,6 +413,7 @@ libc_hidden_proto(htons)
 # endif
 #endif
 
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
 #define IN6_IS_ADDR_UNSPECIFIED(a) \
 	(((__const uint32_t *) (a))[0] == 0				      \
 	 && ((__const uint32_t *) (a))[1] == 0				      \
@@ -441,6 +452,7 @@ libc_hidden_proto(htons)
 	 && (((__const uint32_t *) (a))[1] == ((__const uint32_t *) (b))[1])  \
 	 && (((__const uint32_t *) (a))[2] == ((__const uint32_t *) (b))[2])  \
 	 && (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3]))
+#endif
 
 #if defined __USE_MISC || defined __USE_GNU
 /* Bind socket to a privileged IP port.  */
@@ -455,6 +467,7 @@ extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in)
 #endif
 
 
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
 #define IN6_IS_ADDR_MC_NODELOCAL(a) \
 	(IN6_IS_ADDR_MULTICAST(a)					      \
 	 && ((((__const uint8_t *) (a))[1] & 0xf) == 0x1))
@@ -474,9 +487,11 @@ extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in)
 #define IN6_IS_ADDR_MC_GLOBAL(a) \
 	(IN6_IS_ADDR_MULTICAST(a)					      \
 	 && ((((__const uint8_t *) (a))[1] & 0xf) == 0xe))
+#endif
 
 
-#if defined __USE_GNU && defined __UCLIBC_HAS_IPV6__
+#ifdef __USE_GNU
+# if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
 /* IPv6 packet information.  */
 struct in6_pktinfo
   {
@@ -490,9 +505,9 @@ struct ip6_mtuinfo
     struct sockaddr_in6 ip6m_addr; /* dst address including zone ID */
     uint32_t ip6m_mtu;		   /* path MTU in host byte order */
   };
-#endif
-#if 0 /*def __USE_GNU*/
 
+
+#  if 0
 /* Obsolete hop-by-hop and Destination Options Processing (RFC 2292).  */
 extern int inet6_option_space (int __nbytes)
      __THROW __attribute_deprecated__;
@@ -540,8 +555,11 @@ extern int inet6_rth_reverse (__const void *__in, void *__out) __THROW;
 extern int inet6_rth_segments (__const void *__bp) __THROW;
 extern struct in6_addr *inet6_rth_getaddr (__const void *__bp, int __index)
      __THROW;
+#  endif
+# endif
 
 
+# if 0
 /* Multicast source filter support.  */
 
 /* Get IPv4 source filter.  */
@@ -571,6 +589,7 @@ extern int setsourcefilter (int __s, uint32_t __interface_addr,
 			    socklen_t __grouplen, uint32_t __fmode,
 			    uint32_t __numsrc,
 			    __const struct sockaddr_storage *__slist) __THROW;
+# endif
 #endif	/* use GNU */
 
 __END_DECLS

+ 37 - 1
include/netinet/ip.h

@@ -1,4 +1,5 @@
-/* Copyright (C) 1991,92,93,95,96,97,98,99,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,95,96,97,98,99,2000,2009 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
@@ -152,6 +153,41 @@ struct ip_timestamp
 #define	IPVERSION	4               /* IP version number */
 #define	IP_MAXPACKET	65535		/* maximum packet size */
 
+/*
+ * Definitions for Explicit Congestion Notification (ECN)
+ *
+ * Taken from RFC-3168, Section 5.
+ */
+
+#define	IPTOS_ECN_MASK		0x03
+#define	IPTOS_ECN(x)		((x) & IPTOS_ECN_MASK)
+#define	IPTOS_ECN_NOT_ECT	0x00
+#define	IPTOS_ECN_ECT1		0x01
+#define	IPTOS_ECN_ECT0		0x02
+#define	IPTOS_ECN_CE		0x03
+
+/*
+ * Definitions for IP differentiated services code points (DSCP)
+ *
+ * Taken from RFC-2597, Section 6 and RFC-2598, Section 2.3.
+ */
+
+#define	IPTOS_DSCP_MASK		0xfc
+#define	IPTOS_DSCP(x)		((x) & IPTOS_DSCP_MASK)
+#define	IPTOS_DSCP_AF11		0x28
+#define	IPTOS_DSCP_AF12		0x30
+#define	IPTOS_DSCP_AF13		0x38
+#define	IPTOS_DSCP_AF21		0x48
+#define	IPTOS_DSCP_AF22		0x50
+#define	IPTOS_DSCP_AF23		0x58
+#define	IPTOS_DSCP_AF31		0x68
+#define	IPTOS_DSCP_AF32		0x70
+#define	IPTOS_DSCP_AF33		0x78
+#define	IPTOS_DSCP_AF41		0x88
+#define	IPTOS_DSCP_AF42		0x90
+#define	IPTOS_DSCP_AF43		0x98
+#define	IPTOS_DSCP_EF		0xb8
+
 /*
  * Definitions for IP type of service (ip_tos)
  */

+ 11 - 1
include/netinet/udp.h

@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 95, 96, 97, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1993,1995-1997,2004,2009 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
@@ -74,6 +74,16 @@ struct udphdr
 };
 #endif
 
+/* UDP socket options */
+#define UDP_CORK	1	/* Never send partially complete segments.  */
+#define UDP_ENCAP	100	/* Set the socket to accept
+				   encapsulated packets.  */
+
+/* UDP encapsulation types */
+#define UDP_ENCAP_ESPINUDP_NON_IKE 1	/* draft-ietf-ipsec-nat-t-ike-00/01 */
+#define UDP_ENCAP_ESPINUDP	2	/* draft-ietf-ipsec-udp-encaps-06 */
+#define UDP_ENCAP_L2TPINUDP	3	/* rfc2661 */
+
 #define SOL_UDP            17      /* sockopt level for UDP */
 
 #endif /* netinet/udp.h */

+ 4 - 0
include/nl_types.h

@@ -21,11 +21,13 @@
 
 #include <features.h>
 
+#ifndef __UCLIBC_STRICT_HEADERS__
 /* The default message set used by the gencat program.  */
 #define NL_SETD 1
 
 /* Value for FLAG parameter of `catgets' to say we want XPG4 compliance.  */
 #define NL_CAT_LOCALE 1
+#endif
 
 
 __BEGIN_DECLS
@@ -34,8 +36,10 @@ __BEGIN_DECLS
 #warning "mjn3 FIXME: None of these prototypes have implementations."
 #endif
 
+#ifndef __UCLIBC_STRICT_HEADERS__
 /* Message catalog descriptor type.  */
 typedef void *nl_catd;
+#endif
 
 /* Type used by `nl_langinfo'.  */
 typedef int nl_item;

+ 1 - 0
include/paths.h

@@ -44,6 +44,7 @@
 #define	_PATH_DEVDB	"/var/run/dev.db"
 #define	_PATH_DEVNULL	"/dev/null"
 #define	_PATH_DRUM	"/dev/drum"
+#define	_PATH_GSHADOW	"/etc/gshadow"
 #define	_PATH_KLOG	"/proc/kmsg"
 #define	_PATH_KMEM	"/dev/kmem"
 #define	_PATH_LASTLOG	"/var/log/lastlog"

+ 1 - 0
include/protocols/timed.h

@@ -32,6 +32,7 @@
 #ifndef	_PROTOCOLS_TIMED_H
 #define	_PROTOCOLS_TIMED_H 1
 
+#include <features.h>
 #ifdef __UCLIBC_HAS_RPC__
 #include <rpc/types.h>
 #endif

+ 20 - 0
include/resolv.h

@@ -282,46 +282,61 @@ extern struct __res_state *__res_state(void) __attribute__ ((__const__));
 __END_DECLS
 #define _res (*__res_state())
 
+#if 0
 #define fp_nquery		__fp_nquery
 #define fp_query		__fp_query
 #define hostalias		__hostalias
 #define p_query			__p_query
+#endif
 #define res_close		__res_close
 #define res_init		__res_init
+#if 0
 #define res_isourserver		__res_isourserver
 #define res_mkquery		__res_mkquery
+#endif
 #define res_query		__res_query
 #define res_querydomain		__res_querydomain
 #define res_search		__res_search
+#if 0
 #define res_send		__res_send
+#endif
 
 __BEGIN_DECLS
+#if 0
 void		fp_nquery (const u_char *, int, FILE *) __THROW;
 void		fp_query (const u_char *, FILE *) __THROW;
 const char *	hostalias (const char *) __THROW;
 void		p_query (const u_char *) __THROW;
+#endif
 #ifdef __UCLIBC_HAS_BSD_RES_CLOSE__
 void		res_close (void) __THROW;
 #endif
 int		res_init (void) __THROW;
 libc_hidden_proto(res_init)
+#if 0
 int		res_isourserver (const struct sockaddr_in *) __THROW;
 int		res_mkquery (int, const char *, int, int, const u_char *,
 			     int, const u_char *, u_char *, int) __THROW;
+#endif
 int		res_query (const char *, int, int, u_char *, int) __THROW;
 libc_hidden_proto(res_query)
 int		res_querydomain (const char *, const char *, int, int,
 				 u_char *, int) __THROW;
 libc_hidden_proto(res_querydomain)
 int		res_search (const char *, int, int, u_char *, int) __THROW;
+#if 0
 int		res_send (const u_char *, int, u_char *, int) __THROW;
+#endif
 __END_DECLS
 
+#if 0
 #define b64_ntop		__b64_ntop
 #define b64_pton		__b64_pton
 #define dn_comp			__dn_comp
 #define dn_count_labels		__dn_count_labels
+#endif
 #define dn_expand		__dn_expand
+#if 0
 #define dn_skipname		__dn_skipname
 #define fp_resstat		__fp_resstat
 #define loc_aton		__loc_aton
@@ -359,7 +374,9 @@ __END_DECLS
 #define sym_ntop		__sym_ntop
 #define sym_ntos		__sym_ntos
 #define sym_ston		__sym_ston
+#endif
 __BEGIN_DECLS
+#if 0
 int		res_hnok (const char *) __THROW;
 int		res_ownok (const char *) __THROW;
 int		res_mailok (const char *) __THROW;
@@ -389,8 +406,10 @@ char *		p_secstodate (u_long) __THROW;
 int		dn_count_labels (const char *) __THROW;
 int		dn_comp (const char *, u_char *, int, u_char **, u_char **)
      __THROW;
+#endif
 int		dn_expand (const u_char *, const u_char *, const u_char *,
 			   char *, int) __THROW;
+#if 0
 u_int		res_randomid (void) __THROW;
 int		res_nameinquery (const char *, int, int,
 				 const u_char *, const u_char *) __THROW;
@@ -418,6 +437,7 @@ int		res_nmkquery (res_state, int, const char *, int, int,
 int		res_nsend (res_state, const u_char *, int, u_char *, int)
      __THROW;
 void		res_nclose (res_state) __THROW;
+#endif
 __END_DECLS
 
 # if _LIBC

+ 6 - 0
include/sgtty.h

@@ -19,21 +19,27 @@
 #ifndef	_SGTTY_H
 #define	_SGTTY_H	1
 
+#warning useless header on uClibc
+
 #include <features.h>
 
 #include <sys/ioctl.h>
 
+#ifndef __UCLIBC_STRICT_HEADERS__
 /* On some systems this type is not defined by <bits/ioctl-types.h>;
    in that case, the functions are just stubs that return ENOSYS.  */
 struct sgttyb;
+#endif
 
 __BEGIN_DECLS
 
+#if 0
 /* Fill in *PARAMS with terminal parameters associated with FD.  */
 extern int gtty (int __fd, struct sgttyb *__params) __THROW;
 
 /* Set the terminal parameters associated with FD to *PARAMS.  */
 extern int stty (int __fd, __const struct sgttyb *__params) __THROW;
+#endif
 
 
 __END_DECLS

+ 10 - 1
include/signal.h

@@ -310,6 +310,9 @@ extern int sigwait (__const sigset_t *__restrict __set, int *__restrict __sig)
    __THROW.  */
 extern int sigwaitinfo (__const sigset_t *__restrict __set,
 			siginfo_t *__restrict __info) __nonnull ((1));
+#ifdef _LIBC
+extern __typeof(sigwaitinfo) __sigwaitinfo attribute_hidden;
+#endif
 libc_hidden_proto(sigwaitinfo)
 
 /* Select any of pending signals from SET and place information in INFO.
@@ -321,6 +324,9 @@ extern int sigtimedwait (__const sigset_t *__restrict __set,
 			 siginfo_t *__restrict __info,
 			 __const struct timespec *__restrict __timeout)
      __nonnull ((1));
+#ifdef _LIBC
+extern __typeof(sigtimedwait) __sigtimedwait attribute_hidden;
+#endif
 libc_hidden_proto(sigtimedwait)
 
 /* Send signal SIG to the process PID.  Associate data in VAL with the
@@ -386,14 +392,17 @@ extern int siginterrupt (int __sig, int __interrupt) __THROW;
 # include <bits/sigstack.h>
 # ifdef __USE_XOPEN
 /* This will define `ucontext_t' and `mcontext_t'.  */
-#  include <ucontext.h>
+/* SuSv4 obsoleted include/ucontext.h */
+#  include <sys/ucontext.h>
 # endif
 
+# if 0
 /* Run signals handlers on the stack specified by SS (if not NULL).
    If OSS is not NULL, it is filled in with the old signal stack status.
    This interface is obsolete and on many platform not implemented.  */
 extern int sigstack (struct sigstack *__ss, struct sigstack *__oss)
      __THROW __attribute_deprecated__;
+# endif
 
 /* Alternate signal handler stack interface.
    This interface should always be preferred over `sigstack'.  */

+ 1 - 0
include/stdint.h

@@ -238,6 +238,7 @@ typedef unsigned long long int	uintmax_t;
 #  define UINTPTR_MAX		(4294967295U)
 # endif
 
+
 #if !defined(__H8300H__) && !defined(__H8300S__)
 /* Minimum for largest signed integral type.  */
 # define INTMAX_MIN		(-__INT64_C(9223372036854775807)-1)

+ 0 - 1
include/stdio.h

@@ -450,7 +450,6 @@ libc_hidden_proto(vfscanf)
    marked with __THROW.  */
 extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg)
      __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
-libc_hidden_proto(vscanf)
 
 /* Read formatted input from S into argument list ARG.  */
 extern int vsscanf (__const char *__restrict __s,

+ 36 - 19
include/stdlib.h

@@ -50,9 +50,9 @@ __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))
 #  endif
@@ -143,9 +143,11 @@ __END_NAMESPACE_C99
 extern size_t __ctype_get_mb_cur_max (void) __THROW __wur;
 #else
 #ifdef __UCLIBC_HAS_WCHAR__
-#define	MB_CUR_MAX	(_stdlib_mb_cur_max ())
+# define	MB_CUR_MAX	(_stdlib_mb_cur_max ())
 extern size_t _stdlib_mb_cur_max (void) __THROW __wur;
 libc_hidden_proto(_stdlib_mb_cur_max)
+#else
+# define	MB_CUR_MAX	1
 #endif
 #endif
 
@@ -163,7 +165,6 @@ libc_hidden_proto(atoi)
 /* Convert a string to a long integer.  */
 extern long int atol (__const char *__nptr)
      __THROW __attribute_pure__ __nonnull ((1)) __wur;
-libc_hidden_proto(atol)
 __END_NAMESPACE_STD
 
 #if defined __USE_ISOC99 || defined __USE_MISC
@@ -244,14 +245,14 @@ __END_NAMESPACE_C99
 #if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
 /* The concept of one static locale per category is not very well
    thought out.  Many applications will need to process its data using
-   information from several different locales.  Another application is
+   information from several different locales.  Another problem is
    the implementation of the internationalization handling in the
-   upcoming ISO C++ standard library.  To support this another set of
-   the functions using locale data exist which have an additional
+   ISO C++ standard library.  To support this another set of
+   the functions using locale data exist which take an additional
    argument.
 
-   Attention: all these functions are *not* standardized in any form.
-   This is a proof-of-concept implementation.  */
+   Attention: even though several *_l interfaces are part of POSIX:2008,
+   these are not.  */
 
 /* Structure for reentrant locale using functions.  This is an
    (almost) opaque type for the user level programs.  */
@@ -347,10 +348,16 @@ struct random_data
     int32_t *fptr;		/* Front pointer.  */
     int32_t *rptr;		/* Rear pointer.  */
     int32_t *state;		/* Array of state values.  */
+#if 0
+    int rand_type;		/* Type of random number generator.  */
+    int rand_deg;		/* Degree of random number generator.  */
+    int rand_sep;		/* Distance between front and rear.  */
+#else
     /* random_r.c, TYPE_x, DEG_x, SEP_x - small enough for int8_t */
     int8_t rand_type;		/* Type of random number generator.  */
     int8_t rand_deg;		/* Degree of random number generator.  */
     int8_t rand_sep;		/* Distance between front and rear.  */
+#endif
     int32_t *end_ptr;		/* Pointer behind state table.  */
   };
 
@@ -540,7 +547,7 @@ extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
 
 __BEGIN_NAMESPACE_STD
 /* Call all functions registered with `atexit' and `on_exit',
-   in the reverse of the order in which they were registered
+   in the reverse of the order in which they were registered,
    perform stdio cleanup, and terminate program execution with STATUS.  */
 extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
 libc_hidden_proto(exit)
@@ -619,7 +626,7 @@ extern char *mktemp (char *__template) __THROW __nonnull ((1)) __wur;
    Returns a file descriptor open on the file for reading and writing,
    or -1 if it cannot create a uniquely-named file.
 
-   This function is a possible cancellation points and therefore not
+   This function is a possible cancellation point and therefore not
    marked with __THROW.  */
 # ifndef __USE_FILE_OFFSET64
 extern int mkstemp (char *__template) __nonnull ((1)) __wur;
@@ -636,7 +643,7 @@ extern int mkstemp64 (char *__template) __nonnull ((1)) __wur;
 # endif
 #endif
 
-#ifdef __USE_BSD
+#if defined __USE_BSD || defined __USE_XOPEN2K8
 /* Create a unique temporary directory from TEMPLATE.
    The last six characters of TEMPLATE must be "XXXXXX";
    they are replaced with a string that makes the directory name unique.
@@ -662,14 +669,17 @@ extern char *canonicalize_file_name (__const char *__name)
      __THROW __nonnull ((1)) __wur;
 #endif
 
-/* Return the canonical absolute name of file NAME. If the
-   canonical name is PATH_MAX chars or more, returns null
-   with `errno' set to ENAMETOOLONG; if the name fits in
-	 fewer than PATH_MAX chars, returns the name in RESOLVED. */
-/* we choose to handle __resolved==NULL as crash :) */
+#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
+/* Return the canonical absolute name of file NAME.  If RESOLVED is
+   null, the result is malloc'd; otherwise, if the canonical name is
+   PATH_MAX chars or more, returns null with `errno' set to
+   ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,
+   returns the name in RESOLVED.  */
 extern char *realpath (__const char *__restrict __name,
 		       char *__restrict __resolved) __THROW __wur;
 libc_hidden_proto(realpath)
+#endif
+
 
 /* Shorthand for type of comparison functions.  */
 #ifndef __COMPAR_FN_T
@@ -852,6 +862,7 @@ libc_hidden_proto(posix_openpt)
 #ifdef __USE_XOPEN
 /* The next four functions all take a master pseudo-tty fd and
    perform an operation on the associated slave:  */
+
 #ifdef __UCLIBC_HAS_PTY__
 /* Chown the slave to the calling user.  */
 extern int grantpt (int __fd) __THROW;
@@ -894,10 +905,16 @@ extern int getloadavg (double __loadavg[], int __nelem)
 #include <stdint.h>
 extern uint32_t arc4random(void);
 extern void arc4random_stir(void);
-libc_hidden_proto(arc4random_stir)
 extern void arc4random_addrandom(unsigned char *, int);
 #endif
 
+#ifdef _LIBC
+extern int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer) attribute_hidden;
+
+/* Global state for non-reentrant functions.  */
+extern struct drand48_data __libc_drand48_data attribute_hidden;
+#endif
+
 #endif /* don't just need malloc and calloc */
 #undef __need_malloc_and_calloc
 

+ 1 - 4
include/string.h

@@ -124,7 +124,6 @@ libc_hidden_proto(strcoll)
 extern size_t strxfrm (char *__restrict __dest,
 		       __const char *__restrict __src, size_t __n)
      __THROW __nonnull ((2));
-libc_hidden_proto(strxfrm)
 __END_NAMESPACE_STD
 
 #if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
@@ -257,7 +256,6 @@ libc_hidden_proto(strcasestr)
 extern void *memmem (__const void *__haystack, size_t __haystacklen,
 		     __const void *__needle, size_t __needlelen)
      __THROW __attribute_pure__ __nonnull ((1, 3));
-libc_hidden_proto(memmem)
 
 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
    last written byte.  */
@@ -378,7 +376,7 @@ libc_hidden_proto(ffs)
 
 /* The following two functions are non-standard but necessary for non-32 bit
    platforms.  */
-# if 0 /*#ifdef __USE_GNU*/
+#ifdef __USE_GNU
 extern int ffsl (long int __l) __THROW __attribute__ ((__const__));
 #  ifdef __GNUC__
 __extension__ extern int ffsll (long long int __ll)
@@ -449,7 +447,6 @@ extern char *__stpncpy (char *__restrict __dest,
 extern char *stpncpy (char *__restrict __dest,
 		      __const char *__restrict __src, size_t __n)
      __THROW __nonnull ((1, 2));
-libc_hidden_proto(stpncpy)
 
 # if 0			/* uClibc does not support strfry or memfrob. */
 /* Sautee STRING briskly.  */

+ 13 - 17
include/sys/wait.h

@@ -1,5 +1,5 @@
-/* Copyright (C) 1991-1994,1996-2001,2003,2004,2005
-	Free Software Foundation, Inc.
+/* Copyright (C) 1991-1994,1996-2001,2003,2004,2005,2007,2009
+   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
@@ -51,7 +51,7 @@ __BEGIN_DECLS
 #  endif
 
 /* This is the type of the argument to `wait'.  The funky union
-   causes redeclarations with ether `int *' or `union wait *' to be
+   causes redeclarations with either `int *' or `union wait *' to be
    allowed without complaint.  __WAIT_STATUS_DEFN is the type used in
    the actual function definitions.  */
 
@@ -79,22 +79,22 @@ typedef union
 /* This will define all the `__W*' macros.  */
 # include <bits/waitstatus.h>
 
-# define WEXITSTATUS(status)	__WEXITSTATUS(__WAIT_INT(status))
-# define WTERMSIG(status)	__WTERMSIG(__WAIT_INT(status))
-# define WSTOPSIG(status)	__WSTOPSIG(__WAIT_INT(status))
-# define WIFEXITED(status)	__WIFEXITED(__WAIT_INT(status))
-# define WIFSIGNALED(status)	__WIFSIGNALED(__WAIT_INT(status))
-# define WIFSTOPPED(status)	__WIFSTOPPED(__WAIT_INT(status))
+# define WEXITSTATUS(status)	__WEXITSTATUS (__WAIT_INT (status))
+# define WTERMSIG(status)	__WTERMSIG (__WAIT_INT (status))
+# define WSTOPSIG(status)	__WSTOPSIG (__WAIT_INT (status))
+# define WIFEXITED(status)	__WIFEXITED (__WAIT_INT (status))
+# define WIFSIGNALED(status)	__WIFSIGNALED (__WAIT_INT (status))
+# define WIFSTOPPED(status)	__WIFSTOPPED (__WAIT_INT (status))
 # ifdef __WIFCONTINUED
-#  define WIFCONTINUED(status)	__WIFCONTINUED(__WAIT_INT(status))
+#  define WIFCONTINUED(status)	__WIFCONTINUED (__WAIT_INT (status))
 # endif
 #endif	/* <stdlib.h> not included.  */
 
 #ifdef	__USE_BSD
 # define WCOREFLAG		__WCOREFLAG
-# define WCOREDUMP(status)	__WCOREDUMP(__WAIT_INT(status))
-# define W_EXITCODE(ret, sig)	__W_EXITCODE(ret, sig)
-# define W_STOPCODE(sig)	__W_STOPCODE(sig)
+# define WCOREDUMP(status)	__WCOREDUMP (__WAIT_INT (status))
+# define W_EXITCODE(ret, sig)	__W_EXITCODE (ret, sig)
+# define W_STOPCODE(sig)	__W_STOPCODE (sig)
 #endif
 
 /* The following values are used by the `waitid' function.  */
@@ -172,10 +172,6 @@ extern __pid_t wait3 (__WAIT_STATUS __stat_loc, int __options,
 #endif
 
 #ifdef __USE_BSD
-/* This being here makes the prototypes valid whether or not
-   we have already included <sys/resource.h> to define `struct rusage'.  */
-struct rusage;
-
 /* PID is like waitpid.  Other args are like wait3.  */
 extern __pid_t wait4 (__pid_t __pid, __WAIT_STATUS __stat_loc, int __options,
 		      struct rusage *__usage) __THROW;

+ 0 - 2
include/time.h

@@ -207,7 +207,6 @@ extern time_t mktime (struct tm *__tp) __THROW;
 extern size_t strftime (char *__restrict __s, size_t __maxsize,
 			__const char *__restrict __format,
 			__const struct tm *__restrict __tp) __THROW;
-libc_hidden_proto(strftime)
 __END_NAMESPACE_STD
 
 # ifdef __USE_XOPEN
@@ -216,7 +215,6 @@ __END_NAMESPACE_STD
 extern char *strptime (__const char *__restrict __s,
 		       __const char *__restrict __fmt, struct tm *__tp)
      __THROW;
-libc_hidden_proto(strptime)
 # endif
 
 #ifdef __UCLIBC_HAS_XLOCALE__

+ 2 - 0
include/unistd.h

@@ -51,9 +51,11 @@ __BEGIN_DECLS
    Software Development Utilities Option.  */
 #define	_POSIX2_SW_DEV	200112L
 
+#if 0 /* uClibc does not provide the utility */
 /* If defined, the implementation supports the
    creation of locales with the localedef utility.  */
 #define _POSIX2_LOCALEDEF       200112L
+#endif
 
 /* X/Open version number to which the library conforms.  It is selectable.  */
 #ifdef __USE_UNIX98

+ 0 - 1
include/wchar-stub.h

@@ -7,7 +7,6 @@
 #ifndef _WCHAR_H
 #define _WCHAR_H
 
-#define MB_CUR_MAX 1
 typedef unsigned int wint_t;
 #define WEOF (0xffffffffu)
 

+ 5 - 7
include/wchar.h

@@ -170,12 +170,10 @@ __END_NAMESPACE_C99
 #ifdef __USE_GNU
 /* Compare S1 and S2, ignoring case.  */
 extern int wcscasecmp (__const wchar_t *__s1, __const wchar_t *__s2) __THROW;
-libc_hidden_proto(wcscasecmp)
 
 /* Compare no more than N chars of S1 and S2, ignoring case.  */
 extern int wcsncasecmp (__const wchar_t *__s1, __const wchar_t *__s2,
 			size_t __n) __THROW;
-libc_hidden_proto(wcsncasecmp)
 
 #ifdef __UCLIBC_HAS_XLOCALE__
 /* Similar to the two functions above but take the information from
@@ -202,7 +200,6 @@ libc_hidden_proto(wcscoll)
    `wcscoll' to the original strings.  */
 extern size_t wcsxfrm (wchar_t *__restrict __s1,
 		       __const wchar_t *__restrict __s2, size_t __n) __THROW;
-libc_hidden_proto(wcsxfrm)
 __END_NAMESPACE_C99
 
 #ifdef __USE_GNU
@@ -233,7 +230,6 @@ __BEGIN_NAMESPACE_C99
 /* Find the first occurrence of WC in WCS.  */
 extern wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc)
      __THROW __attribute_pure__;
-libc_hidden_proto(wcschr)
 /* Find the last occurrence of WC in WCS.  */
 extern wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc)
      __THROW __attribute_pure__;
@@ -244,7 +240,6 @@ __END_NAMESPACE_C99
    the closing NUL wide character in case C is not found in S.  */
 extern wchar_t *wcschrnul (__const wchar_t *__s, wchar_t __wc)
      __THROW __attribute_pure__;
-libc_hidden_proto(wcschrnul)
 #endif
 
 __BEGIN_NAMESPACE_C99
@@ -549,7 +544,6 @@ extern int fwide (__FILE *__fp, int __mode) __THROW;
 extern int fwprintf (__FILE *__restrict __stream,
 		     __const wchar_t *__restrict __format, ...)
      /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
-libc_hidden_proto(fwprintf)
 /* Write formatted output to stdout.
 
    This function is a possible cancellation point and therefore not
@@ -762,7 +756,6 @@ __BEGIN_NAMESPACE_C99
 extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
 			__const wchar_t *__restrict __format,
 			__const struct tm *__restrict __tp) __THROW;
-libc_hidden_proto(wcsftime)
 __END_NAMESPACE_C99
 
 # if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
@@ -788,6 +781,11 @@ libc_hidden_proto(wcsftime_l)
 # include <wctype.h>
 #endif
 
+#ifdef _LIBC
+extern size_t __wcslcpy(wchar_t *__restrict dst,
+			const wchar_t *__restrict src, size_t n) attribute_hidden;
+#endif
+
 __END_DECLS
 
 #endif	/* _WCHAR_H defined */

+ 2 - 2
include/wctype.h

@@ -157,12 +157,13 @@ extern int iswpunct (wint_t __wc) __THROW;
    set of wide characters for which none of `iswalnum', `iswgraph', or
    `iswpunct' is true.  */
 extern int iswspace (wint_t __wc) __THROW;
+libc_hidden_proto(iswspace)
 
 /* Test for any wide character that corresponds to an uppercase letter
    or is one of a locale-specific set of wide character for which none
    of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true.  */
 extern int iswupper (wint_t __wc) __THROW;
-libc_hidden_proto(iswspace)
+libc_hidden_proto(iswupper)
 
 /* Test for any wide character that corresponds to a hexadecimal-digit
    character equivalent to that performed be the functions described
@@ -305,7 +306,6 @@ extern int iswblank_l (wint_t __wc, __locale_t __locale) __THROW;
    by the string argument PROPERTY.  */
 extern wctype_t wctype_l (__const char *__property, __locale_t __locale)
      __THROW;
-libc_hidden_proto(wctype_l)
 
 /* Determine whether the wide-character WC has the property described by
    DESC.  */

+ 9 - 22
include/xlocale.h

@@ -1,5 +1,5 @@
 /* Definition of locale datatype.
-   Copyright (C) 1997,2000,02 Free Software Foundation, Inc.
+   Copyright (C) 1997,2000,2002,2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -21,15 +21,6 @@
 #ifndef _XLOCALE_H
 #define _XLOCALE_H	1
 
-#include <features.h>
-
-#ifndef __UCLIBC_HAS_XLOCALE__
-#error Attempted to include xlocale.h when uClibc built without extended locale support.
-#endif
-
-#include <bits/uClibc_locale.h>
-/* #include <bits/uClibc_touplow.h> */
-
 #if 0
 /* Structure for reentrant locale using functions.  This is an
    (almost) opaque type for the user level programs.  The file and
@@ -37,26 +28,22 @@
    go away without warning.  */
 typedef struct __locale_struct
 {
-#if 0
   /* Note: LC_ALL is not a valid index into this array.  */
   struct locale_data *__locales[13]; /* 13 = __LC_LAST. */
-#endif
 
   /* To increase the speed of this solution we add some special members.  */
-/*   const unsigned short int *__ctype_b; */
-/*   const int *__ctype_tolower; */
-/*   const int *__ctype_toupper; */
-  const __uint16_t *__ctype_b;
-  const __ctype_touplow_t *__ctype_tolower;
-  const __ctype_touplow_t *__ctype_toupper;
-
-  struct __uclibc_locale_struct *__locale_ptr;
+  const unsigned short int *__ctype_b;
+  const int *__ctype_tolower;
+  const int *__ctype_toupper;
 
-#if 0
   /* Note: LC_ALL is not a valid index into this array.  */
   const char *__names[13];
-#endif
 } *__locale_t;
+
+/* POSIX 2008 makes locale_t official.  */
+typedef __locale_t locale_t;
+#else
+# include <locale.h>
 #endif
 
 #endif /* xlocale.h */

+ 1 - 1
ldso/include/dl-defs.h

@@ -212,7 +212,7 @@ typedef struct {
    _dl_find_hash for this reloc TYPE.  TPNT is the module in which the
    matching SYM was found.  */
 #ifndef DL_FIND_HASH_VALUE
-# define DL_FIND_HASH_VALUE(TPNT, TYPE, SYM) (DL_RELOC_ADDR ((SYM)->st_value, (TPNT)->loadaddr))
+# define DL_FIND_HASH_VALUE(TPNT, TYPE, SYM) (DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value))
 #endif
 
 /* Unmap all previously-mapped segments accumulated in LOADADDR.

+ 16 - 2
ldso/include/dl-elf.h

@@ -200,8 +200,13 @@ unsigned int __dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info
 		if (dynamic_info[tag]) \
 			dynamic_info[tag] = (unsigned long) DL_RELOC_ADDR(load_off, dynamic_info[tag]); \
 	} while (0)
-	/* Don't adjust .dynamic unnecessarily.  */
-	if (load_off != 0) {
+	/* Don't adjust .dynamic unnecessarily.  For FDPIC targets,
+	   we'd have to walk all the loadsegs to find out if it was
+	   actually unnecessary, so skip this optimization.  */
+#if !defined __FDPIC__ && !defined __DSBT__
+	if (load_off != 0)
+#endif
+	{
 		ADJUST_DYN_INFO(DT_HASH, load_off);
 		ADJUST_DYN_INFO(DT_PLTGOT, load_off);
 		ADJUST_DYN_INFO(DT_STRTAB, load_off);
@@ -212,6 +217,15 @@ unsigned int __dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info
 		ADJUST_DYN_INFO(DT_GNU_HASH_IDX, load_off);
 #endif
 	}
+#ifdef __DSBT__
+	/* Get the mapped address of the DSBT base.  */
+	ADJUST_DYN_INFO(DT_DSBT_BASE_IDX, load_off);
+
+	/* Initialize loadmap dsbt info.  */
+	load_off.map->dsbt_table = dynamic_info[DT_DSBT_BASE_IDX];
+	load_off.map->dsbt_size = dynamic_info[DT_DSBT_SIZE_IDX];
+	load_off.map->dsbt_index = dynamic_info[DT_DSBT_INDEX_IDX];
+#endif
 #undef ADJUST_DYN_INFO
 	return rtld_flags;
 }

+ 1 - 1
ldso/include/dl-syscall.h

@@ -95,7 +95,7 @@ static __always_inline _syscall0(gid_t, _dl_getegid)
 # define __NR_getpid __NR_getxpid
 #endif
 #define __NR__dl_getpid __NR_getpid
-static __always_inline _syscall0(gid_t, _dl_getpid);
+static __always_inline _syscall0(gid_t, _dl_getpid)
 
 #define __NR__dl_readlink __NR_readlink
 static __always_inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,

+ 1 - 0
ldso/ldso/Makefile.in

@@ -30,6 +30,7 @@ CFLAGS-ldso/ldso/$(TARGET_ARCH)/ := $(CFLAGS-ldso)
 
 CFLAGS-ldso.c := -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\" $(CFLAGS-ldso)
 
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-$(UCLIBC_LDSO_NAME).so := -Wl,--dsbt-index=1
 ifneq ($(SUPPORT_LD_DEBUG),y)
 LDFLAGS-$(UCLIBC_LDSO_NAME).so := $(LDFLAGS)
 else

+ 6 - 6
ldso/ldso/bfin/dl-syscalls.h

@@ -31,7 +31,7 @@ extern int _dl_errno;
 #if DYNAMIC_LOADER_IN_SIMULATOR
 #define __NR___syscall_mmap2	    __NR_mmap2
 static __inline__ _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr,
-	size_t, len, int, prot, int, flags, int, fd, off_t, offset);
+	size_t, len, int, prot, int, flags, int, fd, off_t, offset)
 
 /* Make sure we don't get another definition of _dl_mmap from the
    machine-independent code.  */
@@ -155,7 +155,7 @@ _dl_mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
 static __always_inline unsigned long _dl_read(int fd, const void *buf, unsigned long count);
 
 static __always_inline _syscall3(__off_t, __syscall_lseek, int, fd, __off_t, offset,
-			int, whence);
+			int, whence)
 static __always_inline ssize_t
 _dl_pread(int fd, void *buf, size_t count, off_t offset)
 {
@@ -178,7 +178,7 @@ _dl_pread(int fd, void *buf, size_t count, off_t offset)
 #else
 #define __NR___syscall_pread __NR_pread
 static __always_inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
-			size_t, count, off_t, offset_hi, off_t, offset_lo);
+			size_t, count, off_t, offset_hi, off_t, offset_lo)
 
 static __always_inline ssize_t
 _dl_pread(int fd, void *buf, size_t count, off_t offset)
@@ -191,18 +191,18 @@ _dl_pread(int fd, void *buf, size_t count, off_t offset)
 #ifdef __NR_sram_alloc
 #define __NR__dl_sram_alloc __NR_sram_alloc
 static __always_inline _syscall2(__ptr_t, _dl_sram_alloc,
-			size_t, len, unsigned long, flags);
+			size_t, len, unsigned long, flags)
 #endif
 
 #ifdef __NR_sram_free
 #define __NR__dl_sram_free __NR_sram_free
-static __always_inline _syscall1(int, _dl_sram_free, __ptr_t, addr);
+static __always_inline _syscall1(int, _dl_sram_free, __ptr_t, addr)
 #endif
 
 #ifdef __NR_dma_memcpy
 #define __NR__dl_dma_memcpy __NR_dma_memcpy
 static __always_inline _syscall3(__ptr_t, _dl_dma_memcpy,
-			__ptr_t, dest, __ptr_t, src, size_t, len);
+			__ptr_t, dest, __ptr_t, src, size_t, len)
 #endif
 
 #define __UCLIBC_MMAP_HAS_6_ARGS__

+ 49 - 0
ldso/ldso/c6x/dl-debug.h

@@ -0,0 +1,49 @@
+/* C6X DSBT ELF shared library loader suppport.
+ *
+ * Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * All rights reserved.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+static const char *_dl_reltypes_tab[] =
+{
+  	"R_C6000_NONE",			/* 0 */
+	"R_C6000_ABS32",
+	"R_C6000_ABS16",
+	"R_C6000_ABS8",
+	"R_C6000_PCR_S21",
+	"R_C6000_PCR_S12",		/* 5 */
+	"R_C6000_PCR_S10",
+	"R_C6000_PCR_S7",
+	"R_C6000_ABS_S16",
+	"R_C6000_ABS_L16",
+	"R_C6000_ABS_H16",		/* 10 */
+	"R_C6000_SBR_U15_B",
+	"R_C6000_SBR_U15_H",
+	"R_C6000_SBR_U15_W",
+	"R_C6000_SBR_S16",
+	"R_C6000_SBR_L16_B",		/* 15 */
+	"R_C6000_SBR_L16_H",
+	"R_C6000_SBR_L16_W",
+	"R_C6000_SBR_H16_B",
+	"R_C6000_SBR_H16_H",
+	"R_C6000_SBR_H16_W",		/* 20 */
+	"R_C6000_SBR_GOT_U15_W",
+	"R_C6000_SBR_GOT_L16_W",
+	"R_C6000_SBR_GOT_H16_W",
+	"R_C6000_DSBT_INDEX",
+	"R_C6000_PREL31",		/* 25 */
+	"R_C6000_COPY",
+	"R_C6000_JUMP_SLOT",
+	"R_C6000_SBR_GOT32",
+	"R_C6000_PCR_H16",
+	"R_C6000_PCR_L16",		/* 30 */
+#if 0
+	"R_C6000_ALIGN",		/* 253 */
+	"R_C6000_FPHEAD",		/* 254 */
+	"R_C6000_NOCMP",		/* 255 */
+#endif
+};

+ 91 - 0
ldso/ldso/c6x/dl-inlines.h

@@ -0,0 +1,91 @@
+/* Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * Borrowed heavily from frv arch:
+ * Copyright (C) 2003, 2004 Red Hat, Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+/* Figure out whether the given address is in one of the mapped
+   segments.  */
+static __always_inline int
+__dl_addr_in_loadaddr (void *p, struct elf32_dsbt_loadaddr loadaddr)
+{
+	struct elf32_dsbt_loadmap *map = loadaddr.map;
+	int c;
+
+	for (c = 0; c < map->nsegs; c++)
+		if ((void*)map->segs[c].addr <= p
+		    && (char*)p < (char*)map->segs[c].addr + map->segs[c].p_memsz)
+			return 1;
+
+	return 0;
+}
+
+/* Figure out how many LOAD segments there are in the given headers,
+   and allocate a block for the load map big enough for them.
+   got_value will be properly initialized later on, with INIT_GOT.  */
+static __always_inline int
+__dl_init_loadaddr (struct elf32_dsbt_loadaddr *loadaddr, Elf32_Phdr *ppnt,
+		    int pcnt)
+{
+	int count = 0, i;
+	size_t size;
+
+	for (i = 0; i < pcnt; i++)
+		if (ppnt[i].p_type == PT_LOAD)
+			count++;
+
+	size = sizeof (struct elf32_dsbt_loadmap)
+		+ sizeof (struct elf32_dsbt_loadseg) * count;
+	loadaddr->map = _dl_malloc (size);
+	if (! loadaddr->map)
+		_dl_exit (-1);
+
+	loadaddr->map->version = 0;
+	loadaddr->map->nsegs = 0;
+
+	return count;
+}
+
+/* Incrementally initialize a load map.  */
+static __always_inline void
+__dl_init_loadaddr_hdr (struct elf32_dsbt_loadaddr loadaddr, void *addr,
+			Elf32_Phdr *phdr, int maxsegs)
+{
+	struct elf32_dsbt_loadseg *segdata;
+
+	if (loadaddr.map->nsegs == maxsegs)
+		_dl_exit (-1);
+
+	segdata = &loadaddr.map->segs[loadaddr.map->nsegs++];
+	segdata->addr = (Elf32_Addr) addr;
+	segdata->p_vaddr = phdr->p_vaddr;
+	segdata->p_memsz = phdr->p_memsz;
+
+#if defined (__SUPPORT_LD_DEBUG__)
+	{
+		if (_dl_debug)
+			_dl_dprintf(_dl_debug_file, "%i: mapped %x at %x, size %x\n",
+				    loadaddr.map->nsegs-1,
+				    segdata->p_vaddr, segdata->addr, segdata->p_memsz);
+	}
+#endif
+}
+
+static __always_inline void
+__dl_loadaddr_unmap (struct elf32_dsbt_loadaddr loadaddr)
+{
+	int i;
+
+	for (i = 0; i < loadaddr.map->nsegs; i++)
+		_dl_munmap ((void*)loadaddr.map->segs[i].addr,
+			    loadaddr.map->segs[i].p_memsz);
+
+	/* _dl_unmap is only called for dlopen()ed libraries, for which
+	   calling free() is safe, or before we've completed the initial
+	   relocation, in which case calling free() is probably pointless,
+	   but still safe.  */
+	_dl_free (loadaddr.map);
+}

+ 122 - 0
ldso/ldso/c6x/dl-startup.h

@@ -0,0 +1,122 @@
+/* Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * Borrowed heavily from frv arch:
+ * Copyright (C) 2003 Red Hat, Inc.
+ * 
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#undef DL_START
+#define DL_START(X)   \
+int  \
+_dl_start (unsigned placeholder, \
+	   struct elf32_dsbt_loadmap *dl_boot_progmap, \
+	   struct elf32_dsbt_loadmap *dl_boot_ldsomap, \
+	   Elf32_Dyn *dl_boot_ldso_dyn_pointer,	       \
+	   X)
+
+/*
+ * On entry, the kernel has set up the stack thusly:
+ *
+ *	0(sp)			pad0
+ *	4(sp)			pad1
+ *	8(sp)			argc
+ *	12(sp)			argv[0]
+ *	...
+ *	(4*(argc+3))(sp)	NULL
+ *	(4*(argc+4))(sp)	envp[0]
+ *	...
+ *				NULL
+ *
+ * Register values are unspecified, except:
+ *
+ *	B4  --> executable loadmap address
+ *	A6  --> interpreter loadmap address
+ *	B6  --> dynamic section address
+ *	B14 --> our DP setup by kernel
+ *
+ * NB: DSBT index is always 0 for the executable
+ *     and 1 for the interpreter
+ */
+
+__asm__("	.text\n"
+	".globl _start\n"
+	"_start:\n"
+	"          B .S2		_dl_start\n"
+	"          STW .D2T2		B14, *+B14[1]\n"
+	"          ADD .D1X		B15,8,A8\n"
+	"          ADDKPC .S2		ret_from_dl,B3,2\n"
+	"ret_from_dl:\n"
+	"	   B .S2X		A4\n"
+	" ||       LDW .D2T2		*+B14[0],B14\n"
+	" 	   ADDKPC .S2		__dl_fini,B0,0\n"
+	"          MV .S1X		B0,A4\n"
+	"	   NOP\n"
+	"	   NOP\n"
+	"	   NOP\n"
+	"__dl_fini:\n"
+	"          LDW .D2T2		*+B14[1],B14\n"
+	"	   NOP		4\n"
+	" 	   LDW .D2T1		*+B14($GOT(_dl_fini)), A0\n"
+	"          NOP		4\n"
+	"	   BNOP .S2X		A0, 5\n");
+
+__asm__("	.text\n"
+	"__c6x_cache_sync:\n"
+	"	   MVK .S2		330,B0\n"
+	"	   SWE\n"
+	"	   NOP\n"
+	"	   BNOP .S2		B3,5\n"
+	"	   NOP\n"
+	"	   NOP\n"
+	"	   NOP\n"
+	"	   NOP\n"
+	"\n"
+);
+
+/*
+ * Get a pointer to the argv array.  On many platforms this can be just
+ * the address of the first argument, on other platforms we need to
+ * do something a little more subtle here.
+ */
+#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS) + 1)
+
+struct elf32_dsbt_loadmap;
+
+/*
+ * Here is a macro to perform a relocation.  This is only used when
+ * bootstrapping the dynamic loader.  RELP is the relocation that we
+ * are performing, REL is the pointer to the address we are relocating.
+ * SYMBOL is the symbol involved in the relocation, and LOAD is the
+ * load address.
+ */
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
+	switch(ELF32_R_TYPE((RELP)->r_info)){				\
+	case R_C6000_ABS_L16:						\
+	    {								\
+		    unsigned int opcode = *(REL);			\
+		    unsigned int v = (SYMBOL) + (RELP)->r_addend;	\
+		    opcode &= ~0x7fff80;				\
+		    opcode |= ((v & 0xffff) << 7);			\
+		    *(REL) = opcode;					\
+	    }								\
+	    break;							\
+	case R_C6000_ABS_H16:						\
+	    {								\
+		    unsigned int opcode = *(REL);			\
+		    unsigned int v = (SYMBOL) + (RELP)->r_addend;	\
+		    opcode &= ~0x7fff80;				\
+		    opcode |= ((v >> 9) & 0x7fff80);			\
+		    *(REL) = opcode;					\
+	    }								\
+	    break;							\
+	case R_C6000_ABS32:						\
+	    *(REL) = (SYMBOL) + (RELP)->r_addend;			\
+	    break;							\
+	default:							\
+	  _dl_exit(1);							\
+	}
+
+extern void __c6x_cache_sync(unsigned long start, unsigned long end)
+  attribute_hidden;

+ 25 - 0
ldso/ldso/c6x/dl-syscalls.h

@@ -0,0 +1,25 @@
+/* Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+/* We can't use the real errno in ldso, since it has not yet
+ * been dynamicly linked in yet. */
+#include "sys/syscall.h"
+extern int _dl_errno;
+#undef __set_errno
+#define __set_errno(X) {(_dl_errno) = (X);}
+#include <sys/mman.h>
+
+#ifdef __NR_pread64
+#define __NR___syscall_pread __NR_pread64
+static __always_inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
+			size_t, count, off_t, offset_hi, off_t, offset_lo);
+
+static __always_inline ssize_t
+_dl_pread(int fd, void *buf, size_t count, off_t offset)
+{
+  return(__syscall_pread(fd,buf,count, offset, offset >> 31));
+}
+#endif

+ 209 - 0
ldso/ldso/c6x/dl-sysdep.h

@@ -0,0 +1,209 @@
+/* Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * Borrowed heavily from frv arch:
+ * Copyright (C) 2003, 2004 Red Hat, Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <bits/elf-dsbt.h>
+
+/*
+ * Define this if the system uses RELOCA.
+ */
+#define ELF_USES_RELOCA 1
+
+/* JMPREL relocs are inside the DT_RELA table.  */
+/* Actually looks like a linker bug sets DT_JMPREL anyway */
+#define ELF_MACHINE_PLTREL_OVERLAP 1
+
+#undef DL_NO_COPY_RELOCS
+
+#define HAVE_DL_INLINES_H
+
+
+/*
+ * Various assembly language/system dependent  hacks that are required
+ * so that we can minimize the amount of platform specific code.
+ */
+
+/* Initialization sequence for the GOT.  */
+#define INIT_GOT(GOT_BASE,MODULE) \
+{ \
+  GOT_BASE[0] = (unsigned long) _dl_linux_resolve; \
+  GOT_BASE[1] = (unsigned long) MODULE; \
+}
+
+/* Here we define the magic numbers that this dynamic loader should accept */
+#define MAGIC1 EM_TI_C6000
+#undef  MAGIC2
+
+/* Used for error messages */
+#define ELF_TARGET "C6000"
+
+/* Need bootstrap relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
+
+struct elf_resolve;
+
+extern int _dl_linux_resolve(void) attribute_hidden;
+
+struct funcdesc_ht;
+struct elf32_dsbt_loadaddr;
+
+/* We must force strings used early in the bootstrap into the text
+   segment (const data), such that they are referenced relative to
+   the DP register rather than through the GOT which will not have
+   been relocated when these are used. */
+#undef SEND_EARLY_STDERR
+#define SEND_EARLY_STDERR(S) \
+  do { static char __s[] = (S); SEND_STDERR (__s); } while (0)
+
+#define DL_LOADADDR_TYPE struct elf32_dsbt_loadaddr
+
+#define DL_RELOC_ADDR(LOADADDR, ADDR) \
+  ((ElfW(Addr))__reloc_pointer ((void*)(ADDR), (LOADADDR).map))
+
+#define DL_INIT_LOADADDR_BOOT(LOADADDR, BASEADDR) \
+	do {						  		\
+	    struct elf32_dsbt_loadmap *map;				\
+	    map = dl_boot_ldsomap ?: dl_boot_progmap;			\
+	    if (map->version != 0) {			  		\
+	        SEND_EARLY_STDERR ("Invalid loadmap version number\n"); \
+                _dl_exit(-1);						\
+	    }								\
+	    if (map->nsegs < 2) {					\
+	        SEND_EARLY_STDERR ("Invalid segment count in loadmap\n"); \
+                _dl_exit(-1);						\
+	    }								\
+	    (LOADADDR).map = map;					\
+	} while(0)
+
+#define DL_INIT_LOADADDR_PROG(LOADADDR, BASEADDR) \
+	do {						  		\
+	    if (dl_boot_progmap->version != 0) {	  		\
+	        SEND_EARLY_STDERR ("Invalid loadmap version number\n"); \
+                _dl_exit(-1);						\
+	    }								\
+	    if (dl_boot_progmap->nsegs < 2) {				\
+	        SEND_EARLY_STDERR ("Invalid segment count in loadmap\n"); \
+                _dl_exit(-1);						\
+	    }								\
+	    (LOADADDR).map = dl_boot_progmap;				\
+	} while(0)
+
+#define DL_INIT_LOADADDR_EXTRA_DECLS \
+  int dl_init_loadaddr_load_count;
+
+#define DL_INIT_LOADADDR(LOADADDR, BASEADDR, PHDR, PHDRCNT) \
+  (dl_init_loadaddr_load_count = \
+     __dl_init_loadaddr (&(LOADADDR), (PHDR), (PHDRCNT)))
+
+#define DL_INIT_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \
+  (__dl_init_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR), \
+			   dl_init_loadaddr_load_count))
+
+#define DL_LOADADDR_UNMAP(LOADADDR, LEN) \
+  (__dl_loadaddr_unmap ((LOADADDR)))
+
+#define DL_LIB_UNMAP(LIB, LEN) \
+  (__dl_loadaddr_unmap ((LIB)->loadaddr))
+
+#define DL_LOADADDR_BASE(LOADADDR) \
+  ((LOADADDR).map->dsbt_table)
+
+#define DL_ADDR_IN_LOADADDR(ADDR, TPNT, TFROM) \
+  (! (TFROM) && __dl_addr_in_loadaddr ((void*)(ADDR), (TPNT)->loadaddr))
+
+
+/* We only support loading DSBT relocatable shared libraries.
+   It probably wouldn't be too hard to support loading statically
+   linked executables that require relocation.*/
+#define DL_CHECK_LIB_TYPE(epnt, piclib, _dl_progname, libname) \
+do \
+{ \
+    (piclib) = 2; \
+} \
+while (0)
+
+/* We want want to apply all relocations in the interpreter during
+   bootstrap.  Because of this, we have to skip the interpreter
+   relocations in _dl_parse_relocation_information(), see
+   elfinterp.c.  */
+#define DL_SKIP_BOOTSTRAP_RELOC(SYMTAB, INDEX, STRTAB) 0
+
+#ifdef __NR_pread64
+#define _DL_PREAD(FD, BUF, SIZE, OFFSET) \
+  (_dl_pread((FD), (BUF), (SIZE), (OFFSET)))
+#endif
+
+#define DL_GET_READY_TO_RUN_EXTRA_PARMS \
+  , struct elf32_dsbt_loadmap *dl_boot_progmap \
+  , struct elf32_dsbt_loadmap *dl_boot_ldsomap
+#define DL_GET_READY_TO_RUN_EXTRA_ARGS \
+  , dl_boot_progmap \
+  , dl_boot_ldsomap
+
+
+/*
+ * Compute the GOT address.
+ * Also setup program and interpreter DSBT table entries.
+ */
+#define DL_BOOT_COMPUTE_GOT(GOT) \
+  do {								\
+    unsigned long *ldso_dsbt, *prog_dsbt;			\
+    ldso_dsbt = dl_boot_ldsomap->dsbt_table;			\
+    prog_dsbt = dl_boot_progmap->dsbt_table;			\
+    ldso_dsbt[0] = prog_dsbt[0] = (unsigned long)prog_dsbt;	\
+    ldso_dsbt[1] = prog_dsbt[1] = (unsigned long)ldso_dsbt;	\
+    (GOT) = ldso_dsbt + dl_boot_ldsomap->dsbt_size;		\
+  } while(0)
+
+#define DL_BOOT_COMPUTE_DYN(dpnt, got, load_addr) \
+  ((dpnt) = dl_boot_ldso_dyn_pointer)
+
+
+#ifdef __USE_GNU
+# include <link.h>
+#else
+# define __USE_GNU
+# include <link.h>
+# undef __USE_GNU
+#endif
+
+static __always_inline Elf32_Addr
+elf_machine_load_address (void)
+{
+	/* this is never an issue on DSBT systems */
+	return 0;
+}
+
+static __always_inline void
+elf_machine_relative (DL_LOADADDR_TYPE load_off, const Elf32_Addr rel_addr,
+		      Elf32_Word relative_count)
+{
+}
+
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
+   PLT entries should not be allowed to define the value.
+   ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
+   of the main executable's symbols, as for a COPY reloc.  */
+#define elf_machine_type_class(type) \
+  ((((type) == R_C6000_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT)	\
+   | (((type) == R_C6000_COPY) * ELF_RTYPE_CLASS_COPY))
+
+#define ARCH_NUM 3
+#define DT_DSBT_BASE_IDX	(DT_NUM + OS_NUM)
+#define DT_DSBT_SIZE_IDX	(DT_NUM + OS_NUM + 1)
+#define DT_DSBT_INDEX_IDX	(DT_NUM + OS_NUM + 2)
+
+#define ARCH_DYNAMIC_INFO(dpnt,  dynamic, debug_addr) \
+do { \
+if (dpnt->d_tag == DT_C6000_DSBT_BASE) \
+     dynamic[DT_DSBT_BASE_IDX] = dpnt->d_un.d_val; \
+else if (dpnt->d_tag == DT_C6000_DSBT_SIZE) \
+     dynamic[DT_DSBT_SIZE_IDX] = dpnt->d_un.d_val; \
+else if (dpnt->d_tag == DT_C6000_DSBT_INDEX) \
+     dynamic[DT_DSBT_INDEX_IDX] = dpnt->d_un.d_val; \
+} while (0)

+ 296 - 0
ldso/ldso/c6x/elfinterp.c

@@ -0,0 +1,296 @@
+/* TI C64X DSBT ELF shared library loader suppport
+ * Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * Borrowed heavily from frv arch:
+ * Copyright (C) 2003, 2004 Red Hat, Inc.
+ * Contributed by Alexandre Oliva <aoliva@redhat.com>
+ * Lots of code copied from ../i386/elfinterp.c, so:
+ * Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
+ *               David Engel, Hongjiu Lu and Mitch D'Souza
+ * Copyright (C) 2001-2002, Erik Andersen
+ * All rights reserved.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+
+/* Program to load an ELF binary on a linux system, and run it.
+   References to symbols in sharable libraries can be resolved by either
+   an ELF sharable library or a linux style of shared library. */
+
+/* Disclaimer:  I have never seen any AT&T source code for SVr4, nor have
+   I ever taken any courses on internals.  This program was developed using
+   information available through the book "UNIX SYSTEM V RELEASE 4,
+   Programmers guide: Ansi C and Programming Support Tools", which did
+   a more than adequate job of explaining everything required to get this
+   working. */
+
+extern void __c6x_cache_sync(unsigned long start, unsigned long end)
+    attribute_hidden;
+
+static void
+_dl_c6x_flush_relocs(struct elf32_dsbt_loadmap *map)
+{
+	unsigned long s, e;
+	s = map->segs[0].addr;
+	e = s + map->segs[0].p_memsz;
+	__c6x_cache_sync(s, e);
+	s = map->segs[1].addr;
+	e = s + map->segs[1].p_memsz;
+	__c6x_cache_sync(s, e);
+}
+
+
+attribute_hidden
+char *
+_dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
+{
+	ELF_RELOC *this_reloc;
+	char *strtab;
+	ElfW(Sym) *symtab;
+	int symtab_index;
+	char *rel_addr;
+	char *new_addr;
+	char **got_addr;
+	char *symname;
+
+	rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
+
+	this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry);
+	symtab_index = ELF_R_SYM(this_reloc->r_info);
+
+	symtab = (Elf32_Sym *) tpnt->dynamic_info[DT_SYMTAB];
+	strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
+	symname = strtab + symtab[symtab_index].st_name;
+
+	/* Address of GOT entry fix up */
+	got_addr = (char **) DL_RELOC_ADDR(tpnt->loadaddr, this_reloc->r_offset);
+
+	/* Get the address to be used to fill in the GOT entry.  */
+	new_addr = _dl_find_hash(symname, tpnt->symbol_scope, tpnt,
+				 ELF_RTYPE_CLASS_PLT, NULL);
+	if (unlikely(!new_addr)) {
+		_dl_dprintf(2, "%s: can't resolve symbol '%s' in lib '%s'.\n", _dl_progname, symname, tpnt->libname);
+		_dl_exit(1);
+	}
+
+
+#if defined (__SUPPORT_LD_DEBUG__)
+	if (_dl_debug_bindings) {
+		_dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
+		if (_dl_debug_detail)
+			_dl_dprintf(_dl_debug_file,
+				    "\n\tpatched %x ==> %x @ %x\n",
+				    *got_addr, new_addr, got_addr);
+	}
+	if (!_dl_debug_nofixups) {
+		*got_addr = new_addr;
+	}
+#else
+	*got_addr = new_addr;
+#endif
+
+	return new_addr;
+}
+
+static int
+_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+	  unsigned long rel_addr, unsigned long rel_size,
+	  int (*reloc_fnc) (struct elf_resolve *tpnt, struct dyn_elf *scope,
+			    ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab))
+{
+	unsigned int i;
+	char *strtab;
+	Elf32_Sym *symtab;
+	ELF_RELOC *rpnt;
+	int symtab_index;
+
+	/* Now parse the relocation information */
+	rpnt = (ELF_RELOC *)rel_addr;
+	rel_size = rel_size / sizeof(ELF_RELOC);
+
+	symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
+	strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
+
+	for (i = 0; i < rel_size; i++, rpnt++) {
+	        int res;
+
+		symtab_index = ELF32_R_SYM(rpnt->r_info);
+		debug_sym(symtab,strtab,symtab_index);
+		debug_reloc(symtab,strtab,rpnt);
+
+		res = reloc_fnc (tpnt, scope, rpnt, symtab, strtab);
+
+		if (res==0) continue;
+
+		_dl_dprintf(2, "\n%s: ",_dl_progname);
+
+		if (symtab_index)
+			_dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name);
+
+		if (res <0) {
+		        int reloc_type = ELF32_R_TYPE(rpnt->r_info);
+#if defined (__SUPPORT_LD_DEBUG__)
+			_dl_dprintf(2, "can't handle reloc type %s\n ", _dl_reltypes(reloc_type));
+#else
+			_dl_dprintf(2, "can't handle reloc type %x\n", reloc_type);
+#endif
+			_dl_exit(-res);
+		} else if (res >0) {
+			_dl_dprintf(2, "can't resolve symbol\n");
+			return res;
+		}
+	}
+	_dl_c6x_flush_relocs(tpnt->loadaddr.map);
+	return 0;
+}
+
+static int
+_dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
+	      ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
+{
+	int reloc_type;
+	int symtab_index;
+	char *symname;
+	unsigned long *reloc_addr;
+	unsigned long symbol_addr, sym_val;
+	long reloc_addend;
+	unsigned long old_val, new_val;
+
+	reloc_addr = (unsigned long *)(intptr_t)
+		DL_RELOC_ADDR (tpnt->loadaddr, rpnt->r_offset);
+
+	reloc_type   = ELF32_R_TYPE(rpnt->r_info);
+	reloc_addend = rpnt->r_addend;
+	symtab_index = ELF32_R_SYM(rpnt->r_info);
+	symbol_addr  = 0;
+	symname      = strtab + symtab[symtab_index].st_name;
+
+	if (ELF32_ST_BIND (symtab[symtab_index].st_info) == STB_LOCAL) {
+		symbol_addr = (unsigned long)
+			DL_RELOC_ADDR (tpnt->loadaddr, symtab[symtab_index].st_value);
+	} else {
+		symbol_addr = (unsigned long) _dl_find_hash(strtab + symtab[symtab_index].st_name,
+							    scope, tpnt, elf_machine_type_class(reloc_type),
+							    NULL);
+		/*
+		 * We want to allow undefined references to weak symbols - this might
+		 * have been intentional.  We should not be linking local symbols
+		 * here, so all bases should be covered.
+		 */
+
+		if (!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
+			_dl_dprintf (2, "%s: can't resolve symbol '%s'\n",
+				     _dl_progname, strtab + symtab[symtab_index].st_name);
+			_dl_exit (1);
+		}
+	}
+	old_val = *reloc_addr;
+	sym_val = symbol_addr + reloc_addend;
+
+	switch (reloc_type) {
+	case R_C6000_NONE:
+		break;
+	case R_C6000_ABS32:
+	case R_C6000_JUMP_SLOT:
+		new_val = sym_val;
+		*reloc_addr = sym_val;
+		break;
+	case R_C6000_ABS_L16:
+		new_val = (old_val & ~0x007fff80) | ((sym_val & 0xffff) << 7);
+		*reloc_addr = new_val;
+		break;
+	case R_C6000_ABS_H16:
+		new_val = (old_val & ~0x007fff80) | ((sym_val >> 9) & 0x007fff80);
+		*reloc_addr = new_val;
+		break;
+	case R_C6000_PCR_S21:
+		new_val = sym_val - (((unsigned long)reloc_addr) & ~31);
+		*reloc_addr = (old_val & ~0x0fffff80) | (((new_val >> 2) & 0x1fffff) << 7);
+		break;
+	case R_C6000_COPY:
+		if (symbol_addr) {
+#if defined (__SUPPORT_LD_DEBUG__)
+			if (_dl_debug_move)
+				_dl_dprintf(_dl_debug_file,
+					    "\n%s move %d bytes from %x to %x",
+					    symname, symtab[symtab_index].st_size,
+					    symbol_addr, reloc_addr);
+#endif
+			
+			_dl_memcpy((char *)reloc_addr,
+				   (char *)symbol_addr,
+				   symtab[symtab_index].st_size);
+		}
+		break;
+	default:
+		return -1; /*call _dl_exit(1) */
+	}
+#if defined (__SUPPORT_LD_DEBUG__)
+	if (_dl_debug_reloc && _dl_debug_detail && reloc_type != R_C6000_NONE) {
+		_dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n", old_val, new_val, reloc_addr);
+	}
+#endif
+	return 0;
+}
+
+static int
+_dl_do_lazy_reloc (struct elf_resolve *tpnt,
+		   struct dyn_elf *scope attribute_unused,
+		   ELF_RELOC *rpnt, ElfW(Sym) *symtab attribute_unused,
+		   char *strtab attribute_unused)
+{
+	int reloc_type;
+	unsigned long *reloc_addr;
+	unsigned long old_val;
+
+	reloc_addr = (unsigned long *) DL_RELOC_ADDR(tpnt->loadaddr, rpnt->r_offset);
+	reloc_type = ELF_R_TYPE(rpnt->r_info);
+
+	old_val = *reloc_addr;
+
+	switch (reloc_type) {
+		case R_C6000_NONE:
+			break;
+		case R_C6000_JUMP_SLOT:
+			*reloc_addr = DL_RELOC_ADDR(tpnt->loadaddr, old_val);
+			break;
+		default:
+			return -1;
+	}
+
+#if defined (__SUPPORT_LD_DEBUG__)
+	if (_dl_debug_reloc && _dl_debug_detail)
+		_dl_dprintf(_dl_debug_file, "\n\tpatched: %x ==> %x @ %x\n",
+			    old_val, *reloc_addr, reloc_addr);
+#endif
+
+	return 0;
+}
+
+void
+_dl_parse_lazy_relocation_information
+(struct dyn_elf *rpnt, unsigned long rel_addr, unsigned long rel_size)
+{
+	_dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
+}
+
+int
+_dl_parse_relocation_information
+(struct dyn_elf *rpnt, unsigned long rel_addr, unsigned long rel_size)
+{
+	return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
+}
+
+/* We don't have copy relocs.  */
+int
+_dl_parse_copy_information
+(struct dyn_elf *rpnt,
+ unsigned long rel_addr,
+ unsigned long rel_size)
+{
+	return 0;
+}
+

+ 68 - 0
ldso/ldso/c6x/resolve.S

@@ -0,0 +1,68 @@
+;;
+;;  Copyright (C) 2010 Texas Instruments Incorporated
+;;  Mark Salter <msalter@redhat.com>
+;;
+;;  Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+;;
+
+;;      The function below is tail-called by resolver stubs when a
+;; 	lazily-bound function is called.  It must preserve all
+;; 	registers that could be used to pass arguments to the actual
+;; 	function.
+
+;; 	_dl_linux_resolver() figures out where the jump symbol is
+;; 	_really_ supposed to have jumped to and returns that to us.
+;; 	Once we have that, we prepare to tail-call the actual
+;; 	function, clean up after ourselves, restoring the original
+;; 	arguments, then jump to the fixed up address.  */
+
+; resolver stub - called from PLT to resolve target address and update GOT
+;
+;   B0        : reloc offset (bytes from DT_RELPLT)
+;   B1        : module pointer, loaded from GOT[1]
+;   DP        : caller's DP
+;   A4,B4, etc: callee's arguments
+;   B3        : return address
+
+	.text
+	.align 5
+	.global	_dl_linux_resolve
+_dl_linux_resolve:
+	stw .d2t2	B14, *B15--[2]
+	stdw .d2t1	A15:A14, *B15--
+	stdw .d2t2	B13:B12, *B15--
+	stdw .d2t1	A13:A12, *B15--
+	stdw .d2t2	B11:B10, *B15--
+	stdw .d2t1	A11:A10, *B15--
+	stdw .d2t2	B9:B8, *B15--
+	stdw .d2t1	A9:A8, *B15--
+	stdw .d2t2	B7:B6, *B15--
+	stdw .d2t1	A7:A6, *B15--
+	stdw .d2t2	B5:B4, *B15--
+	stdw .d2t1	A5:A4, *B15--
+	stdw .d2t2	B3:B2, *B15--
+	stdw .d2t1	A3:A2, *B15--
+
+	; call lookup routine
+	MV .S1X		B1, A4		; arg 1: module id
+||	MV .S2		B0,B4		; arg 2: reloc offset
+	CALLP .S2	_dl_linux_resolver, B3	; returns &f in A4
+	MV .S2X		A4,B0            ; &f
+
+	lddw .d2t1	*++B15, A3:A2
+	lddw .d2t2	*++B15, B3:B2
+	lddw .d2t1	*++B15, A5:A4
+	lddw .d2t2	*++B15, B5:B4
+	lddw .d2t1	*++B15, A7:A6
+	lddw .d2t2	*++B15, B7:B6
+	lddw .d2t1	*++B15, A9:A8
+	lddw .d2t2	*++B15, B9:B8
+	lddw .d2t1	*++B15, A11:A10
+	lddw .d2t2	*++B15, B11:B10
+	lddw .d2t1	*++B15, A13:A12
+	lddw .d2t2	*++B15, B13:B12
+	lddw .d2t1	*++B15, A15:A14
+	ldw .d2t2	*++B15[2], B14
+
+	B .S2		B0               ; tail-call f
+	NOP		5

+ 49 - 1
ldso/ldso/dl-elf.c

@@ -188,7 +188,7 @@ unsigned long _dl_error_number;
 unsigned long _dl_internal_error_number;
 
 struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
-	struct elf_resolve *tpnt, char *full_libname, int __attribute__((unused)) trace_loaded_objects)
+	struct elf_resolve *tpnt, char *full_libname, int attribute_unused trace_loaded_objects)
 {
 	char *pnt;
 	struct elf_resolve *tpnt1;
@@ -826,6 +826,54 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
 		INIT_GOT(lpnt, tpnt);
 	}
 
+#ifdef __DSBT__
+	/* Handle DSBT initialization */
+	{
+		struct elf_resolve *t, *ref = NULL;
+		int idx = tpnt->loadaddr.map->dsbt_index;
+		unsigned *dsbt = tpnt->loadaddr.map->dsbt_table;
+
+		if (idx == 0) {
+			/* This DSO has not been assigned an index */
+			_dl_dprintf(2, "%s: '%s' is missing a dsbt index assignment!\n",
+				    _dl_progname, libname);
+			_dl_exit(1);
+		}
+
+		/*
+		 * Setup dsbt slot for this module in dsbt of all modules.
+		 */
+		for (t = _dl_loaded_modules; t; t = t->next) {
+			/* find a dsbt table from another module */
+			if (ref == NULL && t != tpnt) {
+				ref = t;
+
+				/* make sure index is not already used */
+				if (t->loadaddr.map->dsbt_table[idx]) {
+					struct elf_resolve *dup;
+					char *dup_name;
+
+					for (dup = _dl_loaded_modules; dup; dup = dup->next)
+						if (dup != tpnt && dup->loadaddr.map->dsbt_index == idx)
+							break;
+					if (dup)
+						dup_name = dup->libname;
+					else if (idx == 1)
+						dup_name = "runtime linker";
+					else
+						dup_name = "unknown library";
+					_dl_dprintf(2, "%s: '%s' dsbt index %d already used by %s!\n",
+						    _dl_progname, libname, idx, dup_name);
+					_dl_exit(1);
+				}
+			}
+			t->loadaddr.map->dsbt_table[idx] = (unsigned)dsbt;
+		}
+		if (ref)
+			_dl_memcpy(dsbt, ref->loadaddr.map->dsbt_table,
+				   tpnt->loadaddr.map->dsbt_size * sizeof(unsigned *));
+	}
+#endif
 	_dl_if_debug_dprint("\n\tfile='%s';  generating link map\n", libname);
 	_dl_if_debug_dprint("\t\tdynamic: %x  base: %x\n", dynamic_addr, DL_LOADADDR_BASE(lib_loadaddr));
 	_dl_if_debug_dprint("\t\t  entry: %x  phdr: %x  phnum: %x\n\n",

+ 1 - 1
ldso/ldso/i386/elfinterp.c

@@ -162,7 +162,7 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
 	int reloc_type;
 	int symtab_index;
 	char *symname;
-	struct elf_resolve *tls_tpnt = 0;
+	struct elf_resolve *tls_tpnt = NULL;
 	unsigned long *reloc_addr;
 	unsigned long symbol_addr;
 #if defined (__SUPPORT_LD_DEBUG__)

+ 6 - 8
ldso/ldso/ldso.c

@@ -119,15 +119,13 @@ extern void _start(void);
 
 #ifdef __UCLIBC_HAS_SSP__
 # include <dl-osinfo.h>
-uintptr_t stack_chk_guard;
+static uintptr_t stack_chk_guard;
 # ifndef THREAD_SET_STACK_GUARD
 /* Only exported for architectures that don't store the stack guard canary
  * in local thread area.  */
 uintptr_t __stack_chk_guard attribute_relro;
-#  ifdef __UCLIBC_HAS_SSP_COMPAT__
-strong_alias(__stack_chk_guard,__guard)
-#  endif
-# elif __UCLIBC_HAS_SSP_COMPAT__
+# endif
+# ifdef __UCLIBC_HAS_SSP_COMPAT__
 uintptr_t __guard attribute_relro;
 # endif
 #endif
@@ -1165,12 +1163,12 @@ of this helper program; chances are you did not intend to run this program.\n\
 	stack_chk_guard = _dl_setup_stack_chk_guard ();
 # ifdef THREAD_SET_STACK_GUARD
 	THREAD_SET_STACK_GUARD (stack_chk_guard);
-#  ifdef __UCLIBC_HAS_SSP_COMPAT__
-	__guard = stack_chk_guard;
-#  endif
 # else
 	__stack_chk_guard = stack_chk_guard;
 # endif
+# ifdef __UCLIBC_HAS_SSP_COMPAT__
+	__guard = stack_chk_guard;
+# endif
 #endif
 
 #ifdef __LDSO_PRELINK_SUPPORT__

+ 1 - 1
ldso/ldso/sparc/elfinterp.c

@@ -170,7 +170,7 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
 	int reloc_type;
 	int symtab_index;
 	char *symname;
-	struct elf_resolve *tls_tpnt = 0;
+	struct elf_resolve *tls_tpnt = NULL;
 	struct symbol_ref sym_ref;
 	ElfW(Addr) *reloc_addr;
 	ElfW(Addr) symbol_addr;

+ 1 - 1
ldso/ldso/x86_64/elfinterp.c

@@ -157,7 +157,7 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
 	int reloc_type;
 	int symtab_index;
 	char *symname;
-	struct elf_resolve *tls_tpnt = 0;
+	struct elf_resolve *tls_tpnt = NULL;
 	struct symbol_ref sym_ref;
 	ElfW(Addr) *reloc_addr;
 	ElfW(Addr) symbol_addr;

+ 1 - 0
ldso/libdl/Makefile.in

@@ -19,6 +19,7 @@ endif
 
 CFLAGS-libdl.c := -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\"
 
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libdl.so := -Wl,--dsbt-index=3
 LDFLAGS-libdl.so := $(LDFLAGS) -Wl,-fini,dl_cleanup
 
 LIBS-libdl.so := $(LIBS) $(ldso)

+ 4 - 1
ldso/libdl/libdl.c

@@ -651,7 +651,6 @@ void *dlsym(void *vhandle, const char *name)
 	ElfW(Addr) from;
 	struct dyn_elf *rpnt;
 	void *ret;
-	struct elf_resolve *tls_tpnt = NULL;
 	struct symbol_ref sym_ref = { NULL, NULL };
 	/* Nastiness to support underscore prefixes.  */
 #ifdef __UCLIBC_UNDERSCORES__
@@ -973,6 +972,10 @@ static int do_dlclose(void *vhandle, int need_fini)
 			free(tpnt);
 		}
 	}
+	for (rpnt1 = handle->next; rpnt1; rpnt1 = rpnt1_tmp) {
+		rpnt1_tmp = rpnt1->next;
+		free(rpnt1);
+	}
 	free(handle->init_fini.init_fini);
 	free(handle);
 

+ 1 - 0
libc/Makefile.in

@@ -15,6 +15,7 @@ ifneq ($(VERSION_SCRIPT),)
 VERSION_SCRIPT := -Wl,--version-script,$(VERSION_SCRIPT)
 endif
 
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libc.so := -Wl,--dsbt-index=2
 LDFLAGS-libc.so := $(LDFLAGS) $(VERSION_SCRIPT) -Wl,-init,$(SYMBOL_PREFIX)__uClibc_init
 ifeq ($(UCLIBC_HAS_STDIO_FUTEXES),y)
 CFLAGS += -D__USE_STDIO_FUTEXES__

+ 4 - 0
libc/inet/getaddrinfo.c

@@ -639,9 +639,13 @@ gaih_inet(const char *name, const struct gaih_service *service,
 					tmpbuflen *= 2;
 					tmpbuf = alloca(tmpbuflen);
 					rc = gethostbyaddr_r(at2->addr,
+#ifdef __UCLIBC_HAS_IPV6__
 						((at2->family == AF_INET6)
 						 ? sizeof(struct in6_addr)
 						 : sizeof(struct in_addr)),
+#else
+						sizeof(struct in_addr),
+#endif
 						at2->family,
 						&th, tmpbuf, tmpbuflen,
 						&h, &herrno);

+ 10 - 0
libc/inet/ifaddrs.c

@@ -59,7 +59,9 @@ struct ifaddrs_storage
     struct sockaddr sa;
     struct sockaddr_ll sl;
     struct sockaddr_in s4;
+#ifdef __UCLIBC_HAS_IPV6__
     struct sockaddr_in6 s6;
+#endif
   } addr, netmask, broadaddr;
   char name[IF_NAMESIZE + 1];
 };
@@ -621,6 +623,7 @@ getifaddrs (struct ifaddrs **ifap)
 				      rta_data, rta_payload);
 			    break;
 
+#ifdef __UCLIBC_HAS_IPV6__
 			  case AF_INET6:
 			    /* Size must match that of an address for IPv6.  */
 			    if (rta_payload == 16)
@@ -633,6 +636,7 @@ getifaddrs (struct ifaddrs **ifap)
 				    = ifam->ifa_index;
 			      }
 			    break;
+#endif
 
 			  default:
 			    if (rta_payload <= sizeof (ifas[ifa_index].addr))
@@ -668,6 +672,7 @@ getifaddrs (struct ifaddrs **ifap)
 				  rta_data, rta_payload);
 			  break;
 
+#ifdef __UCLIBC_HAS_IPV6__
 			case AF_INET6:
 			  /* Size must match that of an address for IPv6.  */
 			  if (rta_payload == 16)
@@ -680,6 +685,7 @@ getifaddrs (struct ifaddrs **ifap)
 				  ifam->ifa_index;
 			    }
 			  break;
+#endif
 
 			default:
 			  if (rta_payload <= sizeof (ifas[ifa_index].addr))
@@ -709,6 +715,7 @@ getifaddrs (struct ifaddrs **ifap)
 				    rta_data, rta_payload);
 			  break;
 
+#ifdef __UCLIBC_HAS_IPV6__
 			case AF_INET6:
 			  /* Size must match that of an address for IPv6.  */
 			  if (rta_payload == 16)
@@ -721,6 +728,7 @@ getifaddrs (struct ifaddrs **ifap)
 				  = ifam->ifa_index;
 			    }
 			  break;
+#endif
 
 			default:
 			  if (rta_payload <= sizeof (ifas[ifa_index].addr))
@@ -777,10 +785,12 @@ getifaddrs (struct ifaddrs **ifap)
 		      max_prefixlen = 32;
 		      break;
 
+#ifdef __UCLIBC_HAS_IPV6__
 		    case AF_INET6:
 		      cp = (char *) &ifas[ifa_index].netmask.s6.sin6_addr;
 		      max_prefixlen = 128;
 		      break;
+#endif
 		    }
 
 		  ifas[ifa_index].ifa.ifa_netmask->sa_family

+ 1 - 0
libc/inet/rpc/clnt_tcp.c

@@ -402,6 +402,7 @@ clnttcp_control (CLIENT *cl, int request, char *info)
       /* This will set the xid of the NEXT call */
       *(u_long *)ct->ct_mcall =  htonl (*(u_long *)info - 1);
       /* decrement by 1 as clnttcp_call() increments once */
+      break;
     case CLGET_VERS:
       /*
        * This RELIES on the information that, in the call body,

+ 1 - 0
libc/inet/rpc/clnt_udp.c

@@ -554,6 +554,7 @@ clntudp_control (CLIENT *cl, int request, char *info)
       /* This will set the xid of the NEXT call */
       *(u_long *)cu->cu_outbuf =  htonl(*(u_long *)info - 1);
       /* decrement by 1 as clntudp_call() increments once */
+      break;
     case CLGET_VERS:
       /*
        * This RELIES on the information that, in the call body,

+ 1 - 0
libc/inet/rpc/clnt_unix.c

@@ -377,6 +377,7 @@ clntunix_control (CLIENT *cl, int request, char *info)
       /* This will set the xid of the NEXT call */
       *(u_long *) ct->ct_mcall =  htonl (*(u_long *)info - 1);
       /* decrement by 1 as clntunix_call() increments once */
+      break;
     case CLGET_VERS:
       /*
        * This RELIES on the information that, in the call body,

+ 4 - 0
libc/inet/rpc/sa_len.c

@@ -52,10 +52,14 @@ int __libc_sa_len (sa_family_t af)
 #endif
     case AF_INET:
       return sizeof (struct sockaddr_in);
+#ifdef __UCLIBC_HAS_IPV6__
     case AF_INET6:
       return sizeof (struct sockaddr_in6);
+#endif
+#if 0
     case AF_IPX:
       return sizeof (struct sockaddr_ipx);
+#endif
     case AF_LOCAL:
       return sizeof (struct sockaddr_un);
     }

+ 1 - 0
libc/inet/rpc/svc.c

@@ -41,6 +41,7 @@
 
 #include <errno.h>
 #include <unistd.h>
+#include <string.h>
 #include "rpc_private.h"
 #include <rpc/svc.h>
 #include <rpc/pmap_clnt.h>

+ 0 - 5
libc/misc/ctype/ctype.c

@@ -306,8 +306,6 @@ int tolower_l(int c, __locale_t l)
 	return __UCLIBC_CTYPE_IN_TO_DOMAIN(c) ? l->__ctype_tolower[c] : c;
 }
 libc_hidden_def(tolower_l)
-/*remove after 0.9.31. See ctype.h for why.
- *weak_alias (tolower_l, __tolower_l) */
 
 #endif
 /**********************************************************************/
@@ -346,9 +344,6 @@ int toupper_l(int c, __locale_t l)
 #endif
 	return __UCLIBC_CTYPE_IN_TO_DOMAIN(c) ? l->__ctype_toupper[c] : c;
 }
-libc_hidden_def(toupper_l)
-/*remove after 0.9.31. See ctype.h for why.
- *weak_alias (toupper_l, __toupper_l) */
 
 #endif
 /**********************************************************************/

+ 3 - 1
libc/misc/elf/dl-iterate-phdr.c

@@ -62,9 +62,11 @@ dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
       /* This entry describes this statically-linked program itself.  */
       struct dl_phdr_info info;
       int ret;
-#ifdef __FDPIC__
+#if defined(__FDPIC__)
       info.dlpi_addr.map = NULL;
       info.dlpi_addr.got_value = NULL;
+#elif defined(__DSBT__)
+      info.dlpi_addr.map = NULL;
 #else
       info.dlpi_addr = 0;
 #endif

+ 0 - 5
libc/misc/fnmatch/fnmatch.c

@@ -334,11 +334,6 @@ is_char_class (const wchar_t *wcs)
 #  include "fnmatch_loop.c"
 # endif
 
-#ifndef __UCLIBC_HAS_WCHAR__
-# undef MB_CUR_MAX
-# define MB_CUR_MAX 1
-#endif
-
 int
 fnmatch (const char *pattern, const char *string, int flags)
 {

+ 2 - 2
libc/misc/ftw/ftw.c

@@ -752,7 +752,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
 
 
 /* Entry points.  */
-#if __UCLIBC_HAS_FTW__
+#ifdef __UCLIBC_HAS_FTW__
 int
 FTW_NAME (const char *path, FTW_FUNC_T func, int descriptors)
 {
@@ -760,7 +760,7 @@ FTW_NAME (const char *path, FTW_FUNC_T func, int descriptors)
 }
 #endif
 
-#if __UCLIBC_HAS_NFTW__
+#ifdef __UCLIBC_HAS_NFTW__
 #ifndef _LIBC
 int
 NFTW_NAME (const char *path, NFTW_FUNC_T func, int descriptors, int flags)

+ 12 - 20
libc/misc/internals/__uClibc_main.c

@@ -45,22 +45,15 @@ void *__libc_stack_end = NULL;
 
 # ifdef __UCLIBC_HAS_SSP__
 #  include <dl-osinfo.h>
+static uintptr_t stack_chk_guard;
 #  ifndef THREAD_SET_STACK_GUARD
 /* Only exported for architectures that don't store the stack guard canary
  * in thread local area. */
-#   include <stdint.h>
-uintptr_t stack_chk_guard;
 /* for gcc-4.1 non-TLS */
 uintptr_t __stack_chk_guard attribute_relro;
+#  endif
 /* for gcc-3.x + Etoh ssp */
-#   ifdef __UCLIBC_HAS_SSP_COMPAT__
-#    ifdef __HAVE_SHARED__
-strong_alias(__stack_chk_guard,__guard)
-#    else
-uintptr_t __guard attribute_relro;
-#    endif
-#   endif
-#  elif defined __UCLIBC_HAS_SSP_COMPAT__
+#  ifdef __UCLIBC_HAS_SSP_COMPAT__
 uintptr_t __guard attribute_relro;
 #  endif
 # endif
@@ -255,18 +248,14 @@ void __uClibc_init(void)
 #ifndef SHARED
 # ifdef __UCLIBC_HAS_SSP__
     /* Set up the stack checker's canary.  */
+    stack_chk_guard = _dl_setup_stack_chk_guard();
 #  ifdef THREAD_SET_STACK_GUARD
-    uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard();
     THREAD_SET_STACK_GUARD (stack_chk_guard);
-#   ifdef __UCLIBC_HAS_SSP_COMPAT__
-    stack_chk_guard = _dl_setup_stack_chk_guard();
-    __guard = stack_chk_guard;
-#   endif
 #  else
     __stack_chk_guard = stack_chk_guard;
-#   if !defined __HAVE_SHARED__ && defined __UCLIBC_HAS_SSP_COMPAT__
-     __guard = stack_chk_guard;
-#   endif
+#  endif
+#  ifdef __UCLIBC_HAS_SSP_COMPAT__
+    __guard = stack_chk_guard;
 #  endif
 # endif
 #endif
@@ -317,6 +306,11 @@ void __uClibc_fini(void)
 }
 libc_hidden_def(__uClibc_fini)
 
+#ifndef SHARED
+extern void __nptl_deallocate_tsd (void) __attribute ((weak));
+extern unsigned int __nptl_nthreads __attribute ((weak));
+#endif
+
 /* __uClibc_main is the new main stub for uClibc. This function is
  * called from crt1 (version 0.9.28 or newer), after ALL shared libraries
  * are initialized, just before we call the application's main function.
@@ -497,7 +491,6 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
 # ifdef SHARED
 		__libc_pthread_functions.ptr__nptl_deallocate_tsd ();
 # else
-		extern void __nptl_deallocate_tsd (void) __attribute ((weak));
 		__nptl_deallocate_tsd ();
 # endif
 
@@ -507,7 +500,6 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
 # ifdef SHARED
 		unsigned int *const ptr = __libc_pthread_functions.ptr_nthreads;
 # else
-		extern unsigned int __nptl_nthreads __attribute ((weak));
 		unsigned int *const ptr = &__nptl_nthreads;
 # endif
 

+ 4 - 1
libc/misc/internals/tempname.c

@@ -62,7 +62,10 @@ int attribute_hidden ___path_search (char *tmpl, size_t tmpl_len, const char *di
 	const char *pfx /*, int try_tmpdir*/)
 {
     /*const char *d; */
-    size_t dlen, plen;
+    /* dir and pfx lengths should always fit into an int,
+       so don't bother using size_t here.  Especially since
+       the printf func requires an int for precision (%*s).  */
+    int dlen, plen;
 
     if (!pfx || !pfx[0])
     {

+ 3 - 1
libc/misc/locale/locale.c

@@ -1057,6 +1057,7 @@ libc_hidden_def(__XL_NPP(nl_langinfo))
 /**********************************************************************/
 #ifdef L_newlocale
 
+#warning mask defines for extra locale categories
 
 #ifdef __UCLIBC_MJN3_ONLY__
 #warning TODO: Move posix and utf8 strings.
@@ -1302,7 +1303,9 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
 
 	return base;
 }
+#ifdef __UCLIBC_HAS_XLOCALE__
 libc_hidden_def(newlocale)
+#endif
 
 #endif
 /**********************************************************************/
@@ -1336,7 +1339,6 @@ __locale_t duplocale(__locale_t dataset)
 	}
 	return r;
 }
-libc_hidden_def(duplocale)
 
 #endif
 /**********************************************************************/

+ 1 - 0
libc/misc/pthread/tsd.c

@@ -2,6 +2,7 @@
    We define it here instead of in libpthread so t here instead of in libpthread so that it doesn't
    need to have a TLS segment of its own just for this one pointer.  */
 
+void **__libc_dl_error_tsd(void) __attribute__ ((const));
 void ** __attribute__ ((const))
 __libc_dl_error_tsd (void)
 {

+ 0 - 4
libc/misc/regex/regcomp.c

@@ -819,11 +819,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
   dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size);
   dfa->state_hash_mask = table_size - 1;
 
-#ifdef __UCLIBC_HAS_WCHAR__
   dfa->mb_cur_max = MB_CUR_MAX;
-#else
-  dfa->mb_cur_max = 1;
-#endif
 #if 0
   if (dfa->mb_cur_max == 6
       && strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0)

+ 1 - 3
libc/misc/regex/regex_internal.c

@@ -627,7 +627,7 @@ re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
 
 	      if (pstr->is_utf8)
 		{
-		  const unsigned char *raw, *p, *q, *end;
+		  const unsigned char *raw, *p, *end;
 
 		  /* Special case UTF-8.  Multi-byte chars start with any
 		     byte other than 0x80 - 0xbf.  */
@@ -654,13 +654,11 @@ re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
 			  unsigned char buf[6];
 			  size_t mbclen;
 
-			  q = p;
 			  if (BE (pstr->trans != NULL, 0))
 			    {
 			      int i = mlen < 6 ? mlen : 6;
 			      while (--i >= 0)
 				buf[i] = pstr->trans[p[i]];
-			      q = buf;
 			    }
 			  /* XXX Don't use mbrtowc, we know which conversion
 			     to use (UTF-8 -> UCS4).  */

+ 1 - 1
libc/misc/sysvipc/msgq.c

@@ -12,7 +12,7 @@
 
 #ifdef __NR_msgctl
 #define __NR___libc_msgctl __NR_msgctl
-static __inline__ _syscall3(int, __libc_msgctl, int, msqid, int, cmd, struct msqid_ds *, buf);
+static __inline__ _syscall3(int, __libc_msgctl, int, msqid, int, cmd, struct msqid_ds *, buf)
 #endif
 /* Message queue control operation.  */
 int msgctl(int msqid, int cmd, struct msqid_ds *buf)

+ 1 - 1
libc/misc/sysvipc/sem.c

@@ -41,7 +41,7 @@ union semun {
 
 #ifdef __NR_semctl
 #define __NR___semctl __NR_semctl
-static __inline__ _syscall4(int, __semctl, int, semid, int, semnum, int, cmd, void *, arg);
+static __inline__ _syscall4(int, __semctl, int, semid, int, semnum, int, cmd, void *, arg)
 #endif
 
 int semctl(int semid, int semnum, int cmd, ...)

+ 1 - 1
libc/misc/sysvipc/shm.c

@@ -55,7 +55,7 @@ void * shmat (int shmid, const void *shmaddr, int shmflg)
 /* Provide operations to control over shared memory segments.  */
 #ifdef __NR_shmctl
 #define __NR___libc_shmctl __NR_shmctl
-static __inline__ _syscall3(int, __libc_shmctl, int, shmid, int, cmd, struct shmid_ds *, buf);
+static __inline__ _syscall3(int, __libc_shmctl, int, shmid, int, cmd, struct shmid_ds *, buf)
 #endif
 int shmctl(int shmid, int cmd, struct shmid_ds *buf)
 {

+ 10 - 10
libc/misc/time/time.c

@@ -799,7 +799,6 @@ size_t strftime(char *__restrict s, size_t maxsize,
 {
 	return strftime_l(s, maxsize, format, timeptr, __UCLIBC_CURLOCALE);
 }
-libc_hidden_def(strftime)
 
 #else  /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
 
@@ -999,7 +998,6 @@ static int load_field(int k, const struct tm *__restrict timeptr)
 #warning TODO: Check multibyte format string validity.
 #endif
 
-libc_hidden_proto(__XL_NPP(strftime))
 size_t __XL_NPP(strftime)(char *__restrict s, size_t maxsize,
 					  const char *__restrict format,
 					  const struct tm *__restrict timeptr   __LOCALE_PARAM )
@@ -1013,7 +1011,7 @@ size_t __XL_NPP(strftime)(char *__restrict s, size_t maxsize,
 	const char *stack[MAX_PUSH];
 	size_t count;
 	size_t o_count;
-	int field_val, i, j, lvl;
+	int field_val = 0, i = 0, j, lvl;
 	int x[3];			/* wday, yday, year */
 	int isofm, days;
 	char buf[__UIM_BUFLEN_LONG];
@@ -1291,7 +1289,9 @@ OUTPUT:
 	}
 	goto LOOP;
 }
-libc_hidden_def(__XL_NPP(strftime))
+# ifdef L_strftime_l
+libc_hidden_def(strftime_l)
+# endif
 
 #endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
 
@@ -1314,7 +1314,6 @@ char *strptime(const char *__restrict buf, const char *__restrict format,
 {
 	return strptime_l(buf, format, tm, __UCLIBC_CURLOCALE);
 }
-libc_hidden_def(strptime)
 
 #else  /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
 
@@ -1460,7 +1459,6 @@ static const unsigned char spec[] = {
 
 #define MAX_PUSH 4
 
-libc_hidden_proto(__XL_NPP(strptime))
 char *__XL_NPP(strptime)(const char *__restrict buf, const char *__restrict format,
 					 struct tm *__restrict tm   __LOCALE_PARAM)
 {
@@ -1671,7 +1669,9 @@ LOOP:
 	}
 	return NULL;
 }
-libc_hidden_def(__XL_NPP(strptime))
+# ifdef L_strptime_l
+libc_hidden_def(strptime_l)
+# endif
 
 #endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
 
@@ -2455,11 +2455,9 @@ size_t wcsftime(wchar_t *__restrict s, size_t maxsize,
 {
 	return wcsftime_l(s, maxsize, format, timeptr, __UCLIBC_CURLOCALE);
 }
-libc_hidden_def(wcsftime)
 
 #else  /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
 
-libc_hidden_proto(__XL_NPP(wcsftime))
 size_t __XL_NPP(wcsftime)(wchar_t *__restrict s, size_t maxsize,
 					  const wchar_t *__restrict format,
 					  const struct tm *__restrict timeptr   __LOCALE_PARAM )
@@ -2467,7 +2465,9 @@ size_t __XL_NPP(wcsftime)(wchar_t *__restrict s, size_t maxsize,
 #warning wcsftime always fails
 	return 0;					/* always fail */
 }
-libc_hidden_def(__XL_NPP(wcsftime))
+#ifdef L_wcsftime_l
+libc_hidden_def(wcsftime_l)
+#endif
 
 #endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
 

+ 1 - 1
libc/misc/utmp/utent.c

@@ -98,8 +98,8 @@ struct utmp *getutent(void)
     __UCLIBC_MUTEX_UNLOCK(utmplock);
     return ret;
 }
-libc_hidden_def(getutent)
 #endif
+libc_hidden_def(getutent)
 
 void endutent(void)
 {

+ 16 - 7
libc/misc/wctype/_wctype.c

@@ -140,28 +140,27 @@ enum {
 #ifdef __UCLIBC_DO_XLOCALE
 
 #define ISW_FUNC_BODY(NAME) \
-libc_hidden_proto(__PASTE3(isw,NAME,_l)) \
 int __PASTE3(isw,NAME,_l) (wint_t wc, __locale_t l) \
 { \
 	return iswctype_l(wc, __PASTE2(_CTYPE_is,NAME), l); \
-} \
-libc_hidden_def(__PASTE3(isw,NAME,_l))
+}
 
 #else  /* __UCLIBC_DO_XLOCALE */
 
 #define ISW_FUNC_BODY(NAME) \
-libc_hidden_proto(__PASTE2(isw,NAME)) \
 int __PASTE2(isw,NAME) (wint_t wc) \
 { \
 	return iswctype(wc, __PASTE2(_CTYPE_is,NAME)); \
-} \
-libc_hidden_def(__PASTE2(isw,NAME))
+}
 
 #endif /* __UCLIBC_DO_XLOCALE */
 /**********************************************************************/
 #if defined(L_iswalnum) || defined(L_iswalnum_l)
 
 ISW_FUNC_BODY(alnum);
+# ifdef L_iswalnum
+libc_hidden_def(iswalnum)
+# endif
 
 #endif
 /**********************************************************************/
@@ -198,6 +197,9 @@ ISW_FUNC_BODY(graph);
 #if defined(L_iswlower) || defined(L_iswlower_l)
 
 ISW_FUNC_BODY(lower);
+# ifdef L_iswlower
+libc_hidden_def(iswlower)
+# endif
 
 #endif
 /**********************************************************************/
@@ -216,12 +218,20 @@ ISW_FUNC_BODY(punct);
 #if defined(L_iswspace) || defined(L_iswspace_l)
 
 ISW_FUNC_BODY(space);
+# ifdef L_iswspace
+libc_hidden_def(iswspace)
+# else
+libc_hidden_def(iswspace_l)
+# endif
 
 #endif
 /**********************************************************************/
 #if defined(L_iswupper) || defined(L_iswupper_l)
 
 ISW_FUNC_BODY(upper);
+# ifdef L_iswupper
+libc_hidden_def(iswupper)
+# endif
 
 #endif
 /**********************************************************************/
@@ -461,7 +471,6 @@ wctype_t wctype_l (const char *property, __locale_t locale)
 {
 	return wctype(property);
 }
-libc_hidden_def(wctype_l)
 
 #endif
 /**********************************************************************/

+ 0 - 1
libc/stdio/_scanf.c

@@ -198,7 +198,6 @@ int vscanf(const char * __restrict format, va_list arg)
 {
 	return vfscanf(stdin, format, arg);
 }
-libc_hidden_def(vscanf)
 
 #endif
 /**********************************************************************/

+ 10 - 0
libc/stdio/_vfprintf.c

@@ -417,6 +417,8 @@ extern uintmax_t _load_inttype(int desttype, const void *src, int uflag) attribu
 /**********************************************************************/
 #ifdef L_parse_printf_format
 
+#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__
+
 /* NOTE: This function differs from the glibc version in that parsing stops
  * upon encountering an invalid conversion specifier.  Since this is the way
  * my printf functions work, I think it makes sense to do it that way here.
@@ -484,6 +486,8 @@ size_t parse_printf_format(register const char *template,
 	return count;
 }
 
+#endif
+
 #endif
 /**********************************************************************/
 #ifdef L__ppfs_init
@@ -1670,6 +1674,9 @@ static int _do_one_spec(FILE * __restrict stream,
 #endif
 					s = "(null)";
 					slen = 6;
+					/* Use an empty string rather than truncation if precision is too small. */
+					if (ppfs->info.prec >= 0 && ppfs->info.prec < slen)
+						slen = 0;
 				}
 			} else {			/* char */
 				s = buf;
@@ -1726,6 +1733,9 @@ static int _do_one_spec(FILE * __restrict stream,
 				NULL_STRING:
 					s = "(null)";
 					SLEN = slen = 6;
+					/* Use an empty string rather than truncation if precision is too small. */
+					if (ppfs->info.prec >= 0 && ppfs->info.prec < slen)
+						SLEN = slen = 0;
 				}
 			} else {			/* char */
 				*wbuf = btowc( (unsigned char)(*((const int *) *argptr)) );

+ 0 - 1
libc/stdio/fwprintf.c

@@ -21,4 +21,3 @@ int fwprintf(FILE * __restrict stream, const wchar_t * __restrict format, ...)
 
 	return rv;
 }
-libc_hidden_def(fwprintf)

+ 3 - 4
libc/stdlib/_strtod.c

@@ -544,7 +544,6 @@ libc_hidden_def(__XL_NPP(strtof))
 #define Wchar char
 #endif
 
-libc_hidden_proto(__XL_NPP(strtod))
 double __XL_NPP(strtod)(const Wchar *__restrict str,
 					Wchar **__restrict endptr   __LOCALE_PARAM )
 {
@@ -562,7 +561,9 @@ double __XL_NPP(strtod)(const Wchar *__restrict str,
 	return y;
 #endif
 }
-libc_hidden_def(__XL_NPP(strtod))
+#ifdef L_strtod
+libc_hidden_def(strtod)
+#endif
 
 #endif
 #endif
@@ -580,7 +581,6 @@ libc_hidden_def(__XL_NPP(strtod))
 #define Wchar char
 #endif
 
-libc_hidden_proto(__XL_NPP(strtold))
 long double __XL_NPP(strtold) (const Wchar *str, Wchar **endptr   __LOCALE_PARAM )
 {
 #if FPMAX_TYPE == 3
@@ -597,7 +597,6 @@ long double __XL_NPP(strtold) (const Wchar *str, Wchar **endptr   __LOCALE_PARAM
 	return y;
 #endif
 }
-libc_hidden_def(__XL_NPP(strtold))
 
 #endif
 #endif

+ 10 - 17
libc/stdlib/arc4random.c

@@ -54,8 +54,7 @@ static __inline__ uint8_t arc4_getbyte(struct arc4_stream *);
 static __inline__ uint32_t arc4_getword(struct arc4_stream *);
 
 static __inline__ void
-arc4_init(as)
-	struct arc4_stream *as;
+arc4_init(struct arc4_stream *as)
 {
 	int     n;
 
@@ -66,10 +65,7 @@ arc4_init(as)
 }
 
 static __inline__ void
-arc4_addrandom(as, dat, datlen)
-	struct arc4_stream *as;
-	u_char *dat;
-	int     datlen;
+arc4_addrandom(struct arc4_stream *as, u_char *dat, int datlen)
 {
 	int     n;
 	uint8_t si;
@@ -86,8 +82,7 @@ arc4_addrandom(as, dat, datlen)
 }
 
 static void
-arc4_stir(as)
-	struct arc4_stream *as;
+arc4_stir(struct arc4_stream *as)
 {
 	int     fd;
 	struct {
@@ -137,8 +132,7 @@ arc4_stir(as)
 }
 
 static __inline__ uint8_t
-arc4_getbyte(as)
-	struct arc4_stream *as;
+arc4_getbyte(struct arc4_stream *as)
 {
 	uint8_t si, sj;
 
@@ -152,8 +146,7 @@ arc4_getbyte(as)
 }
 
 static __inline__ uint32_t
-arc4_getword(as)
-	struct arc4_stream *as;
+arc4_getword(struct arc4_stream *as)
 {
 	uint32_t val;
 	val = arc4_getbyte(as) << 24;
@@ -163,8 +156,8 @@ arc4_getword(as)
 	return val;
 }
 
-void
-arc4random_stir(void)
+static void
+__arc4random_stir(void)
 {
 	if (!rs_initialized) {
 		arc4_init(&rs);
@@ -172,13 +165,13 @@ arc4random_stir(void)
 	}
 	arc4_stir(&rs);
 }
-libc_hidden_def(arc4random_stir)
+strong_alias(__arc4random_stir,arc4random_stir)
 
 void
 arc4random_addrandom(u_char *dat, int datlen)
 {
 	if (!rs_initialized)
-		arc4random_stir();
+		__arc4random_stir();
 	arc4_addrandom(&rs, dat, datlen);
 }
 
@@ -186,7 +179,7 @@ uint32_t
 arc4random(void)
 {
 	if (!rs_initialized)
-		arc4random_stir();
+		__arc4random_stir();
 	return arc4_getword(&rs);
 }
 

+ 2 - 2
libc/stdlib/drand48-iter.c

@@ -21,15 +21,15 @@
 #include <stdlib.h>
 #include <limits.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <sys/types.h>
 
 /* Global state for non-reentrant functions.  */
-struct drand48_data __libc_drand48_data attribute_hidden;
+struct drand48_data __libc_drand48_data;
 
 #ifdef __UCLIBC_MJN3_ONLY__
 #warning turn int __drand48_iterate into void
 #endif /* __UCLIBC_MJN3_ONLY__ */
-int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer) attribute_hidden;
 int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer)
 {
   uint64_t X;

+ 0 - 4
libc/stdlib/drand48.c

@@ -19,10 +19,6 @@
 
 #include <stdlib.h>
 
-
-/* Global state for non-reentrant functions.  Defined in drand48-iter.c.  */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
 double drand48 (void)
 {
   double result;

+ 0 - 4
libc/stdlib/erand48.c

@@ -19,10 +19,6 @@
 
 #include <stdlib.h>
 
-
-/* Global state for non-reentrant functions.  Defined in drand48-iter.c.  */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
 double erand48 (unsigned short int xsubi[3])
 {
     double result;

+ 0 - 3
libc/stdlib/erand48_r.c

@@ -21,9 +21,6 @@
 #include <stdlib.h>
 #include <limits.h>
 
-extern int __drand48_iterate(unsigned short xsubi[3],
-	struct drand48_data *buffer) attribute_hidden;
-
 int erand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, double *result)
 {
     union ieee754_double temp;

+ 0 - 4
libc/stdlib/jrand48.c

@@ -19,10 +19,6 @@
 
 #include <stdlib.h>
 
-
-/* Global state for non-reentrant functions.  Defined in drand48-iter.c.  */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
 long int jrand48 (unsigned short int xsubi[3])
 {
     long int result;

+ 0 - 3
libc/stdlib/jrand48_r.c

@@ -19,9 +19,6 @@
 
 #include <stdlib.h>
 
-extern int __drand48_iterate(unsigned short xsubi[3],
-	struct drand48_data *buffer) attribute_hidden;
-
 int jrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result)
 {
     /* Compute next state.  */

+ 0 - 4
libc/stdlib/lrand48.c

@@ -19,10 +19,6 @@
 
 #include <stdlib.h>
 
-
-/* Global state for non-reentrant functions.  Defined in drand48-iter.c.  */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
 long int lrand48 (void)
 {
     long int result;

Some files were not shown because too many files changed in this diff