Cherrypick from master 2006-03-07 20:46:09 UTC Paweł Sikora <pluto@pld-linux.org> '- klibc fix.':
glibc-ctype-compat.patch -> 1.1
glibc-sparc-mman.h.patch -> 1.1
glibc-sparc64-dl-machine.patch -> 1.2
postshell.c -> 1.6
Cherrypick from master 2008-11-24 16:38:25 UTC Jakub Bogusz <qboosh@pld-linux.org> '- added try-restart, fixed force-reload':
glibc-localedb-gen -> 1.6
nscd.init -> 1.16
Cherrypick from master 2009-06-08 20:30:00 UTC Elan Ruusamäe <glen@pld-linux.org> '- no bash for ldd':
glibc-posix-sh.patch -> 1.1
--- /dev/null
+glibc 2.3.x changes some symbols (__ctype_b, __ctype_toupper,
+__ctype_tolower) as hidden attribute. These symbols that are
+crashing the old 2.2.x dynamic linking code in static binaries
+are now exported. This patch is originally pulled from RedHat.
+
+--- glibc/ctype/ctype-info.c 28 Sep 2002 20:36:35 -0000 1.1.1.9
++++ glibc/ctype/ctype-info.c 29 Sep 2002 11:38:50 -0000 1.4
+@@ -48,18 +48,32 @@ extern const char _nl_C_LC_CTYPE_class_a
+
+ #define b(t,x,o) (((const t *) _nl_C_LC_CTYPE_##x) + o)
+
++// const unsigned short int *__ctype_b = b (unsigned short int, class, 128);
++// const __uint32_t *__ctype32_b = b (__uint32_t, class32, 0);
++// const __int32_t *__ctype_tolower = b (__int32_t, tolower, 128);
++// const __int32_t *__ctype_toupper = b (__int32_t, toupper, 128);
++// const __uint32_t *__ctype32_tolower = b (__uint32_t, tolower, 128);
++// const __uint32_t *__ctype32_toupper = b (__uint32_t, toupper, 128);
++
++// compat_symbol (libc, __ctype_b, __ctype_b, GLIBC_2_0);
++// compat_symbol (libc, __ctype_tolower, __ctype_tolower, GLIBC_2_0);
++// compat_symbol (libc, __ctype_toupper, __ctype_toupper, GLIBC_2_0);
++// compat_symbol (libc, __ctype32_b, __ctype32_b, GLIBC_2_0);
++// compat_symbol (libc, __ctype32_tolower, __ctype32_tolower, GLIBC_2_2);
++// compat_symbol (libc, __ctype32_toupper, __ctype32_toupper, GLIBC_2_2);
++
++#endif
++
++/* Temporarily exported until all .a libraries are recompiled. */
++#undef b
++#define b(t,x,o) (((const t *) _nl_C_LC_CTYPE_##x) + o)
++extern const char _nl_C_LC_CTYPE_class[] attribute_hidden;
++extern const char _nl_C_LC_CTYPE_class32[] attribute_hidden;
++extern const char _nl_C_LC_CTYPE_toupper[] attribute_hidden;
++extern const char _nl_C_LC_CTYPE_tolower[] attribute_hidden;
+ const unsigned short int *__ctype_b = b (unsigned short int, class, 128);
+ const __uint32_t *__ctype32_b = b (__uint32_t, class32, 0);
+ const __int32_t *__ctype_tolower = b (__int32_t, tolower, 128);
+ const __int32_t *__ctype_toupper = b (__int32_t, toupper, 128);
+ const __uint32_t *__ctype32_tolower = b (__uint32_t, tolower, 128);
+ const __uint32_t *__ctype32_toupper = b (__uint32_t, toupper, 128);
+-
+-compat_symbol (libc, __ctype_b, __ctype_b, GLIBC_2_0);
+-compat_symbol (libc, __ctype_tolower, __ctype_tolower, GLIBC_2_0);
+-compat_symbol (libc, __ctype_toupper, __ctype_toupper, GLIBC_2_0);
+-compat_symbol (libc, __ctype32_b, __ctype32_b, GLIBC_2_0);
+-compat_symbol (libc, __ctype32_tolower, __ctype32_tolower, GLIBC_2_2);
+-compat_symbol (libc, __ctype32_toupper, __ctype32_toupper, GLIBC_2_2);
+-
+-#endif
+--- glibc-2.3.1-cygnus/locale/lc-ctype.c 28 Sep 2002 20:37:14 -0000 1.1.1.8
++++ glibc-2.3.1-redhat/locale/lc-ctype.c 29 Sep 2002 11:38:51 -0000 1.5
+@@ -75,18 +75,32 @@ _nl_postload_ctype (void)
+ We need those relocations so that a versioned definition with a COPY
+ reloc in an executable will override the libc.so definition. */
+
+-compat_symbol (libc, __ctype_b, __ctype_b, GLIBC_2_0);
+-compat_symbol (libc, __ctype_tolower, __ctype_tolower, GLIBC_2_0);
+-compat_symbol (libc, __ctype_toupper, __ctype_toupper, GLIBC_2_0);
+-compat_symbol (libc, __ctype32_b, __ctype32_b, GLIBC_2_0);
+-compat_symbol (libc, __ctype32_tolower, __ctype32_tolower, GLIBC_2_2);
+-compat_symbol (libc, __ctype32_toupper, __ctype32_toupper, GLIBC_2_2);
++// compat_symbol (libc, __ctype_b, __ctype_b, GLIBC_2_0);
++// compat_symbol (libc, __ctype_tolower, __ctype_tolower, GLIBC_2_0);
++// compat_symbol (libc, __ctype_toupper, __ctype_toupper, GLIBC_2_0);
++// compat_symbol (libc, __ctype32_b, __ctype32_b, GLIBC_2_0);
++// compat_symbol (libc, __ctype32_tolower, __ctype32_tolower, GLIBC_2_2);
++// compat_symbol (libc, __ctype32_toupper, __ctype32_toupper, GLIBC_2_2);
+
++// __ctype_b = current (uint16_t, CLASS, 128);
++// __ctype_toupper = current (uint32_t, TOUPPER, 128);
++// __ctype_tolower = current (uint32_t, TOLOWER, 128);
++// __ctype32_b = current (uint32_t, CLASS32, 0);
++// __ctype32_toupper = current (uint32_t, TOUPPER32, 0);
++// __ctype32_tolower = current (uint32_t, TOLOWER32, 0);
++#endif
++
++ /* Temporary. */
++ extern __const unsigned short int *__ctype_b; /* Characteristics. */
++ extern __const __int32_t *__ctype_tolower; /* Case conversions. */
++ extern __const __int32_t *__ctype_toupper; /* Case conversions. */
++ extern const uint32_t *__ctype32_b;
++ extern const uint32_t *__ctype32_toupper;
++ extern const uint32_t *__ctype32_tolower;
+ __ctype_b = current (uint16_t, CLASS, 128);
+ __ctype_toupper = current (uint32_t, TOUPPER, 128);
+ __ctype_tolower = current (uint32_t, TOLOWER, 128);
+ __ctype32_b = current (uint32_t, CLASS32, 0);
+ __ctype32_toupper = current (uint32_t, TOUPPER32, 0);
+ __ctype32_tolower = current (uint32_t, TOLOWER32, 0);
+-#endif
+ }
--- /dev/null
+#!/bin/sh
+
+SUPPORTED_LOCALES=x
+OLD_STYLE="no"
+DESTDIR=
+
+[ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
+[ -f /etc/sysconfig/localedb ] && . /etc/sysconfig/localedb
+
+LOCDIR=@localedir@
+ARCHIVE=${LOCDIR}/locale-archive
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ -l=* | --locales=*)
+ SUPPORTED_LOCALES="`echo $1 | sed -e 's/^[^=]*=//'`"
+ ;;
+ -l | --locales)
+ SUPPORTED_LOCALES="$2"
+ shift
+ ;;
+ -o | --old-style)
+ OLD_STYLE="yes"
+ ;;
+ -d=* | --destdir=*)
+ DESTDIR="`echo $1 | sed -e 's/^[^]]*=//'`"
+ ;;
+ -d | --destdir)
+ DESTDIR="$2"
+ shift
+ ;;
+ -h | --help | --usage)
+ cat <<EOF
+Usage: localedb-gen [-l|--locales <locales>] [-o|--old-style]
+ [-d|--destdir <DESTDIR>]
+ localedb-gen [-h|--help|--usage]
+EOF
+ exit
+ ;;
+ *)
+ echo "Unrecognized option: $1"
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+if [ "${SUPPORTED_LOCALES}" = "x" ]; then
+ echo "SUPPORTED_LOCALES not set"
+ echo "You can set it in /etc/sysconfig/i18n file"
+ exit 1
+fi
+
+if [ "${DESTDIR}" = "" ] && rpm -qf ${ARCHIVE} >/dev/null 2>&1 ; then
+ echo "${ARCHIVE} belongs to `rpm -qf ${ARCHIVE}` package - uninstall it first!"
+ exit 1
+fi
+
+rm -rf ${DESTDIR}${LOCDIR}
+install -d ${DESTDIR}${LOCDIR}
+cd ${DESTDIR}${LOCDIR}
+
+if [ "${DESTDIR}" = "" ]; then
+ DESTDIROPT=
+else
+ DESTDIROPT="--prefix ${DESTDIR}"
+fi
+
+for loc in ${SUPPORTED_LOCALES} ; do
+ if echo ${loc} | grep -q / ; then
+ chset="`echo ${loc} | sed -e 's@^.*/@@'`"
+ loc="`echo ${loc} | sed -e 's@/.*$@@'`"
+ elif echo ${loc} | grep -q '\.' ; then
+ chset="`echo ${loc} | sed -e 's@^.*\.@@'`"
+ elif grep -qs "^${loc}/[^ ]* .*$" /usr/share/i18n/SUPPORTED ; then
+ chset="`grep \"^${loc}/.* .*$\" /usr/share/i18n/SUPPORTED | sed -e 's@^.*/\([^ ]*\) .*$@\1@'`"
+ else
+ echo "Charset not known for locale ${loc} - skipping..."
+ continue
+ fi
+ iloc="`echo ${loc} | sed -e 's/\.[^@]*//'`"
+ echo -n "Generating ${loc} using charset ${chset}... "
+ if [ "${OLD_STYLE}" = "yes" ]; then
+ localedef -f ${chset} -i ${iloc} ${DESTDIR}${LOCDIR}${loc}
+ else
+ localedef -f ${chset} -i ${iloc} ${loc} ${DESTDIROPT}
+ fi
+ echo
+done
+
+echo "DONE."
--- /dev/null
+--- glibc-2.10.1/elf/ldd.bash.in 2009-06-08 23:02:27.663745478 +0300
++++ glibc-2.10.1/elf/ldd.bash.in 2009-06-08 23:04:15.706861781 +0300
+@@ -1,4 +1,4 @@
+-#! @BASH@
++#! /bin/sh
+ # Copyright (C) 1996-2008, 2009 Free Software Foundation, Inc.
+ # This file is part of the GNU C Library.
+
+@@ -36,16 +36,16 @@
+ case "$1" in
+ --vers | --versi | --versio | --version)
+ echo 'ldd (GNU libc) @VERSION@'
+- printf $"Copyright (C) %s Free Software Foundation, Inc.
++ printf "Copyright (C) %s Free Software Foundation, Inc.
+ This is free software; see the source for copying conditions. There is NO
+ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ " "2009"
+- printf $"Written by %s and %s.
++ printf "Written by %s and %s.
+ " "Roland McGrath" "Ulrich Drepper"
+ exit 0
+ ;;
+ --h | --he | --hel | --help)
+- echo $"Usage: ldd [OPTION]... FILE...
++ echo "Usage: ldd [OPTION]... FILE...
+ --help print this help and exit
+ --version print version information and exit
+ -d, --data-relocs process data relocations
+@@ -53,7 +53,7 @@
+ -u, --unused print unused direct dependencies
+ -v, --verbose print all information
+ "
+- echo $"For bug reporting instructions, please see:
++ echo "For bug reporting instructions, please see:
+ <http://www.gnu.org/software/libc/bugs.html>.
+ "
+ exit 0
+@@ -79,15 +79,15 @@
+ shift
+ ;;
+ --v | --ve | --ver)
+- echo >&2 $"ldd: option \`$1' is ambiguous"
++ echo >&2 "ldd: option \`$1' is ambiguous"
+ exit 1
+ ;;
+ --) # Stop option processing.
+ shift; break
+ ;;
+ -*)
+- echo >&2 'ldd:' $"unrecognized option" "\`$1'"
+- echo >&2 $"Try \`ldd --help' for more information."
++ echo >&2 'ldd:' "unrecognized option" "\`$1'"
++ echo >&2 "Try \`ldd --help' for more information."
+ exit 1
+ ;;
+ *)
+@@ -112,20 +112,14 @@
+ # environments where the executed program might not have permissions
+ # to write to the console/tty. But only bash 3.x supports the pipefail
+ # option, and we don't bother to handle the case for older bash versions.
+-if set -o pipefail 2> /dev/null; then
+- try_trace() {
+- eval $add_env '"$@"' | cat
+- }
+-else
+- try_trace() {
+- eval $add_env '"$@"'
+- }
+-fi
++try_trace() {
++ eval $add_env '"$@"'
++}
+
+ case $# in
+ 0)
+- echo >&2 'ldd:' $"missing file arguments"
+- echo >&2 $"Try \`ldd --help' for more information."
++ echo >&2 'ldd:' "missing file arguments"
++ echo >&2 "Try \`ldd --help' for more information."
+ exit 1
+ ;;
+ 1)
+@@ -147,13 +141,13 @@
+ ;;
+ esac
+ if test ! -e "$file"; then
+- echo "ldd: ${file}:" $"No such file or directory" >&2
++ echo "ldd: ${file}:" "No such file or directory" >&2
+ result=1
+ elif test ! -f "$file"; then
+- echo "ldd: ${file}:" $"not regular file" >&2
++ echo "ldd: ${file}:" "not regular file" >&2
+ result=1
+ elif test -r "$file"; then
+- test -x "$file" || echo 'ldd:' $"\
++ test -x "$file" || echo 'ldd:' "\
+ warning: you do not have execution permission for" "\`$file'" >&2
+ RTLD=
+ ret=1
+@@ -182,7 +176,7 @@
+ 1)
+ # This can be a non-ELF binary or no binary at all.
+ nonelf "$file" || {
+- echo $" not a dynamic executable"
++ echo " not a dynamic executable"
+ result=1
+ }
+ ;;
+@@ -190,12 +184,12 @@
+ try_trace "$RTLD" "$file" || result=1
+ ;;
+ *)
+- echo 'ldd:' ${RTLD} $"exited with unknown exit code" "($ret)" >&2
++ echo 'ldd:' ${RTLD} "exited with unknown exit code" "($ret)" >&2
+ exit 1
+ ;;
+ esac
+ else
+- echo 'ldd:' $"error: you do not have read permission for" "\`$file'" >&2
++ echo 'ldd:' "error: you do not have read permission for" "\`$file'" >&2
+ result=1
+ fi
+ done
--- /dev/null
+ 2005-03-10 GOTO Masanori <gotom@debian.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/bits/mman.h: Define MAP_POPULATE and
+ MAP_NONBLOCK.
+ * sysdeps/unix/sysv/linux/sparc/bits/mman.h: Likewise.
+ Correct MAP_GROWSDOWN value.
+
+===================================================================
+RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/sh/bits/mman.h,v
+retrieving revision 1.3
+retrieving revision 1.4
+diff -u -r1.3 -r1.4
+--- libc/sysdeps/unix/sysv/linux/sh/bits/mman.h 2003/09/25 16:39:37 1.3
++++ libc/sysdeps/unix/sysv/linux/sh/bits/mman.h 2005/03/13 09:35:02 1.4
+@@ -1,5 +1,5 @@
+ /* Definitions for POSIX memory map interface. Linux/SH version.
+- Copyright (C) 1997, 1999, 2000, 2003 Free Software Foundation, Inc.
++ Copyright (C) 1997, 1999, 2000, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+@@ -61,6 +61,8 @@
+ # define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
+ # define MAP_LOCKED 0x2000 /* Lock the mapping. */
+ # define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
++# define MAP_POPULATE 0x8000 /* Populate (prefault) pagetables. */
++# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
+ #endif
+
+ /* Flags to `msync'. */
+===================================================================
+RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/sparc/bits/mman.h,v
+retrieving revision 1.7
+retrieving revision 1.8
+diff -u -r1.7 -r1.8
+--- libc/sysdeps/unix/sysv/linux/sparc/bits/mman.h 2003/09/25 16:39:37 1.7
++++ libc/sysdeps/unix/sysv/linux/sparc/bits/mman.h 2005/03/13 09:35:03 1.8
+@@ -1,5 +1,5 @@
+ /* Definitions for POSIX memory map interface. Linux/SPARC version.
+- Copyright (C) 1997, 1999, 2000, 2003 Free Software Foundation, Inc.
++ Copyright (C) 1997, 1999, 2000, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+@@ -57,12 +57,14 @@
+
+ /* These are Linux-specific. */
+ #ifdef __USE_MISC
+-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
++# define MAP_GROWSDOWN 0x0200 /* Stack-like segment. */
+ # define MAP_DENYWRITE 0x0800 /* ETXTBSY */
+ # define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
+ # define MAP_LOCKED 0x0100 /* Lock the mapping. */
+ # define MAP_NORESERVE 0x0040 /* Don't check for reservations. */
+ # define _MAP_NEW 0x80000000 /* Binary compatibility with SunOS. */
++# define MAP_POPULATE 0x8000 /* Populate (prefault) pagetables. */
++# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
+ #endif
+
+ /* Flags to `msync'. */
--- /dev/null
+--- glibc-2.3.6/sysdeps/sparc/sparc64/dl-machine.h.orig 2005-12-27 01:19:34.023832576 +0100
++++ glibc-2.3.6/sysdeps/sparc/sparc64/dl-machine.h 2005-12-27 01:19:26.440985344 +0100
+@@ -18,6 +18,9 @@
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
++#ifndef dl_machine_h
++#define dl_machine_h
++
+ #define ELF_MACHINE_NAME "sparc64"
+
+ #include <string.h>
+@@ -233,232 +236,6 @@
+ return value;
+ }
+
+-#ifdef RESOLVE
+-
+-/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
+- MAP is the object containing the reloc. */
+-
+-auto inline void
+-__attribute__ ((always_inline))
+-elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
+- const Elf64_Sym *sym, const struct r_found_version *version,
+- void *const reloc_addr_arg)
+-{
+- Elf64_Addr *const reloc_addr = reloc_addr_arg;
+- const unsigned long int r_type = ELF64_R_TYPE_ID (reloc->r_info);
+-
+-#if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC
+- if (__builtin_expect (r_type == R_SPARC_RELATIVE, 0))
+- *reloc_addr = map->l_addr + reloc->r_addend;
+-# ifndef RTLD_BOOTSTRAP
+- else if (r_type == R_SPARC_NONE) /* Who is Wilbur? */
+- return;
+-# endif
+- else
+-#endif
+- {
+-#if !defined RTLD_BOOTSTRAP && !defined RESOLVE_CONFLICT_FIND_MAP
+- const Elf64_Sym *const refsym = sym;
+-#endif
+- Elf64_Addr value;
+-#ifndef RESOLVE_CONFLICT_FIND_MAP
+- if (sym->st_shndx != SHN_UNDEF &&
+- ELF64_ST_BIND (sym->st_info) == STB_LOCAL)
+- value = map->l_addr;
+- else
+- {
+- value = RESOLVE (&sym, version, r_type);
+- if (sym)
+- value += sym->st_value;
+- }
+-#else
+- value = 0;
+-#endif
+- value += reloc->r_addend; /* Assume copy relocs have zero addend. */
+-
+- switch (r_type)
+- {
+-#if !defined RTLD_BOOTSTRAP && !defined RESOLVE_CONFLICT_FIND_MAP
+- case R_SPARC_COPY:
+- if (sym == NULL)
+- /* This can happen in trace mode if an object could not be
+- found. */
+- break;
+- if (sym->st_size > refsym->st_size
+- || (GLRO(dl_verbose) && sym->st_size < refsym->st_size))
+- {
+- const char *strtab;
+-
+- strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
+- _dl_error_printf ("\
+-%s: Symbol `%s' has different size in shared object, consider re-linking\n",
+- rtld_progname ?: "<program name unknown>",
+- strtab + refsym->st_name);
+- }
+- memcpy (reloc_addr_arg, (void *) value,
+- MIN (sym->st_size, refsym->st_size));
+- break;
+-#endif
+- case R_SPARC_64:
+- case R_SPARC_GLOB_DAT:
+- *reloc_addr = value;
+- break;
+-#ifndef RTLD_BOOTSTRAP
+- case R_SPARC_8:
+- *(char *) reloc_addr = value;
+- break;
+- case R_SPARC_16:
+- *(short *) reloc_addr = value;
+- break;
+- case R_SPARC_32:
+- *(unsigned int *) reloc_addr = value;
+- break;
+- case R_SPARC_DISP8:
+- *(char *) reloc_addr = (value - (Elf64_Addr) reloc_addr);
+- break;
+- case R_SPARC_DISP16:
+- *(short *) reloc_addr = (value - (Elf64_Addr) reloc_addr);
+- break;
+- case R_SPARC_DISP32:
+- *(unsigned int *) reloc_addr = (value - (Elf64_Addr) reloc_addr);
+- break;
+- case R_SPARC_WDISP30:
+- *(unsigned int *) reloc_addr =
+- ((*(unsigned int *)reloc_addr & 0xc0000000) |
+- ((value - (Elf64_Addr) reloc_addr) >> 2));
+- break;
+-
+- /* MEDLOW code model relocs */
+- case R_SPARC_LO10:
+- *(unsigned int *) reloc_addr =
+- ((*(unsigned int *)reloc_addr & ~0x3ff) |
+- (value & 0x3ff));
+- break;
+- case R_SPARC_HI22:
+- *(unsigned int *) reloc_addr =
+- ((*(unsigned int *)reloc_addr & 0xffc00000) |
+- (value >> 10));
+- break;
+- case R_SPARC_OLO10:
+- *(unsigned int *) reloc_addr =
+- ((*(unsigned int *)reloc_addr & ~0x1fff) |
+- (((value & 0x3ff) + ELF64_R_TYPE_DATA (reloc->r_info)) & 0x1fff));
+- break;
+-
+- /* MEDMID code model relocs */
+- case R_SPARC_H44:
+- *(unsigned int *) reloc_addr =
+- ((*(unsigned int *)reloc_addr & 0xffc00000) |
+- (value >> 22));
+- break;
+- case R_SPARC_M44:
+- *(unsigned int *) reloc_addr =
+- ((*(unsigned int *)reloc_addr & ~0x3ff) |
+- ((value >> 12) & 0x3ff));
+- break;
+- case R_SPARC_L44:
+- *(unsigned int *) reloc_addr =
+- ((*(unsigned int *)reloc_addr & ~0xfff) |
+- (value & 0xfff));
+- break;
+-
+- /* MEDANY code model relocs */
+- case R_SPARC_HH22:
+- *(unsigned int *) reloc_addr =
+- ((*(unsigned int *)reloc_addr & 0xffc00000) |
+- (value >> 42));
+- break;
+- case R_SPARC_HM10:
+- *(unsigned int *) reloc_addr =
+- ((*(unsigned int *)reloc_addr & ~0x3ff) |
+- ((value >> 32) & 0x3ff));
+- break;
+- case R_SPARC_LM22:
+- *(unsigned int *) reloc_addr =
+- ((*(unsigned int *)reloc_addr & 0xffc00000) |
+- ((value >> 10) & 0x003fffff));
+- break;
+-#endif
+- case R_SPARC_JMP_SLOT:
+-#ifdef RESOLVE_CONFLICT_FIND_MAP
+- /* R_SPARC_JMP_SLOT conflicts against .plt[32768+]
+- relocs should be turned into R_SPARC_64 relocs
+- in .gnu.conflict section.
+- r_addend non-zero does not mean it is a .plt[32768+]
+- reloc, instead it is the actual address of the function
+- to call. */
+- sparc64_fixup_plt (NULL, reloc, reloc_addr, value, 0, 0);
+-#else
+- sparc64_fixup_plt (map, reloc, reloc_addr, value,
+- reloc->r_addend, 0);
+-#endif
+- break;
+-#ifndef RTLD_BOOTSTRAP
+- case R_SPARC_UA16:
+- ((unsigned char *) reloc_addr_arg) [0] = value >> 8;
+- ((unsigned char *) reloc_addr_arg) [1] = value;
+- break;
+- case R_SPARC_UA32:
+- ((unsigned char *) reloc_addr_arg) [0] = value >> 24;
+- ((unsigned char *) reloc_addr_arg) [1] = value >> 16;
+- ((unsigned char *) reloc_addr_arg) [2] = value >> 8;
+- ((unsigned char *) reloc_addr_arg) [3] = value;
+- break;
+- case R_SPARC_UA64:
+- if (! ((long) reloc_addr_arg & 3))
+- {
+- /* Common in .eh_frame */
+- ((unsigned int *) reloc_addr_arg) [0] = value >> 32;
+- ((unsigned int *) reloc_addr_arg) [1] = value;
+- break;
+- }
+- ((unsigned char *) reloc_addr_arg) [0] = value >> 56;
+- ((unsigned char *) reloc_addr_arg) [1] = value >> 48;
+- ((unsigned char *) reloc_addr_arg) [2] = value >> 40;
+- ((unsigned char *) reloc_addr_arg) [3] = value >> 32;
+- ((unsigned char *) reloc_addr_arg) [4] = value >> 24;
+- ((unsigned char *) reloc_addr_arg) [5] = value >> 16;
+- ((unsigned char *) reloc_addr_arg) [6] = value >> 8;
+- ((unsigned char *) reloc_addr_arg) [7] = value;
+- break;
+-#endif
+-#if !defined RTLD_BOOTSTRAP || defined _NDEBUG
+- default:
+- _dl_reloc_bad_type (map, r_type, 0);
+- break;
+-#endif
+- }
+- }
+-}
+-
+-auto inline void
+-__attribute__ ((always_inline))
+-elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
+- void *const reloc_addr_arg)
+-{
+- Elf64_Addr *const reloc_addr = reloc_addr_arg;
+- *reloc_addr = l_addr + reloc->r_addend;
+-}
+-
+-auto inline void
+-__attribute__ ((always_inline))
+-elf_machine_lazy_rel (struct link_map *map,
+- Elf64_Addr l_addr, const Elf64_Rela *reloc)
+-{
+- switch (ELF64_R_TYPE (reloc->r_info))
+- {
+- case R_SPARC_NONE:
+- break;
+- case R_SPARC_JMP_SLOT:
+- break;
+- default:
+- _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 1);
+- break;
+- }
+-}
+-
+-#endif /* RESOLVE */
+-
+ /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
+ PLT entries should not be allowed to define the value.
+ ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
+@@ -766,3 +543,231 @@
+ " add %sp, 6*8, %sp\n" \
+ " .size _dl_start_user, . - _dl_start_user\n" \
+ " .previous\n");
++
++#endif /* dl_machine_h */
++
++#ifdef RESOLVE
++
++/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
++ MAP is the object containing the reloc. */
++
++auto inline void
++__attribute__ ((always_inline))
++elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
++ const Elf64_Sym *sym, const struct r_found_version *version,
++ void *const reloc_addr_arg)
++{
++ Elf64_Addr *const reloc_addr = reloc_addr_arg;
++ const unsigned long int r_type = ELF64_R_TYPE_ID (reloc->r_info);
++
++#if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC
++ if (__builtin_expect (r_type == R_SPARC_RELATIVE, 0))
++ *reloc_addr = map->l_addr + reloc->r_addend;
++# ifndef RTLD_BOOTSTRAP
++ else if (r_type == R_SPARC_NONE) /* Who is Wilbur? */
++ return;
++# endif
++ else
++#endif
++ {
++#if !defined RTLD_BOOTSTRAP && !defined RESOLVE_CONFLICT_FIND_MAP
++ const Elf64_Sym *const refsym = sym;
++#endif
++ Elf64_Addr value;
++#ifndef RESOLVE_CONFLICT_FIND_MAP
++ if (sym->st_shndx != SHN_UNDEF &&
++ ELF64_ST_BIND (sym->st_info) == STB_LOCAL)
++ value = map->l_addr;
++ else
++ {
++ value = RESOLVE (&sym, version, r_type);
++ if (sym)
++ value += sym->st_value;
++ }
++#else
++ value = 0;
++#endif
++ value += reloc->r_addend; /* Assume copy relocs have zero addend. */
++
++ switch (r_type)
++ {
++#if !defined RTLD_BOOTSTRAP && !defined RESOLVE_CONFLICT_FIND_MAP
++ case R_SPARC_COPY:
++ if (sym == NULL)
++ /* This can happen in trace mode if an object could not be
++ found. */
++ break;
++ if (sym->st_size > refsym->st_size
++ || (GLRO(dl_verbose) && sym->st_size < refsym->st_size))
++ {
++ const char *strtab;
++
++ strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
++ _dl_error_printf ("\
++%s: Symbol `%s' has different size in shared object, consider re-linking\n",
++ rtld_progname ?: "<program name unknown>",
++ strtab + refsym->st_name);
++ }
++ memcpy (reloc_addr_arg, (void *) value,
++ MIN (sym->st_size, refsym->st_size));
++ break;
++#endif
++ case R_SPARC_64:
++ case R_SPARC_GLOB_DAT:
++ *reloc_addr = value;
++ break;
++#ifndef RTLD_BOOTSTRAP
++ case R_SPARC_8:
++ *(char *) reloc_addr = value;
++ break;
++ case R_SPARC_16:
++ *(short *) reloc_addr = value;
++ break;
++ case R_SPARC_32:
++ *(unsigned int *) reloc_addr = value;
++ break;
++ case R_SPARC_DISP8:
++ *(char *) reloc_addr = (value - (Elf64_Addr) reloc_addr);
++ break;
++ case R_SPARC_DISP16:
++ *(short *) reloc_addr = (value - (Elf64_Addr) reloc_addr);
++ break;
++ case R_SPARC_DISP32:
++ *(unsigned int *) reloc_addr = (value - (Elf64_Addr) reloc_addr);
++ break;
++ case R_SPARC_WDISP30:
++ *(unsigned int *) reloc_addr =
++ ((*(unsigned int *)reloc_addr & 0xc0000000) |
++ ((value - (Elf64_Addr) reloc_addr) >> 2));
++ break;
++
++ /* MEDLOW code model relocs */
++ case R_SPARC_LO10:
++ *(unsigned int *) reloc_addr =
++ ((*(unsigned int *)reloc_addr & ~0x3ff) |
++ (value & 0x3ff));
++ break;
++ case R_SPARC_HI22:
++ *(unsigned int *) reloc_addr =
++ ((*(unsigned int *)reloc_addr & 0xffc00000) |
++ (value >> 10));
++ break;
++ case R_SPARC_OLO10:
++ *(unsigned int *) reloc_addr =
++ ((*(unsigned int *)reloc_addr & ~0x1fff) |
++ (((value & 0x3ff) + ELF64_R_TYPE_DATA (reloc->r_info)) & 0x1fff));
++ break;
++
++ /* MEDMID code model relocs */
++ case R_SPARC_H44:
++ *(unsigned int *) reloc_addr =
++ ((*(unsigned int *)reloc_addr & 0xffc00000) |
++ (value >> 22));
++ break;
++ case R_SPARC_M44:
++ *(unsigned int *) reloc_addr =
++ ((*(unsigned int *)reloc_addr & ~0x3ff) |
++ ((value >> 12) & 0x3ff));
++ break;
++ case R_SPARC_L44:
++ *(unsigned int *) reloc_addr =
++ ((*(unsigned int *)reloc_addr & ~0xfff) |
++ (value & 0xfff));
++ break;
++
++ /* MEDANY code model relocs */
++ case R_SPARC_HH22:
++ *(unsigned int *) reloc_addr =
++ ((*(unsigned int *)reloc_addr & 0xffc00000) |
++ (value >> 42));
++ break;
++ case R_SPARC_HM10:
++ *(unsigned int *) reloc_addr =
++ ((*(unsigned int *)reloc_addr & ~0x3ff) |
++ ((value >> 32) & 0x3ff));
++ break;
++ case R_SPARC_LM22:
++ *(unsigned int *) reloc_addr =
++ ((*(unsigned int *)reloc_addr & 0xffc00000) |
++ ((value >> 10) & 0x003fffff));
++ break;
++#endif
++ case R_SPARC_JMP_SLOT:
++#ifdef RESOLVE_CONFLICT_FIND_MAP
++ /* R_SPARC_JMP_SLOT conflicts against .plt[32768+]
++ relocs should be turned into R_SPARC_64 relocs
++ in .gnu.conflict section.
++ r_addend non-zero does not mean it is a .plt[32768+]
++ reloc, instead it is the actual address of the function
++ to call. */
++ sparc64_fixup_plt (NULL, reloc, reloc_addr, value, 0, 0);
++#else
++ sparc64_fixup_plt (map, reloc, reloc_addr, value,
++ reloc->r_addend, 0);
++#endif
++ break;
++#ifndef RTLD_BOOTSTRAP
++ case R_SPARC_UA16:
++ ((unsigned char *) reloc_addr_arg) [0] = value >> 8;
++ ((unsigned char *) reloc_addr_arg) [1] = value;
++ break;
++ case R_SPARC_UA32:
++ ((unsigned char *) reloc_addr_arg) [0] = value >> 24;
++ ((unsigned char *) reloc_addr_arg) [1] = value >> 16;
++ ((unsigned char *) reloc_addr_arg) [2] = value >> 8;
++ ((unsigned char *) reloc_addr_arg) [3] = value;
++ break;
++ case R_SPARC_UA64:
++ if (! ((long) reloc_addr_arg & 3))
++ {
++ /* Common in .eh_frame */
++ ((unsigned int *) reloc_addr_arg) [0] = value >> 32;
++ ((unsigned int *) reloc_addr_arg) [1] = value;
++ break;
++ }
++ ((unsigned char *) reloc_addr_arg) [0] = value >> 56;
++ ((unsigned char *) reloc_addr_arg) [1] = value >> 48;
++ ((unsigned char *) reloc_addr_arg) [2] = value >> 40;
++ ((unsigned char *) reloc_addr_arg) [3] = value >> 32;
++ ((unsigned char *) reloc_addr_arg) [4] = value >> 24;
++ ((unsigned char *) reloc_addr_arg) [5] = value >> 16;
++ ((unsigned char *) reloc_addr_arg) [6] = value >> 8;
++ ((unsigned char *) reloc_addr_arg) [7] = value;
++ break;
++#endif
++#if !defined RTLD_BOOTSTRAP || defined _NDEBUG
++ default:
++ _dl_reloc_bad_type (map, r_type, 0);
++ break;
++#endif
++ }
++ }
++}
++
++auto inline void
++__attribute__ ((always_inline))
++elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
++ void *const reloc_addr_arg)
++{
++ Elf64_Addr *const reloc_addr = reloc_addr_arg;
++ *reloc_addr = l_addr + reloc->r_addend;
++}
++
++auto inline void
++__attribute__ ((always_inline))
++elf_machine_lazy_rel (struct link_map *map,
++ Elf64_Addr l_addr, const Elf64_Rela *reloc)
++{
++ switch (ELF64_R_TYPE (reloc->r_info))
++ {
++ case R_SPARC_NONE:
++ break;
++ case R_SPARC_JMP_SLOT:
++ break;
++ default:
++ _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 1);
++ break;
++ }
++}
++
++#endif /* RESOLVE */
--- /dev/null
+#!/bin/sh
+#
+# nscd: Starts the Name Switch Cache Daemon
+#
+# chkconfig: 345 30 80
+# description: This is a daemon which handles passwd and group lookups \
+# for running programs and cache the results for the next \
+# query. You should start this daemon only if you use \
+# slow Services like NIS or NIS+
+# processname: nscd
+# config: /etc/nscd.conf
+#
+
+# Sanity checks.
+[ -f /etc/nscd.conf ] || exit 0
+[ -x /usr/sbin/nscd ] || exit 0
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Get sysconfig
+[ -f /etc/sysconfig/nscd ] && . /etc/sysconfig/nscd
+
+start() {
+ if [ ! -f /var/lock/subsys/nscd ]; then
+ msg_starting "Name Switch Cache Daemon"
+ daemon nscd
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nscd
+ else
+ msg_already_running "Name Switch Cache Daemon"
+ fi
+}
+
+stop() {
+ if [ -f /var/lock/subsys/nscd ]; then
+ msg_stopping "Name Switch Cache Daemon"
+ busy
+ /usr/sbin/nscd -K
+ rm -f /var/lock/subsys/nscd >/dev/null 2>&1
+ ok
+ else
+ msg_not_running "Name Switch Cache Daemon"
+ fi
+}
+
+condrestart() {
+ if [ -f /var/lock/subsys/nscd ]; then
+ stop
+ start
+ else
+ msg_not_running "Name Switch Cache Daemon"
+ RETVAL=$1
+ fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ try-restart)
+ condrestart 0
+ ;;
+ force-reload)
+ condrestart 7
+ ;;
+ reload)
+ if [ -f /var/lock/subsys/nscd ]; then
+ for db in passwd group hosts; do
+ show "Invalidating %s cache" $db; busy
+ nscd -i $db && ok || fail
+ done
+ else
+ msg_not_running "Name Switch Cache Daemon"
+ fi
+ ;;
+ status)
+ status nscd
+ exit $?
+ ;;
+ *)
+ msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
+ exit 3
+esac
+
+exit $RETVAL
--- /dev/null
+/*
+ * Copyright (c) 2002 Michal Moskal <malekith@pld-linux.org>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Michal Moskal.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY MICHAL MOSKAL AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Usage
+ * ~~~~~
+ *
+ * This simple program is aimed to be used as script interpreter in rpm
+ * %post scriptlets and the like. It opens file passed as first argument
+ * and executes commands found there. Only linear execution is supported.
+ * For example, in glibc.spec:
+ *
+ * %post -p /sbin/postshell
+ * ldconfig
+ * -telinit q
+ *
+ * (full patch like /sbin/ldconfig or -/sbin/tellinit will also work).
+ *
+ * If command starts with - its exit status is ignored. Otherwise last
+ * non-zero exit status is returned.
+ *
+ * There are no builtin commands (yet :).
+ *
+ * Following commands *will* work as expected (as in Bourne shell):
+ *
+ * /bin/echo "Foo bar baz"
+ * insmod foobar options="foo bar 'qux'"
+ * false
+ *
+ * Following *won't*:
+ *
+ * exit 1
+ * echo foo || echo baz
+ * set -x
+ *
+ * Patches and bugreports are welcome, direct them to Michal Moskal
+ * <malekith@pld-linux.org>.
+ */
+
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+
+#define MAX_LINE 1024
+#define MAX_ARGS 32
+#define SEARCH_PATH { "/sbin/", "/bin/", "/usr/sbin/", "/usr/bin/", NULL }
+
+int exit_status;
+int ignore_status;
+
+void do_execve(char **argv)
+{
+ char *path[] = SEARCH_PATH;
+ char file[MAX_LINE + 100];
+ int i;
+
+ if (**argv == '.' || **argv == '/')
+ execve(argv[0], argv, environ);
+ else
+ for (i = 0; path[i]; i++) {
+ strcpy(file, path[i]);
+ strcat(file, argv[0]);
+ execve(file, argv, environ);
+ }
+}
+
+int exec_and_wait(char **argv)
+{
+ pid_t pid;
+
+ pid = fork();
+
+ if (pid == -1) {
+ perror("fork");
+ return -1;
+ } else if (pid == 0) {
+ /* child. */
+ do_execve(argv);
+ if (!ignore_status)
+ perror(argv[0]);
+ exit(127);
+ } else {
+ int status, err;
+
+ err = waitpid(pid, &status, 0);
+ if (err < 0) {
+ perror("waitpid");
+ return -1;
+ } else
+ return WEXITSTATUS(status);
+ }
+}
+
+void split_argv(char **argv, char *s)
+{
+ char *dst;
+ int argc, delim;
+
+ for (argc = 0; argc < MAX_ARGS; argc++) {
+ while (*s == ' ' || *s == '\t')
+ s++;
+
+ if (*s == 0)
+ break;
+
+ argv[argc] = s;
+ dst = s;
+
+ while (*s && *s != ' ' && *s != '\t') {
+ if (*s == '\'' || *s == '"') {
+ delim = *s++;
+ while (*s && *s != delim)
+ *dst++ = *s++;
+ if (*s)
+ s++;
+ } else {
+ *dst++ = *s++;
+ }
+ }
+
+ if (*dst) {
+ if (s == dst)
+ s++;
+ *dst++ = 0;
+ }
+ }
+
+ argv[argc] = NULL;
+}
+
+void exec_line(char *s)
+{
+ char *argv[MAX_ARGS + 1];
+ int ret;
+
+ split_argv(argv, s);
+
+ ignore_status = 0;
+
+ if (**argv == '-') {
+ ignore_status++;
+ (*argv)++;
+ }
+
+ ret = exec_and_wait(argv);
+
+ if (ret && !ignore_status)
+ exit_status = ret;
+}
+
+void exec_file(int fd)
+{
+ char line[MAX_LINE];
+ struct stat sbuf;
+ char *p, *s, *a;
+
+ if (fstat(fd, &sbuf) < 0) {
+ perror("fstat()");
+ exit(1);
+ }
+
+ if ((p = mmap(0, sbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0)) < 0) {
+ perror("mmap()");
+ exit(1);
+ }
+
+ for (a = s = p; s < p + sbuf.st_size; s++) {
+ if (*s == '\n') {
+ memcpy(line, a, s - a);
+ line[s - a] = '\0';
+ exec_line(line);
+ a = ++s;
+ }
+ }
+
+ // last line was not terminated.
+ if (s == p + sbuf.st_size) {
+ memcpy(line, a, s - a);
+ line[s - a] = '\0';
+ exec_line(line);
+ }
+
+ if (munmap(p, sbuf.st_size) < 0) {
+ perror("munmap()");
+ exit(1);
+ }
+}
+
+#define error(msg) write(2, msg, strlen(msg))
+int main(int argc, char **argv)
+{
+ int fd;
+
+ if (argc < 2) {
+ error("USAGE: ");
+ error(argv[0]);
+ error(" filename\n");
+ exit(1);
+ }
+
+ fd = open(argv[1], O_RDONLY);
+
+ if (fd == -1) {
+ perror(argv[1]);
+ exit(1);
+ }
+
+ exec_file(fd);
+ close(fd);
+ exit(exit_status);
+}