summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/.gitignore12
-rw-r--r--utils/Makefile.in132
-rw-r--r--utils/bswap.h52
-rw-r--r--utils/chroot_realpath.c48
-rw-r--r--utils/getconf.c1335
-rw-r--r--utils/iconv.c271
-rw-r--r--utils/ldconfig.c130
-rw-r--r--utils/ldd.c206
-rw-r--r--utils/mmap-windows.c100
-rw-r--r--utils/porting.h97
-rw-r--r--utils/readelf.c363
-rw-r--r--utils/readsoname2.c14
12 files changed, 2112 insertions, 648 deletions
diff --git a/utils/.gitignore b/utils/.gitignore
new file mode 100644
index 000000000..7cdfa90c1
--- /dev/null
+++ b/utils/.gitignore
@@ -0,0 +1,12 @@
+getconf
+getconf.host
+iconv
+iconv.host
+ldconfig
+ldconfig.host
+ldd
+ldd.host
+locale
+locale.host
+getconf
+getconf.host
diff --git a/utils/Makefile.in b/utils/Makefile.in
index 611e07efa..6349aa73d 100644
--- a/utils/Makefile.in
+++ b/utils/Makefile.in
@@ -1,45 +1,81 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2009 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-CFLAGS-utils := -DNOT_IN_libc $(SSP_ALL_CFLAGS) -B$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
+subdirs += utils
-CFLAGS-utils-common := -I$(top_srcdir)ldso/include -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" -DUCLIBC_LDSO=$(UCLIBC_LDSO)
-CFLAGS-utils-shared := $(PIEFLAG) $(LDPIEFLAG)
+# "make utils" flags
+
+CFLAGS-utils := \
+ $(SSP_ALL_CFLAGS) \
+ -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) \
+ -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
-CFLAGS-ldconfig := $(CFLAGS-utils-common)
+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-common) $(CFLAGS-utils-shared)
+CFLAGS-ldd := $(CFLAGS-utils-shared) -DBUILDING_LINKAGE
-# needs CFLAGS-utils explicitely, because the source file is not located in utils
-CFLAGS-iconv := $(CFLAGS-utils) $(CFLAGS-utils-shared) -DL_iconv_main
-
-CFLAGS-readelf := $(CFLAGS-utils-shared)
+# 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
CFLAGS-locale := $(CFLAGS-utils)
-
-BUILD_CFLAGS-utils := -include $(top_srcdir)include/elf.h
-
-BUILD_CFLAGS-utils-common := $(CFLAGS-utils-common)
-
-ifeq ($(LDSO_CACHE_SUPPORT),y)
-BUILD_CFLAGS-utils-common += -D__LDSO_CACHE_SUPPORT__=1
-endif
-
-BUILD_CFLAGS-ldconfig.host := $(BUILD_CFLAGS-utils-common)
-
-BUILD_CFLAGS-ldd.host := $(BUILD_CFLAGS-utils-common)
-
-BUILD_LDFLAGS-utils := -Wl,-s
+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)\" \
+ -DARCH_NATIVE_BIT=$(ARCH_NATIVE_BIT) \
+ $(UTILS_CONFIG_FLAGS-y)
+BUILD_CFLAGS-ldconfig.host := \
+ -DBUILDING_LINKAGE \
+ -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) \
+ -I$(top_srcdir)ldso/include
+BUILD_CFLAGS-ldd.host := \
+ -DBUILDING_LINKAGE \
+ -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) \
+ -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
@@ -47,56 +83,60 @@ utils_OUT := $(top_builddir)utils
DEPS-ldconfig := $(utils_DIR)/chroot_realpath.c
DEPS-ldconfig.host := $(DEPS-ldconfig)
-utils_OBJ := readelf
+utils_OBJ := getconf
ifeq ($(HAVE_SHARED),y)
utils_OBJ += ldconfig ldd
endif
-utils_ICONV_OBJ =
-utils_LOCALE_OBJ =
+utils_LOCALE_OBJ :=
ifeq ($(UCLIBC_HAS_LOCALE),y)
-utils_ICONV_OBJ := $(utils_OUT)/iconv
-utils_LOCALE_OBJ := $(utils_OUT)/locale
+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_ICONV_OBJ) $(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)/iconv: $(top_srcdir)libc/misc/wchar/wchar.c | $(libc)
- $(compile.u)
-
$(utils_OUT)/locale: $(top_srcdir)extra/locale/programs/locale.c | $(libc)
$(compile.u)
-hostutils: $(hostutils_OBJ)
+$(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
-utils_install: utils
- $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)usr/bin
- #$(INSTALL) -m 755 $(utils_OUT)/readelf $(PREFIX)$(RUNTIME_PREFIX)usr/bin/readelf
+# 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)
- $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)sbin
- $(INSTALL) -m 755 $(utils_OUT)/ldd $(PREFIX)$(RUNTIME_PREFIX)usr/bin/ldd
- $(INSTALL) -m 755 $(utils_OUT)/ldconfig $(PREFIX)$(RUNTIME_PREFIX)sbin/ldconfig
+ $(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)
- $(INSTALL) -m 755 $(utils_OUT)/iconv $(PREFIX)$(RUNTIME_PREFIX)usr/bin/iconv
- $(INSTALL) -m 755 $(utils_OUT)/locale $(PREFIX)$(RUNTIME_PREFIX)usr/bin/locale
+ $(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 += utils_clean
-utils_clean:
- $(RM) $(utils_OUT)/{ldconfig,ldd,readelf,iconv,locale,*.host}
+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/utils/bswap.h b/utils/bswap.h
index 666b80a73..0047e4e98 100644
--- a/utils/bswap.h
+++ b/utils/bswap.h
@@ -6,40 +6,6 @@
#ifndef _BSWAP_H
#define _BSWAP_H 1
-#if !defined(__BYTE_ORDER) && defined(BYTE_ORDER)
-# define __BYTE_ORDER BYTE_ORDER
-# if !defined(__BIG_ENDIAN) && defined(BIG_ENDIAN)
-# define __BIG_ENDIAN BIG_ENDIAN
-# endif
-# if !defined(__LITTLE_ENDIAN) && defined(LITTLE_ENDIAN)
-# define __LITTLE_ENDIAN LITTLE_ENDIAN
-# endif
-#endif
-
-#ifndef __BYTE_ORDER
-# ifdef __linux__
-# include <endian.h>
-# else
-# define __LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
-# define __BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
-# define __PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */
-
-# if defined(sun386) || defined(i386) || defined(__LITTLE_ENDIAN__)
-# define __BYTE_ORDER __LITTLE_ENDIAN
-# endif
-
-# if defined(sparc) || defined(__BIG_ENDIAN__)
-# define __BYTE_ORDER __BIG_ENDIAN
-# endif
-
-# endif /* __linux__ */
-#endif /* __BYTE_ORDER */
-
-
-#ifndef __BYTE_ORDER
-# error "Undefined __BYTE_ORDER"
-#endif
-
#ifdef __linux__
# include <byteswap.h>
#else
@@ -56,6 +22,24 @@ static __inline__ uint32_t bswap_32(uint32_t x)
(((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/utils/chroot_realpath.c b/utils/chroot_realpath.c
index 0785c6c5b..f17a2184f 100644
--- a/utils/chroot_realpath.c
+++ b/utils/chroot_realpath.c
@@ -1,5 +1,5 @@
/*
- * chroot_realpath.c -- reslove pathname as if inside chroot
+ * 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
@@ -14,37 +14,19 @@
*
* 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.
+ * see <http://www.gnu.org/licenses/>.
*
* 2005/09/12: Dan Howell (modified from realpath.c to emulate chroot)
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <limits.h> /* for PATH_MAX */
-#include <sys/param.h> /* for MAXPATHLEN */
-#include <errno.h>
-#ifndef __set_errno
-#define __set_errno(val) ((errno) = (val))
-#endif
-
-#include <sys/stat.h> /* for S_IFLNK */
-
-#ifndef PATH_MAX
-#define PATH_MAX _POSIX_PATH_MAX
-#endif
+#include "porting.h"
#define MAX_READLINKS 32
-char *chroot_realpath(const char *chroot, const char *path,
+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];
@@ -58,16 +40,16 @@ char *chroot_realpath(const char *chroot, const char *path,
int chroot_len;
/* Trivial case. */
- if (chroot == NULL || *chroot == '\0' ||
- (*chroot == '/' && chroot[1] == '\0')) {
+ if (root == NULL || *root == '\0' ||
+ (*root == '/' && root[1] == '\0')) {
strcpy(resolved_path, path);
return resolved_path;
}
- chroot_len = strlen(chroot);
+ chroot_len = strlen(root);
if (chroot_len + strlen(path) >= PATH_MAX - 3) {
- __set_errno(ENAMETOOLONG);
+ errno = ENAMETOOLONG;
return NULL;
}
@@ -77,7 +59,7 @@ char *chroot_realpath(const char *chroot, const char *path,
max_path = copy_path + PATH_MAX - chroot_len - 3;
/* Start with the chroot path. */
- strcpy(new_path, chroot);
+ strcpy(new_path, root);
new_path += chroot_len;
while (*new_path == '/' && new_path > got_path)
new_path--;
@@ -112,7 +94,7 @@ char *chroot_realpath(const char *chroot, const char *path,
/* Safely copy the next pathname component. */
while (*path != '\0' && *path != '/') {
if (path > max_path) {
- __set_errno(ENAMETOOLONG);
+ errno = ENAMETOOLONG;
return NULL;
}
*new_path++ = *path++;
@@ -123,7 +105,7 @@ char *chroot_realpath(const char *chroot, const char *path,
#ifdef S_IFLNK
/* Protect against infinite loops. */
if (readlinks++ > MAX_READLINKS) {
- __set_errno(ELOOP);
+ errno = ELOOP;
return NULL;
}
/* See if latest pathname component is a symlink. */
@@ -148,7 +130,7 @@ char *chroot_realpath(const char *chroot, const char *path,
while (*(--new_path) != '/') ;
/* Safe sex check. */
if (strlen(path) + n >= PATH_MAX - 2) {
- __set_errno(ENAMETOOLONG);
+ errno = ENAMETOOLONG;
return NULL;
}
/* Insert symlink contents into path. */
diff --git a/utils/getconf.c b/utils/getconf.c
new file mode 100644
index 000000000..3dd3d75d9
--- /dev/null
+++ b/utils/getconf.c
@@ -0,0 +1,1335 @@
+/* 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, see <http://www.gnu.org/licenses/>. */
+
+#define _GNU_SOURCE 1
+#include "porting.h"
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define PACKAGE "getconf regression test"
+#undef VERSION
+#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]);
+
+#ifndef __UCLIBC_HAS___PROGNAME__
+static const char *__progname = "getconf";
+#endif
+
+static attribute_noreturn void
+usage (void)
+{
+ fprintf (stderr,
+ _("Usage: %s [-v specification] variable_name [pathname]\n"),
+ __progname);
+ fprintf (stderr,
+ _(" %s -a [pathname]\n"), __progname);
+ exit (2);
+}
+
+
+static attribute_noreturn 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/utils/iconv.c b/utils/iconv.c
new file mode 100644
index 000000000..48a10155e
--- /dev/null
+++ b/utils/iconv.c
@@ -0,0 +1,271 @@
+
+/* 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, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+/* 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
+ */
+
+/* keep libgen before string.h - and porting.h to use the
+ * XPG version of basename */
+#include <libgen.h>
+#include "porting.h"
+#include <string.h>
+#include <iconv.h>
+#include <stdarg.h>
+#include <wchar.h>
+#include "wchar.c" /* for _UC_iconv_t and __iconv_codesets */
+
+#ifdef L_iconv_main
+static
+#else
+extern
+#endif
+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/utils/ldconfig.c b/utils/ldconfig.c
index 0abd0613e..e6b788118 100644
--- a/utils/ldconfig.c
+++ b/utils/ldconfig.c
@@ -26,21 +26,7 @@
* 2005/09/16: Dan Howell (modified for cross-development)
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <ctype.h>
-#include <getopt.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <link.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include "bswap.h"
-#include "dl-defs.h"
+#include "porting.h"
#define BUFFER_SIZE 4096
@@ -71,22 +57,6 @@ struct exec {
/* Code indicating core file. */
#define CMAGIC 0421
-char *___strtok = NULL;
-
-/* For SunOS */
-#ifndef PATH_MAX
-#include <limits.h>
-#define PATH_MAX _POSIX_PATH_MAX
-#endif
-
-/* For SunOS */
-#ifndef N_MAGIC
-#define N_MAGIC(exec) ((exec).a_magic & 0xffff)
-#endif
-
-#define EXIT_OK 0
-#define EXIT_FATAL 128
-
char *prog = NULL;
int debug = 0; /* debug mode */
int verbose = 0; /* verbose mode */
@@ -124,6 +94,7 @@ struct needed_tab needed_tab[] = {
extern char *chroot_realpath(const char *chroot, const char *path,
char resolved_path[]);
+#if defined __UCLIBC_STATIC_LDCONFIG__ || !defined __UCLIBC_HAS_BSD_ERR__
/* These two are used internally -- you shouldn't need to use them */
static void verror_msg(const char *s, va_list p)
{
@@ -142,7 +113,7 @@ static void warnx(const char *s, ...)
fprintf(stderr, "\n");
}
-static void err(int errnum, const char *s, ...)
+static attribute_noreturn void err(int errnum, const char *s, ...)
{
va_list p;
@@ -155,14 +126,14 @@ static void err(int errnum, const char *s, ...)
static void vperror_msg(const char *s, va_list p)
{
- int err = errno;
+ int e = errno;
if (s == 0)
s = "";
verror_msg(s, p);
if (*s)
s = ": ";
- fprintf(stderr, "%s%s\n", s, strerror(err));
+ fprintf(stderr, "%s%s\n", s, strerror(e));
}
static void warn(const char *s, ...)
@@ -173,12 +144,15 @@ static void warn(const char *s, ...)
vperror_msg(s, p);
va_end(p);
}
+#else
+# include <err.h>
+#endif
static void *xmalloc(size_t size)
{
void *ptr;
if ((ptr = malloc(size)) == NULL)
- err(EXIT_FATAL, "out of memory");
+ err(EXIT_FAILURE, "out of memory");
return ptr;
}
@@ -186,7 +160,7 @@ static char *xstrdup(const char *str)
{
char *ptr;
if ((ptr = strdup(str)) == NULL)
- err(EXIT_FATAL, "out of memory");
+ err(EXIT_FAILURE, "out of memory");
return ptr;
}
@@ -201,8 +175,8 @@ static char *xstrdup(const char *str)
#define readsonameXX readsoname64
#define __ELF_NATIVE_CLASS 64
#include "readsoname2.c"
-char *readsoname(char *name, FILE *infile, int expected_type,
- int *type, int elfclass)
+static char *readsoname(char *name, FILE *infile, int expected_type,
+ int *type, int elfclass)
{
char *res;
@@ -234,8 +208,8 @@ char *readsoname(char *name, FILE *infile, int expected_type,
* If the expected, actual/deduced types missmatch we display a warning
* and use the actual/deduced type.
*/
-char *is_shlib(const char *dir, const char *name, int *type,
- int *islink, int expected_type)
+static char *is_shlib(const char *dir, const char *name, int *type,
+ int *islink, int expected_type)
{
char *good = NULL;
char *cp, *cp2;
@@ -279,15 +253,15 @@ char *is_shlib(const char *dir, const char *name, int *type,
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) {
+ && 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(elf_hdr->e_ident+1, "ELF", 3) != 0)
+ strncmp((const char *)elf_hdr->e_ident + 1, "ELF", 3) != 0)
{
/* silently ignore linker scripts */
- if (strncmp((char *)&exec, "/* GNU ld", 9) != 0)
+ if (strncmp((const char *)&exec, "/* GNU ld", 9) != 0)
warnx("%s is not a shared library, skipping", buff);
} else {
/* always call readsoname to update type */
@@ -309,7 +283,7 @@ char *is_shlib(const char *dir, const char *name, int *type,
/* 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
+ if (debug && (strncmp((const char *)good, name, len) != 0
|| (name[len] != '\0' && name[len] != '.')))
warnx("%s has inconsistent soname (%s)", buff, good);
}
@@ -351,7 +325,7 @@ char *is_shlib(const char *dir, const char *name, int *type,
}
/* update the symlink to new library */
-void link_shlib(const char *dir, const char *file, const char *so)
+static void link_shlib(const char *dir, const char *file, const char *so)
{
int change = 1;
char libname[BUFFER_SIZE];
@@ -408,7 +382,7 @@ void link_shlib(const char *dir, const char *file, const char *so)
}
/* figure out which library is greater */
-int libcmp(char *p1, char *p2)
+static int libcmp(char *p1, char *p2)
{
while (*p1) {
if (isdigit(*p1) && isdigit(*p2)) {
@@ -440,7 +414,7 @@ struct lib {
};
/* update all shared library links in a directory */
-void scan_dir(const char *rawname)
+static void scan_dir(const char *rawname)
{
DIR *dir;
const char *name;
@@ -453,7 +427,7 @@ void scan_dir(const char *rawname)
/* We need a writable copy of this string */
path = strdup(rawname);
if (!path) {
- err(EXIT_FATAL, "Out of memory!\n");
+ err(EXIT_FAILURE, "Out of memory!\n");
}
/* Eliminate all double //s */
path_n = path;
@@ -582,22 +556,22 @@ void cache_write(void)
}
#else
/* return the list of system-specific directories */
-char *get_extpath(void)
+static char *get_extpath(void)
{
char *res = NULL, *cp;
FILE *file;
- struct stat stat;
+ 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), &stat);
- res = xmalloc(stat.st_size + 1);
- fread(res, 1, stat.st_size, file);
+ fstat(fileno(file), &st);
+ res = xmalloc(st.st_size + 1);
+ (void)fread(res, 1, st.st_size, file);
fclose(file);
- res[stat.st_size] = '\0';
+ res[st.st_size] = '\0';
/* convert comments fo spaces */
for (cp = res; *cp; /*nada */ ) {
@@ -679,17 +653,17 @@ void cache_write(void)
return;
if (!chroot_realpath(chroot_dir, cachefile, realcachefile))
- err(EXIT_FATAL, "can't resolve %s in chroot %s (%s)",
+ 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_FATAL, "can't unlink %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't unlink %s~ (%s)", cachefile,
strerror(errno));
if ((cachefd = creat(tempfile, 0644)) < 0)
- err(EXIT_FATAL, "can't create %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't create %s~ (%s)", cachefile,
strerror(errno));
if (byteswap) {
@@ -700,7 +674,7 @@ void cache_write(void)
magic_ptr = &magic;
}
if (write(cachefd, magic_ptr, sizeof(header_t)) != sizeof(header_t))
- err(EXIT_FATAL, "can't write %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't write %s~ (%s)", cachefile,
strerror(errno));
for (cur_lib = lib_head; cur_lib != NULL; cur_lib = cur_lib->next) {
@@ -718,31 +692,31 @@ void cache_write(void)
}
if (write(cachefd, lib_ptr, sizeof(libentry_t)) !=
sizeof(libentry_t))
- err(EXIT_FATAL, "can't write %s~ (%s)", cachefile,
+ 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_FATAL, "can't write %s~ (%s)", cachefile,
+ 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_FATAL, "can't write %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't write %s~ (%s)", cachefile,
strerror(errno));
}
if (close(cachefd))
- err(EXIT_FATAL, "can't close %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't close %s~ (%s)", cachefile,
strerror(errno));
if (chmod(tempfile, 0644))
- err(EXIT_FATAL, "can't chmod %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't chmod %s~ (%s)", cachefile,
strerror(errno));
if (rename(tempfile, realcachefile))
- err(EXIT_FATAL, "can't rename %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't rename %s~ (%s)", cachefile,
strerror(errno));
}
@@ -757,22 +731,22 @@ void cache_print(void)
char realcachefile[BUFFER_SIZE];
if (!chroot_realpath(chroot_dir, cachefile, realcachefile))
- err(EXIT_FATAL, "can't resolve %s in chroot %s (%s)",
+ 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_FATAL, "can't read %s (%s)", cachefile, strerror(errno));
+ 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_FATAL, "can't map %s (%s)", cachefile, strerror(errno));
+ 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_FATAL, "%s cache corrupt", cachefile);
+ err(EXIT_FAILURE, "%s cache corrupt", cachefile);
if (memcmp(((header_t *) c)->version, LDSO_CACHE_VER, LDSO_CACHE_VER_LEN))
- err(EXIT_FATAL, "wrong cache version - expected %s",
+ err(EXIT_FAILURE, "wrong cache version - expected %s",
LDSO_CACHE_VER);
header = (header_t *) c;
@@ -811,7 +785,7 @@ void cache_print(void)
}
#endif
-void usage(void)
+static attribute_noreturn void usage(void)
{
fprintf(stderr,
#ifdef __LDSO_CACHE_SUPPORT__
@@ -844,7 +818,7 @@ void usage(void)
"\tlib ... :\tlibraries to link\n\n"
#endif
);
- exit(EXIT_FATAL);
+ exit(EXIT_FAILURE);
}
#define DIR_SEP ":, \t\n"
@@ -917,11 +891,11 @@ int main(int argc, char **argv)
if (chroot_dir && *chroot_dir) {
if (chroot(chroot_dir) < 0) {
if (chdir(chroot_dir) < 0)
- err(EXIT_FATAL, "couldn't chroot to %s (%s)", chroot_dir, strerror(errno));
+ err(EXIT_FAILURE, "couldn't chroot to %s (%s)", chroot_dir, strerror(errno));
chroot_dir = ".";
} else {
if (chdir("/") < 0)
- err(EXIT_FATAL, "couldn't chdir to / (%s)", strerror(errno));
+ err(EXIT_FAILURE, "couldn't chdir to / (%s)", strerror(errno));
chroot_dir = NULL;
}
}
@@ -933,7 +907,7 @@ int main(int argc, char **argv)
if (printcache) {
/* print the cache -- don't you trust me? */
cache_print();
- exit(EXIT_OK);
+ exit(EXIT_SUCCESS);
} else if (libmode) {
/* so you want to do things manually, eh? */
@@ -953,7 +927,7 @@ int main(int argc, char **argv)
/* we'd better do a little bit of checking */
if ((so = is_shlib(dir, cp, &libtype, &islink, LIB_ANY)) == NULL)
- err(EXIT_FATAL, "%s%s%s is not a shared library",
+ 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 */
@@ -1006,5 +980,5 @@ int main(int argc, char **argv)
cache_write();
}
- exit(EXIT_OK);
+ exit(EXIT_SUCCESS);
}
diff --git a/utils/ldd.c b/utils/ldd.c
index 7818c3713..7fd4f7bb0 100644
--- a/utils/ldd.c
+++ b/utils/ldd.c
@@ -13,31 +13,18 @@
* Licensed under GPLv2 or later
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#include "bswap.h"
-#include "link.h"
-#include "dl-defs.h"
-/* makefile will include elf.h for us */
-
-#ifdef DMALLOC
-#include <dmalloc.h>
-#endif
+#include "porting.h"
#if defined(__alpha__)
#define MATCH_MACHINE(x) (x == EM_ALPHA)
#define ELFCLASSM ELFCLASS64
#endif
+#if defined(__arc__)
+#define MATCH_MACHINE(x) (x == EM_ARCOMPACT)
+#define ELFCLASSM ELFCLASS32
+#endif
+
#if defined(__arm__) || defined(__thumb__)
#define MATCH_MACHINE(x) (x == EM_ARM)
#define ELFCLASSM ELFCLASS32
@@ -81,6 +68,11 @@
#define ELFCLASSM ELFCLASS32
#endif
+#if defined(__metag__)
+#define MATCH_MACHINE(x) (x == EM_METAG)
+#define ELFCLASSM ELFCLASS32
+#endif
+
#if defined(__mips__)
#define MATCH_MACHINE(x) (x == EM_MIPS || x == EM_MIPS_RS3_LE)
#define ELFCLASSM ELFCLASS32
@@ -99,11 +91,6 @@
#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
@@ -119,6 +106,16 @@
#define ELFCLASSM ELFCLASS64
#endif
+#if defined(__microblaze__)
+#define MATCH_MACHINE(x) (x == EM_MICROBLAZE_OLD)
+#define ELFCLASSM ELFCLASS32
+#endif
+
+#if defined(__xtensa__)
+#define MATCH_MACHINE(x) (x == EM_XTENSA)
+#define ELFCLASSM ELFCLASS32
+#endif
+
#ifndef MATCH_MACHINE
# ifdef __linux__
# include <asm/elf.h>
@@ -134,15 +131,13 @@
# warning "You really should add a MATCH_MACHINE() macro for your architecture"
#endif
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if UCLIBC_ENDIAN_HOST == UCLIBC_ENDIAN_LITTLE
#define ELFDATAM ELFDATA2LSB
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#elif UCLIBC_ENDIAN_HOST == UCLIBC_ENDIAN_BIG
#define ELFDATAM ELFDATA2MSB
#endif
-#ifndef UCLIBC_RUNTIME_PREFIX
-# define UCLIBC_RUNTIME_PREFIX "/"
-#endif
+#define TRUSTED_LDSO UCLIBC_RUNTIME_PREFIX "lib/" UCLIBC_LDSO
struct library {
char *name;
@@ -150,16 +145,16 @@ struct library {
char *path;
struct library *next;
};
-struct library *lib_list = NULL;
-char not_found[] = "not found";
-char *interp_name = NULL;
-char *interp_dir = NULL;
+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) {
+ if (byteswap) {
return (bswap_32(value));
} else {
return (value);
@@ -167,17 +162,17 @@ static __inline__ uint32_t byteswap32_to_host(uint32_t value)
}
static __inline__ uint64_t byteswap64_to_host(uint64_t value)
{
- if (byteswap == 1) {
+ if (byteswap) {
return (bswap_64(value));
} else {
return (value);
}
}
-#if ELFCLASSM == ELFCLASS32
-# define byteswap_to_host(x) byteswap32_to_host(x)
-#else
+#if __WORDSIZE == 64
# define byteswap_to_host(x) byteswap64_to_host(x)
+#else
+# define byteswap_to_host(x) byteswap32_to_host(x)
#endif
static ElfW(Shdr) *elf_find_section_type(uint32_t key, ElfW(Ehdr) *ehdr)
@@ -236,33 +231,21 @@ static char *elf_find_rpath(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic)
return NULL;
}
-int check_elf_header(ElfW(Ehdr) *const ehdr)
+static int check_elf_header(ElfW(Ehdr) *const ehdr)
{
- if (!ehdr || strncmp((char *)ehdr, ELFMAG, SELFMAG) != 0 ||
- ehdr->e_ident[EI_CLASS] != ELFCLASSM ||
- ehdr->e_ident[EI_VERSION] != EV_CURRENT)
- {
+ if (!ehdr || *(uint32_t*)ehdr != ELFMAG_U32
+ /* Use __WORDSIZE, not ELFCLASSM which depends on the host */
+ || ehdr->e_ident[EI_CLASS] != (__WORDSIZE >> 5)
+ || ehdr->e_ident[EI_VERSION] != EV_CURRENT
+ ) {
return 1;
}
/* Check if the target endianness matches the host's endianness */
- byteswap = 0;
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- if (ehdr->e_ident[5] == ELFDATA2MSB) {
- /* Ick -- we will have to byte-swap everything */
- byteswap = 1;
- }
-#elif __BYTE_ORDER == __BIG_ENDIAN
- if (ehdr->e_ident[5] == ELFDATA2LSB) {
- /* Ick -- we will have to byte-swap everything */
- byteswap = 1;
- }
-#else
-#error Unknown host byte order!
-#endif
+ byteswap = !(ehdr->e_ident[5] == ELFDATAM);
- /* Be vary lazy, and only byteswap the stuff we use */
- if (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);
@@ -277,7 +260,7 @@ int check_elf_header(ElfW(Ehdr) *const ehdr)
static caddr_t cache_addr = NULL;
static size_t cache_size = 0;
-int map_cache(void)
+static int map_cache(void)
{
int fd;
struct stat st;
@@ -290,7 +273,7 @@ int map_cache(void)
else if (cache_addr != NULL)
return 0;
- if (stat(LDSO_CACHE, &st) || (fd = open(LDSO_CACHE, O_RDONLY, 0)) < 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;
@@ -334,7 +317,7 @@ fail:
return -1;
}
-int unmap_cache(void)
+static int unmap_cache(void)
{
if (cache_addr == NULL || cache_addr == (caddr_t) - 1)
return -1;
@@ -367,7 +350,7 @@ static void search_for_named_library(char *name, char *result,
/* We need a writable copy of this string */
path = strdup(path_list);
if (!path) {
- fprintf(stderr, "Out of memory!\n");
+ fprintf(stderr, "%s: Out of memory!\n", __func__);
exit(EXIT_FAILURE);
}
/* Eliminate all double //s */
@@ -400,8 +383,8 @@ static void search_for_named_library(char *name, char *result,
*result = '\0';
}
-void locate_library_file(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic, int is_suid,
- struct library *lib)
+static void locate_library_file(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic,
+ int is_suid, struct library *lib)
{
char *buf;
char *path;
@@ -416,7 +399,7 @@ void locate_library_file(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic, int is_suid,
/* We need some elbow room here. Make some room... */
buf = malloc(1024);
if (!buf) {
- fprintf(stderr, "Out of memory!\n");
+ fprintf(stderr, "%s: Out of memory!\n", __func__);
exit(EXIT_FAILURE);
}
@@ -519,13 +502,15 @@ static int add_library(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic, int is_setuid, char
for (cur = lib_list; cur; cur = cur->next) {
/* Check if this library is already in the list */
tmp1 = tmp2 = cur->name;
+ if (!cur->name)
+ continue;
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);
+ /*printf("find_elf_interpreter is skipping '%s' (already in list)\n", cur->name); */
return 0;
}
}
@@ -543,7 +528,7 @@ static int add_library(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic, int is_setuid, char
/* 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);
+ /*printf("add_library is adding '%s' to '%s'\n", newlib->name, newlib->path); */
if (!lib_list) {
lib_list = newlib;
} else {
@@ -566,6 +551,7 @@ static void find_needed_libraries(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic, int is_s
}
}
+#ifdef __LDSO_LDD_SUPPORT__
static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr)
{
ElfW(Phdr) *phdr;
@@ -581,7 +567,7 @@ static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr)
interp_name = strdup(s);
interp_dir = strdup(s);
tmp = strrchr(interp_dir, '/');
- if (*tmp)
+ if (tmp)
*tmp = '\0';
else {
free(interp_dir);
@@ -595,8 +581,10 @@ static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr)
}
for (cur = lib_list; cur; cur = cur->next) {
/* Check if this library is already in the list */
+ if (!tmp1 || !cur->name)
+ return NULL;
if (strcmp(cur->name, tmp1) == 0) {
- //printf("find_elf_interpreter is replacing '%s' (already in list)\n", cur->name);
+ /*printf("find_elf_interpreter is replacing '%s' (already in list)\n", cur->name); */
newlib = cur;
free(newlib->name);
if (newlib->path != not_found) {
@@ -604,7 +592,7 @@ static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr)
}
newlib->name = NULL;
newlib->path = NULL;
- return NULL;
+ break;
}
}
if (newlib == NULL)
@@ -618,7 +606,7 @@ static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr)
newlib->next = NULL;
#if 0
- //printf("find_elf_interpreter is adding '%s' to '%s'\n", newlib->name, newlib->path);
+ /*printf("find_elf_interpreter is adding '%s' to '%s'\n", newlib->name, newlib->path); */
if (!lib_list) {
lib_list = newlib;
} else {
@@ -631,20 +619,23 @@ static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr)
}
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"
*/
-int find_dependancies(char *filename)
+static int find_dependencies(char *filename)
{
int is_suid = 0;
FILE *thefile;
- struct library *interp;
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;
@@ -673,7 +664,7 @@ int find_dependancies(char *filename)
ehdr = mmap(0, statbuf.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fileno(thefile), 0);
if (ehdr == MAP_FAILED) {
fclose(thefile);
- fprintf(stderr, "Out of memory!\n");
+ fprintf(stderr, "mmap(%s) failed: %s\n", filename, strerror(errno));
return -1;
}
@@ -701,9 +692,9 @@ foo:
}
interpreter_already_found = 0;
+#ifdef __LDSO_LDD_SUPPORT__
interp = find_elf_interpreter(ehdr);
-#ifdef __LDSO_LDD_SUPPORT__
if (interp
&& (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN)
&& ehdr->e_ident[EI_CLASS] == ELFCLASSM
@@ -711,8 +702,8 @@ foo:
&& ehdr->e_ident[EI_VERSION] == EV_CURRENT
&& MATCH_MACHINE(ehdr->e_machine))
{
- struct stat statbuf;
- if (stat(interp->path, &statbuf) == 0 && S_ISREG(statbuf.st_mode)) {
+ struct stat st;
+ if (stat(interp->path, &st) == 0 && S_ISREG(st.st_mode)) {
pid_t pid;
int status;
static const char *const environment[] = {
@@ -721,16 +712,59 @@ foo:
"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;
}
@@ -759,8 +793,8 @@ int main(int argc, char **argv)
struct library *cur;
if (argc < 2) {
- fprintf(stderr, "ldd: missing file arguments\n");
- fprintf(stderr, "Try `ldd --help' for more information.\n");
+ fprintf(stderr, "ldd: missing file arguments\n"
+ "Try `ldd --help' for more information.\n");
exit(EXIT_FAILURE);
}
if (argc > 2)
@@ -775,8 +809,8 @@ int main(int argc, char **argv)
}
if (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0) {
- fprintf(stderr, "Usage: ldd [OPTION]... FILE...\n");
- fprintf(stderr, "\t--help\t\tprint this help and exit\n");
+ fprintf(stderr, "Usage: ldd [OPTION]... FILE...\n"
+ "\t--help\t\tprint this help and exit\n");
exit(EXIT_SUCCESS);
}
@@ -792,7 +826,7 @@ int main(int argc, char **argv)
map_cache();
- if (find_dependancies(filename) != 0)
+ if (find_dependencies(filename) != 0)
continue;
while (got_em_all) {
@@ -802,7 +836,7 @@ int main(int argc, char **argv)
if (cur->resolved == 0 && cur->path) {
got_em_all = 1;
printf("checking sub-depends for '%s'\n", cur->path);
- find_dependancies(cur->path);
+ find_dependencies(cur->path);
cur->resolved = 1;
}
}
diff --git a/utils/mmap-windows.c b/utils/mmap-windows.c
new file mode 100644
index 000000000..1799392f0
--- /dev/null
+++ b/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/utils/porting.h b/utils/porting.h
new file mode 100644
index 000000000..f83074111
--- /dev/null
+++ b/utils/porting.h
@@ -0,0 +1,97 @@
+/* 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
+
+/* __WORDSIZE ist used for __ELF_NATIVE_CLASS, which is used for ElfW().
+ We want to provide the wordsize of the target, not of the host, when
+ compiling readelf.host
+ */
+#include <link.h>
+#ifdef ARCH_NATIVE_BIT
+#undef __WORDSIZE
+#define __WORDSIZE ARCH_NATIVE_BIT
+#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/utils/readelf.c b/utils/readelf.c
deleted file mode 100644
index 2af4b5ca9..000000000
--- a/utils/readelf.c
+++ /dev/null
@@ -1,363 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * A small little readelf 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 <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include "bswap.h"
-#include "link.h"
-/* makefile will include elf.h for us */
-
-static int byteswap;
-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 __WORDSIZE == 64
-# define byteswap_to_host(x) byteswap64_to_host(x)
-#else
-# define byteswap_to_host(x) byteswap32_to_host(x)
-#endif
-
-static ElfW(Shdr) * elf_find_section_type( uint32_t key, ElfW(Ehdr) *ehdr)
-{
- int j;
- ElfW(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);
- ElfW(Addr) 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 int check_elf_header(ElfW(Ehdr) *const ehdr)
-{
- if (! ehdr || strncmp((void *)ehdr, ELFMAG, SELFMAG) != 0 ||
- (ehdr->e_ident[EI_CLASS] != ELFCLASS32 &&
- ehdr->e_ident[EI_CLASS] != ELFCLASS64) ||
- ehdr->e_ident[EI_VERSION] != EV_CURRENT)
- {
- return 1;
- }
-
- /* Check if the target endianness matches the host's endianness */
- byteswap = 0;
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- if (ehdr->e_ident[5] == ELFDATA2MSB) {
- /* Ick -- we will have to byte-swap everything */
- byteswap = 1;
- }
-#elif __BYTE_ORDER == __BIG_ENDIAN
- if (ehdr->e_ident[5] == ELFDATA2LSB) {
- byteswap = 1;
- }
-#else
-#error Unknown host byte order!
-#endif
- /* Be vary lazy, and only byteswap the stuff we use */
- if (byteswap==1) {
- ehdr->e_type=bswap_16(ehdr->e_type);
- ehdr->e_machine=bswap_16(ehdr->e_machine);
- 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;
-}
-
-
-static void describe_elf_hdr(ElfW(Ehdr)* ehdr)
-{
- char *tmp, *tmp1;
-
- switch (ehdr->e_type) {
- case ET_NONE: tmp = "None"; tmp1 = "NONE"; break;
- case ET_REL: tmp = "Relocatable File"; tmp1 = "REL"; break;
- case ET_EXEC: tmp = "Executable file"; tmp1 = "EXEC"; break;
- case ET_DYN: tmp = "Shared object file"; tmp1 = "DYN"; break;
- case ET_CORE: tmp = "Core file"; tmp1 = "CORE"; break;
- default:
- tmp = tmp1 = "Unknown";
- }
- printf( "Type:\t\t%s (%s)\n", tmp1, tmp);
-
- switch (ehdr->e_machine) {
- case EM_NONE: tmp="No machine"; break;
- case EM_M32: tmp="AT&T WE 32100"; break;
- case EM_SPARC: tmp="SUN SPARC"; break;
- case EM_386: tmp="Intel 80386"; break;
- case EM_68K: tmp="Motorola m68k family"; break;
- case EM_88K: tmp="Motorola m88k family"; break;
- case EM_486: tmp="Intel 80486"; break;
- case EM_860: tmp="Intel 80860"; break;
- case EM_MIPS: tmp="MIPS R3000 big-endian"; break;
- case EM_S370: tmp="IBM System/370"; break;
- case EM_MIPS_RS3_LE: tmp="MIPS R3000 little-endian"; break;
- case EM_OLD_SPARCV9: tmp="Sparc v9 (old)"; break;
- case EM_PARISC: tmp="HPPA"; break;
- /*case EM_PPC_OLD: tmp="Power PC (old)"; break; conflicts with EM_VPP500 */
- case EM_SPARC32PLUS: tmp="Sun's v8plus"; break;
- case EM_960: tmp="Intel 80960"; break;
- case EM_PPC: tmp="PowerPC"; break;
- case EM_PPC64: tmp="PowerPC 64-bit"; break;
- case EM_V800: tmp="NEC V800 series"; break;
- case EM_FR20: tmp="Fujitsu FR20"; break;
- case EM_RH32: tmp="TRW RH-32"; break;
- case EM_MCORE: tmp="MCORE"; break;
- case EM_ARM: tmp="ARM"; break;
- case EM_FAKE_ALPHA: tmp="Digital Alpha"; break;
- case EM_SH: tmp="Renesas SH"; break;
- case EM_SPARCV9: tmp="SPARC v9 64-bit"; break;
- case EM_TRICORE: tmp="Siemens Tricore"; break;
- case EM_ARC: tmp="Argonaut RISC Core"; break;
- case EM_H8_300: tmp="Renesas H8/300"; break;
- case EM_H8_300H: tmp="Renesas H8/300H"; break;
- case EM_H8S: tmp="Renesas H8S"; break;
- case EM_H8_500: tmp="Renesas H8/500"; break;
- case EM_IA_64: tmp="Intel Merced"; break;
- case EM_MIPS_X: tmp="Stanford MIPS-X"; break;
- case EM_COLDFIRE: tmp="Motorola Coldfire"; break;
- case EM_68HC12: tmp="Motorola M68HC12"; break;
- case EM_ALPHA: tmp="Alpha"; break;
- case EM_CYGNUS_D10V:
- case EM_D10V: tmp="Mitsubishi D10V"; break;
- case EM_CYGNUS_D30V:
- case EM_D30V: tmp="Mitsubishi D30V"; break;
- case EM_CYGNUS_M32R:
- case EM_M32R: tmp="Renesas M32R (formerly Mitsubishi M32r)"; break;
- case EM_CYGNUS_V850:
- case EM_V850: tmp="NEC v850"; break;
- case EM_CYGNUS_MN10300:
- case EM_MN10300: tmp="Matsushita MN10300"; break;
- case EM_CYGNUS_MN10200:
- case EM_MN10200: tmp="Matsushita MN10200"; break;
- case EM_CYGNUS_FR30:
- case EM_FR30: tmp="Fujitsu FR30"; break;
- case EM_CYGNUS_FRV:
- case EM_PJ_OLD:
- case EM_PJ: tmp="picoJava"; break;
- case EM_MMA: tmp="Fujitsu MMA Multimedia Accelerator"; break;
- case EM_PCP: tmp="Siemens PCP"; break;
- case EM_NCPU: tmp="Sony nCPU embeeded RISC"; break;
- case EM_NDR1: tmp="Denso NDR1 microprocessor"; break;
- case EM_STARCORE: tmp="Motorola Start*Core processor"; break;
- case EM_ME16: tmp="Toyota ME16 processor"; break;
- case EM_ST100: tmp="STMicroelectronic ST100 processor"; break;
- case EM_TINYJ: tmp="Advanced Logic Corp. Tinyj emb.fam"; break;
- case EM_FX66: tmp="Siemens FX66 microcontroller"; break;
- case EM_ST9PLUS: tmp="STMicroelectronics ST9+ 8/16 mc"; break;
- case EM_ST7: tmp="STmicroelectronics ST7 8 bit mc"; break;
- case EM_68HC16: tmp="Motorola MC68HC16 microcontroller"; break;
- case EM_68HC11: tmp="Motorola MC68HC11 microcontroller"; break;
- case EM_68HC08: tmp="Motorola MC68HC08 microcontroller"; break;
- case EM_68HC05: tmp="Motorola MC68HC05 microcontroller"; break;
- case EM_SVX: tmp="Silicon Graphics SVx"; break;
- case EM_ST19: tmp="STMicroelectronics ST19 8 bit mc"; break;
- case EM_VAX: tmp="Digital VAX"; break;
- case EM_AVR_OLD:
- case EM_AVR: tmp="Atmel AVR 8-bit microcontroller"; break;
- case EM_CRIS: tmp="Axis Communications 32-bit embedded processor"; break;
- case EM_JAVELIN: tmp="Infineon Technologies 32-bit embedded processor"; break;
- case EM_FIREPATH: tmp="Element 14 64-bit DSP Processor"; break;
- case EM_ZSP: tmp="LSI Logic 16-bit DSP Processor"; break;
- case EM_MMIX: tmp="Donald Knuth's educational 64-bit processor"; break;
- case EM_HUANY: tmp="Harvard University machine-independent object files"; break;
- case EM_PRISM: tmp="SiTera Prism"; break;
- case EM_X86_64: tmp="AMD x86-64 architecture"; break;
- case EM_S390_OLD:
- case EM_S390: tmp="IBM S390"; break;
- case EM_XSTORMY16: tmp="Sanyo Xstormy16 CPU core"; break;
- case EM_OPENRISC:
- case EM_OR32: tmp="OpenRISC"; break;
- case EM_CRX: tmp="National Semiconductor CRX microprocessor"; break;
- case EM_DLX: tmp="OpenDLX"; break;
- case EM_IP2K_OLD:
- case EM_IP2K: tmp="Ubicom IP2xxx 8-bit microcontrollers"; break;
- case EM_IQ2000: tmp="Vitesse IQ2000"; break;
- case EM_XTENSA_OLD:
- case EM_XTENSA: tmp="Tensilica Xtensa Processor"; break;
- case EM_M32C: tmp="Renesas M32c"; break;
- case EM_MT: tmp="Morpho Techologies MT processor"; break;
- case EM_BLACKFIN: tmp="Analog Devices Blackfin"; break;
- case EM_NIOS32: tmp="Altera Nios 32"; break;
- case EM_ALTERA_NIOS2: tmp="Altera Nios II"; break;
- case EM_VPP500: tmp="Fujitsu VPP500"; break;
- case EM_PDSP: tmp="Sony DSP Processor"; break;
- default: tmp="unknown";
- }
- printf( "Machine:\t%s\n", tmp);
-
- switch (ehdr->e_ident[EI_CLASS]) {
- case ELFCLASSNONE: tmp = "Invalid class"; break;
- case ELFCLASS32: tmp = "ELF32"; break;
- case ELFCLASS64: tmp = "ELF64"; break;
- default: tmp = "Unknown";
- }
- printf( "Class:\t\t%s\n", tmp);
-
- switch (ehdr->e_ident[EI_DATA]) {
- case ELFDATANONE: tmp = "Invalid data encoding"; break;
- case ELFDATA2LSB: tmp = "2's complement, little endian"; break;
- case ELFDATA2MSB: tmp = "2's complement, big endian"; break;
- default: tmp = "Unknown";
- }
- printf( "Data:\t\t%s\n", tmp);
-
- printf( "Version:\t%d %s\n", ehdr->e_ident[EI_VERSION],
- (ehdr->e_ident[EI_VERSION]==EV_CURRENT)?
- "(current)" : "(unknown: %lx)");
-
- switch (ehdr->e_ident[EI_OSABI]) {
- case ELFOSABI_SYSV: tmp ="UNIX - System V"; break;
- case ELFOSABI_HPUX: tmp ="UNIX - HP-UX"; break;
- case ELFOSABI_NETBSD: tmp ="UNIX - NetBSD"; break;
- case ELFOSABI_LINUX: tmp ="UNIX - Linux"; break;
- case ELFOSABI_HURD: tmp ="GNU/Hurd"; break;
- case ELFOSABI_SOLARIS: tmp ="UNIX - Solaris"; break;
- case ELFOSABI_AIX: tmp ="UNIX - AIX"; break;
- case ELFOSABI_IRIX: tmp ="UNIX - IRIX"; break;
- case ELFOSABI_FREEBSD: tmp ="UNIX - FreeBSD"; break;
- case ELFOSABI_TRU64: tmp ="UNIX - TRU64"; break;
- case ELFOSABI_MODESTO: tmp ="Novell - Modesto"; break;
- case ELFOSABI_OPENBSD: tmp ="UNIX - OpenBSD"; break;
- case ELFOSABI_STANDALONE: tmp ="Standalone App"; break;
- case ELFOSABI_ARM: tmp ="ARM"; break;
- default: tmp = "Unknown";
- }
- printf( "OS/ABI:\t\t%s\n", tmp);
-
- printf( "ABI Version:\t%d\n", ehdr->e_ident[EI_ABIVERSION]);
-}
-
-static void list_needed_libraries(ElfW(Dyn)* dynamic, char *strtab)
-{
- ElfW(Dyn) *dyns;
-
- printf("Dependancies:\n");
- for (dyns=dynamic; byteswap_to_host(dyns->d_tag)!=DT_NULL; ++dyns) {
- if (dyns->d_tag == DT_NEEDED) {
- printf("\t%s\n", (char*)strtab + byteswap_to_host(dyns->d_un.d_val));
- }
- }
-}
-
-static void describe_elf_interpreter(ElfW(Ehdr)* ehdr)
-{
- ElfW(Phdr) *phdr;
- phdr = elf_find_phdr_type(PT_INTERP, ehdr);
- if (phdr) {
- printf("Interpreter:\t%s\n", (char*)ehdr + byteswap_to_host(phdr->p_offset));
- }
-}
-
-int main( int argc, char** argv)
-{
- /* map the .so, and locate interesting pieces */
- char *dynstr;
- char *thefilename = argv[1];
- FILE *thefile;
- struct stat statbuf;
- ElfW(Ehdr) *ehdr = 0;
- ElfW(Shdr) *dynsec;
- ElfW(Dyn) *dynamic;
-
- if (argc < 2 || !thefilename) {
- fprintf(stderr, "No filename specified.\n");
- exit(EXIT_FAILURE);
- }
- if (!(thefile = fopen(thefilename, "r"))) {
- perror(thefilename);
- exit(EXIT_FAILURE);
- }
- if (fstat(fileno(thefile), &statbuf) < 0) {
- perror(thefilename);
- exit(EXIT_FAILURE);
- }
-
- if ((size_t)statbuf.st_size < sizeof(ElfW(Ehdr)))
- goto foo;
-
- /* mmap the file to make reading stuff from it effortless */
- ehdr = (ElfW(Ehdr) *)mmap(0, statbuf.st_size,
- PROT_READ|PROT_WRITE, MAP_PRIVATE, fileno(thefile), 0);
-
-foo:
- /* Check if this looks legit */
- if (check_elf_header(ehdr)) {
- fprintf(stderr, "This does not appear to be an ELF file.\n");
- exit(EXIT_FAILURE);
- }
- describe_elf_hdr(ehdr);
- describe_elf_interpreter(ehdr);
-
- dynsec = elf_find_section_type(SHT_DYNAMIC, ehdr);
- if (dynsec) {
- dynamic = (ElfW(Dyn)*)(byteswap_to_host(dynsec->sh_offset) + (char *)ehdr);
- dynstr = (char *)elf_find_dynamic(DT_STRTAB, dynamic, ehdr, 0);
- list_needed_libraries(dynamic, dynstr);
- }
-
- return 0;
-}
diff --git a/utils/readsoname2.c b/utils/readsoname2.c
index 6a9f00775..5cda3318d 100644
--- a/utils/readsoname2.c
+++ b/utils/readsoname2.c
@@ -1,4 +1,4 @@
-char *readsonameXX(char *name, FILE *infile, int expected_type, int *type)
+static char *readsonameXX(char *name, FILE *infile, int expected_type, int *type)
{
ElfW(Ehdr) *epnt;
ElfW(Phdr) *ppnt;
@@ -35,13 +35,11 @@ char *readsonameXX(char *name, FILE *infile, int expected_type, int *type)
if ((char *)(epnt + 1) > (char *)(header + st.st_size))
goto skip;
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- byteswap = (epnt->e_ident[5] == ELFDATA2MSB) ? 1 : 0;
-#elif __BYTE_ORDER == __BIG_ENDIAN
- byteswap = (epnt->e_ident[5] == ELFDATA2LSB) ? 1 : 0;
-#else
-#error Unknown host byte order!
-#endif
+ 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);