summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO38
-rw-r--r--.gitignore7
-rw-r--r--PKGBUILD115
-rw-r--r--bz20338.patch114
-rw-r--r--glibc-1915d6d1.patch.xzbin214744 -> 0 bytes
-rw-r--r--sdt-config.h6
-rw-r--r--sdt.h430
-rw-r--r--xldd369
8 files changed, 887 insertions, 192 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 5666ba11047c..9be42e29470d 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,30 +1,34 @@
-# Generated by mksrcinfo v8
-# Fri May 11 17:47:38 UTC 2018
pkgbase = arm-linux-gnueabihf-glibc
- pkgdesc = GNU C Library (arm-linux-gnueabihf)
- pkgver = 2.27
- pkgrel = 3
- url = http://www.gnu.org/software/libc/
+ pkgdesc = GNU C Library
+ pkgver = 2.39
+ pkgrel = 1
+ url = https://www.gnu.org/software/libc/
arch = any
license = GPL
license = LGPL
- makedepends = arm-linux-gnueabihf-gcc-stage2>=8.1.0-1
- makedepends = gperf
- depends = arm-linux-gnueabihf-linux-api-headers>=4.16.1-1
- provides = arm-linux-gnueabihf-glibc-headers=2.27
+ makedepends = arm-linux-gnueabihf-gcc-stage2>=13.2.0
+ makedepends = python
+ depends = arm-linux-gnueabihf-linux-api-headers>=6.1
+ provides = arm-linux-gnueabihf-glibc-headers=2.39
provides = arm-linux-gnueabihf-eglibc
conflicts = arm-linux-gnueabihf-glibc-headers
conflicts = arm-linux-gnueabihf-eglibc
replaces = arm-linux-gnueabihf-glibc-headers
options = !buildflags
options = !strip
+ options = lto
options = staticlibs
- source = https://ftp.gnu.org/gnu/glibc/glibc-2.27.tar.xz
- source = https://ftp.gnu.org/gnu/glibc/glibc-2.27.tar.xz.sig
- source = bz20338.patch
- md5sums = 898cd5656519ffbc3a03fe811dd89e82
- md5sums = SKIP
- md5sums = dc0d3ad59aeaaf591b085a77de6e03e9
+ source = https://ftp.gnu.org/gnu/glibc/glibc-2.39.tar.xz
+ source = https://ftp.gnu.org/gnu/glibc/glibc-2.39.tar.xz.sig
+ source = sdt.h
+ source = sdt-config.h
+ source = xldd
+ validpgpkeys = 7273542B39962DF7B299931416792B4EA25340F8
+ validpgpkeys = BC7C7372637EC10C57D7AA6579C43DFBF1CF2187
+ sha256sums = f77bd47cf8170c57365ae7bf86696c118adb3b120d3259c64c502d3dc1e2d926
+ sha256sums = SKIP
+ sha256sums = 1ecf90005ff5a65374c7266acb164fa265aff92328593bdca2352acf5dab240d
+ sha256sums = cdc234959c6fdb43f000d3bb7d1080b0103f4080f5e67bcfe8ae1aaf477812f0
+ sha256sums = 96aaa6baacd84f8cd517e5b31d575b766a7af5a3be6fad3c8707da796e8f8ca7
pkgname = arm-linux-gnueabihf-glibc
-
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index c14ca8a5b418..000000000000
--- a/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-*.pkg.*
-src/
-pkg/
-glibc-*.tar.xz
-*.sig
-*.sign
-*.part
diff --git a/PKGBUILD b/PKGBUILD
index d30da13b8df7..447b2bed1c1d 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,61 +3,40 @@
# Contributor: Allan McRae <allan@archlinux.org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Kevin Mihelich <kevin@archlinuxarm.org>
-# Maintainer: Tavian Barnes <tavianator@tavianator.com>
+# Contributor: Tavian Barnes <tavianator@tavianator.com>
+# Contributor: Vyacheslav Razykov <v.razykov@gmail.com>
+# Maintainer: Wilken Gottwalt <wilken dot gottwalt at posteo dot net>
-_target="arm-linux-gnueabihf"
+_target=arm-linux-gnueabihf
pkgname=${_target}-glibc
-pkgver=2.27
-pkgrel=3
-pkgdesc="GNU C Library (${_target})"
+pkgver=2.39
+pkgrel=1
+pkgdesc="GNU C Library"
arch=('any')
-url="http://www.gnu.org/software/libc/"
+url="https://www.gnu.org/software/libc/"
license=(GPL LGPL)
-depends=("${_target}-linux-api-headers>=4.16.1-1")
-makedepends=("${_target}-gcc-stage2>=8.1.0-1" gperf)
+depends=("${_target}-linux-api-headers>=6.1")
+makedepends=("${_target}-gcc-stage2>=13.2.0" python)
provides=("${_target}-glibc-headers=${pkgver}" "${_target}-eglibc")
conflicts=("${_target}-glibc-headers" "${_target}-eglibc")
replaces=("${_target}-glibc-headers")
-options=(!buildflags !strip staticlibs)
-_commit=23158b08a0908f381459f273a984c6fd328363cb
-#source=(git+https://sourceware.org/git/glibc.git#commit=$_commit
-source=(https://ftp.gnu.org/gnu/glibc/glibc-$pkgver.tar.xz{,.sig}
- bz20338.patch)
-validpgpkeys=(7273542B39962DF7B299931416792B4EA25340F8) # Carlos O'Donell
-md5sums=('898cd5656519ffbc3a03fe811dd89e82'
- 'SKIP'
- 'dc0d3ad59aeaaf591b085a77de6e03e9')
+options=(!buildflags !strip lto staticlibs)
+source=(https://ftp.gnu.org/gnu/glibc/glibc-${pkgver}.tar.xz{,.sig}
+ sdt.h sdt-config.h
+ xldd)
+validpgpkeys=(7273542B39962DF7B299931416792B4EA25340F8 # Carlos O'Donell
+ BC7C7372637EC10C57D7AA6579C43DFBF1CF2187) # Siddhesh Poyarekar
+sha256sums=('f77bd47cf8170c57365ae7bf86696c118adb3b120d3259c64c502d3dc1e2d926'
+ 'SKIP'
+ '1ecf90005ff5a65374c7266acb164fa265aff92328593bdca2352acf5dab240d'
+ 'cdc234959c6fdb43f000d3bb7d1080b0103f4080f5e67bcfe8ae1aaf477812f0'
+ '96aaa6baacd84f8cd517e5b31d575b766a7af5a3be6fad3c8707da796e8f8ca7')
prepare() {
mkdir -p glibc-build
-
- [[ -d glibc-$pkgver ]] && ln -s glibc-$pkgver glibc
- cd glibc
-
- local i; for i in ${source[@]}; do
- case ${i%::*} in
- *.patch)
- msg2 "Applying ${i}"
- patch -p1 -i "$srcdir/${i}"
- ;;
- esac
- done
}
build() {
- local _configure_flags=(
- --prefix=/
- --with-headers=/usr/${_target}/include
- --enable-add-ons
- --enable-bind-now
- --enable-lock-elision
- --disable-multi-arch
- --enable-stack-protector=strong
- --enable-stackguard-randomization
- --disable-profile
- --disable-werror
- )
-
cd glibc-build
echo "slibdir=/lib" >> configparms
@@ -68,19 +47,39 @@ build() {
# remove fortify for building libraries
CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
+ CFLAGS="${CFLAGS/-fno-plt/} -O2"
+ CXXFLAGS="${CXXFLAGS/-fno-plt/} -O2"
+ LDFLAGS="${LDFLAGS/,-z,now/}"
+
export BUILD_CC=gcc
export CC=${_target}-gcc
export CXX=${_target}-g++
export AR=${_target}-ar
export RANLIB=${_target}-ranlib
- "$srcdir/glibc-$pkgver/configure" \
- --libdir=/lib \
- --libexecdir=/lib \
- ${_configure_flags[@]} \
- --target=${_target} \
- --host=${_target} \
- --build=${CHOST}
+ ../glibc-${pkgver}/configure \
+ --target=${_target} \
+ --host=${_target} \
+ --build=${CHOST} \
+ --prefix=/usr \
+ --libdir=/lib \
+ --libexecdir=/lib \
+ --includedir=/include \
+ --with-headers=/usr/${_target}/include \
+ --enable-add-ons \
+ --enable-bind-now \
+ --enable-cet \
+ --enable-fortify-source \
+ --enable-lock-elision \
+ --enable-stack-protector=strong \
+ --enable-stackguard-randomization \
+ --enable-systemtap \
+ --enable-crypt \
+ --enable-obsolete-rpc \
+ --enable-kernel=2.6.32 \
+ --disable-multi-arch \
+ --disable-profile \
+ --disable-werror
echo "build-programs=no" >> configparms
make
@@ -89,11 +88,19 @@ build() {
package() {
cd glibc-build
- make install_root="$pkgdir/usr/$_target" install
+ make install_root="${pkgdir}"/usr/"${_target}" install
+
+ # provide famous ldd script
+ install -Dm755 "${srcdir}"/xldd "${pkgdir}"/usr/bin/"${_target}"-ldd
+
+ # remove not required files
+ rm -r "$pkgdir"/usr/$_target/{etc,usr/share,var}
- mkdir -p "$pkgdir/usr/$_target/usr"
- ln -s ../{include,lib} "$pkgdir/usr/$_target/usr"
+ # provide tracing probes to libstdc++ for exceptions, possibly for other
+ # libraries too. Useful for gdb's catch command.
+ install -Dm644 "${srcdir}"/sdt.h "${pkgdir}"/usr/"${_target}"/include/sys/sdt.h
+ install -Dm644 "${srcdir}"/sdt-config.h "${pkgdir}"/usr/"${_target}"/include/sys/sdt-config.h
- # Remove unneeded for compilation files
- rm -rf "$pkgdir/usr/$_target/"{bin,sbin,etc,share,var}
+ # strip it manually to prevent makepkg complaining about srcdir references
+ find "${pkgdir}"/usr/"${_target}"/lib -type f -exec /usr/bin/"${_target}"-strip --strip-unneeded {} \; 2>/dev/null || true
}
diff --git a/bz20338.patch b/bz20338.patch
deleted file mode 100644
index d223e9f08882..000000000000
--- a/bz20338.patch
+++ /dev/null
@@ -1,114 +0,0 @@
-From 74250a7cdf106d4ca7d9506e6d5dc7c448dc3434 Mon Sep 17 00:00:00 2001
-From: David Michael <david.michael@coreos.com>
-Date: Thu, 15 Dec 2016 15:22:57 -0800
-Subject: [PATCH] gshadow: Sync fgetsgent_r.c with grp/fgetgrent_r.c
-
- [BZ #20338]
- * gshadow/fgetsgent_r.c: Include <libio/iolibio.h>.
- (flockfile): New macro.
- (funlockfile): Likewise.
- (__fgetsgent_r): Sync with __fgetgrent_r.
- * nss/nss_files/files-sgrp.c: Fix "fgetsgent_r.c" typo.
----
- gshadow/fgetsgent_r.c | 35 ++++++++++++++++++++++++-----------
- nss/nss_files/files-sgrp.c | 2 +-
- 2 files changed, 25 insertions(+), 12 deletions(-)
-
-diff --git a/gshadow/fgetsgent_r.c b/gshadow/fgetsgent_r.c
-index b70f6fa..02cd33a 100644
---- a/gshadow/fgetsgent_r.c
-+++ b/gshadow/fgetsgent_r.c
-@@ -20,39 +20,44 @@
- #include <gshadow.h>
- #include <stdio.h>
-
-+#include <libio/iolibio.h>
-+#define flockfile(s) _IO_flockfile (s)
-+#define funlockfile(s) _IO_funlockfile (s)
-+
- /* Define a line parsing function using the common code
- used in the nss_files module. */
-
- #define STRUCTURE sgrp
- #define ENTNAME sgent
--#define EXTERN_PARSER 1
-+#define EXTERN_PARSER 1
- struct sgent_data {};
-
- #include <nss/nss_files/files-parse.c>
-
-
--/* Read one shadow entry from the given stream. */
-+/* Read one entry from the given stream. */
- int
- __fgetsgent_r (FILE *stream, struct sgrp *resbuf, char *buffer, size_t buflen,
- struct sgrp **result)
- {
- char *p;
-+ int parse_result;
-
-- _IO_flockfile (stream);
-+ flockfile (stream);
- do
- {
- buffer[buflen - 1] = '\xff';
- p = fgets_unlocked (buffer, buflen, stream);
-- if (p == NULL && feof_unlocked (stream))
-+ if (__builtin_expect (p == NULL, 0) && feof_unlocked (stream))
- {
-- _IO_funlockfile (stream);
-+ funlockfile (stream);
- *result = NULL;
- __set_errno (ENOENT);
- return errno;
- }
-- if (p == NULL || buffer[buflen - 1] != '\xff')
-+ if (__builtin_expect (p == NULL, 0) || buffer[buflen - 1] != '\xff')
- {
-- _IO_funlockfile (stream);
-+ funlockfile (stream);
- *result = NULL;
- __set_errno (ERANGE);
- return errno;
-@@ -61,13 +66,21 @@ __fgetsgent_r (FILE *stream, struct sgrp *resbuf, char *buffer, size_t buflen,
- /* Skip leading blanks. */
- while (isspace (*p))
- ++p;
-- } while (*p == '\0' || *p == '#' || /* Ignore empty and comment lines. */
-+ } while (*p == '\0' || *p == '#' /* Ignore empty and comment lines. */
- /* Parse the line. If it is invalid, loop to
- get the next line of the file to parse. */
-- ! parse_line (buffer, (void *) resbuf, (void *) buffer, buflen,
-- &errno));
-+ || ! (parse_result = parse_line (p, resbuf,
-+ (void *) buffer, buflen,
-+ &errno)));
-+
-+ funlockfile (stream);
-
-- _IO_funlockfile (stream);
-+ if (__builtin_expect (parse_result, 0) == -1)
-+ {
-+ /* The parser ran out of space. */
-+ *result = NULL;
-+ return errno;
-+ }
-
- *result = resbuf;
- return 0;
-diff --git a/nss/nss_files/files-sgrp.c b/nss/nss_files/files-sgrp.c
-index 15dc659..05c3805 100644
---- a/nss/nss_files/files-sgrp.c
-+++ b/nss/nss_files/files-sgrp.c
-@@ -23,7 +23,7 @@
- #define DATABASE "gshadow"
- struct sgent_data {};
-
--/* Our parser function is already defined in sgetspent_r.c, so use that
-+/* Our parser function is already defined in sgetsgent_r.c, so use that
- to parse lines from the database file. */
- #define EXTERN_PARSER
- #include "files-parse.c"
---
-2.7.4
-
diff --git a/glibc-1915d6d1.patch.xz b/glibc-1915d6d1.patch.xz
deleted file mode 100644
index 3eefd201662d..000000000000
--- a/glibc-1915d6d1.patch.xz
+++ /dev/null
Binary files differ
diff --git a/sdt-config.h b/sdt-config.h
new file mode 100644
index 000000000000..733045a52771
--- /dev/null
+++ b/sdt-config.h
@@ -0,0 +1,6 @@
+/* includes/sys/sdt-config.h. Generated from sdt-config.h.in by configure.
+
+ This file just defines _SDT_ASM_SECTION_AUTOGROUP_SUPPORT to 0 or 1 to
+ indicate whether the assembler supports "?" in .pushsection directives. */
+
+#define _SDT_ASM_SECTION_AUTOGROUP_SUPPORT 1
diff --git a/sdt.h b/sdt.h
new file mode 100644
index 000000000000..9ddadc7ee89b
--- /dev/null
+++ b/sdt.h
@@ -0,0 +1,430 @@
+/* <sys/sdt.h> - Systemtap static probe definition macros.
+
+ This file is dedicated to the public domain, pursuant to CC0
+ (https://creativecommons.org/publicdomain/zero/1.0/)
+*/
+
+#ifndef _SYS_SDT_H
+#define _SYS_SDT_H 1
+
+/*
+ This file defines a family of macros
+
+ STAP_PROBEn(op1, ..., opn)
+
+ that emit a nop into the instruction stream, and some data into an auxiliary
+ note section. The data in the note section describes the operands, in terms
+ of size and location. Each location is encoded as assembler operand string.
+ Consumer tools such as gdb or systemtap insert breakpoints on top of
+ the nop, and decode the location operand-strings, like an assembler,
+ to find the values being passed.
+
+ The operand strings are selected by the compiler for each operand.
+ They are constrained by gcc inline-assembler codes. The default is:
+
+ #define STAP_SDT_ARG_CONSTRAINT nor
+
+ This is a good default if the operands tend to be integral and
+ moderate in number (smaller than number of registers). In other
+ cases, the compiler may report "'asm' requires impossible reload" or
+ similar. In this case, consider simplifying the macro call (fewer
+ and simpler operands), reduce optimization, or override the default
+ constraints string via:
+
+ #define STAP_SDT_ARG_CONSTRAINT g
+ #include <sys/sdt.h>
+
+ See also:
+ https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation
+ https://gcc.gnu.org/onlinedocs/gcc/Constraints.html
+ */
+
+
+
+#ifdef __ASSEMBLER__
+# define _SDT_PROBE(provider, name, n, arglist) \
+ _SDT_ASM_BODY(provider, name, _SDT_ASM_STRING_1, (_SDT_DEPAREN_##n arglist)) \
+ _SDT_ASM_BASE
+# define _SDT_ASM_1(x) x;
+# define _SDT_ASM_2(a, b) a,b;
+# define _SDT_ASM_3(a, b, c) a,b,c;
+# define _SDT_ASM_5(a, b, c, d, e) a,b,c,d,e;
+# define _SDT_ASM_STRING_1(x) .asciz #x;
+# define _SDT_DEPAREN_0() /* empty */
+# define _SDT_DEPAREN_1(a) a
+# define _SDT_DEPAREN_2(a,b) a b
+# define _SDT_DEPAREN_3(a,b,c) a b c
+# define _SDT_DEPAREN_4(a,b,c,d) a b c d
+# define _SDT_DEPAREN_5(a,b,c,d,e) a b c d e
+# define _SDT_DEPAREN_6(a,b,c,d,e,f) a b c d e f
+# define _SDT_DEPAREN_7(a,b,c,d,e,f,g) a b c d e f g
+# define _SDT_DEPAREN_8(a,b,c,d,e,f,g,h) a b c d e f g h
+# define _SDT_DEPAREN_9(a,b,c,d,e,f,g,h,i) a b c d e f g h i
+# define _SDT_DEPAREN_10(a,b,c,d,e,f,g,h,i,j) a b c d e f g h i j
+# define _SDT_DEPAREN_11(a,b,c,d,e,f,g,h,i,j,k) a b c d e f g h i j k
+# define _SDT_DEPAREN_12(a,b,c,d,e,f,g,h,i,j,k,l) a b c d e f g h i j k l
+#else
+# define _SDT_PROBE(provider, name, n, arglist) \
+ do { \
+ __asm__ __volatile__ (_SDT_ASM_BODY(provider, name, _SDT_ASM_ARGS, (n)) \
+ :: _SDT_ASM_OPERANDS_##n arglist); \
+ __asm__ __volatile__ (_SDT_ASM_BASE); \
+ } while (0)
+# define _SDT_S(x) #x
+# define _SDT_ASM_1(x) _SDT_S(x) "\n"
+# define _SDT_ASM_2(a, b) _SDT_S(a) "," _SDT_S(b) "\n"
+# define _SDT_ASM_3(a, b, c) _SDT_S(a) "," _SDT_S(b) "," \
+ _SDT_S(c) "\n"
+# define _SDT_ASM_5(a, b, c, d, e) _SDT_S(a) "," _SDT_S(b) "," \
+ _SDT_S(c) "," _SDT_S(d) "," \
+ _SDT_S(e) "\n"
+# define _SDT_ASM_ARGS(n) _SDT_ASM_STRING(_SDT_ASM_TEMPLATE_##n)
+# define _SDT_ASM_STRING_1(x) _SDT_ASM_1(.asciz #x)
+
+# define _SDT_ARGFMT(no) %n[_SDT_S##no]@_SDT_ARGTMPL(_SDT_A##no)
+
+# ifndef STAP_SDT_ARG_CONSTRAINT
+# if defined __powerpc__
+# define STAP_SDT_ARG_CONSTRAINT nZr
+# else
+# define STAP_SDT_ARG_CONSTRAINT nor
+# endif
+# endif
+
+# define _SDT_STRINGIFY(x) #x
+# define _SDT_ARG_CONSTRAINT_STRING(x) _SDT_STRINGIFY(x)
+# define _SDT_ARG(n, x) \
+ [_SDT_S##n] "n" ((_SDT_ARGSIGNED (x) ? 1 : -1) * (int) _SDT_ARGSIZE (x)), \
+ [_SDT_A##n] _SDT_ARG_CONSTRAINT_STRING (STAP_SDT_ARG_CONSTRAINT) (_SDT_ARGVAL (x))
+#endif
+#define _SDT_ASM_STRING(x) _SDT_ASM_STRING_1(x)
+
+#define _SDT_ARGARRAY(x) (__builtin_classify_type (x) == 14 \
+ || __builtin_classify_type (x) == 5)
+
+#ifdef __cplusplus
+# define _SDT_ARGSIGNED(x) (!_SDT_ARGARRAY (x) \
+ && __sdt_type<__typeof (x)>::__sdt_signed)
+# define _SDT_ARGSIZE(x) (_SDT_ARGARRAY (x) \
+ ? sizeof (void *) : sizeof (x))
+# define _SDT_ARGVAL(x) (x)
+
+# include <cstddef>
+
+template<typename __sdt_T>
+struct __sdt_type
+{
+ static const bool __sdt_signed = false;
+};
+
+#define __SDT_ALWAYS_SIGNED(T) \
+template<> struct __sdt_type<T> { static const bool __sdt_signed = true; };
+#define __SDT_COND_SIGNED(T,CT) \
+template<> struct __sdt_type<T> { static const bool __sdt_signed = ((CT)(-1) < 1); };
+__SDT_ALWAYS_SIGNED(signed char)
+__SDT_ALWAYS_SIGNED(short)
+__SDT_ALWAYS_SIGNED(int)
+__SDT_ALWAYS_SIGNED(long)
+__SDT_ALWAYS_SIGNED(long long)
+__SDT_ALWAYS_SIGNED(volatile signed char)
+__SDT_ALWAYS_SIGNED(volatile short)
+__SDT_ALWAYS_SIGNED(volatile int)
+__SDT_ALWAYS_SIGNED(volatile long)
+__SDT_ALWAYS_SIGNED(volatile long long)
+__SDT_ALWAYS_SIGNED(const signed char)
+__SDT_ALWAYS_SIGNED(const short)
+__SDT_ALWAYS_SIGNED(const int)
+__SDT_ALWAYS_SIGNED(const long)
+__SDT_ALWAYS_SIGNED(const long long)
+__SDT_ALWAYS_SIGNED(const volatile signed char)
+__SDT_ALWAYS_SIGNED(const volatile short)
+__SDT_ALWAYS_SIGNED(const volatile int)
+__SDT_ALWAYS_SIGNED(const volatile long)
+__SDT_ALWAYS_SIGNED(const volatile long long)
+__SDT_COND_SIGNED(char, char)
+__SDT_COND_SIGNED(wchar_t, wchar_t)
+__SDT_COND_SIGNED(volatile char, char)
+__SDT_COND_SIGNED(volatile wchar_t, wchar_t)
+__SDT_COND_SIGNED(const char, char)
+__SDT_COND_SIGNED(const wchar_t, wchar_t)
+__SDT_COND_SIGNED(const volatile char, char)
+__SDT_COND_SIGNED(const volatile wchar_t, wchar_t)
+#if defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+/* __SDT_COND_SIGNED(char16_t) */
+/* __SDT_COND_SIGNED(char32_t) */
+#endif
+
+template<typename __sdt_E>
+struct __sdt_type<__sdt_E[]> : public __sdt_type<__sdt_E *> {};
+
+template<typename __sdt_E, size_t __sdt_N>
+struct __sdt_type<__sdt_E[__sdt_N]> : public __sdt_type<__sdt_E *> {};
+
+#elif !defined(__ASSEMBLER__)
+__extension__ extern unsigned long long __sdt_unsp;
+# define _SDT_ARGINTTYPE(x) \
+ __typeof (__builtin_choose_expr (((__builtin_classify_type (x) \
+ + 3) & -4) == 4, (x), 0U))
+# define _SDT_ARGSIGNED(x) \
+ (!__extension__ \
+ (__builtin_constant_p ((((unsigned long long) \
+ (_SDT_ARGINTTYPE (x)) __sdt_unsp) \
+ & ((unsigned long long)1 << (sizeof (unsigned long long) \
+ * __CHAR_BIT__ - 1))) == 0) \
+ || (_SDT_ARGINTTYPE (x)) -1 > (_SDT_ARGINTTYPE (x)) 0))
+# define _SDT_ARGSIZE(x) \
+ (_SDT_ARGARRAY (x) ? sizeof (void *) : sizeof (x))
+# define _SDT_ARGVAL(x) (x)
+#endif
+
+#if defined __powerpc__ || defined __powerpc64__
+# define _SDT_ARGTMPL(id) %I[id]%[id]
+#elif defined __i386__
+# define _SDT_ARGTMPL(id) %w[id] /* gcc.gnu.org/PR80115 */
+#else
+# define _SDT_ARGTMPL(id) %[id]
+#endif
+
+#ifdef __LP64__
+# define _SDT_ASM_ADDR .8byte
+#else
+# define _SDT_ASM_ADDR .4byte
+#endif
+
+/* The ia64 and s390 nop instructions take an argument. */
+#if defined(__ia64__) || defined(__s390__) || defined(__s390x__)
+#define _SDT_NOP nop 0
+#else
+#define _SDT_NOP nop
+#endif
+
+#define _SDT_NOTE_NAME "stapsdt"
+#define _SDT_NOTE_TYPE 3
+
+/* If the assembler supports the necessary feature, then we can play
+ nice with code in COMDAT sections, which comes up in C++ code.
+ Without that assembler support, some combinations of probe placements
+ in certain kinds of C++ code may produce link-time errors. */
+#include "sdt-config.h"
+#if _SDT_ASM_SECTION_AUTOGROUP_SUPPORT
+# define _SDT_ASM_AUTOGROUP "?"
+#else
+# define _SDT_ASM_AUTOGROUP ""
+#endif
+
+#define _SDT_ASM_BODY(provider, name, pack_args, args) \
+ _SDT_ASM_1(990: _SDT_NOP) \
+ _SDT_ASM_3( .pushsection .note.stapsdt,_SDT_ASM_AUTOGROUP,"note") \
+ _SDT_ASM_1( .balign 4) \
+ _SDT_ASM_3( .4byte 992f-991f, 994f-993f, _SDT_NOTE_TYPE) \
+ _SDT_ASM_1(991: .asciz _SDT_NOTE_NAME) \
+ _SDT_ASM_1(992: .balign 4) \
+ _SDT_ASM_1(993: _SDT_ASM_ADDR 990b) \
+ _SDT_ASM_1( _SDT_ASM_ADDR _.stapsdt.base) \
+ _SDT_SEMAPHORE(provider,name) \
+ _SDT_ASM_STRING(provider) \
+ _SDT_ASM_STRING(name) \
+ pack_args args \
+ _SDT_ASM_1(994: .balign 4) \
+ _SDT_ASM_1( .popsection)
+
+#define _SDT_ASM_BASE \
+ _SDT_ASM_1(.ifndef _.stapsdt.base) \
+ _SDT_ASM_5( .pushsection .stapsdt.base,"aG","progbits", \
+ .stapsdt.base,comdat) \
+ _SDT_ASM_1( .weak _.stapsdt.base) \
+ _SDT_ASM_1( .hidden _.stapsdt.base) \
+ _SDT_ASM_1( _.stapsdt.base: .space 1) \
+ _SDT_ASM_2( .size _.stapsdt.base, 1) \
+ _SDT_ASM_1( .popsection) \
+ _SDT_ASM_1(.endif)
+
+#if defined _SDT_HAS_SEMAPHORES
+#define _SDT_SEMAPHORE(p,n) _SDT_ASM_1( _SDT_ASM_ADDR p##_##n##_semaphore)
+#else
+#define _SDT_SEMAPHORE(p,n) _SDT_ASM_1( _SDT_ASM_ADDR 0)
+#endif
+
+#define _SDT_ASM_TEMPLATE_0 /* no arguments */
+#define _SDT_ASM_TEMPLATE_1 _SDT_ARGFMT(1)
+#define _SDT_ASM_TEMPLATE_2 _SDT_ASM_TEMPLATE_1 _SDT_ARGFMT(2)
+#define _SDT_ASM_TEMPLATE_3 _SDT_ASM_TEMPLATE_2 _SDT_ARGFMT(3)
+#define _SDT_ASM_TEMPLATE_4 _SDT_ASM_TEMPLATE_3 _SDT_ARGFMT(4)
+#define _SDT_ASM_TEMPLATE_5 _SDT_ASM_TEMPLATE_4 _SDT_ARGFMT(5)
+#define _SDT_ASM_TEMPLATE_6 _SDT_ASM_TEMPLATE_5 _SDT_ARGFMT(6)
+#define _SDT_ASM_TEMPLATE_7 _SDT_ASM_TEMPLATE_6 _SDT_ARGFMT(7)
+#define _SDT_ASM_TEMPLATE_8 _SDT_ASM_TEMPLATE_7 _SDT_ARGFMT(8)
+#define _SDT_ASM_TEMPLATE_9 _SDT_ASM_TEMPLATE_8 _SDT_ARGFMT(9)
+#define _SDT_ASM_TEMPLATE_10 _SDT_ASM_TEMPLATE_9 _SDT_ARGFMT(10)
+#define _SDT_ASM_TEMPLATE_11 _SDT_ASM_TEMPLATE_10 _SDT_ARGFMT(11)
+#define _SDT_ASM_TEMPLATE_12 _SDT_ASM_TEMPLATE_11 _SDT_ARGFMT(12)
+#define _SDT_ASM_OPERANDS_0() [__sdt_dummy] "g" (0)
+#define _SDT_ASM_OPERANDS_1(arg1) _SDT_ARG(1, arg1)
+#define _SDT_ASM_OPERANDS_2(arg1, arg2) \
+ _SDT_ASM_OPERANDS_1(arg1), _SDT_ARG(2, arg2)
+#define _SDT_ASM_OPERANDS_3(arg1, arg2, arg3) \
+ _SDT_ASM_OPERANDS_2(arg1, arg2), _SDT_ARG(3, arg3)
+#define _SDT_ASM_OPERANDS_4(arg1, arg2, arg3, arg4) \
+ _SDT_ASM_OPERANDS_3(arg1, arg2, arg3), _SDT_ARG(4, arg4)
+#define _SDT_ASM_OPERANDS_5(arg1, arg2, arg3, arg4, arg5) \
+ _SDT_ASM_OPERANDS_4(arg1, arg2, arg3, arg4), _SDT_ARG(5, arg5)
+#define _SDT_ASM_OPERANDS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
+ _SDT_ASM_OPERANDS_5(arg1, arg2, arg3, arg4, arg5), _SDT_ARG(6, arg6)
+#define _SDT_ASM_OPERANDS_7(arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
+ _SDT_ASM_OPERANDS_6(arg1, arg2, arg3, arg4, arg5, arg6), _SDT_ARG(7, arg7)
+#define _SDT_ASM_OPERANDS_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
+ _SDT_ASM_OPERANDS_7(arg1, arg2, arg3, arg4, arg5, arg6, arg7), \
+ _SDT_ARG(8, arg8)
+#define _SDT_ASM_OPERANDS_9(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) \
+ _SDT_ASM_OPERANDS_8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8), \
+ _SDT_ARG(9, arg9)
+#define _SDT_ASM_OPERANDS_10(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10) \
+ _SDT_ASM_OPERANDS_9(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9), \
+ _SDT_ARG(10, arg10)
+#define _SDT_ASM_OPERANDS_11(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11) \
+ _SDT_ASM_OPERANDS_10(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10), \
+ _SDT_ARG(11, arg11)
+#define _SDT_ASM_OPERANDS_12(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12) \
+ _SDT_ASM_OPERANDS_11(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11), \
+ _SDT_ARG(12, arg12)
+
+/* These macros can be used in C, C++, or assembly code.
+ In assembly code the arguments should use normal assembly operand syntax. */
+
+#define STAP_PROBE(provider, name) \
+ _SDT_PROBE(provider, name, 0, ())
+#define STAP_PROBE1(provider, name, arg1) \
+ _SDT_PROBE(provider, name, 1, (arg1))
+#define STAP_PROBE2(provider, name, arg1, arg2) \
+ _SDT_PROBE(provider, name, 2, (arg1, arg2))
+#define STAP_PROBE3(provider, name, arg1, arg2, arg3) \
+ _SDT_PROBE(provider, name, 3, (arg1, arg2, arg3))
+#define STAP_PROBE4(provider, name, arg1, arg2, arg3, arg4) \
+ _SDT_PROBE(provider, name, 4, (arg1, arg2, arg3, arg4))
+#define STAP_PROBE5(provider, name, arg1, arg2, arg3, arg4, arg5) \
+ _SDT_PROBE(provider, name, 5, (arg1, arg2, arg3, arg4, arg5))
+#define STAP_PROBE6(provider, name, arg1, arg2, arg3, arg4, arg5, arg6) \
+ _SDT_PROBE(provider, name, 6, (arg1, arg2, arg3, arg4, arg5, arg6))
+#define STAP_PROBE7(provider, name, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
+ _SDT_PROBE(provider, name, 7, (arg1, arg2, arg3, arg4, arg5, arg6, arg7))
+#define STAP_PROBE8(provider,name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) \
+ _SDT_PROBE(provider, name, 8, (arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8))
+#define STAP_PROBE9(provider,name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
+ _SDT_PROBE(provider, name, 9, (arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9))
+#define STAP_PROBE10(provider,name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10) \
+ _SDT_PROBE(provider, name, 10, \
+ (arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10))
+#define STAP_PROBE11(provider,name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11) \
+ _SDT_PROBE(provider, name, 11, \
+ (arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11))
+#define STAP_PROBE12(provider,name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12) \
+ _SDT_PROBE(provider, name, 12, \
+ (arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12))
+
+/* This STAP_PROBEV macro can be used in variadic scenarios, where the
+ number of probe arguments is not known until compile time. Since
+ variadic macro support may vary with compiler options, you must
+ pre-#define SDT_USE_VARIADIC to enable this type of probe.
+
+ The trick to count __VA_ARGS__ was inspired by this post by
+ Laurent Deniau <laurent.deniau@cern.ch>:
+ http://groups.google.com/group/comp.std.c/msg/346fc464319b1ee5
+
+ Note that our _SDT_NARG is called with an extra 0 arg that's not
+ counted, so we don't have to worry about the behavior of macros
+ called without any arguments. */
+
+#ifdef SDT_USE_VARIADIC
+#define _SDT_NARG(...) __SDT_NARG(__VA_ARGS__, 12,11,10,9,8,7,6,5,4,3,2,1,0)
+#define __SDT_NARG(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12, N, ...) N
+#define _SDT_PROBE_N(provider, name, N, ...) \
+ _SDT_PROBE(provider, name, N, (__VA_ARGS__))
+#define STAP_PROBEV(provider, name, ...) \
+ _SDT_PROBE_N(provider, name, _SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__)
+#endif
+
+/* These macros are for use in asm statements. You must compile
+ with -std=gnu99 or -std=c99 to use the STAP_PROBE_ASM macro.
+
+ The STAP_PROBE_ASM macro generates a quoted string to be used in the
+ template portion of the asm statement, concatenated with strings that
+ contain the actual assembly code around the probe site.
+
+ For example:
+
+ asm ("before\n"
+ STAP_PROBE_ASM(provider, fooprobe, %eax 4(%esi))
+ "after");
+
+ emits the assembly code for "before\nafter", with a probe in between.
+ The probe arguments are the %eax register, and the value of the memory
+ word located 4 bytes past the address in the %esi register. Note that
+ because this is a simple asm, not a GNU C extended asm statement, these
+ % characters do not need to be doubled to generate literal %reg names.
+
+ In a GNU C extended asm statement, the probe arguments can be specified
+ using the macro STAP_PROBE_ASM_TEMPLATE(n) for n arguments. The paired
+ macro STAP_PROBE_ASM_OPERANDS gives the C values of these probe arguments,
+ and appears in the input operand list of the asm statement. For example:
+
+ asm ("someinsn %0,%1\n" // %0 is output operand, %1 is input operand
+ STAP_PROBE_ASM(provider, fooprobe, STAP_PROBE_ASM_TEMPLATE(3))
+ "otherinsn %[namedarg]"
+ : "r" (outvar)
+ : "g" (some_value), [namedarg] "i" (1234),
+ STAP_PROBE_ASM_OPERANDS(3, some_value, some_ptr->field, 1234));
+
+ This is just like writing:
+
+ STAP_PROBE3(provider, fooprobe, some_value, some_ptr->field, 1234));
+
+ but the probe site is right between "someinsn" and "otherinsn".
+
+ The probe arguments in STAP_PROBE_ASM can be given as assembly
+ operands instead, even inside a GNU C extended asm statement.
+ Note that these can use operand templates like %0 or %[name],
+ and likewise they must write %%reg for a literal operand of %reg. */
+
+#if __STDC_VERSION__ >= 199901L
+# define STAP_PROBE_ASM(provider, name, ...) \
+ _SDT_ASM_BODY(provider, name, _SDT_ASM_STRING, (__VA_ARGS__)) \
+ _SDT_ASM_BASE
+# define STAP_PROBE_ASM_OPERANDS(n, ...) _SDT_ASM_OPERANDS_##n(__VA_ARGS__)
+#else
+# define STAP_PROBE_ASM(provider, name, args) \
+ _SDT_ASM_BODY(provider, name, _SDT_ASM_STRING, (args)) \
+ _SDT_ASM_BASE
+#endif
+#define STAP_PROBE_ASM_TEMPLATE(n) _SDT_ASM_TEMPLATE_##n
+
+
+/* DTrace compatible macro names. */
+#define DTRACE_PROBE(provider,probe) \
+ STAP_PROBE(provider,probe)
+#define DTRACE_PROBE1(provider,probe,parm1) \
+ STAP_PROBE1(provider,probe,parm1)
+#define DTRACE_PROBE2(provider,probe,parm1,parm2) \
+ STAP_PROBE2(provider,probe,parm1,parm2)
+#define DTRACE_PROBE3(provider,probe,parm1,parm2,parm3) \
+ STAP_PROBE3(provider,probe,parm1,parm2,parm3)
+#define DTRACE_PROBE4(provider,probe,parm1,parm2,parm3,parm4) \
+ STAP_PROBE4(provider,probe,parm1,parm2,parm3,parm4)
+#define DTRACE_PROBE5(provider,probe,parm1,parm2,parm3,parm4,parm5) \
+ STAP_PROBE5(provider,probe,parm1,parm2,parm3,parm4,parm5)
+#define DTRACE_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6) \
+ STAP_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6)
+#define DTRACE_PROBE7(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7) \
+ STAP_PROBE7(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7)
+#define DTRACE_PROBE8(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8) \
+ STAP_PROBE8(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8)
+#define DTRACE_PROBE9(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) \
+ STAP_PROBE9(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9)
+#define DTRACE_PROBE10(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10) \
+ STAP_PROBE10(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10)
+#define DTRACE_PROBE11(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10,parm11) \
+ STAP_PROBE11(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10,parm11)
+#define DTRACE_PROBE12(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10,parm11,parm12) \
+ STAP_PROBE12(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10,parm11,parm12)
+
+
+#endif /* sys/sdt.h */
diff --git a/xldd b/xldd
new file mode 100644
index 000000000000..049f709b3314
--- /dev/null
+++ b/xldd
@@ -0,0 +1,369 @@
+#!/bin/bash
+
+# ldd drop-in replacement for cross-compilation toolchains.
+
+# This file is a slightly modified version of xldd.in from
+# crosstool-ng 1.22.0
+
+# In order to use it, copy it in same directory than other
+# toolchain binaries and rename it with same tuple.
+# (i.e. /opt/arm-sysmic-linux-gnueabihf/bin/arm-sysmic-linux-gnueabihf-ldd)
+# Thus, this will automaticaly detect necessary information
+# about your toolchain.
+
+export LC_ALL=C
+version="forked from crosstool-ng 1.22.0"
+# Change it to 64 if necessary
+bits="32"
+sed="${SED:-sed}"
+grep="${GREP:-grep}"
+
+my_name="$( basename "${0}" )"
+prefix="${0%-ldd}"
+gcc="${prefix}-gcc"
+readelf="${prefix}-readelf"
+fake_load_addr_root="$((0xdeadbeef))"
+fake_load_addr_rpath="$((0xdeadc0de))"
+fake_load_addr_sysroot="$((0x8badf00d))"
+ld_library_path="/lib:/usr/lib"
+
+do_error() {
+ printf "%s: %s\n" "${my_name}" "$*" >&2
+}
+
+do_opt_error() {
+ do_error "$@"
+ printf "Try \`%s --help' for more information\n" "${my_name}" >&2
+}
+
+do_trace() {
+ local depth=0
+
+ [ -z "${CT_XLDD_VERBOSE}" ] && return 0
+
+ for((depth=0; "${#FUNCNAME[$((depth+1))]}" != 0; depth++)); do :; done
+ printf "%*s" $((4*(depth-1))) "" >&2
+ printf -- "$@" >&2
+}
+
+show_version() {
+ # Fake a real ldd, just in case some dumb script would check
+ cat <<_EOF_
+ldd (crosstool-NG) ${version}
+Copyright (C) 2010 "Yann E. MORIN" <yann.morin.1998@free.fr>
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+Licensed under the GPLv2, see the file LICENSES in the top-directory of the
+sources for this package.
+_EOF_
+}
+
+show_help() {
+ cat <<_EOF_
+Usage: ${my_name} [OPTION]... --root DIR FILE...
+ --help print this help and exit
+ --version print version information and exit
+ --root dir treat dir as being the root of the target
+ -s, --show-system mark libs from the sysroot with a trailing '[*]'
+ and libs found via RPATH with a trailing '[+]'
+
+_EOF_
+ cat <<_EOF_ |fmt
+${my_name} tries to mimick the behavior of a real native ldd, but can be
+used in a cross-development environment. Here is how it differs from a
+real native ldd:
+
+If the CT_XLDD_VERBOSE variable is set and non-empty, then ${my_name} will
+print a lot of debug messages, explaining how it builds the library
+search path, and how each library was found and why.
+
+The LD_LIBRARY_PATH variable is not used, as it can not reliably be
+guessed except at runtime, and we can't run.
+
+${my_name} does not scan /etc/ld.so.cache, but instead uses /etc/ld.so.conf
+(it understands the include directives therein for libces that have that).
+
+${my_name} also interprets (tries to!) the RPATH/RUNPATH records found in
+the dynamic ELF section. Such paths are searched for only relative to
+the specified root, not from the sysroot (see below). Also, those paths
+are searched for not only for the file they appear in, but also for its
+dependencies.
+
+${my_name} will search the directory specified with --root for libraries
+to resolve the NEEDED tags. If --root is not set, then ${my_name} will
+use the value in the environment variable \${CT_XLDD_ROOT}. If neither
+is set, then this is an error.
+
+If NEEDED libraries can't be found in the specified root directory, then
+${my_name} will also look in the sysroot of the toolchain to see if it
+can find them.
+
+For NEEDED libraries that were found, the output will look like:
+ libneeded.so => /path/to/libneeded.so (0xloadaddr)
+
+and for those that were not found, the output will look like:
+ libneeded.so not found
+
+The paths are relative to the specified root directory, or to the sysroot
+(eg. /lib/libneeded.so, /usr/lib/libneeded.so, and so on...).
+
+The expected load address 'loadaddr' is a faked address to match the output
+of the real ldd, but has no actual meaning (set to some constants for now,
+0x8badf00d for libraries from the sysroot, 0xdeadc0de for those found via
+the RPATH/RUNPATH records, and 0xdeadbeef for others).
+_EOF_
+
+# Unimplemeted yet:
+# -d, --data-relocs process data relocations
+# -r, --function-relocs process data and function relocations
+# -u, --unused print unused direct dependencies
+# -v, --verbose print all information
+
+# See also this thread:
+# http://sourceware.org/ml/crossgcc/2008-09/msg00057.html
+}
+
+# Parse command line options
+root="${CT_XLDD_ROOT}"
+show_system=
+while true; do
+ case "${1}" in
+ --help)
+ show_help
+ exit 0
+ ;;
+ --version)
+ show_version
+ exit 0
+ ;;
+ --root)
+ root="$2"
+ shift
+ ;;
+ --root=*)
+ root="${1#--root=}"
+ ;;
+ --show-system|-s)
+ show_system=1
+ ;;
+ -*)
+ do_opt_error "unrecognized option \`${1}'"
+ exit 1
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+done
+
+# Sanity checks
+sysroot="$( "${gcc}" -print-sysroot 2>/dev/null )"
+if [ -z "${sysroot}" ]; then
+ sysroot="$( "${gcc}" -print-file-name=libc.so 2>/dev/null \
+ |${sed} -r -e 's:/usr/lib/libc.so$::;' \
+ )"
+fi
+if [ -z "${sysroot}" ]; then
+ do_error "unable to find sysroot for \`${gcc}'"
+fi
+
+if [ -z "${root}" ]; then
+ root=${sysroot}
+fi
+if [ ! -d "${root}" ]; then
+ do_error "\`${root}': no such file or directory"
+ exit 1
+fi
+
+do_report_needed_found() {
+ local needed="${1}"
+ local path="${2}"
+ local origin="${3}"
+ local loadaddr
+ local sys
+
+ case "${origin}" in
+ root)
+ loadaddr="${fake_load_addr_root}"
+ ;;
+ rpath)
+ loadaddr="${fake_load_addr_rpath}"
+ if [ -n "${show_system}" ]; then
+ sys=" [+]"
+ fi
+ ;;
+ sysroot)
+ loadaddr="${fake_load_addr_sysroot}"
+ if [ -n "${show_system}" ]; then
+ sys=" [*]"
+ fi
+ ;;
+ esac
+
+ printf "%8s%s => %s (0x%0*x)%s\n" \
+ "" \
+ "${needed}" \
+ "${path}" \
+ "$((bits/4))" \
+ "${loadaddr}" \
+ "${sys}"
+}
+
+# Search a needed file, scanning ${lib_dir} in the root directory
+do_find_needed() {
+ local needed="${1}"
+ local -a list
+ local -a dirs
+ local found
+ local where
+ local base
+ local d i
+
+ do_trace "Searching for '%s'\n" "${needed}"
+
+ # rpath shall come first!
+ list=( \
+ "rpath:${root}" \
+ "root:${root}" \
+ "sysroot:${sysroot}" \
+ )
+
+ for i in "${list[@]}"; do
+ where="${i%%:*}"
+ base="${i#*:}"
+ if [ "${where}" = "rpath" ]; then
+ dirs=( "${search_rpath[@]}" )
+ else
+ dirs=( "${needed_search_path[@]}" )
+ fi
+ for d in "${dirs[@]}"; do
+ do_trace "-> looking in '%s' (%s)\n" "${d}" "${where}"
+ if [ -f "${base}${d}/${needed}" ]; then
+ found="${d}/${needed}"
+ do_trace "---> found\n"
+ break 2
+ fi
+ done
+ done
+
+ if [ -n "${found}" ]; then
+ do_report_needed_found "${needed}" "${found}" "${where}"
+ do_process_file "${base}${found}"
+ else
+ printf "%8s%s not found\n" "" "${needed}"
+ fi
+
+ do_trace "Done searching for '%s'\n" "${needed}"
+}
+
+# Scan a file for all NEEDED tags
+do_process_file() {
+ local file="${1}"
+ local -a save_search_rpath
+ local n m
+ local found
+
+ do_trace "Parsing file '%s'\n" "${file}"
+
+ save_search_rpath=( "${search_rpath[@]}" )
+ for n in $( "${readelf}" -d "${file}" \
+ |"${grep}" -E '\((RPATH|RUNPATH)\)' \
+ |"${sed}" -r -e 's/^.*Library r(|un)path:[[:space:]]+\[(.*)\]$/\2/;'\
+ ); do
+
+ OIFS=$IFS;
+ IFS=":";
+ narray=($n)
+ for subn in "${narray[@]}"; do
+ do_trace "-> adding rpath '%s'\n" "${subn}"
+ search_rpath+=( "${subn}" )
+ done
+ IFS=$OIFS;
+ done
+ do_trace ": search path:\n"
+ for n in "${search_rpath[@]}" "${needed_search_path[@]}"; do
+ do_trace ": - '%s'\n" "${n}"
+ done
+ do_trace ": end search path\n"
+
+ for n in $( "${readelf}" -d "${file}" \
+ |"${grep}" -E '\(NEEDED\)' \
+ |"${sed}" -r -e 's/^.*Shared library:[[:space:]]+\[([^]]+)\].*/\1/;' \
+ ); do
+ found=0
+ for m in "${needed_list[@]}"; do
+ [ "${n}" = "${m}" ] && found=1 && break
+ done
+ if [ ${found} -ne 0 ]; then
+ do_trace "-> skipping already known dependency '%s'\n" "${n}"
+ continue
+ fi
+ do_trace "-> handling new dependency '%s'\n" "${n}"
+ needed_list+=( "${n}" )
+ do_find_needed "${n}"
+ do_trace "-> done handling dependency '%s'\n" "${n}"
+ done
+
+ search_rpath=( "${save_search_rpath[@]}" )
+
+ do_trace "Finished parsing file '%s'\n" "${file}"
+}
+
+# Recursively scan a /etc/ld.so.conf file
+do_scan_etc_ldsoconf() {
+ local ldsoconf="${1}"
+ local g
+ local f
+
+ [ -f "${ldsoconf}" ] || return 0
+ do_trace "Parsing ld.so.conf: '%s'\n" "${ldsoconf}"
+
+ while read line; do
+ case "${line}" in
+ include\ *)
+ g="${root}${line#include }"
+ do_trace "-> handling include directive '%s'\n" "${g}"
+ for f in ${g}; do
+ do_scan_etc_ldsoconf "${f}"
+ done
+ do_trace "-> finished handling include directive '%s'\n" "${g}"
+ ;;
+ \#*|"")
+ ;;
+ *)
+ do_trace "-> adding search dir '%s'\n" "${line}"
+ needed_search_path+=( "${line}" )
+ ;;
+ esac
+ done <"${ldsoconf}"
+
+ do_trace "Finished parsing ld.so.conf: '%s'\n" "${ldsoconf}"
+}
+
+# Build up the full list of search directories
+declare -a needed_search_path
+do_trace "Adding basic lib dirs\n"
+ld_library_path="${ld_library_path}:"
+while [ -n "${ld_library_path}" ]; do
+ d="${ld_library_path%%:*}"
+ if [ -n "${d}" ]; then
+ do_trace "-> adding search dir '%s'\n" "${d}"
+ needed_search_path+=( "${d}" )
+ fi
+ ld_library_path="${ld_library_path#*:}"
+done
+do_trace "Done adding basic lib dirs\n"
+do_trace "Scanning '/etc/ld.so.conf'\n"
+do_scan_etc_ldsoconf "${root}/etc/ld.so.conf"
+do_trace "Done scanning '/etc/ld.so.conf'\n"
+do_trace "Search path:\n"
+for p in "${needed_search_path[@]}"; do
+ do_trace "-> '%s'\n" "${p}"
+done
+
+declare -a needed_list
+declare -a search_rpath
+do_trace "Scanning file '%s'\n" "${1}"
+do_process_file "${1}"
+do_trace "Done scanning file '%s'\n" "${1}"