[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/build/uClibc/utils/Makefile b/ap/build/uClibc/utils/Makefile
new file mode 100644
index 0000000..bdaea9f
--- /dev/null
+++ b/ap/build/uClibc/utils/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../
+top_builddir=../
+include $(top_builddir)Rules.mak
+all: utils
+include Makefile.in
+include $(top_srcdir)Makerules
diff --git a/ap/build/uClibc/utils/Makefile.in b/ap/build/uClibc/utils/Makefile.in
new file mode 100644
index 0000000..bb85be3
--- /dev/null
+++ b/ap/build/uClibc/utils/Makefile.in
@@ -0,0 +1,139 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2009 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+subdirs += utils
+
+# "make utils" flags
+
+CFLAGS-utils := \
+    $(SSP_ALL_CFLAGS) \
+    -I$(top_srcdir)ldso/include \
+    -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
+    -DUCLIBC_LDSO=\"$(UCLIBC_LDSO)\" \
+    -I$(top_srcdir)/$(KERNEL_HEADERS) \
+    -DNOT_IN_libc \
+    -B$(top_builddir)lib \
+    -Wl,-rpath-link,$(top_builddir)lib
+
+ifeq ($(UCLIBC_BUILD_PIE),y)
+CFLAGS-utils-shared := $(PIEFLAG) $(LDPIEFLAG)
+else
+CFLAGS-utils-shared :=
+endif
+
+CFLAGS-ldconfig := -DBUILDING_LINKAGE
+ifeq ($(UCLIBC_STATIC_LDCONFIG),y)
+CFLAGS-ldconfig += -static
+else
+CFLAGS-ldconfig += $(CFLAGS-utils-shared)
+endif
+
+CFLAGS-ldd := $(CFLAGS-utils-shared) -DBUILDING_LINKAGE
+
+# Need CFLAGS-utils explicitly, because the source file is not located in utils
+CFLAGS-iconv := $(CFLAGS-utils) \
+    $(CFLAGS-utils-shared) \
+    -I$(top_srcdir)libc/misc/wchar \
+    -DL_iconv_main \
+
+CFLAGS-locale := $(CFLAGS-utils)
+CFLAGS-getconf :=$(CFLAGS-utils) \
+	-DGETCONF_DIR='"$(CURDIR)"'
+
+# "make hostutils" flags
+
+UTILS_CONFIG_FLAGS-y :=
+UTILS_CONFIG_FLAGS-$(LDSO_CACHE_SUPPORT) += -D__LDSO_CACHE_SUPPORT__
+UTILS_CONFIG_FLAGS-$(LDSO_LDD_SUPPORT) += -D__LDSO_LDD_SUPPORT__
+UTILS_CONFIG_FLAGS-$(LDSO_STANDALONE_SUPPORT) += -D__LDSO_STANDALONE_SUPPORT__
+
+BUILD_CFLAGS-utils := \
+    -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
+    -DUCLIBC_LDSO=\"$(UCLIBC_LDSO)\" \
+    $(UTILS_CONFIG_FLAGS-y)
+BUILD_CFLAGS-ldconfig.host := \
+				-DBUILDING_LINKAGE \
+				-I$(top_srcdir)ldso/include
+BUILD_CFLAGS-ldd.host      := \
+				-DBUILDING_LINKAGE \
+				-I$(top_srcdir)ldso/include \
+				-include $(top_srcdir)include/elf.h
+BUILD_CFLAGS-locale.host   := \
+				-DNOT_IN_libc \
+				-I$(top_srcdir)utils/ \
+				-I.
+BUILD_CFLAGS-iconv.host    := \
+			-include $(top_builddir)extra/locale/c8tables.h \
+			-I$(top_srcdir)libc/misc/wchar -DL_iconv_main
+
+BUILD_CFLAGS-getconf.host  := \
+				-DGETCONF_DIR='"$(CURDIR)"'
+
+# Rules
+
+utils_DIR := $(top_srcdir)utils
+utils_OUT := $(top_builddir)utils
+
+DEPS-ldconfig := $(utils_DIR)/chroot_realpath.c
+DEPS-ldconfig.host := $(DEPS-ldconfig)
+
+utils_OBJ := getconf
+ifeq ($(HAVE_SHARED),y)
+utils_OBJ += ldconfig ldd
+endif
+
+utils_LOCALE_OBJ :=
+ifeq ($(UCLIBC_HAS_LOCALE),y)
+utils_OBJ += iconv
+#utils_LOCALE_OBJ += $(utils_OUT)/locale
+endif
+
+utils_OBJ := $(patsubst %,$(utils_OUT)/%,$(utils_OBJ))
+
+hostutils_OBJ := $(patsubst %,%.host,$(utils_OBJ))
+hostutils_LOCALE_OBJ := $(patsubst %,%.host,$(utils_LOCALE_OBJ))
+
+utils: $(utils_OBJ) $(utils_LOCALE_OBJ)
+
+# NOTE: We build the utils AFTER we have a uClibc-targeted toolchain.
+
+$(utils_OBJ): $(utils_OUT)/% : $(utils_DIR)/%.c | $(libc)
+	$(compile.u)
+
+$(utils_OUT)/locale: $(top_srcdir)extra/locale/programs/locale.c | $(libc)
+	$(compile.u)
+
+$(utils_OUT)/locale.host: $(top_srcdir)extra/locale/programs/locale.c | $(libc)
+	$(hcompile.u)
+
+hostutils: $(hostutils_OBJ) $(hostutils_LOCALE_OBJ)
+
+$(hostutils_OBJ): $(utils_OUT)/%.host : $(utils_DIR)/%.c
+	$(hcompile.u)
+
+
+install-y += utils_install
+
+# This installs both utils and hostutils, so doesn't depend on either.
+
+utils_install: $(addsuffix $(DOTHOST), $(utils_OBJ) $(utils_LOCALE_OBJ))
+	$(Q)$(INSTALL) -D -m 755 $(utils_OUT)/getconf$(DOTHOST) $(PREFIX)$(DEVEL_PREFIX)bin/getconf
+ifeq ($(HAVE_SHARED),y)
+	$(Q)$(INSTALL) -D -m 755 $(utils_OUT)/ldd$(DOTHOST) $(PREFIX)$(DEVEL_PREFIX)bin/ldd
+	$(Q)$(INSTALL) -D -m 755 $(utils_OUT)/ldconfig$(DOTHOST) $(PREFIX)$(RUNTIME_PREFIX)sbin/ldconfig
+endif
+ifeq ($(UCLIBC_HAS_LOCALE),y)
+	$(Q)$(INSTALL) -D -m 755 $(utils_OUT)/iconv$(DOTHOST) $(PREFIX)$(DEVEL_PREFIX)bin/iconv
+	#$(Q)$(INSTALL) -m 755 $(utils_OUT)/locale$(DOTHOST) $(PREFIX)$(DEVEL_PREFIX)bin/locale
+endif
+
+
+objclean-y += CLEAN_utils
+
+CLEAN_utils:
+	$(do_rm) $(addprefix $(utils_OUT)/, getconf iconv ldconfig ldd locale *.host)
+	$(Q)# This is a hack..
+	$(Q)$(RM) $(utils_OUT)/.*.dep
diff --git a/ap/build/uClibc/utils/bswap.h b/ap/build/uClibc/utils/bswap.h
new file mode 100644
index 0000000..0047e4e
--- /dev/null
+++ b/ap/build/uClibc/utils/bswap.h
@@ -0,0 +1,45 @@
+/*
+ * Lame bswap replacements as we can't assume the host is sane and provides
+ * working versions of these.
+ */
+
+#ifndef _BSWAP_H
+#define	_BSWAP_H 1
+
+#ifdef __linux__
+# include <byteswap.h>
+#else
+
+static __inline__ uint16_t bswap_16(uint16_t x)
+{
+	return ((((x) & 0xff00) >> 8) | \
+	        (((x) & 0x00ff) << 8));
+}
+static __inline__ uint32_t bswap_32(uint32_t x)
+{
+	return ((((x) & 0xff000000) >> 24) | \
+	        (((x) & 0x00ff0000) >>  8) | \
+	        (((x) & 0x0000ff00) <<  8) | \
+	        (((x) & 0x000000ff) << 24));
+}
+static __inline__ uint64_t bswap_64(uint64_t x)
+{
+#define _uswap_64(x, sfx) \
+	return ((((x) & 0xff00000000000000##sfx) >> 56) | \
+	        (((x) & 0x00ff000000000000##sfx) >> 40) | \
+	        (((x) & 0x0000ff0000000000##sfx) >> 24) | \
+	        (((x) & 0x000000ff00000000##sfx) >>  8) | \
+	        (((x) & 0x00000000ff000000##sfx) <<  8) | \
+	        (((x) & 0x0000000000ff0000##sfx) << 24) | \
+	        (((x) & 0x000000000000ff00##sfx) << 40) | \
+	        (((x) & 0x00000000000000ff##sfx) << 56));
+#if defined(__GNUC__)
+	_uswap_64(x, ull)
+#else
+	_uswap_64(x, )
+#endif
+#undef _uswap_64
+}
+#endif
+
+#endif
diff --git a/ap/build/uClibc/utils/chroot_realpath.c b/ap/build/uClibc/utils/chroot_realpath.c
new file mode 100644
index 0000000..0be57bf
--- /dev/null
+++ b/ap/build/uClibc/utils/chroot_realpath.c
@@ -0,0 +1,152 @@
+/*
+ * chroot_realpath.c -- resolve pathname as if inside chroot
+ * Based on realpath.c Copyright (C) 1993 Rick Sladkey <jrs@world.std.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * 2005/09/12: Dan Howell (modified from realpath.c to emulate chroot)
+ */
+
+#include "porting.h"
+
+#define MAX_READLINKS 32
+
+char *chroot_realpath(const char *root, const char *path,
+		      char resolved_path[]);
+
+char *chroot_realpath(const char *root, const char *path,
+		      char resolved_path[])
+{
+	char copy_path[PATH_MAX];
+	char link_path[PATH_MAX];
+	char got_path[PATH_MAX];
+	char *got_path_root = got_path;
+	char *new_path = got_path;
+	char *max_path;
+	int readlinks = 0;
+	int n;
+	int chroot_len;
+
+	/* Trivial case. */
+	if (root == NULL || *root == '\0' ||
+	    (*root == '/' && root[1] == '\0')) {
+		strcpy(resolved_path, path);
+		return resolved_path;
+	}
+
+	chroot_len = strlen(root);
+
+	if (chroot_len + strlen(path) >= PATH_MAX - 3) {
+		errno = ENAMETOOLONG;
+		return NULL;
+	}
+
+	/* Make a copy of the source path since we may need to modify it. */
+	strcpy(copy_path, path);
+	path = copy_path;
+	max_path = copy_path + PATH_MAX - chroot_len - 3;
+
+	/* Start with the chroot path. */
+	strcpy(new_path, root);
+	new_path += chroot_len;
+	while (*new_path == '/' && new_path > got_path)
+		new_path--;
+	got_path_root = new_path;
+	*new_path++ = '/';
+
+	/* Expand each slash-separated pathname component. */
+	while (*path != '\0') {
+		/* Ignore stray "/". */
+		if (*path == '/') {
+			path++;
+			continue;
+		}
+		if (*path == '.') {
+			/* Ignore ".". */
+			if (path[1] == '\0' || path[1] == '/') {
+				path++;
+				continue;
+			}
+			if (path[1] == '.') {
+				if (path[2] == '\0' || path[2] == '/') {
+					path += 2;
+					/* Ignore ".." at root. */
+					if (new_path == got_path_root + 1)
+						continue;
+					/* Handle ".." by backing up. */
+					while ((--new_path)[-1] != '/') ;
+					continue;
+				}
+			}
+		}
+		/* Safely copy the next pathname component. */
+		while (*path != '\0' && *path != '/') {
+			if (path > max_path) {
+				errno = ENAMETOOLONG;
+				return NULL;
+			}
+			*new_path++ = *path++;
+		}
+		if (*path == '\0')
+			/* Don't follow symlink for last pathname component. */
+			break;
+#ifdef S_IFLNK
+		/* Protect against infinite loops. */
+		if (readlinks++ > MAX_READLINKS) {
+			errno = ELOOP;
+			return NULL;
+		}
+		/* See if latest pathname component is a symlink. */
+		*new_path = '\0';
+		n = readlink(got_path, link_path, PATH_MAX - 1);
+		if (n < 0) {
+			/* EINVAL means the file exists but isn't a symlink. */
+			if (errno != EINVAL) {
+				/* Make sure it's null terminated. */
+				*new_path = '\0';
+				strcpy(resolved_path, got_path);
+				return NULL;
+			}
+		} else {
+			/* Note: readlink doesn't add the null byte. */
+			link_path[n] = '\0';
+			if (*link_path == '/')
+				/* Start over for an absolute symlink. */
+				new_path = got_path_root;
+			else
+				/* Otherwise back up over this component. */
+				while (*(--new_path) != '/') ;
+			/* Safe sex check. */
+			if (strlen(path) + n >= PATH_MAX - 2) {
+				errno = ENAMETOOLONG;
+				return NULL;
+			}
+			/* Insert symlink contents into path. */
+			strcat(link_path, path);
+			strcpy(copy_path, link_path);
+			path = copy_path;
+		}
+#endif				/* S_IFLNK */
+		*new_path++ = '/';
+	}
+	/* Delete trailing slash but don't whomp a lone slash. */
+	if (new_path != got_path + 1 && new_path[-1] == '/')
+		new_path--;
+	/* Make sure it's null terminated. */
+	*new_path = '\0';
+	strcpy(resolved_path, got_path);
+	return resolved_path;
+}
diff --git a/ap/build/uClibc/utils/getconf.c b/ap/build/uClibc/utils/getconf.c
new file mode 100644
index 0000000..0b2a5aa
--- /dev/null
+++ b/ap/build/uClibc/utils/getconf.c
@@ -0,0 +1,1336 @@
+/* Copyright (C) 1991, 92, 1995-2008, 2009 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published
+   by the Free Software Foundation; version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#define _GNU_SOURCE 1
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define PACKAGE "getconf regression test"
+#define VERSION ""
+#define _(x) x
+#define error(status, errnum, fmt, ...) \
+	{fprintf(stderr, fmt "\n", ## __VA_ARGS__); exit(status);}
+
+
+struct conf
+  {
+    const char *name;
+    const int call_name;
+    const enum { SYSCONF, CONFSTR, PATHCONF } call;
+  };
+
+static const struct conf vars[] =
+  {
+#ifdef _PC_LINK_MAX
+    { "LINK_MAX", _PC_LINK_MAX, PATHCONF },
+#endif
+#ifdef _PC_LINK_MAX
+    { "_POSIX_LINK_MAX", _PC_LINK_MAX, PATHCONF },
+#endif
+#ifdef _PC_MAX_CANON
+    { "MAX_CANON", _PC_MAX_CANON, PATHCONF },
+#endif
+#ifdef _PC_MAX_CANON
+    { "_POSIX_MAX_CANON", _PC_MAX_CANON, PATHCONF },
+#endif
+#ifdef _PC_MAX_INPUT
+    { "MAX_INPUT", _PC_MAX_INPUT, PATHCONF },
+#endif
+#ifdef _PC_MAX_INPUT
+    { "_POSIX_MAX_INPUT", _PC_MAX_INPUT, PATHCONF },
+#endif
+#ifdef _PC_NAME_MAX
+    { "NAME_MAX", _PC_NAME_MAX, PATHCONF },
+#endif
+#ifdef _PC_NAME_MAX
+    { "_POSIX_NAME_MAX", _PC_NAME_MAX, PATHCONF },
+#endif
+#ifdef _PC_PATH_MAX
+    { "PATH_MAX", _PC_PATH_MAX, PATHCONF },
+#endif
+#ifdef _PC_PATH_MAX
+    { "_POSIX_PATH_MAX", _PC_PATH_MAX, PATHCONF },
+#endif
+#ifdef _PC_PIPE_BUF
+    { "PIPE_BUF", _PC_PIPE_BUF, PATHCONF },
+#endif
+#ifdef _PC_PIPE_BUF
+    { "_POSIX_PIPE_BUF", _PC_PIPE_BUF, PATHCONF },
+#endif
+#ifdef _PC_SOCK_MAXBUF
+    { "SOCK_MAXBUF", _PC_SOCK_MAXBUF, PATHCONF },
+#endif
+#ifdef _PC_ASYNC_IO
+    { "_POSIX_ASYNC_IO", _PC_ASYNC_IO, PATHCONF },
+#endif
+#ifdef _PC_CHOWN_RESTRICTED
+    { "_POSIX_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED, PATHCONF },
+#endif
+#ifdef _PC_NO_TRUNC
+    { "_POSIX_NO_TRUNC", _PC_NO_TRUNC, PATHCONF },
+#endif
+#ifdef _PC_PRIO_IO
+    { "_POSIX_PRIO_IO", _PC_PRIO_IO, PATHCONF },
+#endif
+#ifdef _PC_SYNC_IO
+    { "_POSIX_SYNC_IO", _PC_SYNC_IO, PATHCONF },
+#endif
+#ifdef _PC_VDISABLE
+    { "_POSIX_VDISABLE", _PC_VDISABLE, PATHCONF },
+#endif
+
+#ifdef _SC_ARG_MAX
+    { "ARG_MAX", _SC_ARG_MAX, SYSCONF },
+#endif
+#ifdef _SC_ATEXIT_MAX
+    { "ATEXIT_MAX", _SC_ATEXIT_MAX, SYSCONF },
+#endif
+#ifdef _SC_CHAR_BIT
+    { "CHAR_BIT", _SC_CHAR_BIT, SYSCONF },
+#endif
+#ifdef _SC_CHAR_MAX
+    { "CHAR_MAX", _SC_CHAR_MAX, SYSCONF },
+#endif
+#ifdef _SC_CHAR_MIN
+    { "CHAR_MIN", _SC_CHAR_MIN, SYSCONF },
+#endif
+#ifdef _SC_CHILD_MAX
+    { "CHILD_MAX", _SC_CHILD_MAX, SYSCONF },
+#endif
+#ifdef _SC_CLK_TCK
+    { "CLK_TCK", _SC_CLK_TCK, SYSCONF },
+#endif
+#ifdef _SC_INT_MAX
+    { "INT_MAX", _SC_INT_MAX, SYSCONF },
+#endif
+#ifdef _SC_INT_MIN
+    { "INT_MIN", _SC_INT_MIN, SYSCONF },
+#endif
+#ifdef _SC_UIO_MAXIOV
+    { "IOV_MAX", _SC_UIO_MAXIOV, SYSCONF },
+#endif
+#ifdef _SC_LOGIN_NAME_MAX
+    { "LOGNAME_MAX", _SC_LOGIN_NAME_MAX, SYSCONF },
+#endif
+#ifdef _SC_LONG_BIT
+    { "LONG_BIT", _SC_LONG_BIT, SYSCONF },
+#endif
+#ifdef _SC_MB_LEN_MAX
+    { "MB_LEN_MAX", _SC_MB_LEN_MAX, SYSCONF },
+#endif
+#ifdef _SC_NGROUPS_MAX
+    { "NGROUPS_MAX", _SC_NGROUPS_MAX, SYSCONF },
+#endif
+#ifdef _SC_NL_ARGMAX
+    { "NL_ARGMAX", _SC_NL_ARGMAX, SYSCONF },
+#endif
+#ifdef _SC_NL_LANGMAX
+    { "NL_LANGMAX", _SC_NL_LANGMAX, SYSCONF },
+#endif
+#ifdef _SC_NL_MSGMAX
+    { "NL_MSGMAX", _SC_NL_MSGMAX, SYSCONF },
+#endif
+#ifdef _SC_NL_NMAX
+    { "NL_NMAX", _SC_NL_NMAX, SYSCONF },
+#endif
+#ifdef _SC_NL_SETMAX
+    { "NL_SETMAX", _SC_NL_SETMAX, SYSCONF },
+#endif
+#ifdef _SC_NL_TEXTMAX
+    { "NL_TEXTMAX", _SC_NL_TEXTMAX, SYSCONF },
+#endif
+#ifdef _SC_GETGR_R_SIZE_MAX
+    { "NSS_BUFLEN_GROUP", _SC_GETGR_R_SIZE_MAX, SYSCONF },
+#endif
+#ifdef _SC_GETPW_R_SIZE_MAX
+    { "NSS_BUFLEN_PASSWD", _SC_GETPW_R_SIZE_MAX, SYSCONF },
+#endif
+#ifdef _SC_NZERO
+    { "NZERO", _SC_NZERO, SYSCONF },
+#endif
+#ifdef _SC_OPEN_MAX
+    { "OPEN_MAX", _SC_OPEN_MAX, SYSCONF },
+#endif
+#ifdef _SC_PAGESIZE
+    { "PAGESIZE", _SC_PAGESIZE, SYSCONF },
+#endif
+#ifdef _SC_PAGESIZE
+    { "PAGE_SIZE", _SC_PAGESIZE, SYSCONF },
+#endif
+#ifdef _SC_PASS_MAX
+    { "PASS_MAX", _SC_PASS_MAX, SYSCONF },
+#endif
+#ifdef _SC_THREAD_DESTRUCTOR_ITERATIONS
+    { "PTHREAD_DESTRUCTOR_ITERATIONS", _SC_THREAD_DESTRUCTOR_ITERATIONS, SYSCONF },
+#endif
+#ifdef _SC_THREAD_KEYS_MAX
+    { "PTHREAD_KEYS_MAX", _SC_THREAD_KEYS_MAX, SYSCONF },
+#endif
+#ifdef _SC_THREAD_STACK_MIN
+    { "PTHREAD_STACK_MIN", _SC_THREAD_STACK_MIN, SYSCONF },
+#endif
+#ifdef _SC_THREAD_THREADS_MAX
+    { "PTHREAD_THREADS_MAX", _SC_THREAD_THREADS_MAX, SYSCONF },
+#endif
+#ifdef _SC_SCHAR_MAX
+    { "SCHAR_MAX", _SC_SCHAR_MAX, SYSCONF },
+#endif
+#ifdef _SC_SCHAR_MIN
+    { "SCHAR_MIN", _SC_SCHAR_MIN, SYSCONF },
+#endif
+#ifdef _SC_SHRT_MAX
+    { "SHRT_MAX", _SC_SHRT_MAX, SYSCONF },
+#endif
+#ifdef _SC_SHRT_MIN
+    { "SHRT_MIN", _SC_SHRT_MIN, SYSCONF },
+#endif
+#ifdef _SC_SSIZE_MAX
+    { "SSIZE_MAX", _SC_SSIZE_MAX, SYSCONF },
+#endif
+#ifdef _SC_TTY_NAME_MAX
+    { "TTY_NAME_MAX", _SC_TTY_NAME_MAX, SYSCONF },
+#endif
+#ifdef _SC_TZNAME_MAX
+    { "TZNAME_MAX", _SC_TZNAME_MAX, SYSCONF },
+#endif
+#ifdef _SC_UCHAR_MAX
+    { "UCHAR_MAX", _SC_UCHAR_MAX, SYSCONF },
+#endif
+#ifdef _SC_UINT_MAX
+    { "UINT_MAX", _SC_UINT_MAX, SYSCONF },
+#endif
+#ifdef _SC_UIO_MAXIOV
+    { "UIO_MAXIOV", _SC_UIO_MAXIOV, SYSCONF },
+#endif
+#ifdef _SC_ULONG_MAX
+    { "ULONG_MAX", _SC_ULONG_MAX, SYSCONF },
+#endif
+#ifdef _SC_USHRT_MAX
+    { "USHRT_MAX", _SC_USHRT_MAX, SYSCONF },
+#endif
+#ifdef _SC_WORD_BIT
+    { "WORD_BIT", _SC_WORD_BIT, SYSCONF },
+#endif
+#ifdef _SC_AVPHYS_PAGES
+    { "_AVPHYS_PAGES", _SC_AVPHYS_PAGES, SYSCONF },
+#endif
+#ifdef _SC_NPROCESSORS_CONF
+    { "_NPROCESSORS_CONF", _SC_NPROCESSORS_CONF, SYSCONF },
+#endif
+#ifdef _SC_NPROCESSORS_ONLN
+    { "_NPROCESSORS_ONLN", _SC_NPROCESSORS_ONLN, SYSCONF },
+#endif
+#ifdef _SC_PHYS_PAGES
+    { "_PHYS_PAGES", _SC_PHYS_PAGES, SYSCONF },
+#endif
+#ifdef _SC_ARG_MAX
+    { "_POSIX_ARG_MAX", _SC_ARG_MAX, SYSCONF },
+#endif
+#ifdef _SC_ASYNCHRONOUS_IO
+    { "_POSIX_ASYNCHRONOUS_IO", _SC_ASYNCHRONOUS_IO, SYSCONF },
+#endif
+#ifdef _SC_CHILD_MAX
+    { "_POSIX_CHILD_MAX", _SC_CHILD_MAX, SYSCONF },
+#endif
+#ifdef _SC_FSYNC
+    { "_POSIX_FSYNC", _SC_FSYNC, SYSCONF },
+#endif
+#ifdef _SC_JOB_CONTROL
+    { "_POSIX_JOB_CONTROL", _SC_JOB_CONTROL, SYSCONF },
+#endif
+#ifdef _SC_MAPPED_FILES
+    { "_POSIX_MAPPED_FILES", _SC_MAPPED_FILES, SYSCONF },
+#endif
+#ifdef _SC_MEMLOCK
+    { "_POSIX_MEMLOCK", _SC_MEMLOCK, SYSCONF },
+#endif
+#ifdef _SC_MEMLOCK_RANGE
+    { "_POSIX_MEMLOCK_RANGE", _SC_MEMLOCK_RANGE, SYSCONF },
+#endif
+#ifdef _SC_MEMORY_PROTECTION
+    { "_POSIX_MEMORY_PROTECTION", _SC_MEMORY_PROTECTION, SYSCONF },
+#endif
+#ifdef _SC_MESSAGE_PASSING
+    { "_POSIX_MESSAGE_PASSING", _SC_MESSAGE_PASSING, SYSCONF },
+#endif
+#ifdef _SC_NGROUPS_MAX
+    { "_POSIX_NGROUPS_MAX", _SC_NGROUPS_MAX, SYSCONF },
+#endif
+#ifdef _SC_OPEN_MAX
+    { "_POSIX_OPEN_MAX", _SC_OPEN_MAX, SYSCONF },
+#endif
+#ifdef _SC_PII
+    { "_POSIX_PII", _SC_PII, SYSCONF },
+#endif
+#ifdef _SC_PII_INTERNET
+    { "_POSIX_PII_INTERNET", _SC_PII_INTERNET, SYSCONF },
+#endif
+#ifdef _SC_PII_INTERNET_DGRAM
+    { "_POSIX_PII_INTERNET_DGRAM", _SC_PII_INTERNET_DGRAM, SYSCONF },
+#endif
+#ifdef _SC_PII_INTERNET_STREAM
+    { "_POSIX_PII_INTERNET_STREAM", _SC_PII_INTERNET_STREAM, SYSCONF },
+#endif
+#ifdef _SC_PII_OSI
+    { "_POSIX_PII_OSI", _SC_PII_OSI, SYSCONF },
+#endif
+#ifdef _SC_PII_OSI_CLTS
+    { "_POSIX_PII_OSI_CLTS", _SC_PII_OSI_CLTS, SYSCONF },
+#endif
+#ifdef _SC_PII_OSI_COTS
+    { "_POSIX_PII_OSI_COTS", _SC_PII_OSI_COTS, SYSCONF },
+#endif
+#ifdef _SC_PII_OSI_M
+    { "_POSIX_PII_OSI_M", _SC_PII_OSI_M, SYSCONF },
+#endif
+#ifdef _SC_PII_SOCKET
+    { "_POSIX_PII_SOCKET", _SC_PII_SOCKET, SYSCONF },
+#endif
+#ifdef _SC_PII_XTI
+    { "_POSIX_PII_XTI", _SC_PII_XTI, SYSCONF },
+#endif
+#ifdef _SC_POLL
+    { "_POSIX_POLL", _SC_POLL, SYSCONF },
+#endif
+#ifdef _SC_PRIORITIZED_IO
+    { "_POSIX_PRIORITIZED_IO", _SC_PRIORITIZED_IO, SYSCONF },
+#endif
+#ifdef _SC_PRIORITY_SCHEDULING
+    { "_POSIX_PRIORITY_SCHEDULING", _SC_PRIORITY_SCHEDULING, SYSCONF },
+#endif
+#ifdef _SC_REALTIME_SIGNALS
+    { "_POSIX_REALTIME_SIGNALS", _SC_REALTIME_SIGNALS, SYSCONF },
+#endif
+#ifdef _SC_SAVED_IDS
+    { "_POSIX_SAVED_IDS", _SC_SAVED_IDS, SYSCONF },
+#endif
+#ifdef _SC_SELECT
+    { "_POSIX_SELECT", _SC_SELECT, SYSCONF },
+#endif
+#ifdef _SC_SEMAPHORES
+    { "_POSIX_SEMAPHORES", _SC_SEMAPHORES, SYSCONF },
+#endif
+#ifdef _SC_SHARED_MEMORY_OBJECTS
+    { "_POSIX_SHARED_MEMORY_OBJECTS", _SC_SHARED_MEMORY_OBJECTS, SYSCONF },
+#endif
+#ifdef _SC_SSIZE_MAX
+    { "_POSIX_SSIZE_MAX", _SC_SSIZE_MAX, SYSCONF },
+#endif
+#ifdef _SC_STREAM_MAX
+    { "_POSIX_STREAM_MAX", _SC_STREAM_MAX, SYSCONF },
+#endif
+#ifdef _SC_SYNCHRONIZED_IO
+    { "_POSIX_SYNCHRONIZED_IO", _SC_SYNCHRONIZED_IO, SYSCONF },
+#endif
+#ifdef _SC_THREADS
+    { "_POSIX_THREADS", _SC_THREADS, SYSCONF },
+#endif
+#ifdef _SC_THREAD_ATTR_STACKADDR
+    { "_POSIX_THREAD_ATTR_STACKADDR", _SC_THREAD_ATTR_STACKADDR, SYSCONF },
+#endif
+#ifdef _SC_THREAD_ATTR_STACKSIZE
+    { "_POSIX_THREAD_ATTR_STACKSIZE", _SC_THREAD_ATTR_STACKSIZE, SYSCONF },
+#endif
+#ifdef _SC_THREAD_PRIORITY_SCHEDULING
+    { "_POSIX_THREAD_PRIORITY_SCHEDULING", _SC_THREAD_PRIORITY_SCHEDULING, SYSCONF },
+#endif
+#ifdef _SC_THREAD_PRIO_INHERIT
+    { "_POSIX_THREAD_PRIO_INHERIT", _SC_THREAD_PRIO_INHERIT, SYSCONF },
+#endif
+#ifdef _SC_THREAD_PRIO_PROTECT
+    { "_POSIX_THREAD_PRIO_PROTECT", _SC_THREAD_PRIO_PROTECT, SYSCONF },
+#endif
+#ifdef _SC_THREAD_ROBUST_PRIO_INHERIT
+    { "_POSIX_THREAD_ROBUST_PRIO_INHERIT", _SC_THREAD_ROBUST_PRIO_INHERIT,
+      SYSCONF },
+#endif
+#ifdef _SC_THREAD_ROBUST_PRIO_PROTECT
+    { "_POSIX_THREAD_ROBUST_PRIO_PROTECT", _SC_THREAD_ROBUST_PRIO_PROTECT,
+      SYSCONF },
+#endif
+#ifdef _SC_THREAD_PROCESS_SHARED
+    { "_POSIX_THREAD_PROCESS_SHARED", _SC_THREAD_PROCESS_SHARED, SYSCONF },
+#endif
+#ifdef _SC_THREAD_SAFE_FUNCTIONS
+    { "_POSIX_THREAD_SAFE_FUNCTIONS", _SC_THREAD_SAFE_FUNCTIONS, SYSCONF },
+#endif
+#ifdef _SC_TIMERS
+    { "_POSIX_TIMERS", _SC_TIMERS, SYSCONF },
+#endif
+#ifdef _SC_TIMER_MAX
+    { "TIMER_MAX", _SC_TIMER_MAX, SYSCONF },
+#endif
+#ifdef _SC_TZNAME_MAX
+    { "_POSIX_TZNAME_MAX", _SC_TZNAME_MAX, SYSCONF },
+#endif
+#ifdef _SC_VERSION
+    { "_POSIX_VERSION", _SC_VERSION, SYSCONF },
+#endif
+#ifdef _SC_T_IOV_MAX
+    { "_T_IOV_MAX", _SC_T_IOV_MAX, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_CRYPT
+    { "_XOPEN_CRYPT", _SC_XOPEN_CRYPT, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_ENH_I18N
+    { "_XOPEN_ENH_I18N", _SC_XOPEN_ENH_I18N, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_LEGACY
+    { "_XOPEN_LEGACY", _SC_XOPEN_LEGACY, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_REALTIME
+    { "_XOPEN_REALTIME", _SC_XOPEN_REALTIME, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_REALTIME_THREADS
+    { "_XOPEN_REALTIME_THREADS", _SC_XOPEN_REALTIME_THREADS, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_SHM
+    { "_XOPEN_SHM", _SC_XOPEN_SHM, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_UNIX
+    { "_XOPEN_UNIX", _SC_XOPEN_UNIX, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_VERSION
+    { "_XOPEN_VERSION", _SC_XOPEN_VERSION, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_XCU_VERSION
+    { "_XOPEN_XCU_VERSION", _SC_XOPEN_XCU_VERSION, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_XPG2
+    { "_XOPEN_XPG2", _SC_XOPEN_XPG2, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_XPG3
+    { "_XOPEN_XPG3", _SC_XOPEN_XPG3, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_XPG4
+    { "_XOPEN_XPG4", _SC_XOPEN_XPG4, SYSCONF },
+#endif
+    /* POSIX.2  */
+#ifdef _SC_BC_BASE_MAX
+    { "BC_BASE_MAX", _SC_BC_BASE_MAX, SYSCONF },
+#endif
+#ifdef _SC_BC_DIM_MAX
+    { "BC_DIM_MAX", _SC_BC_DIM_MAX, SYSCONF },
+#endif
+#ifdef _SC_BC_SCALE_MAX
+    { "BC_SCALE_MAX", _SC_BC_SCALE_MAX, SYSCONF },
+#endif
+#ifdef _SC_BC_STRING_MAX
+    { "BC_STRING_MAX", _SC_BC_STRING_MAX, SYSCONF },
+#endif
+    { "CHARCLASS_NAME_MAX", _SC_CHARCLASS_NAME_MAX, SYSCONF },
+#ifdef _SC_COLL_WEIGHTS_MAX
+    { "COLL_WEIGHTS_MAX", _SC_COLL_WEIGHTS_MAX, SYSCONF },
+#endif
+#ifdef _SC_EQUIV_CLASS_MAX
+    { "EQUIV_CLASS_MAX", _SC_EQUIV_CLASS_MAX, SYSCONF },
+#endif
+#ifdef _SC_EXPR_NEST_MAX
+    { "EXPR_NEST_MAX", _SC_EXPR_NEST_MAX, SYSCONF },
+#endif
+#ifdef _SC_LINE_MAX
+    { "LINE_MAX", _SC_LINE_MAX, SYSCONF },
+#endif
+#ifdef _SC_BC_BASE_MAX
+    { "POSIX2_BC_BASE_MAX", _SC_BC_BASE_MAX, SYSCONF },
+#endif
+#ifdef _SC_BC_DIM_MAX
+    { "POSIX2_BC_DIM_MAX", _SC_BC_DIM_MAX, SYSCONF },
+#endif
+#ifdef _SC_BC_SCALE_MAX
+    { "POSIX2_BC_SCALE_MAX", _SC_BC_SCALE_MAX, SYSCONF },
+#endif
+#ifdef _SC_BC_STRING_MAX
+    { "POSIX2_BC_STRING_MAX", _SC_BC_STRING_MAX, SYSCONF },
+#endif
+#ifdef _SC_2_CHAR_TERM
+    { "POSIX2_CHAR_TERM", _SC_2_CHAR_TERM, SYSCONF },
+#endif
+#ifdef _SC_COLL_WEIGHTS_MAX
+    { "POSIX2_COLL_WEIGHTS_MAX", _SC_COLL_WEIGHTS_MAX, SYSCONF },
+#endif
+#ifdef _SC_2_C_BIND
+    { "POSIX2_C_BIND", _SC_2_C_BIND, SYSCONF },
+#endif
+#ifdef _SC_2_C_DEV
+    { "POSIX2_C_DEV", _SC_2_C_DEV, SYSCONF },
+#endif
+#ifdef _SC_2_C_VERSION
+    { "POSIX2_C_VERSION", _SC_2_C_VERSION, SYSCONF },
+#endif
+#ifdef _SC_EXPR_NEST_MAX
+    { "POSIX2_EXPR_NEST_MAX", _SC_EXPR_NEST_MAX, SYSCONF },
+#endif
+#ifdef _SC_2_FORT_DEV
+    { "POSIX2_FORT_DEV", _SC_2_FORT_DEV, SYSCONF },
+#endif
+#ifdef _SC_2_FORT_RUN
+    { "POSIX2_FORT_RUN", _SC_2_FORT_RUN, SYSCONF },
+#endif
+#ifdef _SC_LINE_MAX
+    { "_POSIX2_LINE_MAX", _SC_LINE_MAX, SYSCONF },
+    { "POSIX2_LINE_MAX", _SC_LINE_MAX, SYSCONF },
+#endif
+#ifdef _SC_2_LOCALEDEF
+    { "POSIX2_LOCALEDEF", _SC_2_LOCALEDEF, SYSCONF },
+#endif
+#ifdef _SC_RE_DUP_MAX
+    { "POSIX2_RE_DUP_MAX", _SC_RE_DUP_MAX, SYSCONF },
+#endif
+#ifdef _SC_2_SW_DEV
+    { "POSIX2_SW_DEV", _SC_2_SW_DEV, SYSCONF },
+#endif
+#ifdef _SC_2_UPE
+    { "POSIX2_UPE", _SC_2_UPE, SYSCONF },
+#endif
+#ifdef _SC_2_VERSION
+    { "POSIX2_VERSION", _SC_2_VERSION, SYSCONF },
+#endif
+#ifdef _SC_RE_DUP_MAX
+    { "RE_DUP_MAX", _SC_RE_DUP_MAX, SYSCONF },
+#endif
+
+#ifdef _CS_PATH
+    { "PATH", _CS_PATH, CONFSTR },
+    { "CS_PATH", _CS_PATH, CONFSTR },
+#endif
+
+    /* LFS */
+#ifdef _CS_LFS_CFLAGS
+    { "LFS_CFLAGS", _CS_LFS_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_LFS_LDFLAGS
+    { "LFS_LDFLAGS", _CS_LFS_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_LFS_LIBS
+    { "LFS_LIBS", _CS_LFS_LIBS, CONFSTR },
+#endif
+#ifdef _CS_LFS_LINTFLAGS
+    { "LFS_LINTFLAGS", _CS_LFS_LINTFLAGS, CONFSTR },
+#endif
+#ifdef _CS_LFS64_CFLAGS
+    { "LFS64_CFLAGS", _CS_LFS64_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_LFS64_LDFLAGS
+    { "LFS64_LDFLAGS", _CS_LFS64_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_LFS64_LIBS
+    { "LFS64_LIBS", _CS_LFS64_LIBS, CONFSTR },
+#endif
+#ifdef _CS_LFS64_LINTFLAGS
+    { "LFS64_LINTFLAGS", _CS_LFS64_LINTFLAGS, CONFSTR },
+#endif
+
+    /* Programming environments.  */
+#ifdef _CS_V5_WIDTH_RESTRICTED_ENVS
+    { "_XBS5_WIDTH_RESTRICTED_ENVS", _CS_V5_WIDTH_RESTRICTED_ENVS, CONFSTR },
+    { "XBS5_WIDTH_RESTRICTED_ENVS", _CS_V5_WIDTH_RESTRICTED_ENVS, CONFSTR },
+#endif
+
+#ifdef _SC_XBS5_ILP32_OFF32
+    { "_XBS5_ILP32_OFF32", _SC_XBS5_ILP32_OFF32, SYSCONF },
+#endif
+#ifdef _CS_XBS5_ILP32_OFF32_CFLAGS
+    { "XBS5_ILP32_OFF32_CFLAGS", _CS_XBS5_ILP32_OFF32_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_ILP32_OFF32_LDFLAGS
+    { "XBS5_ILP32_OFF32_LDFLAGS", _CS_XBS5_ILP32_OFF32_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_ILP32_OFF32_LIBS
+    { "XBS5_ILP32_OFF32_LIBS", _CS_XBS5_ILP32_OFF32_LIBS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_ILP32_OFF32_LINTFLAGS
+    { "XBS5_ILP32_OFF32_LINTFLAGS", _CS_XBS5_ILP32_OFF32_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_XBS5_ILP32_OFFBIG
+    { "_XBS5_ILP32_OFFBIG", _SC_XBS5_ILP32_OFFBIG, SYSCONF },
+#endif
+#ifdef _CS_XBS5_ILP32_OFFBIG_CFLAGS
+    { "XBS5_ILP32_OFFBIG_CFLAGS", _CS_XBS5_ILP32_OFFBIG_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_ILP32_OFFBIG_LDFLAGS
+    { "XBS5_ILP32_OFFBIG_LDFLAGS", _CS_XBS5_ILP32_OFFBIG_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_ILP32_OFFBIG_LIBS
+    { "XBS5_ILP32_OFFBIG_LIBS", _CS_XBS5_ILP32_OFFBIG_LIBS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
+    { "XBS5_ILP32_OFFBIG_LINTFLAGS", _CS_XBS5_ILP32_OFFBIG_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_XBS5_LP64_OFF64
+    { "_XBS5_LP64_OFF64", _SC_XBS5_LP64_OFF64, SYSCONF },
+#endif
+#ifdef _CS_XBS5_LP64_OFF64_CFLAGS
+    { "XBS5_LP64_OFF64_CFLAGS", _CS_XBS5_LP64_OFF64_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_LP64_OFF64_LDFLAGS
+    { "XBS5_LP64_OFF64_LDFLAGS", _CS_XBS5_LP64_OFF64_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_LP64_OFF64_LIBS
+    { "XBS5_LP64_OFF64_LIBS", _CS_XBS5_LP64_OFF64_LIBS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_LP64_OFF64_LINTFLAGS
+    { "XBS5_LP64_OFF64_LINTFLAGS", _CS_XBS5_LP64_OFF64_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_XBS5_LPBIG_OFFBIG
+    { "_XBS5_LPBIG_OFFBIG", _SC_XBS5_LPBIG_OFFBIG, SYSCONF },
+#endif
+#ifdef _CS_XBS5_LPBIG_OFFBIG_CFLAGS
+    { "XBS5_LPBIG_OFFBIG_CFLAGS", _CS_XBS5_LPBIG_OFFBIG_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
+    { "XBS5_LPBIG_OFFBIG_LDFLAGS", _CS_XBS5_LPBIG_OFFBIG_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_LPBIG_OFFBIG_LIBS
+    { "XBS5_LPBIG_OFFBIG_LIBS", _CS_XBS5_LPBIG_OFFBIG_LIBS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
+    { "XBS5_LPBIG_OFFBIG_LINTFLAGS", _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_V6_ILP32_OFF32
+    { "_POSIX_V6_ILP32_OFF32", _SC_V6_ILP32_OFF32, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFF32_CFLAGS
+    { "POSIX_V6_ILP32_OFF32_CFLAGS", _CS_POSIX_V6_ILP32_OFF32_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFF32_LDFLAGS
+    { "POSIX_V6_ILP32_OFF32_LDFLAGS", _CS_POSIX_V6_ILP32_OFF32_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFF32_LIBS
+    { "POSIX_V6_ILP32_OFF32_LIBS", _CS_POSIX_V6_ILP32_OFF32_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS
+    { "POSIX_V6_ILP32_OFF32_LINTFLAGS", _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _CS_V6_WIDTH_RESTRICTED_ENVS
+    { "_POSIX_V6_WIDTH_RESTRICTED_ENVS", _CS_V6_WIDTH_RESTRICTED_ENVS, CONFSTR },
+    { "POSIX_V6_WIDTH_RESTRICTED_ENVS", _CS_V6_WIDTH_RESTRICTED_ENVS, CONFSTR },
+#endif
+
+#ifdef _SC_V6_ILP32_OFFBIG
+    { "_POSIX_V6_ILP32_OFFBIG", _SC_V6_ILP32_OFFBIG, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
+    { "POSIX_V6_ILP32_OFFBIG_CFLAGS", _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
+    { "POSIX_V6_ILP32_OFFBIG_LDFLAGS", _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_LIBS
+    { "POSIX_V6_ILP32_OFFBIG_LIBS", _CS_POSIX_V6_ILP32_OFFBIG_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS
+    { "POSIX_V6_ILP32_OFFBIG_LINTFLAGS", _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_V6_LP64_OFF64
+    { "_POSIX_V6_LP64_OFF64", _SC_V6_LP64_OFF64, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V6_LP64_OFF64_CFLAGS
+    { "POSIX_V6_LP64_OFF64_CFLAGS", _CS_POSIX_V6_LP64_OFF64_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_LP64_OFF64_LDFLAGS
+    { "POSIX_V6_LP64_OFF64_LDFLAGS", _CS_POSIX_V6_LP64_OFF64_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_LP64_OFF64_LIBS
+    { "POSIX_V6_LP64_OFF64_LIBS", _CS_POSIX_V6_LP64_OFF64_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_LP64_OFF64_LINTFLAGS
+    { "POSIX_V6_LP64_OFF64_LINTFLAGS", _CS_POSIX_V6_LP64_OFF64_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_V6_LPBIG_OFFBIG
+    { "_POSIX_V6_LPBIG_OFFBIG", _SC_V6_LPBIG_OFFBIG, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
+    { "POSIX_V6_LPBIG_OFFBIG_CFLAGS", _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
+    { "POSIX_V6_LPBIG_OFFBIG_LDFLAGS", _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LIBS
+    { "POSIX_V6_LPBIG_OFFBIG_LIBS", _CS_POSIX_V6_LPBIG_OFFBIG_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
+    { "POSIX_V6_LPBIG_OFFBIG_LINTFLAGS", _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_V7_ILP32_OFF32
+    { "_POSIX_V7_ILP32_OFF32", _SC_V7_ILP32_OFF32, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFF32_CFLAGS
+    { "POSIX_V7_ILP32_OFF32_CFLAGS", _CS_POSIX_V7_ILP32_OFF32_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFF32_LDFLAGS
+    { "POSIX_V7_ILP32_OFF32_LDFLAGS", _CS_POSIX_V7_ILP32_OFF32_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFF32_LIBS
+    { "POSIX_V7_ILP32_OFF32_LIBS", _CS_POSIX_V7_ILP32_OFF32_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS
+    { "POSIX_V7_ILP32_OFF32_LINTFLAGS", _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _CS_V7_WIDTH_RESTRICTED_ENVS
+    { "_POSIX_V7_WIDTH_RESTRICTED_ENVS", _CS_V7_WIDTH_RESTRICTED_ENVS, CONFSTR },
+    { "POSIX_V7_WIDTH_RESTRICTED_ENVS", _CS_V7_WIDTH_RESTRICTED_ENVS, CONFSTR },
+#endif
+
+#ifdef _SC_V7_ILP32_OFFBIG
+    { "_POSIX_V7_ILP32_OFFBIG", _SC_V7_ILP32_OFFBIG, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS
+    { "POSIX_V7_ILP32_OFFBIG_CFLAGS", _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS
+    { "POSIX_V7_ILP32_OFFBIG_LDFLAGS", _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFFBIG_LIBS
+    { "POSIX_V7_ILP32_OFFBIG_LIBS", _CS_POSIX_V7_ILP32_OFFBIG_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS
+    { "POSIX_V7_ILP32_OFFBIG_LINTFLAGS", _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_V7_LP64_OFF64
+    { "_POSIX_V7_LP64_OFF64", _SC_V7_LP64_OFF64, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V7_LP64_OFF64_CFLAGS
+    { "POSIX_V7_LP64_OFF64_CFLAGS", _CS_POSIX_V7_LP64_OFF64_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_LP64_OFF64_LDFLAGS
+    { "POSIX_V7_LP64_OFF64_LDFLAGS", _CS_POSIX_V7_LP64_OFF64_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_LP64_OFF64_LIBS
+    { "POSIX_V7_LP64_OFF64_LIBS", _CS_POSIX_V7_LP64_OFF64_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_LP64_OFF64_LINTFLAGS
+    { "POSIX_V7_LP64_OFF64_LINTFLAGS", _CS_POSIX_V7_LP64_OFF64_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_V7_LPBIG_OFFBIG
+    { "_POSIX_V7_LPBIG_OFFBIG", _SC_V7_LPBIG_OFFBIG, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS
+    { "POSIX_V7_LPBIG_OFFBIG_CFLAGS", _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS
+    { "POSIX_V7_LPBIG_OFFBIG_LDFLAGS", _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_LPBIG_OFFBIG_LIBS
+    { "POSIX_V7_LPBIG_OFFBIG_LIBS", _CS_POSIX_V7_LPBIG_OFFBIG_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS
+    { "POSIX_V7_LPBIG_OFFBIG_LINTFLAGS", _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_ADVISORY_INFO
+    { "_POSIX_ADVISORY_INFO", _SC_ADVISORY_INFO, SYSCONF },
+#endif
+#ifdef _SC_BARRIERS
+    { "_POSIX_BARRIERS", _SC_BARRIERS, SYSCONF },
+#endif
+#ifdef _SC_BASE
+    { "_POSIX_BASE", _SC_BASE, SYSCONF },
+#endif
+#ifdef _SC_C_LANG_SUPPORT
+    { "_POSIX_C_LANG_SUPPORT", _SC_C_LANG_SUPPORT, SYSCONF },
+#endif
+#ifdef _SC_C_LANG_SUPPORT_R
+    { "_POSIX_C_LANG_SUPPORT_R", _SC_C_LANG_SUPPORT_R, SYSCONF },
+#endif
+#ifdef _SC_CLOCK_SELECTION
+    { "_POSIX_CLOCK_SELECTION", _SC_CLOCK_SELECTION, SYSCONF },
+#endif
+#ifdef _SC_CPUTIME
+    { "_POSIX_CPUTIME", _SC_CPUTIME, SYSCONF },
+#endif
+#ifdef _SC_THREAD_CPUTIME
+    { "_POSIX_THREAD_CPUTIME", _SC_THREAD_CPUTIME, SYSCONF },
+#endif
+#ifdef _SC_DEVICE_SPECIFIC
+    { "_POSIX_DEVICE_SPECIFIC", _SC_DEVICE_SPECIFIC, SYSCONF },
+#endif
+#ifdef _SC_DEVICE_SPECIFIC_R
+    { "_POSIX_DEVICE_SPECIFIC_R", _SC_DEVICE_SPECIFIC_R, SYSCONF },
+#endif
+#ifdef _SC_FD_MGMT
+    { "_POSIX_FD_MGMT", _SC_FD_MGMT, SYSCONF },
+#endif
+#ifdef _SC_FIFO
+    { "_POSIX_FIFO", _SC_FIFO, SYSCONF },
+#endif
+#ifdef _SC_PIPE
+    { "_POSIX_PIPE", _SC_PIPE, SYSCONF },
+#endif
+#ifdef _SC_FILE_ATTRIBUTES
+    { "_POSIX_FILE_ATTRIBUTES", _SC_FILE_ATTRIBUTES, SYSCONF },
+#endif
+#ifdef _SC_FILE_LOCKING
+    { "_POSIX_FILE_LOCKING", _SC_FILE_LOCKING, SYSCONF },
+#endif
+#ifdef _SC_FILE_SYSTEM
+    { "_POSIX_FILE_SYSTEM", _SC_FILE_SYSTEM, SYSCONF },
+#endif
+#ifdef _SC_MONOTONIC_CLOCK
+    { "_POSIX_MONOTONIC_CLOCK", _SC_MONOTONIC_CLOCK, SYSCONF },
+#endif
+#ifdef _SC_MULTI_PROCESS
+    { "_POSIX_MULTI_PROCESS", _SC_MULTI_PROCESS, SYSCONF },
+#endif
+#ifdef _SC_SINGLE_PROCESS
+    { "_POSIX_SINGLE_PROCESS", _SC_SINGLE_PROCESS, SYSCONF },
+#endif
+#ifdef _SC_NETWORKING
+    { "_POSIX_NETWORKING", _SC_NETWORKING, SYSCONF },
+#endif
+#ifdef _SC_READER_WRITER_LOCKS
+    { "_POSIX_READER_WRITER_LOCKS", _SC_READER_WRITER_LOCKS, SYSCONF },
+#endif
+#ifdef _SC_SPIN_LOCKS
+    { "_POSIX_SPIN_LOCKS", _SC_SPIN_LOCKS, SYSCONF },
+#endif
+#ifdef _SC_REGEXP
+    { "_POSIX_REGEXP", _SC_REGEXP, SYSCONF },
+#endif
+#ifdef _SC_REGEX_VERSION
+    { "_REGEX_VERSION", _SC_REGEX_VERSION, SYSCONF },
+#endif
+#ifdef _SC_SHELL
+    { "_POSIX_SHELL", _SC_SHELL, SYSCONF },
+#endif
+#ifdef _SC_SIGNALS
+    { "_POSIX_SIGNALS", _SC_SIGNALS, SYSCONF },
+#endif
+#ifdef _SC_SPAWN
+    { "_POSIX_SPAWN", _SC_SPAWN, SYSCONF },
+#endif
+#ifdef _SC_SPORADIC_SERVER
+    { "_POSIX_SPORADIC_SERVER", _SC_SPORADIC_SERVER, SYSCONF },
+#endif
+#ifdef _SC_THREAD_SPORADIC_SERVER
+    { "_POSIX_THREAD_SPORADIC_SERVER", _SC_THREAD_SPORADIC_SERVER, SYSCONF },
+#endif
+#ifdef _SC_SYSTEM_DATABASE
+    { "_POSIX_SYSTEM_DATABASE", _SC_SYSTEM_DATABASE, SYSCONF },
+#endif
+#ifdef _SC_SYSTEM_DATABASE_R
+    { "_POSIX_SYSTEM_DATABASE_R", _SC_SYSTEM_DATABASE_R, SYSCONF },
+#endif
+#ifdef _SC_TIMEOUTS
+    { "_POSIX_TIMEOUTS", _SC_TIMEOUTS, SYSCONF },
+#endif
+#ifdef _SC_TYPED_MEMORY_OBJECTS
+    { "_POSIX_TYPED_MEMORY_OBJECTS", _SC_TYPED_MEMORY_OBJECTS, SYSCONF },
+#endif
+#ifdef _SC_USER_GROUPS
+    { "_POSIX_USER_GROUPS", _SC_USER_GROUPS, SYSCONF },
+#endif
+#ifdef _SC_USER_GROUPS_R
+    { "_POSIX_USER_GROUPS_R", _SC_USER_GROUPS_R, SYSCONF },
+#endif
+#ifdef _SC_2_PBS
+    { "POSIX2_PBS", _SC_2_PBS, SYSCONF },
+#endif
+#ifdef _SC_2_PBS_ACCOUNTING
+    { "POSIX2_PBS_ACCOUNTING", _SC_2_PBS_ACCOUNTING, SYSCONF },
+#endif
+#ifdef _SC_2_PBS_LOCATE
+    { "POSIX2_PBS_LOCATE", _SC_2_PBS_LOCATE, SYSCONF },
+#endif
+#ifdef _SC_2_PBS_TRACK
+    { "POSIX2_PBS_TRACK", _SC_2_PBS_TRACK, SYSCONF },
+#endif
+#ifdef _SC_2_PBS_MESSAGE
+    { "POSIX2_PBS_MESSAGE", _SC_2_PBS_MESSAGE, SYSCONF },
+#endif
+#ifdef _SC_SYMLOOP_MAX
+    { "SYMLOOP_MAX", _SC_SYMLOOP_MAX, SYSCONF },
+#endif
+#ifdef _SC_STREAM_MAX
+    { "STREAM_MAX", _SC_STREAM_MAX, SYSCONF },
+#endif
+#ifdef _SC_AIO_LISTIO_MAX
+    { "AIO_LISTIO_MAX", _SC_AIO_LISTIO_MAX, SYSCONF },
+#endif
+#ifdef _SC_AIO_MAX
+    { "AIO_MAX", _SC_AIO_MAX, SYSCONF },
+#endif
+#ifdef _SC_AIO_PRIO_DELTA_MAX
+    { "AIO_PRIO_DELTA_MAX", _SC_AIO_PRIO_DELTA_MAX, SYSCONF },
+#endif
+#ifdef _SC_DELAYTIMER_MAX
+    { "DELAYTIMER_MAX", _SC_DELAYTIMER_MAX, SYSCONF },
+#endif
+#ifdef _SC_HOST_NAME_MAX
+    { "HOST_NAME_MAX", _SC_HOST_NAME_MAX, SYSCONF },
+#endif
+#ifdef _SC_LOGIN_NAME_MAX
+    { "LOGIN_NAME_MAX", _SC_LOGIN_NAME_MAX, SYSCONF },
+#endif
+#ifdef _SC_MQ_OPEN_MAX
+    { "MQ_OPEN_MAX", _SC_MQ_OPEN_MAX, SYSCONF },
+#endif
+#ifdef _SC_MQ_PRIO_MAX
+    { "MQ_PRIO_MAX", _SC_MQ_PRIO_MAX, SYSCONF },
+#endif
+#ifdef _SC_DEVICE_IO
+    { "_POSIX_DEVICE_IO", _SC_DEVICE_IO, SYSCONF },
+#endif
+#ifdef _SC_TRACE
+    { "_POSIX_TRACE", _SC_TRACE, SYSCONF },
+#endif
+#ifdef _SC_TRACE_EVENT_FILTER
+    { "_POSIX_TRACE_EVENT_FILTER", _SC_TRACE_EVENT_FILTER, SYSCONF },
+#endif
+#ifdef _SC_TRACE_INHERIT
+    { "_POSIX_TRACE_INHERIT", _SC_TRACE_INHERIT, SYSCONF },
+#endif
+#ifdef _SC_TRACE_LOG
+    { "_POSIX_TRACE_LOG", _SC_TRACE_LOG, SYSCONF },
+#endif
+#ifdef _SC_RTSIG_MAX
+    { "RTSIG_MAX", _SC_RTSIG_MAX, SYSCONF },
+#endif
+#ifdef _SC_SEM_NSEMS_MAX
+    { "SEM_NSEMS_MAX", _SC_SEM_NSEMS_MAX, SYSCONF },
+#endif
+#ifdef _SC_SEM_VALUE_MAX
+    { "SEM_VALUE_MAX", _SC_SEM_VALUE_MAX, SYSCONF },
+#endif
+#ifdef _SC_SIGQUEUE_MAX
+    { "SIGQUEUE_MAX", _SC_SIGQUEUE_MAX, SYSCONF },
+#endif
+#ifdef _PC_FILESIZEBITS
+    { "FILESIZEBITS", _PC_FILESIZEBITS, PATHCONF },
+#endif
+#ifdef _PC_ALLOC_SIZE_MIN
+    { "POSIX_ALLOC_SIZE_MIN", _PC_ALLOC_SIZE_MIN, PATHCONF },
+#endif
+#ifdef _PC_REC_INCR_XFER_SIZE
+    { "POSIX_REC_INCR_XFER_SIZE", _PC_REC_INCR_XFER_SIZE, PATHCONF },
+#endif
+#ifdef _PC_REC_MAX_XFER_SIZE
+    { "POSIX_REC_MAX_XFER_SIZE", _PC_REC_MAX_XFER_SIZE, PATHCONF },
+#endif
+#ifdef _PC_REC_MIN_XFER_SIZE
+    { "POSIX_REC_MIN_XFER_SIZE", _PC_REC_MIN_XFER_SIZE, PATHCONF },
+#endif
+#ifdef _PC_REC_XFER_ALIGN
+    { "POSIX_REC_XFER_ALIGN", _PC_REC_XFER_ALIGN, PATHCONF },
+#endif
+#ifdef _PC_SYMLINK_MAX
+    { "SYMLINK_MAX", _PC_SYMLINK_MAX, PATHCONF },
+#endif
+#ifdef _CS_GNU_LIBC_VERSION
+    { "GNU_LIBC_VERSION", _CS_GNU_LIBC_VERSION, CONFSTR },
+#endif
+#ifdef _CS_GNU_LIBPTHREAD_VERSION
+    { "GNU_LIBPTHREAD_VERSION", _CS_GNU_LIBPTHREAD_VERSION, CONFSTR },
+#endif
+#ifdef _PC_2_SYMLINKS
+    { "POSIX2_SYMLINKS", _PC_2_SYMLINKS, PATHCONF },
+#endif
+
+#ifdef _SC_LEVEL1_ICACHE_SIZE
+    { "LEVEL1_ICACHE_SIZE", _SC_LEVEL1_ICACHE_SIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL1_ICACHE_ASSOC
+    { "LEVEL1_ICACHE_ASSOC", _SC_LEVEL1_ICACHE_ASSOC, SYSCONF },
+#endif
+#ifdef _SC_LEVEL1_ICACHE_LINESIZE
+    { "LEVEL1_ICACHE_LINESIZE", _SC_LEVEL1_ICACHE_LINESIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL1_DCACHE_SIZE
+    { "LEVEL1_DCACHE_SIZE", _SC_LEVEL1_DCACHE_SIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL1_DCACHE_ASSOC
+    { "LEVEL1_DCACHE_ASSOC", _SC_LEVEL1_DCACHE_ASSOC, SYSCONF },
+#endif
+#ifdef _SC_LEVEL1_DCACHE_LINESIZE
+    { "LEVEL1_DCACHE_LINESIZE", _SC_LEVEL1_DCACHE_LINESIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL2_CACHE_SIZE
+    { "LEVEL2_CACHE_SIZE", _SC_LEVEL2_CACHE_SIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL2_CACHE_ASSOC
+    { "LEVEL2_CACHE_ASSOC", _SC_LEVEL2_CACHE_ASSOC, SYSCONF },
+#endif
+#ifdef _SC_LEVEL2_CACHE_LINESIZE
+    { "LEVEL2_CACHE_LINESIZE", _SC_LEVEL2_CACHE_LINESIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL3_CACHE_SIZE
+    { "LEVEL3_CACHE_SIZE", _SC_LEVEL3_CACHE_SIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL3_CACHE_ASSOC
+    { "LEVEL3_CACHE_ASSOC", _SC_LEVEL3_CACHE_ASSOC, SYSCONF },
+#endif
+#ifdef _SC_LEVEL3_CACHE_LINESIZE
+    { "LEVEL3_CACHE_LINESIZE", _SC_LEVEL3_CACHE_LINESIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL4_CACHE_SIZE
+    { "LEVEL4_CACHE_SIZE", _SC_LEVEL4_CACHE_SIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL4_CACHE_ASSOC
+    { "LEVEL4_CACHE_ASSOC", _SC_LEVEL4_CACHE_ASSOC, SYSCONF },
+#endif
+#ifdef _SC_LEVEL4_CACHE_LINESIZE
+    { "LEVEL4_CACHE_LINESIZE", _SC_LEVEL4_CACHE_LINESIZE, SYSCONF },
+#endif
+
+#ifdef _SC_IPV6
+    { "IPV6", _SC_IPV6, SYSCONF },
+#endif
+#ifdef _SC_RAW_SOCKETS
+    { "RAW_SOCKETS", _SC_RAW_SOCKETS, SYSCONF },
+#endif
+
+    { NULL, 0, SYSCONF }
+  };
+
+
+static const struct { const char *name; int num; } specs[] =
+  {
+#ifdef _SC_XBS5_ILP32_OFF32
+    { "XBS5_ILP32_OFF32", _SC_XBS5_ILP32_OFF32 },
+#endif
+#ifdef _SC_XBS5_ILP32_OFFBIG
+    { "XBS5_ILP32_OFFBIG", _SC_XBS5_ILP32_OFFBIG },
+#endif
+#ifdef _SC_XBS5_LP64_OFF64
+    { "XBS5_LP64_OFF64", _SC_XBS5_LP64_OFF64 },
+#endif
+#ifdef _SC_XBS5_LPBIG_OFFBIG
+    { "XBS5_LPBIG_OFFBIG", _SC_XBS5_LPBIG_OFFBIG },
+#endif
+#ifdef _SC_V6_ILP32_OFF32
+    { "POSIX_V6_ILP32_OFF32", _SC_V6_ILP32_OFF32 },
+#endif
+#ifdef _SC_V6_ILP32_OFFBIG
+    { "POSIX_V6_ILP32_OFFBIG", _SC_V6_ILP32_OFFBIG },
+#endif
+#ifdef _SC_V6_LP64_OFF64
+    { "POSIX_V6_LP64_OFF64", _SC_V6_LP64_OFF64 },
+#endif
+#ifdef _SC_V6_LPBIG_OFFBIG
+    { "POSIX_V6_LPBIG_OFFBIG", _SC_V6_LPBIG_OFFBIG },
+#endif
+#ifdef _SC_V7_ILP32_OFF32
+    { "POSIX_V7_ILP32_OFF32", _SC_V7_ILP32_OFF32 },
+#endif
+#ifdef _SC_V7_ILP32_OFFBIG
+    { "POSIX_V7_ILP32_OFFBIG", _SC_V7_ILP32_OFFBIG },
+#endif
+#ifdef _SC_V7_LP64_OFF64
+    { "POSIX_V7_LP64_OFF64", _SC_V7_LP64_OFF64 },
+#endif
+#ifdef _SC_V7_LPBIG_OFFBIG
+    { "POSIX_V7_LPBIG_OFFBIG", _SC_V7_LPBIG_OFFBIG },
+#endif
+  };
+static const int nspecs = sizeof (specs) / sizeof (specs[0]);
+
+#ifdef __UCLIBC_HAS___PROGNAME__
+extern const char *__progname;
+#else
+#define __progname "foo"
+#endif
+
+static void
+usage (void)
+{
+  fprintf (stderr,
+	   _("Usage: %s [-v specification] variable_name [pathname]\n"),
+	   __progname);
+  fprintf (stderr,
+	   _("       %s -a [pathname]\n"), __progname);
+  exit (2);
+}
+
+
+static void
+print_all (const char *path)
+{
+  register const struct conf *c;
+  size_t clen;
+  long int value;
+  char *cvalue;
+  for (c = vars; c->name != NULL; ++c) {
+    printf("%-35s", c->name);
+    switch (c->call) {
+      case PATHCONF:
+	value = pathconf (path, c->call_name);
+	if (value != -1) {
+	  printf("%ld", value);
+	}
+	printf("\n");
+	break;
+      case SYSCONF:
+	value = sysconf (c->call_name);
+	if (value == -1l) {
+	  if (c->call_name == _SC_UINT_MAX
+	    || c->call_name == _SC_ULONG_MAX)
+	    printf ("%lu", value);
+	}
+	else {
+	  printf ("%ld", value);
+	}
+	printf ("\n");
+	break;
+      case CONFSTR:
+	clen = confstr (c->call_name, (char *) NULL, 0);
+	cvalue = (char *) malloc (clen);
+	if (cvalue == NULL)
+	  error (3, 0, _("memory exhausted"));
+	if (confstr (c->call_name, cvalue, clen) != clen)
+	  error (3, errno, "confstr");
+	printf ("%.*s\n", (int) clen, cvalue);
+	free (cvalue);
+	break;
+    }
+  }
+  exit (0);
+}
+
+int
+main (int argc, char *argv[])
+{
+  register const struct conf *c;
+
+  /* Set locale.  Do not set LC_ALL because the other categories must
+     not be affected (according to POSIX.2).  */
+
+  /* Initialize the message catalog.  */
+
+  if (argc > 1 && strcmp (argv[1], "--version") == 0)
+    {
+      printf ("getconf (GNU %s) %s\n", PACKAGE, VERSION);
+      printf ("\
+Copyright (C) %s Free Software Foundation, Inc.\n\
+This is free software; see the source for copying conditions.  There is NO\n\
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
+", "2009");
+      printf ("Written by %s.\n", "Roland McGrath");
+      return 0;
+    }
+
+  if (argc > 1 && strcmp (argv[1], "--help") == 0)
+    {
+      printf ("\
+Usage: getconf [-v SPEC] VAR\n\
+  or:  getconf [-v SPEC] PATH_VAR PATH\n\
+\n\
+Get the configuration value for variable VAR, or for variable PATH_VAR\n\
+for path PATH.  If SPEC is given, give values for compilation\n\
+environment SPEC.\n\n");
+      fputs ("For bug reporting instructions, please see:\n\
+<http://www.gnu.org/software/libc/bugs.html>.\n", stdout);
+      return 0;
+    }
+
+  const char *getconf_dir = getenv ("GETCONF_DIR") ?: GETCONF_DIR;
+  size_t getconf_dirlen = strlen (getconf_dir);
+
+  const char *spec = NULL;
+  char buf[sizeof "POSIX_V6_LPBIG_OFFBIG"];
+  char *argv0 = argv[0];
+  if (argc > 1 && strncmp (argv[1], "-v", 2) == 0)
+    {
+      if (argv[1][2] == '\0')
+	{
+	  if (argc < 3)
+	    usage ();
+
+	  spec = argv[2];
+	  argv += 2;
+	  argc -= 2;
+	}
+      else
+	{
+	  spec = &argv[1][2];
+	  argv += 1;
+	  argc += 1;
+	}
+    }
+  else
+    {
+      char default_name[getconf_dirlen + sizeof "/default"];
+      memcpy (mempcpy (default_name, getconf_dir, getconf_dirlen),
+	      "/default", sizeof "/default");
+      int len = readlink (default_name, buf, sizeof buf - 1);
+      if (len > 0)
+	{
+	  buf[len] = '\0';
+	  spec = buf;
+	}
+    }
+
+  /* Check for the specifications we know.  */
+  if (spec != NULL)
+    {
+      int i;
+      for (i = 0; i < nspecs; ++i)
+	if (strcmp (spec, specs[i].name) == 0)
+	  break;
+
+      if (i == nspecs)
+	error (2, 0, _("unknown specification \"%s\""), spec);
+
+      switch (specs[i].num)
+	{
+#if !defined(_XBS5_ILP32_OFF32) && defined(_SC_XBS5_ILP32_OFF32)
+	case _SC_XBS5_ILP32_OFF32:
+#endif
+#if !defined(_XBS5_ILP32_OFFBIG) && defined(_SC_XBS5_ILP32_OFFBIG)
+	case _SC_XBS5_ILP32_OFFBIG:
+#endif
+#if !defined(_XBS5_LP64_OFF64) && defined(_SC_XBS5_LP64_OFF64)
+	case _SC_XBS5_LP64_OFF64:
+#endif
+#if !defined(_XBS5_LPBIG_OFFBIG) && defined(_SC_XBS5_LPBIG_OFFBIG)
+	case _SC_XBS5_LPBIG_OFFBIG:
+#endif
+#if !defined(_POSIX_V6_ILP32_OFF32) && defined(_SC_V6_ILP32_OFF32)
+	case _SC_V6_ILP32_OFF32:
+#endif
+#if !defined(_POSIX_V6_ILP32_OFFBIG) && defined(_SC_V6_ILP32_OFFBIG)
+	case _SC_V6_ILP32_OFFBIG:
+#endif
+#if !defined(_POSIX_V6_LP64_OFF64) && defined(_SC_V6_LP64_OFF64)
+	case _SC_V6_LP64_OFF64:
+#endif
+#if !defined(_POSIX_V6_LPBIG_OFFBIG) && defined(_SC_V6_LPBIG_OFFBIG)
+	case _SC_V6_LPBIG_OFFBIG:
+#endif
+#if !defined(_POSIX_V7_ILP32_OFF32) && defined(_SC_V7_ILP32_OFF32)
+	case _SC_V7_ILP32_OFF32:
+#endif
+#if !defined(_POSIX_V7_ILP32_OFFBIG) && defined(_SC_V7_ILP32_OFFBIG)
+	case _SC_V7_ILP32_OFFBIG:
+#endif
+#if !defined(_POSIX_V7_LP64_OFF64) && defined(_SC_V7_LP64_OFF64)
+	case _SC_V7_LP64_OFF64:
+#endif
+#if !defined(_POSIX_V7_LPBIG_OFFBIG) && defined(_SC_V7_LPBIG_OFFBIG)
+	case _SC_V7_LPBIG_OFFBIG:
+#endif
+	    {
+	      const char *args[argc + 3];
+	      size_t spec_len = strlen (spec);
+	      char getconf_name[getconf_dirlen + 1 + spec_len + 1];
+	      memcpy (mempcpy (mempcpy (getconf_name, getconf_dir,
+					getconf_dirlen),
+			       "/", 1), spec, spec_len + 1);
+	      args[0] = argv0;
+	      args[1] = "-v";
+	      args[2] = spec;
+	      memcpy (&args[3], &argv[1], argc * sizeof (argv[1]));
+	      execv (getconf_name, (char * const *) args);
+	      error (4, errno, _("Couldn't execute %s"), getconf_name);
+	    }
+	  default:
+	    break;
+	}
+    }
+
+  if (argc > 1 && strcmp (argv[1], "-a") == 0)
+    {
+      if (argc == 2)
+	print_all ("/");
+      else if (argc == 3)
+	print_all (argv[2]);
+      else
+	usage ();
+    }
+
+  int ai = 1;
+  if (argc > ai && strcmp (argv[ai], "--") == 0)
+    ++ai;
+
+  if (argc - ai < 1 || argc - ai > 2)
+    usage ();
+
+  for (c = vars; c->name != NULL; ++c)
+    if (strcmp (c->name, argv[ai]) == 0
+	|| (strncmp (c->name, "_POSIX_", 7) == 0
+	    && strcmp (c->name + 7, argv[ai]) == 0))
+      {
+	long int value;
+	size_t clen;
+	char *cvalue;
+	switch (c->call)
+	  {
+	  case PATHCONF:
+	    if (argc - ai < 2)
+	      usage ();
+	    errno = 0;
+	    value = pathconf (argv[ai + 1], c->call_name);
+	    if (value == -1)
+	      {
+		if (errno) {
+		  error (3, errno, "pathconf: %s", argv[ai + 1]);
+		} else
+		  puts (_("undefined"));
+	      }
+	    else
+	      printf ("%ld\n", value);
+	    exit (0);
+
+	  case SYSCONF:
+	    if (argc - ai > 1)
+	      usage ();
+	    value = sysconf (c->call_name);
+	    if (value == -1l)
+	      {
+		if (c->call_name == _SC_UINT_MAX
+		    || c->call_name == _SC_ULONG_MAX)
+		  printf ("%lu\n", value);
+		else
+		  puts (_("undefined"));
+	      }
+	    else
+	      printf ("%ld\n", value);
+	    exit (0);
+
+	  case CONFSTR:
+	    if (argc - ai > 1)
+	      usage ();
+	    clen = confstr (c->call_name, (char *) NULL, 0);
+	    cvalue = (char *) malloc (clen);
+	    if (cvalue == NULL)
+	      error (3, 0, _("memory exhausted"));
+
+	    if (confstr (c->call_name, cvalue, clen) != clen)
+	      error (3, errno, "confstr");
+
+	    printf ("%.*s\n", (int) clen, cvalue);
+	    exit (0);
+	  }
+      }
+
+  error (2, 0, _("Unrecognized variable `%s'"), argv[ai]);
+  /* NOTREACHED */
+  return 2;
+}
diff --git a/ap/build/uClibc/utils/iconv.c b/ap/build/uClibc/utils/iconv.c
new file mode 100644
index 0000000..589c64c
--- /dev/null
+++ b/ap/build/uClibc/utils/iconv.c
@@ -0,0 +1,264 @@
+
+/*  Copyright (C) 2002, 2003, 2004     Manuel Novoa III
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/*  ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION!
+ *
+ *  Besides uClibc, I'm using this code in my libc for elks, which is
+ *  a 16-bit environment with a fairly limited compiler.  It would make
+ *  things much easier for me if this file isn't modified unnecessarily.
+ *  In particular, please put any new or replacement functions somewhere
+ *  else, and modify the makefile to use your version instead.
+ *  Thanks.  Manuel
+ *
+ *  ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION! */
+
+
+/* May 23, 2002     Initial Notes:
+ *
+ * I'm still tweaking this stuff, but it passes the tests I've thrown
+ * at it, and Erik needs it for the gcc port.  The glibc extension
+ * __wcsnrtombs() hasn't been tested, as I didn't find a test for it
+ * in the glibc source.  I also need to fix the behavior of
+ * _wchar_utf8sntowcs() if the max number of wchars to convert is 0.
+ *
+ * UTF-8 -> wchar -> UTF-8 conversion tests on Markus Kuhn's UTF-8-demo.txt
+ * file on my platform (x86) show about 5-10% faster conversion speed than
+ * glibc with mbsrtowcs()/wcsrtombs() and almost twice as fast as glibc with
+ * individual mbrtowc()/wcrtomb() calls.
+ *
+ * If 'DECODER' is defined, then _wchar_utf8sntowcs() will be compiled
+ * as a fail-safe UTF-8 decoder appropriate for a terminal, etc.  which
+ * needs to deal gracefully with whatever is sent to it.  In that mode,
+ * it passes Markus Kuhn's UTF-8-test.txt stress test.  I plan to add
+ * an arg to force that behavior, so the interface will be changing.
+ *
+ * I need to fix the error checking for 16-bit wide chars.  This isn't
+ * an issue for uClibc, but may be for ELKS.  I'm currently not sure
+ * if I'll use 16-bit, 32-bit, or configureable wchars in ELKS.
+ *
+ * July 1, 2002
+ *
+ * Fixed _wchar_utf8sntowcs() for the max number of wchars == 0 case.
+ * Fixed nul-char bug in btowc(), and another in __mbsnrtowcs() for 8-bit
+ *    locales.
+ * Enabled building of a C/POSIX-locale-only version, so full locale support
+ *    no longer needs to be enabled.
+ *
+ * Nov 4, 2002
+ *
+ * Fixed a bug in _wchar_wcsntoutf8s().  Don't store wcs position if dst is NULL.
+ * Also, introduce an awful hack into _wchar_wcsntoutf8s() and wcsrtombs() in
+ *   order to support %ls in printf.  See comments below for details.
+ * Change behaviour of wc<->mb functions when in the C locale.  Now they do
+ *   a 1-1 map for the range 0x80-UCHAR_MAX.  This is for backwards compatibility
+ *   and consistency with the stds requirements that a printf format string by
+ *   a valid multibyte string beginning and ending in it's initial shift state.
+ *
+ * Nov 5, 2002
+ *
+ * Forgot to change btowc and wctob when I changed the wc<->mb functions yesterday.
+ *
+ * Nov 7, 2002
+ *
+ * Add wcwidth and wcswidth, based on Markus Kuhn's wcwidth of 2002-05-08.
+ *   Added some size/speed optimizations and integrated it into my locale
+ *   framework.  Minimally tested at the moment, but the stub C-locale
+ *   version (which most people would probably be using) should be fine.
+ *
+ * Nov 21, 2002
+ *
+ * Revert the wc<->mb changes from earlier this month involving the C-locale.
+ * Add a couple of ugly hacks to support *wprintf.
+ * Add a mini iconv() and iconv implementation (requires locale support).
+ *
+ * Aug 1, 2003
+ * Bug fix for mbrtowc.
+ *
+ * Aug 18, 2003
+ * Bug fix: _wchar_utf8sntowcs and _wchar_wcsntoutf8s now set errno if EILSEQ.
+ *
+ * Feb 11, 2004
+ * Bug fix: Fix size check for remaining output space in iconv().
+ *
+ * Manuel
+ */
+
+#include "porting.h"
+#include <string.h>
+#include <iconv.h>
+#include <stdarg.h>
+#include <libgen.h>
+#include <wchar.h>
+#include "wchar.c" /* for _UC_iconv_t and __iconv_codesets */
+
+extern const unsigned char __iconv_codesets[];
+
+#define IBUF BUFSIZ
+#define OBUF BUFSIZ
+
+static char *progname;
+static int hide_errors;
+
+static void error_msg(const char *fmt, ...)
+	 __attribute__ ((noreturn, format (printf, 1, 2)));
+
+static void error_msg(const char *fmt, ...)
+{
+	va_list arg;
+
+	if (!hide_errors) {
+		fprintf(stderr, "%s: ", progname);
+		va_start(arg, fmt);
+		vfprintf(stderr, fmt, arg);
+		va_end(arg);
+	}
+
+	exit(EXIT_FAILURE);
+}
+
+int main(int argc, char **argv)
+{
+	FILE *ifile;
+	FILE *ofile = stdout;
+	const char *p;
+	const char *s;
+	static const char opt_chars[] = "tfocsl";
+	                              /* 012345 */
+	const char *opts[sizeof(opt_chars)]; /* last is infile name */
+	iconv_t ic;
+	char ibuf[IBUF];
+	char obuf[OBUF];
+	char *pi;
+	char *po;
+	size_t ni, no, r, pos;
+
+	hide_errors = 0;
+
+	for (s = opt_chars ; *s ; s++) {
+		opts[ s - opt_chars ] = NULL;
+	}
+
+	progname = *argv;
+	while (--argc) {
+		p = *++argv;
+		if ((*p != '-') || (*++p == 0)) {
+			break;
+		}
+		do {
+			if ((s = strchr(opt_chars,*p)) == NULL) {
+			USAGE:
+				s = basename(progname);
+				fprintf(stderr,
+						"%s [-cs] -f fromcode -t tocode [-o outputfile] [inputfile ...]\n"
+						"  or\n%s -l\n", s, s);
+				return EXIT_FAILURE;
+			}
+			if ((s - opt_chars) < 3) {
+				if ((--argc == 0) || opts[s - opt_chars]) {
+					goto USAGE;
+				}
+				opts[s - opt_chars] = *++argv;
+			} else {
+				opts[s - opt_chars] = p;
+			}
+		} while (*++p);
+	}
+
+	if (opts[5]) {				/* -l */
+		fprintf(stderr, "Recognized codesets:\n");
+		for (s = (char *)__iconv_codesets ; *s ; s += *s) {
+			fprintf(stderr,"  %s\n", s+2);
+		}
+		s = __LOCALE_DATA_CODESET_LIST;
+		do {
+			fprintf(stderr,"  %s\n", __LOCALE_DATA_CODESET_LIST+ (unsigned char)(*s));
+		} while (*++s);
+
+		return EXIT_SUCCESS;
+	}
+
+	if (opts[4]) {
+		hide_errors = 1;
+	}
+
+	if (!opts[0] || !opts[1]) {
+		goto USAGE;
+	}
+	if ((ic = iconv_open(opts[0],opts[1])) == ((iconv_t)(-1))) {
+		error_msg( "unsupported codeset in %s -> %s conversion\n", opts[1], opts[0]);
+	}
+	if (opts[3]) {				/* -c */
+		((_UC_iconv_t *) ic)->skip_invalid_input = 1;
+	}
+
+	if ((s = opts[2]) != NULL) {
+		if (!(ofile = fopen(s, "w"))) {
+			error_msg( "couldn't open %s for writing\n", s);
+		}
+	}
+
+	pos = ni = 0;
+	do {
+		if (!argc || ((**argv == '-') && !((*argv)[1]))) {
+			ifile = stdin;		/* we don't check for duplicates */
+		} else if (!(ifile = fopen(*argv, "r"))) {
+			error_msg( "couldn't open %s for reading\n", *argv);
+		}
+
+		while ((r = fread(ibuf + ni, 1, IBUF - ni, ifile)) > 0) {
+			pos += r;
+			ni += r;
+			no = OBUF;
+			pi = ibuf;
+			po = obuf;
+			if ((r = iconv(ic, &pi, &ni, &po, &no)) == ((size_t)(-1))) {
+				if ((errno != EINVAL) && (errno != E2BIG)) {
+					error_msg( "iconv failed at pos %lu : %m\n", (unsigned long) (pos - ni));
+				}
+			}
+			if ((r = OBUF - no) > 0) {
+				if (fwrite(obuf, 1, OBUF - no, ofile) < r) {
+					error_msg( "write error\n");
+				}
+			}
+			if (ni) {			/* still bytes in buffer! */
+				memmove(ibuf, pi, ni);
+			}
+		}
+
+		if (ferror(ifile)) {
+			error_msg( "read error\n");
+		}
+
+		++argv;
+
+		if (ifile != stdin) {
+			fclose(ifile);
+		}
+
+	} while (--argc > 0);
+
+	iconv_close(ic);
+
+	if (ni) {
+		error_msg( "incomplete sequence\n");
+	}
+
+	return (((_UC_iconv_t *) ic)->skip_invalid_input < 2)
+		? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/ap/build/uClibc/utils/ldconfig.c b/ap/build/uClibc/utils/ldconfig.c
new file mode 100644
index 0000000..024be7c
--- /dev/null
+++ b/ap/build/uClibc/utils/ldconfig.c
@@ -0,0 +1,984 @@
+/*
+ * ldconfig - update shared library symlinks
+ *
+ * usage: ldconfig [-DvqnNX] [-f conf] [-C cache] [-r root] dir ...
+ *        ldconfig -l [-Dv] lib ...
+ *        ldconfig -p
+ *        -D: debug mode, don't update links
+ *        -v: verbose mode, print things as we go
+ *        -q: quiet mode, don't print warnings
+ *        -n: don't process standard directories
+ *        -N: don't update the library cache
+ *        -X: don't update the library links
+ *        -l: library mode, manually link libraries
+ *        -p: print the current library cache
+ *        -f conf: use conf instead of /etc/ld.so.conf
+ *        -C cache: use cache instead of /etc/ld.so.cache
+ *        -r root: first, do a chroot to the indicated directory
+ *        dir ...: directories to process
+ *        lib ...: libraries to link
+ *
+ * Copyright 1994-2000 David Engel and Mitch D'Souza
+ *
+ * This program may be used for any purpose as long as this
+ * copyright notice is kept.
+ *
+ * 2005/09/16: Dan Howell (modified for cross-development)
+ */
+
+#include "porting.h"
+
+#define BUFFER_SIZE 4096
+
+struct exec {
+	unsigned long a_info;	/* Use macros N_MAGIC, etc for access */
+	unsigned a_text;	/* length of text, in bytes */
+	unsigned a_data;	/* length of data, in bytes */
+	unsigned a_bss;		/* length of uninitialized data area for file, in bytes */
+	unsigned a_syms;	/* length of symbol table data in file, in bytes */
+	unsigned a_entry;	/* start address */
+	unsigned a_trsize;	/* length of relocation info for text, in bytes */
+	unsigned a_drsize;	/* length of relocation info for data, in bytes */
+};
+
+#if !defined (N_MAGIC)
+#define N_MAGIC(exec) ((exec).a_info & 0xffff)
+#endif
+#define N_MAGIC_SWAP(exec) (bswap_32((exec).a_info) & 0xffff)
+/* Code indicating object file or impure executable.  */
+#define OMAGIC 0407
+/* Code indicating pure executable.  */
+#define NMAGIC 0410
+/* Code indicating demand-paged executable.  */
+#define ZMAGIC 0413
+/* This indicates a demand-paged executable with the header in the text.
+   The first page is unmapped to help trap NULL pointer references */
+#define QMAGIC 0314
+/* Code indicating core file.  */
+#define CMAGIC 0421
+
+char *___strtok = NULL;
+
+char *prog = NULL;
+int debug = 0;			/* debug mode */
+int verbose = 0;		/* verbose mode */
+int libmode = 0;		/* library mode */
+int nolinks = 0;		/* don't update links */
+int nocache = 0;		/* don't build cache */
+void cache_print(void);
+void cache_write(void);
+void cache_dolib(const char *dir, const char *so, int libtype);
+#ifdef __LDSO_CACHE_SUPPORT__
+char *conffile = LDSO_CONF;	/* default conf file */
+char *cachefile = LDSO_CACHE;	/* default cache file */
+#endif
+char *chroot_dir = NULL;
+int byteswap = 0;
+
+struct needed_tab {
+	char *soname;
+	int type;
+};
+
+struct needed_tab needed_tab[] = {
+	{"libc.so.0", LIB_ELF_LIBC0},
+	{"libm.so.0", LIB_ELF_LIBC0},
+	{"libdl.so.0", LIB_ELF_LIBC0},
+	{"libc.so.5", LIB_ELF_LIBC5},
+	{"libm.so.5", LIB_ELF_LIBC5},
+	{"libdl.so.1", LIB_ELF_LIBC5},
+	{"libc.so.6", LIB_ELF_LIBC6},
+	{"libm.so.6", LIB_ELF_LIBC6},
+	{"libdl.so.2", LIB_ELF_LIBC6},
+	{NULL, LIB_ELF}
+};
+
+extern char *chroot_realpath(const char *chroot, const char *path,
+			     char resolved_path[]);
+
+/* These two are used internally -- you shouldn't need to use them */
+static void verror_msg(const char *s, va_list p)
+{
+	fflush(stdout);
+	fprintf(stderr, "%s: ", prog);
+	vfprintf(stderr, s, p);
+}
+
+static void warnx(const char *s, ...)
+{
+	va_list p;
+
+	va_start(p, s);
+	verror_msg(s, p);
+	va_end(p);
+	fprintf(stderr, "\n");
+}
+
+static void err(int errnum, const char *s, ...) attribute_noreturn;
+static void err(int errnum, const char *s, ...)
+{
+	va_list p;
+
+	va_start(p, s);
+	verror_msg(s, p);
+	va_end(p);
+	fprintf(stderr, "\n");
+	exit(errnum);
+}
+
+static void vperror_msg(const char *s, va_list p)
+{
+	int e = errno;
+
+	if (s == 0)
+		s = "";
+	verror_msg(s, p);
+	if (*s)
+		s = ": ";
+	fprintf(stderr, "%s%s\n", s, strerror(e));
+}
+
+static void warn(const char *s, ...)
+{
+	va_list p;
+
+	va_start(p, s);
+	vperror_msg(s, p);
+	va_end(p);
+}
+
+static void *xmalloc(size_t size)
+{
+	void *ptr;
+	if ((ptr = malloc(size)) == NULL)
+		err(EXIT_FAILURE, "out of memory");
+	return ptr;
+}
+
+static char *xstrdup(const char *str)
+{
+	char *ptr;
+	if ((ptr = strdup(str)) == NULL)
+		err(EXIT_FAILURE, "out of memory");
+	return ptr;
+}
+
+#undef __ELF_NATIVE_CLASS
+#undef readsonameXX
+#define readsonameXX readsoname32
+#define __ELF_NATIVE_CLASS 32
+#include "readsoname2.c"
+
+#undef __ELF_NATIVE_CLASS
+#undef readsonameXX
+#define readsonameXX readsoname64
+#define __ELF_NATIVE_CLASS 64
+#include "readsoname2.c"
+static char *readsoname(char *name, FILE *infile, int expected_type,
+			int *type, int elfclass)
+{
+	char *res;
+
+	if (elfclass == ELFCLASS32)
+		res = readsoname32(name, infile, expected_type, type);
+	else {
+		res = readsoname64(name, infile, expected_type, type);
+#if 0
+		/* relies on multilib support which we dont have ... */
+		*type |= LIB_ELF64;
+#endif
+	}
+
+	return res;
+}
+
+/* If shared library, return a malloced copy of the soname and set the
+ * type, else return NULL.
+ *
+ * expected_type should be either LIB_ANY or one of the following:-
+ * LIB_DLL
+ * LIB_ELF
+ * LIB_ELF_LIBC5
+ * LIB_ELF_LIBC6
+ *
+ * If the lib is ELF and we can not deduce the type the type will
+ * be set based on expected_type.
+ *
+ * If the expected, actual/deduced types missmatch we display a warning
+ * and use the actual/deduced type.
+ */
+static char *is_shlib(const char *dir, const char *name, int *type,
+		      int *islink, int expected_type)
+{
+	char *good = NULL;
+	char *cp, *cp2;
+	FILE *file;
+	struct exec exec;
+	ElfW(Ehdr) *elf_hdr;
+	struct stat statbuf;
+	char buff[BUFFER_SIZE];
+	char real[BUFFER_SIZE];
+	static int byteswapflag = -1;	/* start with byte-order unknown */
+
+	/* see if name is of the form *.so* */
+	if (name[strlen(name) - 1] != '~' && (cp = strstr(name, ".so"))) {
+		/* find the start of the Vminor part, if any */
+		if (cp[3] == '.' && (cp2 = strchr(cp + 4, '.')))
+			cp = cp2;
+		else
+			cp = cp + strlen(cp);
+
+		/* construct the full path name */
+		sprintf(buff, "%s%s%s", dir, (*dir && strcmp(dir, "/")) ? "/" : "", name);
+
+		/* get real path in case of chroot */
+		if (!chroot_realpath(chroot_dir, buff, real))
+			warn("can't resolve %s in chroot %s", buff, chroot_dir);
+
+		/* first, make sure it's a regular file */
+		if (lstat(real, &statbuf))
+			warn("skipping %s", buff);
+		else if (!S_ISREG(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode))
+			warnx("%s is not a regular file or symlink, skipping", buff);
+		else {
+			/* is it a regular file or a symlink */
+			*islink = S_ISLNK(statbuf.st_mode);
+
+			/* then try opening it */
+			if (!(file = fopen(real, "rb")))
+				warn("skipping %s", buff);
+			else {
+				/* now make sure it's a shared library */
+				if (fread(&exec, sizeof exec, 1, file) < 1)
+					warnx("can't read header from %s, skipping", buff);
+				else if (N_MAGIC(exec) != ZMAGIC
+				 && N_MAGIC(exec) != QMAGIC
+				 && N_MAGIC_SWAP(exec) != ZMAGIC
+				 && N_MAGIC_SWAP(exec) != QMAGIC) {
+					elf_hdr = (ElfW(Ehdr) *) & exec;
+					if (elf_hdr->e_ident[0] != 0x7f ||
+					    strncmp((char *)elf_hdr->e_ident + 1, "ELF", 3) != 0)
+					{
+						/* silently ignore linker scripts */
+						if (strncmp((char *)&exec, "/* GNU ld", 9) != 0)
+							warnx("%s is not a shared library, skipping", buff);
+					} else {
+						/* always call readsoname to update type */
+						if (expected_type == LIB_DLL) {
+							warnx("%s is not an a.out library, it's ELF!", buff);
+							expected_type = LIB_ANY;
+						}
+						*type = LIB_ELF;
+						good = readsoname(buff, file, expected_type, type,
+						                  elf_hdr->e_ident[EI_CLASS]);
+						if (byteswapflag == -1)
+							/* byte-order detected */
+							byteswapflag = byteswap;
+						if (good == NULL || *islink) {
+							if (good != NULL)
+								free(good);
+							good = xstrdup(name);
+						} else {
+							/* if the soname does not match the filename,
+							   issue a warning, but only in debug mode. */
+							int len = strlen(good);
+							if (debug && (strncmp(good, name, len) != 0
+							    || (name[len] != '\0' && name[len] != '.')))
+								warnx("%s has inconsistent soname (%s)", buff, good);
+						}
+					}
+				} else {
+					/* Determine byte-order */
+					byteswap = (N_MAGIC(exec) == ZMAGIC || N_MAGIC(exec) == QMAGIC) ? 0 : 1;
+					if (byteswapflag == -1)
+						/* byte-order detected */
+						byteswapflag = byteswap;
+
+					if (*islink)
+						good = xstrdup(name);
+					else {
+						good = xmalloc(cp - name + 1);
+						strncpy(good, name, cp - name);
+						good[cp - name] = '\0';
+					}
+					if (expected_type != LIB_ANY && expected_type != LIB_DLL) {
+						warnx("%s is not an ELF library, its an a.out DLL!", buff);
+						expected_type = LIB_ANY;
+					}
+
+					*type = LIB_DLL;
+				}
+				fclose(file);
+
+				if (byteswapflag >= 0 && byteswap != byteswapflag) {
+					byteswapflag = -2;
+					warnx("mixed byte-order detected, using host byte-order...");
+				}
+				if (byteswapflag == -2)
+					byteswap = 0;
+			}
+		}
+	}
+
+	return good;
+}
+
+/* update the symlink to new library */
+static void link_shlib(const char *dir, const char *file, const char *so)
+{
+	int change = 1;
+	char libname[BUFFER_SIZE];
+	char linkname[BUFFER_SIZE];
+	char reallibname[BUFFER_SIZE];
+	char reallinkname[BUFFER_SIZE];
+	struct stat libstat;
+	struct stat linkstat;
+
+	/* construct the full path names */
+	sprintf(libname, "%s/%s", dir, file);
+	sprintf(linkname, "%s/%s", dir, so);
+	if (!chroot_realpath(chroot_dir, libname, reallibname))
+		warn("can't resolve %s in chroot %s", libname, chroot_dir);
+	if (!chroot_realpath(chroot_dir, linkname, reallinkname))
+		warn("can't resolve %s in chroot %s", linkname, chroot_dir);
+
+	/* see if a link already exists */
+	if (!stat(reallinkname, &linkstat)) {
+		/* now see if it's the one we want */
+		if (stat(reallibname, &libstat))
+			warn("can't stat %s", libname);
+		else if (libstat.st_dev == linkstat.st_dev &&
+		         libstat.st_ino == linkstat.st_ino)
+			change = 0;
+	}
+
+	/* then update the link, if required */
+	if (change > 0 && !nolinks) {
+		if (!lstat(reallinkname, &linkstat)) {
+			if (!S_ISLNK(linkstat.st_mode)) {
+				warnx("%s is not a symlink", linkname);
+				change = -1;
+			} else if (remove(reallinkname)) {
+				warn("can't unlink %s", linkname);
+				change = -1;
+			}
+		}
+		if (change > 0) {
+			if (symlink(file, reallinkname)) {
+				warn("can't link %s to %s", linkname, file);
+				change = -1;
+			}
+		}
+	}
+
+	/* some people like to know what we're doing */
+	if (verbose > 0)
+		printf("\t%s => %s%s\n", so, file,
+		       change < 0 ? " (SKIPPED)" :
+		       (change > 0 ? " (changed)" : ""));
+
+	return;
+}
+
+/* figure out which library is greater */
+static int libcmp(char *p1, char *p2)
+{
+	while (*p1) {
+		if (isdigit(*p1) && isdigit(*p2)) {
+			/* must compare this numerically */
+			int v1, v2;
+			v1 = strtoul(p1, &p1, 10);
+			v2 = strtoul(p2, &p2, 10);
+			if (v1 != v2)
+				return v1 - v2;
+		} else if (isdigit(*p1) && !isdigit(*p2))
+			return 1;
+		else if (!isdigit(*p1) && isdigit(*p2))
+			return -1;
+		else if (*p1 != *p2)
+			return *p1 - *p2;
+		else
+			p1++, p2++;
+	}
+
+	return *p1 - *p2;
+}
+
+struct lib {
+	char *so;		/* soname of a library */
+	char *name;		/* name of a library */
+	int libtype;		/* type of a library */
+	int islink;		/* is it a symlink */
+	struct lib *next;	/* next library in list */
+};
+
+/* update all shared library links in a directory */
+static void scan_dir(const char *rawname)
+{
+	DIR *dir;
+	const char *name;
+	struct dirent *ent;
+	char *so, *path, *path_n;
+	struct lib *lp, *libs = NULL;
+	int i, libtype, islink, expected_type = LIB_ANY;
+	char realname[BUFFER_SIZE];
+
+	/* We need a writable copy of this string */
+	path = strdup(rawname);
+	if (!path) {
+		err(EXIT_FAILURE, "Out of memory!\n");
+	}
+	/* Eliminate all double //s */
+	path_n = path;
+	while ((path_n = strstr(path_n, "//"))) {
+		i = strlen(path_n);
+		memmove(path_n, path_n + 1, i - 1);
+		*(path_n + i - 1) = '\0';
+	}
+	name = path;
+
+#if 0
+	char *t;
+	/* Check for an embedded expected type */
+	t = strrchr(name, '=');
+	if (t) {
+		*t++ = '\0';	/* Skip = char */
+		if (strcasecmp(t, "libc4") == 0) {
+			expected_type = LIB_DLL;
+		} else {
+			if (strcasecmp(t, "libc5") == 0) {
+				expected_type = LIB_ELF_LIBC5;
+			} else {
+				if (strcasecmp(t, "libc6") == 0) {
+					expected_type = LIB_ELF_LIBC6;
+				} else {
+					if (strcasecmp(t, "libc0") == 0) {
+						expected_type = LIB_ELF_LIBC0;
+					} else {
+						warnx("Unknown type field '%s' for dir '%s' - ignored", t, name);
+						expected_type = LIB_ANY;
+					}
+				}
+			}
+		}
+	}
+#endif
+
+	/* let 'em know what's going on */
+	if (verbose > 0)
+		printf("%s:\n", name);
+
+	/* get real path in case of chroot */
+	if (!chroot_realpath(chroot_dir, name, realname))
+		warn("can't resolve %s in chroot %s", name, chroot_dir);
+
+	/* if we can't open it, we can't do anything */
+	if ((dir = opendir(realname)) == NULL) {
+		warn("skipping %s", name);
+		free(path);
+		return;
+	}
+
+	/* yes, we have to look at every single file */
+	while ((ent = readdir(dir)) != NULL) {
+		/* if it's not a shared library, don't bother */
+		if ((so = is_shlib(name, ent->d_name, &libtype, &islink, expected_type)) == NULL)
+			continue;
+
+		/* have we already seen one with the same so name? */
+		for (lp = libs; lp; lp = lp->next) {
+			if (strcmp(so, lp->so) == 0) {
+				/* we have, which one do we want to use? */
+				if ((!islink && lp->islink) ||
+				    (islink == lp->islink &&
+				     libcmp(ent->d_name, lp->name) > 0)) {
+					/* let's use the new one */
+					free(lp->name);
+					lp->name = xstrdup(ent->d_name);
+					lp->libtype = libtype;
+					lp->islink = islink;
+				}
+				break;
+			}
+		}
+
+		/* congratulations, you're the first one we've seen */
+		if (!lp) {
+			lp = xmalloc(sizeof *lp);
+			lp->so = xstrdup(so);
+			lp->name = xstrdup(ent->d_name);
+			lp->libtype = libtype;
+			lp->islink = islink;
+			lp->next = libs;
+			libs = lp;
+		}
+
+		free(so);
+	}
+
+	/* don't need this any more */
+	closedir(dir);
+
+	/* now we have all the latest libs, update the links */
+	for (lp = libs; lp; lp = lp->next) {
+		if (!lp->islink)
+			link_shlib(name, lp->name, lp->so);
+		if (!nocache)
+			cache_dolib(name, lp->so, lp->libtype);
+	}
+
+	/* always try to clean up after ourselves */
+	while (libs) {
+		lp = libs->next;
+		free(libs->so);
+		free(libs->name);
+		free(libs);
+		libs = lp;
+	}
+
+	free(path);
+	return;
+}
+
+#ifndef __LDSO_CACHE_SUPPORT__
+void cache_print(void)
+{
+	printf("Library cache disabled\n");
+}
+void cache_dolib(const char *dir, const char *so, int libtype)
+{
+	return;
+}
+void cache_write(void)
+{
+	return;
+}
+#else
+/* return the list of system-specific directories */
+static char *get_extpath(void)
+{
+	char *res = NULL, *cp;
+	FILE *file;
+	struct stat st;
+	char realconffile[BUFFER_SIZE];
+
+	if (!chroot_realpath(chroot_dir, conffile, realconffile))
+		return NULL;
+
+	if ((file = fopen(realconffile, "r")) != NULL) {
+		fstat(fileno(file), &st);
+		res = xmalloc(st.st_size + 1);
+		(void)fread(res, 1, st.st_size, file);
+		fclose(file);
+		res[st.st_size] = '\0';
+
+		/* convert comments fo spaces */
+		for (cp = res; *cp; /*nada */ ) {
+			if (*cp == '#') {
+				do
+					*cp++ = ' ';
+				while (*cp && *cp != '\n');
+			} else {
+				cp++;
+			}
+		}
+	}
+
+	return res;
+}
+
+typedef struct liblist {
+	int flags;
+	int sooffset;
+	int liboffset;
+	char *soname;
+	char *libname;
+	struct liblist *next;
+} liblist_t;
+
+static header_t magic = { LDSO_CACHE_MAGIC, LDSO_CACHE_VER, 0 };
+static liblist_t *lib_head = NULL;
+
+static int liblistcomp(liblist_t *x, liblist_t *y)
+{
+	int res;
+
+	if ((res = libcmp(x->soname, y->soname)) == 0) {
+		res = libcmp(strrchr(x->libname, '/') + 1,
+			     strrchr(y->libname, '/') + 1);
+	}
+
+	return res;
+}
+
+void cache_dolib(const char *dir, const char *so, int libtype)
+{
+	char fullpath[PATH_MAX];
+	liblist_t *new_lib, *cur_lib;
+
+	magic.nlibs++;
+	sprintf(fullpath, "%s/%s", dir, so);
+	new_lib = xmalloc(sizeof(liblist_t));
+	new_lib->flags = libtype;
+	new_lib->soname = xstrdup(so);
+	new_lib->libname = xstrdup(fullpath);
+
+	if (lib_head == NULL || liblistcomp(new_lib, lib_head) > 0) {
+		new_lib->next = lib_head;
+		lib_head = new_lib;
+	} else {
+		for (cur_lib = lib_head; cur_lib->next != NULL &&
+		     liblistcomp(new_lib, cur_lib->next) <= 0;
+		     cur_lib = cur_lib->next)
+			/* nothing */ ;
+		new_lib->next = cur_lib->next;
+		cur_lib->next = new_lib;
+	}
+}
+
+void cache_write(void)
+{
+	int cachefd;
+	int stroffset = 0;
+	char realcachefile[BUFFER_SIZE];
+	char tempfile[BUFFER_SIZE];
+	header_t swap_magic;
+	header_t *magic_ptr;
+	libentry_t swap_lib;
+	libentry_t *lib_ptr;
+	liblist_t *cur_lib;
+
+	if (!magic.nlibs)
+		return;
+
+	if (!chroot_realpath(chroot_dir, cachefile, realcachefile))
+		err(EXIT_FAILURE, "can't resolve %s in chroot %s (%s)",
+		    cachefile, chroot_dir, strerror(errno));
+
+	sprintf(tempfile, "%s~", realcachefile);
+
+	if (unlink(tempfile) && errno != ENOENT)
+		err(EXIT_FAILURE, "can't unlink %s~ (%s)", cachefile,
+		    strerror(errno));
+
+	if ((cachefd = creat(tempfile, 0644)) < 0)
+		err(EXIT_FAILURE, "can't create %s~ (%s)", cachefile,
+		    strerror(errno));
+
+	if (byteswap) {
+		swap_magic = magic;
+		swap_magic.nlibs = bswap_32(swap_magic.nlibs);
+		magic_ptr = &swap_magic;
+	} else {
+		magic_ptr = &magic;
+	}
+	if (write(cachefd, magic_ptr, sizeof(header_t)) != sizeof(header_t))
+		err(EXIT_FAILURE, "can't write %s~ (%s)", cachefile,
+		    strerror(errno));
+
+	for (cur_lib = lib_head; cur_lib != NULL; cur_lib = cur_lib->next) {
+		cur_lib->sooffset = stroffset;
+		stroffset += strlen(cur_lib->soname) + 1;
+		cur_lib->liboffset = stroffset;
+		stroffset += strlen(cur_lib->libname) + 1;
+		if (byteswap) {
+			swap_lib.flags = bswap_32(cur_lib->flags);
+			swap_lib.sooffset = bswap_32(cur_lib->sooffset);
+			swap_lib.liboffset = bswap_32(cur_lib->liboffset);
+			lib_ptr = &swap_lib;
+		} else {
+			lib_ptr = (libentry_t *) cur_lib;
+		}
+		if (write(cachefd, lib_ptr, sizeof(libentry_t)) !=
+		    sizeof(libentry_t))
+			err(EXIT_FAILURE, "can't write %s~ (%s)", cachefile,
+			    strerror(errno));
+	}
+
+	for (cur_lib = lib_head; cur_lib != NULL; cur_lib = cur_lib->next) {
+		if ((size_t)write(cachefd, cur_lib->soname, strlen(cur_lib->soname) + 1)
+		    != strlen(cur_lib->soname) + 1)
+			err(EXIT_FAILURE, "can't write %s~ (%s)", cachefile,
+			    strerror(errno));
+		if ((size_t)write(cachefd, cur_lib->libname, strlen(cur_lib->libname) + 1)
+		    != strlen(cur_lib->libname) + 1)
+			err(EXIT_FAILURE, "can't write %s~ (%s)", cachefile,
+			    strerror(errno));
+	}
+
+	if (close(cachefd))
+		err(EXIT_FAILURE, "can't close %s~ (%s)", cachefile,
+		    strerror(errno));
+
+	if (chmod(tempfile, 0644))
+		err(EXIT_FAILURE, "can't chmod %s~ (%s)", cachefile,
+		    strerror(errno));
+
+	if (rename(tempfile, realcachefile))
+		err(EXIT_FAILURE, "can't rename %s~ (%s)", cachefile,
+		    strerror(errno));
+}
+
+void cache_print(void)
+{
+	caddr_t c;
+	struct stat st;
+	int fd = 0;
+	char *strs;
+	header_t *header;
+	libentry_t *libent;
+	char realcachefile[BUFFER_SIZE];
+
+	if (!chroot_realpath(chroot_dir, cachefile, realcachefile))
+		err(EXIT_FAILURE, "can't resolve %s in chroot %s (%s)",
+		    cachefile, chroot_dir, strerror(errno));
+
+	if (stat(realcachefile, &st) || (fd = open(realcachefile, O_RDONLY)) < 0)
+		err(EXIT_FAILURE, "can't read %s (%s)", cachefile, strerror(errno));
+
+	c = mmap(0, st.st_size, PROT_READ, LDSO_CACHE_MMAP_FLAGS, fd, 0);
+	if (c == MAP_FAILED)
+		err(EXIT_FAILURE, "can't map %s (%s)", cachefile, strerror(errno));
+	close(fd);
+
+	if (memcmp(((header_t *) c)->magic, LDSO_CACHE_MAGIC, LDSO_CACHE_MAGIC_LEN))
+		err(EXIT_FAILURE, "%s cache corrupt", cachefile);
+
+	if (memcmp(((header_t *) c)->version, LDSO_CACHE_VER, LDSO_CACHE_VER_LEN))
+		err(EXIT_FAILURE, "wrong cache version - expected %s",
+		    LDSO_CACHE_VER);
+
+	header = (header_t *) c;
+	libent = (libentry_t *) (c + sizeof(header_t));
+	strs = (char *)&libent[header->nlibs];
+
+	printf("%d libs found in cache `%s' (version %s)\n",
+	       header->nlibs, cachefile, LDSO_CACHE_VER);
+
+	for (fd = 0; fd < header->nlibs; fd++) {
+		printf("\t%s ", strs + libent[fd].sooffset);
+		switch (libent[fd].flags & ~LIB_ELF64) {
+		case LIB_DLL:
+			printf("(libc4)");
+			break;
+		case LIB_ELF:
+			printf("(ELF%s)", libent[fd].flags & LIB_ELF64 ? "/64" : "");
+			break;
+		case LIB_ELF_LIBC0:
+			printf("(libc0%s)", libent[fd].flags & LIB_ELF64 ? "/64" : "");
+			break;
+		case LIB_ELF_LIBC5:
+		case LIB_ELF_LIBC6:
+			printf("(libc%d%s)",
+			       (libent[fd].flags & ~LIB_ELF64) + 3,
+			       libent[fd].flags & LIB_ELF64 ? "/64" : "");
+			break;
+		default:
+			printf("(unknown)");
+			break;
+		}
+		printf(" => %s\n", strs + libent[fd].liboffset);
+	}
+
+	munmap(c, st.st_size);
+}
+#endif
+
+static void usage(void) attribute_noreturn;
+static void usage(void)
+{
+	fprintf(stderr,
+#ifdef __LDSO_CACHE_SUPPORT__
+		"ldconfig - updates symlinks and cache for shared libraries\n\n"
+		"Usage: ldconfig [-DvqnNX] [-f conf] [-C cache] [-r root] dir ...\n"
+		"       ldconfig -l [-Dv] lib ...\n"
+		"       ldconfig -p\n\nOptions:\n"
+#else
+		"ldconfig - updates symlinks for shared libraries\n\n"
+		"Usage: ldconfig [-DvqnX] [-r root] dir ...\n"
+		"       ldconfig -l [-Dv] lib ...\n\nOptions:\n"
+#endif
+		"\t-D:\t\tdebug mode, don't update links\n"
+		"\t-v:\t\tverbose mode, print things as we go\n"
+		"\t-q:\t\tquiet mode, don't print warnings\n"
+		"\t-n:\t\tdon't process standard directories\n"
+		"\t-N:\t\tdon't update the library cache\n"
+		"\t-X:\t\tdon't update the library links\n"
+		"\t-l:\t\tlibrary mode, manually link libraries\n"
+		"\t-p:\t\tprint the current library cache\n"
+#ifdef __LDSO_CACHE_SUPPORT__
+		"\t-f conf :\tuse conf instead of %s\n"
+		"\t-C cache:\tuse cache instead of %s\n"
+#endif
+		"\t-r root :\tfirst, do a chroot to the indicated directory\n"
+		"\tdir ... :\tdirectories to process\n"
+#ifdef __LDSO_CACHE_SUPPORT__
+		"\tlib ... :\tlibraries to link\n\n", LDSO_CONF, LDSO_CACHE
+#else
+		"\tlib ... :\tlibraries to link\n\n"
+#endif
+	    );
+	exit(EXIT_FAILURE);
+}
+
+#define DIR_SEP      ":, \t\n"
+int main(int argc, char **argv)
+{
+	int i, c;
+	int nodefault = 0;
+	char *cp, *dir, *so;
+	int libtype, islink;
+	int printcache = 0;
+#ifdef __LDSO_CACHE_SUPPORT__
+	char *extpath;
+#endif
+
+	prog = argv[0];
+	opterr = 0;
+
+	while ((c = getopt(argc, argv, "DvqnNXlpf:C:r:")) != EOF)
+		switch (c) {
+		case 'D':
+			debug = 1;	/* debug mode */
+			nocache = 1;
+			nolinks = 1;
+			verbose = 1;
+			break;
+		case 'v':
+			verbose = 1;	/* verbose mode */
+			break;
+		case 'q':
+			if (verbose <= 0)
+				verbose = -1;	/* quiet mode */
+			break;
+		case 'n':
+			nodefault = 1;	/* no default dirs */
+			nocache = 1;
+			break;
+		case 'N':
+			nocache = 1;	/* don't build cache */
+			break;
+		case 'X':
+			nolinks = 1;	/* don't update links */
+			break;
+		case 'l':
+			libmode = 1;	/* library mode */
+			break;
+		case 'p':
+			printcache = 1;	/* print cache */
+			break;
+		case 'f':
+#ifdef __LDSO_CACHE_SUPPORT__
+			conffile = optarg;	/* alternate conf file */
+#endif
+			break;
+		case 'C':
+#ifdef __LDSO_CACHE_SUPPORT__
+			cachefile = optarg;	/* alternate cache file */
+#endif
+			break;
+		case 'r':
+			chroot_dir = optarg;
+			break;
+		default:
+			usage();
+			break;
+
+			/* THE REST OF THESE ARE UNDOCUMENTED AND MAY BE REMOVED
+			   IN FUTURE VERSIONS. */
+		}
+
+	if (chroot_dir && *chroot_dir) {
+		if (chroot(chroot_dir) < 0) {
+			if (chdir(chroot_dir) < 0)
+				err(EXIT_FAILURE, "couldn't chroot to %s (%s)", chroot_dir, strerror(errno));
+			chroot_dir = ".";
+		} else {
+			if (chdir("/") < 0)
+				err(EXIT_FAILURE, "couldn't chdir to / (%s)", strerror(errno));
+			chroot_dir = NULL;
+		}
+	}
+
+	/* allow me to introduce myself, hi, my name is ... */
+	if (verbose > 0)
+		printf("%s: uClibc version\n", argv[0]);
+
+	if (printcache) {
+		/* print the cache -- don't you trust me? */
+		cache_print();
+		exit(EXIT_SUCCESS);
+	} else if (libmode) {
+		/* so you want to do things manually, eh? */
+
+		/* ok, if you're so smart, which libraries do we link? */
+		for (i = optind; i < argc; i++) {
+			/* split into directory and file parts */
+			if (!(cp = strrchr(argv[i], '/'))) {
+				dir = ".";	/* no dir, only a filename */
+				cp = argv[i];
+			} else {
+				if (cp == argv[i])
+					dir = "/";	/* file in root directory */
+				else
+					dir = argv[i];
+				*cp++ = '\0';	/* neither of the above */
+			}
+
+			/* we'd better do a little bit of checking */
+			if ((so = is_shlib(dir, cp, &libtype, &islink, LIB_ANY)) == NULL)
+				err(EXIT_FAILURE, "%s%s%s is not a shared library",
+				    dir, (*dir && strcmp(dir, "/")) ? "/" : "", cp);
+
+			/* so far, so good, maybe he knows what he's doing */
+			link_shlib(dir, cp, so);
+		}
+	} else {
+		/* the lazy bum want's us to do all the work for him */
+
+		/* don't cache dirs on the command line */
+		int nocache_save = nocache;
+		nocache = 1;
+
+		/* OK, which directories should we do? */
+		for (i = optind; i < argc; i++)
+			scan_dir(argv[i]);
+
+		/* restore the desired caching state */
+		nocache = nocache_save;
+
+		/* look ma, no defaults */
+		if (!nodefault) {
+			scan_dir(UCLIBC_RUNTIME_PREFIX "lib");
+			scan_dir(UCLIBC_RUNTIME_PREFIX "usr/lib");
+#ifndef __LDSO_CACHE_SUPPORT__
+			scan_dir(UCLIBC_RUNTIME_PREFIX "usr/X11R6/lib");
+#else
+			/* I guess the defaults aren't good enough */
+			if ((extpath = get_extpath())) {
+				for (cp = strtok(extpath, DIR_SEP); cp; cp = strtok(NULL, DIR_SEP)) {
+					/* strip trailing slashes */
+					int len = strlen(cp);
+					if (len)
+						while (cp[--len] == '/' && len)
+							cp[len] = 0;
+					/* we do the redundancy check only if cache usage is enabled */
+					if (strcmp(UCLIBC_RUNTIME_PREFIX "lib", cp) == 0
+					    || strcmp(UCLIBC_RUNTIME_PREFIX "usr/lib", cp) == 0) {
+						if (verbose >= 0)
+							warnx("You should remove `%s' from `%s'", cp, LDSO_CONF);
+						continue;
+					}
+					scan_dir(cp);
+				}
+				free(extpath);
+			}
+#endif
+		}
+
+		if (!nocache)
+			cache_write();
+	}
+
+	exit(EXIT_SUCCESS);
+}
diff --git a/ap/build/uClibc/utils/ldd.c b/ap/build/uClibc/utils/ldd.c
new file mode 100644
index 0000000..04fbbc6
--- /dev/null
+++ b/ap/build/uClibc/utils/ldd.c
@@ -0,0 +1,862 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * A small little ldd implementation for uClibc
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Several functions in this file (specifically, elf_find_section_type(),
+ * elf_find_phdr_type(), and elf_find_dynamic(), were stolen from elflib.c from
+ * elfvector (http://www.BitWagon.com/elfvector.html) by John F. Reiser
+ * <jreiser@BitWagon.com>, which is copyright 2000 BitWagon Software LLC
+ * (GPL2).
+ *
+ * Licensed under GPLv2 or later
+ */
+
+#include "porting.h"
+
+#if defined(__alpha__)
+#define MATCH_MACHINE(x) (x == EM_ALPHA)
+#define ELFCLASSM	ELFCLASS64
+#endif
+
+#if defined(__arm__) || defined(__thumb__)
+#define MATCH_MACHINE(x) (x == EM_ARM)
+#define ELFCLASSM	ELFCLASS32
+#endif
+
+#if defined(__avr32__)
+#define MATCH_MACHINE(x) (x == EM_AVR32)
+#define ELFCLASSM      ELFCLASS32
+#endif
+
+#if defined(__s390__)
+#define MATCH_MACHINE(x) (x == EM_S390)
+#define ELFCLASSM	ELFCLASS32
+#endif
+
+#if defined(__hppa__)
+#define MATCH_MACHINE(x) (x == EM_PARISC)
+#if defined(__LP64__)
+#define ELFCLASSM		ELFCLASS64
+#else
+#define ELFCLASSM		ELFCLASS32
+#endif
+#endif
+
+#if defined(__i386__)
+#ifndef EM_486
+#define MATCH_MACHINE(x) (x == EM_386)
+#else
+#define MATCH_MACHINE(x) (x == EM_386 || x == EM_486)
+#endif
+#define ELFCLASSM	ELFCLASS32
+#endif
+
+#if defined(__ia64__)
+#define MATCH_MACHINE(x) (x == EM_IA_64)
+#define ELFCLASSM	ELFCLASS64
+#endif
+
+#if defined(__mc68000__)
+#define MATCH_MACHINE(x) (x == EM_68K)
+#define ELFCLASSM	ELFCLASS32
+#endif
+
+#if defined(__mips__)
+#define MATCH_MACHINE(x) (x == EM_MIPS || x == EM_MIPS_RS3_LE)
+#define ELFCLASSM	ELFCLASS32
+#endif
+
+#if defined(__powerpc64__)
+#define MATCH_MACHINE(x) (x == EM_PPC64)
+#define ELFCLASSM	ELFCLASS64
+#elif defined(__powerpc__)
+#define MATCH_MACHINE(x) (x == EM_PPC)
+#define ELFCLASSM	ELFCLASS32
+#endif
+
+#if defined(__sh__)
+#define MATCH_MACHINE(x) (x == EM_SH)
+#define ELFCLASSM	ELFCLASS32
+#endif
+
+#if defined(__v850e__)
+#define MATCH_MACHINE(x) ((x) == EM_V850 || (x) == EM_CYGNUS_V850)
+#define ELFCLASSM	ELFCLASS32
+#endif
+
+#if defined(__sparc__)
+#define MATCH_MACHINE(x) ((x) == EM_SPARC || (x) == EM_SPARC32PLUS)
+#define ELFCLASSM    ELFCLASS32
+#endif
+
+#if defined(__cris__)
+#define MATCH_MACHINE(x) (x == EM_CRIS)
+#define ELFCLASSM	ELFCLASS32
+#endif
+
+#if defined(__x86_64__)
+#define MATCH_MACHINE(x) (x == EM_X86_64)
+#define ELFCLASSM	ELFCLASS64
+#endif
+
+#if defined(__microblaze__)
+#define MATCH_MACHINE(x) (x == EM_MICROBLAZE_OLD)
+#define ELFCLASSM	ELFCLASS32
+#endif
+
+#ifndef MATCH_MACHINE
+# ifdef __linux__
+#  include <asm/elf.h>
+# endif
+# ifdef ELF_ARCH
+#  define MATCH_MACHINE(x) (x == ELF_ARCH)
+# endif
+# ifdef ELF_CLASS
+#  define ELFCLASSM ELF_CLASS
+# endif
+#endif
+#ifndef MATCH_MACHINE
+# warning "You really should add a MATCH_MACHINE() macro for your architecture"
+#endif
+
+#if UCLIBC_ENDIAN_HOST == UCLIBC_ENDIAN_LITTLE
+#define ELFDATAM	ELFDATA2LSB
+#elif UCLIBC_ENDIAN_HOST == UCLIBC_ENDIAN_BIG
+#define ELFDATAM	ELFDATA2MSB
+#endif
+
+#define ARRAY_SIZE(v)	(sizeof(v) / sizeof(*v))
+#define TRUSTED_LDSO	UCLIBC_RUNTIME_PREFIX "lib/" UCLIBC_LDSO
+
+struct library {
+	char *name;
+	int resolved;
+	char *path;
+	struct library *next;
+};
+static struct library *lib_list = NULL;
+static char not_found[] = "not found";
+static char *interp_name = NULL;
+static char *interp_dir = NULL;
+static int byteswap;
+static int interpreter_already_found = 0;
+
+static __inline__ uint32_t byteswap32_to_host(uint32_t value)
+{
+	if (byteswap == 1) {
+		return (bswap_32(value));
+	} else {
+		return (value);
+	}
+}
+static __inline__ uint64_t byteswap64_to_host(uint64_t value)
+{
+	if (byteswap == 1) {
+		return (bswap_64(value));
+	} else {
+		return (value);
+	}
+}
+
+#if ELFCLASSM == ELFCLASS32
+# define byteswap_to_host(x) byteswap32_to_host(x)
+#else
+# define byteswap_to_host(x) byteswap64_to_host(x)
+#endif
+
+static ElfW(Shdr) *elf_find_section_type(uint32_t key, ElfW(Ehdr) *ehdr)
+{
+	int j;
+	ElfW(Shdr) *shdr;
+	shdr = (ElfW(Shdr) *) (ehdr->e_shoff + (char *)ehdr);
+	for (j = ehdr->e_shnum; --j >= 0; ++shdr) {
+		if (key == byteswap32_to_host(shdr->sh_type)) {
+			return shdr;
+		}
+	}
+	return NULL;
+}
+
+static ElfW(Phdr) *elf_find_phdr_type(uint32_t type, ElfW(Ehdr) *ehdr)
+{
+	int j;
+	ElfW(Phdr) *phdr = (ElfW(Phdr) *) (ehdr->e_phoff + (char *)ehdr);
+	for (j = ehdr->e_phnum; --j >= 0; ++phdr) {
+		if (type == byteswap32_to_host(phdr->p_type)) {
+			return phdr;
+		}
+	}
+	return NULL;
+}
+
+/* Returns value if return_val==1, ptr otherwise */
+static void *elf_find_dynamic(int64_t const key, ElfW(Dyn) *dynp,
+		       ElfW(Ehdr) *ehdr, int return_val)
+{
+	ElfW(Phdr) *pt_text = elf_find_phdr_type(PT_LOAD, ehdr);
+	unsigned tx_reloc = byteswap_to_host(pt_text->p_vaddr) - byteswap_to_host(pt_text->p_offset);
+	for (; DT_NULL != byteswap_to_host(dynp->d_tag); ++dynp) {
+		if (key == byteswap_to_host(dynp->d_tag)) {
+			if (return_val == 1)
+				return (void *)byteswap_to_host(dynp->d_un.d_val);
+			else
+				return (void *)(byteswap_to_host(dynp->d_un.d_val) - tx_reloc + (char *)ehdr);
+		}
+	}
+	return NULL;
+}
+
+static char *elf_find_rpath(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic)
+{
+	ElfW(Dyn) *dyns;
+
+	for (dyns = dynamic; byteswap_to_host(dyns->d_tag) != DT_NULL; ++dyns) {
+		if (DT_RPATH == byteswap_to_host(dyns->d_tag)) {
+			char *strtab;
+			strtab = (char *)elf_find_dynamic(DT_STRTAB, dynamic, ehdr, 0);
+			return ((char *)strtab + byteswap_to_host(dyns->d_un.d_val));
+		}
+	}
+	return NULL;
+}
+
+static int check_elf_header(ElfW(Ehdr) *const ehdr)
+{
+	if (!ehdr || *(uint32_t*)ehdr != ELFMAG_U32
+	 || ehdr->e_ident[EI_CLASS] != ELFCLASSM
+	 || ehdr->e_ident[EI_VERSION] != EV_CURRENT
+	) {
+		return 1;
+	}
+
+	/* Check if the target endianness matches the host's endianness */
+	byteswap = 0;
+	if (UCLIBC_ENDIAN_HOST == UCLIBC_ENDIAN_LITTLE) {
+		if (ehdr->e_ident[5] == ELFDATA2MSB)
+			byteswap = 1;
+	} else if (UCLIBC_ENDIAN_HOST == UCLIBC_ENDIAN_BIG) {
+		if (ehdr->e_ident[5] == ELFDATA2LSB)
+			byteswap = 1;
+	}
+
+	/* Be very lazy, and only byteswap the stuff we use */
+	if (byteswap) {
+		ehdr->e_type = bswap_16(ehdr->e_type);
+		ehdr->e_phoff = byteswap_to_host(ehdr->e_phoff);
+		ehdr->e_shoff = byteswap_to_host(ehdr->e_shoff);
+		ehdr->e_phnum = bswap_16(ehdr->e_phnum);
+		ehdr->e_shnum = bswap_16(ehdr->e_shnum);
+	}
+
+	return 0;
+}
+
+#ifdef __LDSO_CACHE_SUPPORT__
+static caddr_t cache_addr = NULL;
+static size_t cache_size = 0;
+
+static int map_cache(void)
+{
+	int fd;
+	struct stat st;
+	header_t *header;
+	libentry_t *libent;
+	int i, strtabsize;
+
+	if (cache_addr == (caddr_t) - 1)
+		return -1;
+	else if (cache_addr != NULL)
+		return 0;
+
+	if (stat(LDSO_CACHE, &st) || (fd = open(LDSO_CACHE, O_RDONLY)) < 0) {
+		fprintf(stderr, "ldd: can't open cache '%s'\n", LDSO_CACHE);
+		cache_addr = (caddr_t) - 1;	/* so we won't try again */
+		return -1;
+	}
+
+	cache_size = st.st_size;
+	cache_addr = mmap(0, cache_size, PROT_READ, MAP_SHARED, fd, 0);
+	close(fd);
+	if (cache_addr == MAP_FAILED) {
+		fprintf(stderr, "ldd: can't map cache '%s'\n", LDSO_CACHE);
+		return -1;
+	}
+
+	header = (header_t *) cache_addr;
+
+	if (cache_size < sizeof(header_t)
+	    || memcmp(header->magic, LDSO_CACHE_MAGIC, LDSO_CACHE_MAGIC_LEN)
+	    || memcmp(header->version, LDSO_CACHE_VER, LDSO_CACHE_VER_LEN)
+	    || cache_size < (sizeof(header_t) + header->nlibs * sizeof(libentry_t))
+	    || cache_addr[cache_size - 1] != '\0')
+	{
+		fprintf(stderr, "ldd: cache '%s' is corrupt\n", LDSO_CACHE);
+		goto fail;
+	}
+
+	strtabsize = cache_size - sizeof(header_t) - header->nlibs * sizeof(libentry_t);
+	libent = (libentry_t *) & header[1];
+
+	for (i = 0; i < header->nlibs; i++) {
+		if (libent[i].sooffset >= strtabsize || libent[i].liboffset >= strtabsize) {
+			fprintf(stderr, "ldd: cache '%s' is corrupt\n", LDSO_CACHE);
+			goto fail;
+		}
+	}
+
+	return 0;
+
+fail:
+	munmap(cache_addr, cache_size);
+	cache_addr = (caddr_t) - 1;
+	return -1;
+}
+
+static int unmap_cache(void)
+{
+	if (cache_addr == NULL || cache_addr == (caddr_t) - 1)
+		return -1;
+
+#if 1
+	munmap(cache_addr, cache_size);
+	cache_addr = NULL;
+#endif
+
+	return 0;
+}
+#else
+static __inline__ void map_cache(void)
+{
+}
+static __inline__ void unmap_cache(void)
+{
+}
+#endif
+
+/* This function's behavior must exactly match that
+ * in uClibc/ldso/ldso/dl-elf.c */
+static void search_for_named_library(char *name, char *result,
+				     const char *path_list)
+{
+	int i, count = 1;
+	char *path, *path_n;
+	struct stat filestat;
+
+	/* We need a writable copy of this string */
+	path = strdup(path_list);
+	if (!path) {
+		fprintf(stderr, "%s: Out of memory!\n", __func__);
+		exit(EXIT_FAILURE);
+	}
+	/* Eliminate all double //s */
+	path_n = path;
+	while ((path_n = strstr(path_n, "//"))) {
+		i = strlen(path_n);
+		memmove(path_n, path_n + 1, i - 1);
+		*(path_n + i - 1) = '\0';
+	}
+
+	/* Replace colons with zeros in path_list and count them */
+	for (i = strlen(path); i > 0; i--) {
+		if (path[i] == ':') {
+			path[i] = 0;
+			count++;
+		}
+	}
+	path_n = path;
+	for (i = 0; i < count; i++) {
+		strcpy(result, path_n);
+		strcat(result, "/");
+		strcat(result, name);
+		if (stat(result, &filestat) == 0 && filestat.st_mode & S_IRUSR) {
+			free(path);
+			return;
+		}
+		path_n += (strlen(path_n) + 1);
+	}
+	free(path);
+	*result = '\0';
+}
+
+static void locate_library_file(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic,
+                                int is_suid, struct library *lib)
+{
+	char *buf;
+	char *path;
+	struct stat filestat;
+
+	/* If this is a fully resolved name, our job is easy */
+	if (stat(lib->name, &filestat) == 0) {
+		lib->path = strdup(lib->name);
+		return;
+	}
+
+	/* We need some elbow room here.  Make some room... */
+	buf = malloc(1024);
+	if (!buf) {
+		fprintf(stderr, "%s: Out of memory!\n", __func__);
+		exit(EXIT_FAILURE);
+	}
+
+	/* This function must match the behavior of _dl_load_shared_library
+	 * in readelflib1.c or things won't work out as expected... */
+
+	/* The ABI specifies that RPATH is searched first, so do that now.  */
+	path = elf_find_rpath(ehdr, dynamic);
+	if (path) {
+		search_for_named_library(lib->name, buf, path);
+		if (*buf != '\0') {
+			lib->path = buf;
+			return;
+		}
+	}
+
+	/* Next check LD_{ELF_}LIBRARY_PATH if specified and allowed.
+	 * Since this app doesn't actually run an executable I will skip
+	 * the suid check, and just use LD_{ELF_}LIBRARY_PATH if set */
+	if (is_suid == 1)
+		path = NULL;
+	else
+		path = getenv("LD_LIBRARY_PATH");
+	if (path) {
+		search_for_named_library(lib->name, buf, path);
+		if (*buf != '\0') {
+			lib->path = buf;
+			return;
+		}
+	}
+#ifdef __LDSO_CACHE_SUPPORT__
+	if (cache_addr != NULL && cache_addr != (caddr_t) - 1) {
+		int i;
+		header_t *header = (header_t *) cache_addr;
+		libentry_t *libent = (libentry_t *) & header[1];
+		char *strs = (char *)&libent[header->nlibs];
+
+		for (i = 0; i < header->nlibs; i++) {
+			if ((libent[i].flags == LIB_ELF ||
+			     libent[i].flags == LIB_ELF_LIBC0 ||
+			     libent[i].flags == LIB_ELF_LIBC5) &&
+			    strcmp(lib->name, strs + libent[i].sooffset) == 0)
+			{
+				lib->path = strdup(strs + libent[i].liboffset);
+				return;
+			}
+		}
+	}
+#endif
+
+	/* Next look for libraries wherever the shared library
+	 * loader was installed -- this is usually where we
+	 * should find things... */
+	if (interp_dir) {
+		search_for_named_library(lib->name, buf, interp_dir);
+		if (*buf != '\0') {
+			lib->path = buf;
+			return;
+		}
+	}
+
+	/* Lastly, search the standard list of paths for the library.
+	   This list must exactly match the list in uClibc/ldso/ldso/dl-elf.c */
+	path = UCLIBC_RUNTIME_PREFIX "lib:" UCLIBC_RUNTIME_PREFIX "usr/lib"
+#ifndef __LDSO_CACHE_SUPPORT__
+	    ":" UCLIBC_RUNTIME_PREFIX "usr/X11R6/lib"
+#endif
+	    ;
+	search_for_named_library(lib->name, buf, path);
+	if (*buf != '\0') {
+		lib->path = buf;
+	} else {
+		free(buf);
+		lib->path = not_found;
+	}
+}
+
+static int add_library(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic, int is_setuid, char *s)
+{
+	char *tmp, *tmp1, *tmp2;
+	struct library *cur, *newlib = lib_list;
+
+	if (!s || !strlen(s))
+		return 1;
+
+	tmp = s;
+	while (*tmp) {
+		if (*tmp == '/')
+			s = tmp + 1;
+		tmp++;
+	}
+
+	/* We add ldso elsewhere */
+	if (interpreter_already_found && (tmp = strrchr(interp_name, '/')) != NULL) {
+		int len = strlen(interp_dir);
+		if (strcmp(s, interp_name + 1 + len) == 0)
+			return 1;
+	}
+
+	for (cur = lib_list; cur; cur = cur->next) {
+		/* Check if this library is already in the list */
+		tmp1 = tmp2 = cur->name;
+		while (*tmp1) {
+			if (*tmp1 == '/')
+				tmp2 = tmp1 + 1;
+			tmp1++;
+		}
+		if (strcmp(tmp2, s) == 0) {
+			/*printf("find_elf_interpreter is skipping '%s' (already in list)\n", cur->name); */
+			return 0;
+		}
+	}
+
+	/* Ok, this lib needs to be added to the list */
+	newlib = malloc(sizeof(struct library));
+	if (!newlib)
+		return 1;
+	newlib->name = malloc(strlen(s) + 1);
+	strcpy(newlib->name, s);
+	newlib->resolved = 0;
+	newlib->path = NULL;
+	newlib->next = NULL;
+
+	/* Now try and locate where this library might be living... */
+	locate_library_file(ehdr, dynamic, is_setuid, newlib);
+
+	/*printf("add_library is adding '%s' to '%s'\n", newlib->name, newlib->path); */
+	if (!lib_list) {
+		lib_list = newlib;
+	} else {
+		for (cur = lib_list; cur->next; cur = cur->next) ;	/* nothing */
+		cur->next = newlib;
+	}
+	return 0;
+}
+
+static void find_needed_libraries(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic, int is_setuid)
+{
+	ElfW(Dyn) *dyns;
+
+	for (dyns = dynamic; byteswap_to_host(dyns->d_tag) != DT_NULL; ++dyns) {
+		if (DT_NEEDED == byteswap_to_host(dyns->d_tag)) {
+			char *strtab;
+			strtab = (char *)elf_find_dynamic(DT_STRTAB, dynamic, ehdr, 0);
+			add_library(ehdr, dynamic, is_setuid, (char *)strtab + byteswap_to_host(dyns->d_un.d_val));
+		}
+	}
+}
+
+#ifdef __LDSO_LDD_SUPPORT__
+static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr)
+{
+	ElfW(Phdr) *phdr;
+
+	if (interpreter_already_found == 1)
+		return NULL;
+	phdr = elf_find_phdr_type(PT_INTERP, ehdr);
+	if (phdr) {
+		struct library *cur, *newlib = NULL;
+		char *s = (char *)ehdr + byteswap_to_host(phdr->p_offset);
+
+		char *tmp, *tmp1;
+		interp_name = strdup(s);
+		interp_dir = strdup(s);
+		tmp = strrchr(interp_dir, '/');
+		if (tmp)
+			*tmp = '\0';
+		else {
+			free(interp_dir);
+			interp_dir = interp_name;
+		}
+		tmp1 = tmp = s;
+		while (*tmp) {
+			if (*tmp == '/')
+				tmp1 = tmp + 1;
+			tmp++;
+		}
+		for (cur = lib_list; cur; cur = cur->next) {
+			/* Check if this library is already in the list */
+			if (strcmp(cur->name, tmp1) == 0) {
+				/*printf("find_elf_interpreter is replacing '%s' (already in list)\n", cur->name); */
+				newlib = cur;
+				free(newlib->name);
+				if (newlib->path != not_found) {
+					free(newlib->path);
+				}
+				newlib->name = NULL;
+				newlib->path = NULL;
+				break;
+			}
+		}
+		if (newlib == NULL)
+			newlib = malloc(sizeof(struct library));
+		if (!newlib)
+			return NULL;
+		newlib->name = malloc(strlen(s) + 1);
+		strcpy(newlib->name, s);
+		newlib->path = strdup(newlib->name);
+		newlib->resolved = 1;
+		newlib->next = NULL;
+
+#if 0
+		/*printf("find_elf_interpreter is adding '%s' to '%s'\n", newlib->name, newlib->path); */
+		if (!lib_list) {
+			lib_list = newlib;
+		} else {
+			for (cur = lib_list; cur->next; cur = cur->next) ;	/* nothing */
+			cur->next = newlib;
+		}
+#endif
+		interpreter_already_found = 1;
+		return newlib;
+	}
+	return NULL;
+}
+#endif /* __LDSO_LDD_SUPPORT__ */
+
+/* map the .so, and locate interesting pieces */
+/*
+#warning "There may be two warnings here about vfork() clobbering, ignore them"
+*/
+static int find_dependencies(char *filename)
+{
+	int is_suid = 0;
+	FILE *thefile;
+	struct stat statbuf;
+	ElfW(Ehdr) *ehdr = NULL;
+	ElfW(Shdr) *dynsec = NULL;
+	ElfW(Dyn) *dynamic = NULL;
+#ifdef __LDSO_LDD_SUPPORT__
+	struct library *interp;
+#endif
+
+	if (filename == not_found)
+		return 0;
+
+	if (!filename) {
+		fprintf(stderr, "No filename specified.\n");
+		return -1;
+	}
+	if (!(thefile = fopen(filename, "r"))) {
+		perror(filename);
+		return -1;
+	}
+	if (fstat(fileno(thefile), &statbuf) < 0) {
+		perror(filename);
+		fclose(thefile);
+		return -1;
+	}
+
+	if ((size_t) statbuf.st_size < sizeof(ElfW(Ehdr)))
+		goto foo;
+
+	if (!S_ISREG(statbuf.st_mode))
+		goto foo;
+
+	/* mmap the file to make reading stuff from it effortless */
+	ehdr = mmap(0, statbuf.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fileno(thefile), 0);
+	if (ehdr == MAP_FAILED) {
+		fclose(thefile);
+		fprintf(stderr, "mmap(%s) failed: %s\n", filename, strerror(errno));
+		return -1;
+	}
+
+foo:
+	fclose(thefile);
+
+	/* Check if this looks like a legit ELF file */
+	if (check_elf_header(ehdr)) {
+		fprintf(stderr, "%s: not an ELF file.\n", filename);
+		return -1;
+	}
+	/* Check if this is the right kind of ELF file */
+	if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN) {
+		fprintf(stderr, "%s: not a dynamic executable\n", filename);
+		return -1;
+	}
+	if (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN) {
+		if (statbuf.st_mode & S_ISUID)
+			is_suid = 1;
+		if ((statbuf.st_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
+			is_suid = 1;
+		/* FIXME */
+		if (is_suid)
+			fprintf(stderr, "%s: is setuid\n", filename);
+	}
+
+	interpreter_already_found = 0;
+#ifdef __LDSO_LDD_SUPPORT__
+	interp = find_elf_interpreter(ehdr);
+
+	if (interp
+	    && (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN)
+	    && ehdr->e_ident[EI_CLASS] == ELFCLASSM
+	    && ehdr->e_ident[EI_DATA] == ELFDATAM
+	    && ehdr->e_ident[EI_VERSION] == EV_CURRENT
+	    && MATCH_MACHINE(ehdr->e_machine))
+	{
+		struct stat st;
+		if (stat(interp->path, &st) == 0 && S_ISREG(st.st_mode)) {
+			pid_t pid;
+			int status;
+			static const char *const environment[] = {
+				"PATH=/usr/bin:/bin:/usr/sbin:/sbin",
+				"SHELL=/bin/sh",
+				"LD_TRACE_LOADED_OBJECTS=1",
+				NULL
+			};
+# ifdef __LDSO_STANDALONE_SUPPORT__
+			char * lib_path = getenv("LD_LIBRARY_PATH");
+			/* The 'extended' environment inclusing the LD_LIBRARY_PATH */
+			static char *ext_environment[ARRAY_SIZE(environment) + 1];
+			char **envp = (char **) environment;
+
+			if (lib_path) {
+				/*
+				 * If the LD_LIBRARY_PATH is set, it needs to include it
+				 * into the environment for the new process to be spawned
+				 */
+				char ** eenvp = (char **) ext_environment;
+
+				/* Copy the N-1 environment's entries */
+				while (*envp)
+					*eenvp++=*envp++;
+
+				/* Make room for LD_LIBRARY_PATH */
+				*eenvp = (char *) malloc(sizeof("LD_LIBRARY_PATH=")
+									  + strlen(lib_path));
+				strcpy(*eenvp, "LD_LIBRARY_PATH=");
+				strcat(*eenvp, lib_path);
+				lib_path = *eenvp;
+				/* ext_environment[size] is already NULL */
+
+				/* Use the extended environment */
+				envp = ext_environment;
+			}
+			if ((pid = vfork()) == 0) {
+				/*
+				 * Force to use the standard dynamic linker in stand-alone mode.
+				 * It will fails at runtime if support is not actually available
+				 */
+				execle(TRUSTED_LDSO, TRUSTED_LDSO, filename, NULL, envp);
+				_exit(0xdead);
+			}
+# else
+			if ((pid = vfork()) == 0) {
+				/* Cool, it looks like we should be able to actually
+				 * run this puppy.  Do so now... */
+				execle(filename, filename, NULL, environment);
+				_exit(0xdead);
+			}
+# endif
+			/* Wait till it returns */
+			waitpid(pid, &status, 0);
+
+# ifdef __LDSO_STANDALONE_SUPPORT__
+			/* Do not leak */
+			free(lib_path);
+# endif
+
+			if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
+				return 1;
+			}
+
+			/* If the exec failed, we fall through to trying to find
+			 * all the needed libraries ourselves by rummaging about
+			 * in the ELF headers... */
+		}
+	}
+#endif
+
+	dynsec = elf_find_section_type(SHT_DYNAMIC, ehdr);
+	if (dynsec) {
+		dynamic = (ElfW(Dyn) *) (byteswap_to_host(dynsec->sh_offset) + (char *)ehdr);
+		find_needed_libraries(ehdr, dynamic, is_suid);
+	}
+
+	return 0;
+}
+
+int main(int argc, char **argv)
+{
+	int multi = 0;
+	int got_em_all = 1;
+	char *filename = NULL;
+	struct library *cur;
+
+	if (argc < 2) {
+		fprintf(stderr, "ldd: missing file arguments\n"
+				"Try `ldd --help' for more information.\n");
+		exit(EXIT_FAILURE);
+	}
+	if (argc > 2)
+		multi++;
+
+	while (--argc > 0) {
+		++argv;
+
+		if (strcmp(*argv, "--") == 0) {
+			/* Ignore "--" */
+			continue;
+		}
+
+		if (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0) {
+			fprintf(stderr, "Usage: ldd [OPTION]... FILE...\n"
+					"\t--help\t\tprint this help and exit\n");
+			exit(EXIT_SUCCESS);
+		}
+
+		filename = *argv;
+		if (!filename) {
+			fprintf(stderr, "No filename specified.\n");
+			exit(EXIT_FAILURE);
+		}
+
+		if (multi) {
+			printf("%s:\n", *argv);
+		}
+
+		map_cache();
+
+		if (find_dependencies(filename) != 0)
+			continue;
+
+		while (got_em_all) {
+			got_em_all = 0;
+			/* Keep walking the list till everybody is resolved */
+			for (cur = lib_list; cur; cur = cur->next) {
+				if (cur->resolved == 0 && cur->path) {
+					got_em_all = 1;
+					printf("checking sub-depends for '%s'\n", cur->path);
+					find_dependencies(cur->path);
+					cur->resolved = 1;
+				}
+			}
+		}
+
+		unmap_cache();
+
+		/* Print the list */
+		got_em_all = 0;
+		for (cur = lib_list; cur; cur = cur->next) {
+			got_em_all = 1;
+			printf("\t%s => %s (0x00000000)\n", cur->name, cur->path);
+		}
+		if (interp_name && interpreter_already_found == 1)
+			printf("\t%s => %s (0x00000000)\n", interp_name, interp_name);
+		else
+			printf("\tnot a dynamic executable\n");
+
+		for (cur = lib_list; cur; cur = cur->next) {
+			free(cur->name);
+			cur->name = NULL;
+			if (cur->path && cur->path != not_found) {
+				free(cur->path);
+				cur->path = NULL;
+			}
+		}
+		lib_list = NULL;
+	}
+
+	return 0;
+}
diff --git a/ap/build/uClibc/utils/mmap-windows.c b/ap/build/uClibc/utils/mmap-windows.c
new file mode 100644
index 0000000..1799392
--- /dev/null
+++ b/ap/build/uClibc/utils/mmap-windows.c
@@ -0,0 +1,100 @@
+/* mmap() replacement for Windows
+ *
+ * Author: Mike Frysinger <vapier@gentoo.org>
+ * Placed into the public domain
+ */
+
+/* References:
+ * CreateFileMapping: http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx
+ * CloseHandle:       http://msdn.microsoft.com/en-us/library/ms724211(VS.85).aspx
+ * MapViewOfFile:     http://msdn.microsoft.com/en-us/library/aa366761(VS.85).aspx
+ * UnmapViewOfFile:   http://msdn.microsoft.com/en-us/library/aa366882(VS.85).aspx
+ */
+
+#include <io.h>
+#include <windows.h>
+#include <sys/types.h>
+
+#define PROT_READ     0x1
+#define PROT_WRITE    0x2
+/* This flag is only available in WinXP+ */
+#ifdef FILE_MAP_EXECUTE
+#define PROT_EXEC     0x4
+#else
+#define PROT_EXEC        0x0
+#define FILE_MAP_EXECUTE 0
+#endif
+
+#define MAP_SHARED    0x01
+#define MAP_PRIVATE   0x02
+#define MAP_ANONYMOUS 0x20
+#define MAP_ANON      MAP_ANONYMOUS
+#define MAP_FAILED    ((void *) -1)
+
+#ifdef __USE_FILE_OFFSET64
+# define DWORD_HI(x) (x >> 32)
+# define DWORD_LO(x) ((x) & 0xffffffff)
+#else
+# define DWORD_HI(x) (0)
+# define DWORD_LO(x) (x)
+#endif
+
+static void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
+{
+	if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
+		return MAP_FAILED;
+	if (fd == -1) {
+		if (!(flags & MAP_ANON) || offset)
+			return MAP_FAILED;
+	} else if (flags & MAP_ANON)
+		return MAP_FAILED;
+
+	DWORD flProtect;
+	if (prot & PROT_WRITE) {
+		if (prot & PROT_EXEC)
+			flProtect = PAGE_EXECUTE_READWRITE;
+		else
+			flProtect = PAGE_READWRITE;
+	} else if (prot & PROT_EXEC) {
+		if (prot & PROT_READ)
+			flProtect = PAGE_EXECUTE_READ;
+		else if (prot & PROT_EXEC)
+			flProtect = PAGE_EXECUTE;
+	} else
+		flProtect = PAGE_READONLY;
+
+	off_t end = length + offset;
+	HANDLE mmap_fd, h;
+	if (fd == -1)
+		mmap_fd = INVALID_HANDLE_VALUE;
+	else
+		mmap_fd = (HANDLE)_get_osfhandle(fd);
+	h = CreateFileMapping(mmap_fd, NULL, flProtect, DWORD_HI(end), DWORD_LO(end), NULL);
+	if (h == NULL)
+		return MAP_FAILED;
+
+	DWORD dwDesiredAccess;
+	if (prot & PROT_WRITE)
+		dwDesiredAccess = FILE_MAP_WRITE;
+	else
+		dwDesiredAccess = FILE_MAP_READ;
+	if (prot & PROT_EXEC)
+		dwDesiredAccess |= FILE_MAP_EXECUTE;
+	if (flags & MAP_PRIVATE)
+		dwDesiredAccess |= FILE_MAP_COPY;
+	void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length);
+	if (ret == NULL) {
+		CloseHandle(h);
+		ret = MAP_FAILED;
+	}
+	return ret;
+}
+
+static void munmap(void *addr, size_t length)
+{
+	UnmapViewOfFile(addr);
+	/* ruh-ro, we leaked handle from CreateFileMapping() ... */
+}
+
+#undef DWORD_HI
+#undef DWORD_LO
diff --git a/ap/build/uClibc/utils/porting.h b/ap/build/uClibc/utils/porting.h
new file mode 100755
index 0000000..f1fdc70
--- /dev/null
+++ b/ap/build/uClibc/utils/porting.h
@@ -0,0 +1,87 @@
+/* Misc system-specific crap */
+
+#ifndef _PORTING_H_
+#define _PORTING_H_
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <ctype.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#ifdef __LDSO_LDD_SUPPORT__
+# include <sys/wait.h>
+#endif
+
+#if defined(_WIN32) || defined(_WINNT)
+# include "mmap-windows.c"
+#else
+# include <sys/mman.h>
+#endif
+
+#ifdef BUILDING_LINKAGE
+#include <link.h>
+/* makefile will include elf.h for us */
+
+#include "bswap.h"
+#include "dl-defs.h"
+#endif
+
+#ifdef DMALLOC
+#include <dmalloc.h>
+#endif
+
+#ifndef ARRAY_SIZE
+# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+#endif
+
+/* For SunOS */
+#ifndef PATH_MAX
+#define PATH_MAX _POSIX_PATH_MAX
+#endif
+
+#ifndef UCLIBC_RUNTIME_PREFIX
+# define UCLIBC_RUNTIME_PREFIX "/"
+#endif
+
+#undef UCLIBC_ENDIAN_HOST
+#define UCLIBC_ENDIAN_LITTLE 1234
+#define UCLIBC_ENDIAN_BIG    4321
+#if defined(BYTE_ORDER)
+# if BYTE_ORDER == LITTLE_ENDIAN
+#  define UCLIBC_ENDIAN_HOST UCLIBC_ENDIAN_LITTLE
+# elif BYTE_ORDER == BIG_ENDIAN
+#  define UCLIBC_ENDIAN_HOST UCLIBC_ENDIAN_BIG
+# endif
+#elif defined(__BYTE_ORDER)
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+#  define UCLIBC_ENDIAN_HOST UCLIBC_ENDIAN_LITTLE
+# elif __BYTE_ORDER == __BIG_ENDIAN
+#  define UCLIBC_ENDIAN_HOST UCLIBC_ENDIAN_BIG
+# endif
+#endif
+#if !defined(UCLIBC_ENDIAN_HOST)
+# error "Unknown host byte order!"
+#endif
+
+#if defined __GNUC__ || defined __ICC
+# define attribute_noreturn __attribute__ ((__noreturn__))
+#else
+# define attribute_noreturn
+#endif
+
+#endif
diff --git a/ap/build/uClibc/utils/readsoname2.c b/ap/build/uClibc/utils/readsoname2.c
new file mode 100644
index 0000000..5cda331
--- /dev/null
+++ b/ap/build/uClibc/utils/readsoname2.c
@@ -0,0 +1,141 @@
+static char *readsonameXX(char *name, FILE *infile, int expected_type, int *type)
+{
+	ElfW(Ehdr) *epnt;
+	ElfW(Phdr) *ppnt;
+	unsigned int i, j;
+	char *header;
+	ElfW(Addr) dynamic_addr = 0;
+	ElfW(Addr) dynamic_size = 0;
+	unsigned long page_size = getpagesize();
+	ElfW(Addr) strtab_val = 0;
+	ElfW(Addr) needed_val;
+	ElfW(Addr) loadaddr = -1;
+	ElfW(Dyn) *dpnt;
+	struct stat st;
+	char *needed;
+	char *soname = NULL;
+	int multi_libcs = 0;
+
+	if (expected_type == LIB_DLL) {
+		warn("%s does not match type specified for directory!", name);
+		expected_type = LIB_ANY;
+	}
+
+	*type = LIB_ELF;
+
+	if (fstat(fileno(infile), &st))
+		return NULL;
+	header =
+	    mmap(0, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE,
+		 fileno(infile), 0);
+	if (header == (caddr_t) - 1)
+		return NULL;
+
+	epnt = (ElfW(Ehdr) *) header;
+	if ((char *)(epnt + 1) > (char *)(header + st.st_size))
+		goto skip;
+
+	if (UCLIBC_ENDIAN_HOST == UCLIBC_ENDIAN_LITTLE)
+		byteswap = (epnt->e_ident[5] == ELFDATA2MSB) ? 1 : 0;
+	else if (UCLIBC_ENDIAN_HOST == UCLIBC_ENDIAN_BIG)
+		byteswap = (epnt->e_ident[5] == ELFDATA2LSB) ? 1 : 0;
+
+	/* Be very lazy, and only byteswap the stuff we use */
+	if (byteswap == 1) {
+		epnt->e_phoff = bswap_32(epnt->e_phoff);
+		epnt->e_phnum = bswap_16(epnt->e_phnum);
+	}
+
+	ppnt = (ElfW(Phdr) *) & header[epnt->e_phoff];
+	if ((char *)ppnt < (char *)header ||
+	    (char *)(ppnt + epnt->e_phnum) > (char *)(header + st.st_size))
+		goto skip;
+
+	for (i = 0; i < epnt->e_phnum; i++) {
+		/* Be very lazy, and only byteswap the stuff we use */
+		if (byteswap == 1) {
+			ppnt->p_type = bswap_32(ppnt->p_type);
+			ppnt->p_vaddr = bswap_32(ppnt->p_vaddr);
+			ppnt->p_offset = bswap_32(ppnt->p_offset);
+			ppnt->p_filesz = bswap_32(ppnt->p_filesz);
+		}
+
+		if (loadaddr == (ElfW(Addr)) - 1 && ppnt->p_type == PT_LOAD)
+			loadaddr = (ppnt->p_vaddr & ~(page_size - 1)) -
+			    (ppnt->p_offset & ~(page_size - 1));
+		if (ppnt->p_type == 2) {
+			dynamic_addr = ppnt->p_offset;
+			dynamic_size = ppnt->p_filesz;
+		};
+		ppnt++;
+	};
+
+	dpnt = (ElfW(Dyn) *) & header[dynamic_addr];
+	dynamic_size = dynamic_size / sizeof(ElfW(Dyn));
+	if ((char *)dpnt < (char *)header ||
+	    (char *)(dpnt + dynamic_size) > (char *)(header + st.st_size))
+		goto skip;
+
+	if (byteswap == 1) {
+		dpnt->d_tag = bswap_32(dpnt->d_tag);
+		dpnt->d_un.d_val = bswap_32(dpnt->d_un.d_val);
+	}
+
+	while (dpnt->d_tag != DT_NULL) {
+		if (dpnt->d_tag == DT_STRTAB)
+			strtab_val = dpnt->d_un.d_val;
+		dpnt++;
+		if (byteswap == 1) {
+			dpnt->d_tag = bswap_32(dpnt->d_tag);
+			dpnt->d_un.d_val = bswap_32(dpnt->d_un.d_val);
+		}
+	};
+
+	if (!strtab_val)
+		goto skip;
+
+	dpnt = (ElfW(Dyn) *) & header[dynamic_addr];
+	while (dpnt->d_tag != DT_NULL) {
+		if (dpnt->d_tag == DT_SONAME || dpnt->d_tag == DT_NEEDED) {
+			needed_val = dpnt->d_un.d_val;
+			if (needed_val + strtab_val >= loadaddr ||
+			    needed_val + strtab_val < st.st_size - loadaddr) {
+				needed =
+				    (char *)(header - loadaddr + strtab_val +
+					     needed_val);
+
+				if (dpnt->d_tag == DT_SONAME)
+					soname = xstrdup(needed);
+
+				for (j = 0; needed_tab[j].soname != NULL; j++) {
+					if (strcmp(needed, needed_tab[j].soname)
+					    == 0) {
+						if (*type != LIB_ELF
+						    && *type !=
+						    needed_tab[j].type)
+							multi_libcs = 1;
+						*type = needed_tab[j].type;
+					}
+				}
+			}
+		}
+		dpnt++;
+	};
+
+	if (multi_libcs)
+		warn("%s appears to be for multiple libc's", name);
+
+	/* If we could not deduce the libc type, and we know what to expect, set the type */
+	if (*type == LIB_ELF && expected_type != LIB_ANY)
+		*type = expected_type;
+
+	if (expected_type != LIB_ANY && expected_type != LIB_ELF &&
+	    expected_type != *type) {
+		warn("%s does not match type specified for directory!", name);
+	}
+
+      skip:
+	munmap(header, st.st_size);
+
+	return soname;
+}