From abb884883056927e966d2f925e96dc706a6dc1e6 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Thu, 4 Jun 2020 15:40:15 -0400 Subject: [PATCH 01/17] Libunwind v1.5-rc1-28-g9165d2a1 Pull upstream libunwind which supports building on Windows --- src/coreclr/src/pal/src/libunwind/.gitignore | 2 + src/coreclr/src/pal/src/libunwind/.travis.yml | 13 + src/coreclr/src/pal/src/libunwind/README | 2 +- .../src/pal/src/libunwind/acinclude.m4 | 31 - .../src/pal/src/libunwind/aux_/config.guess | 1321 ----- .../src/pal/src/libunwind/aux_/config.sub | 1443 ----- .../src/pal/src/libunwind/aux_/ltmain.sh | 5107 ----------------- .../src/pal/src/libunwind/configure.ac | 22 +- .../src/pal/src/libunwind/include/compiler.h | 2 - .../src/libunwind/include/config.h.cmake.in | 10 + .../src/pal/src/libunwind/include/dwarf-eh.h | 10 + .../src/pal/src/libunwind/include/dwarf.h | 3 +- .../src/libunwind/include/libunwind-aarch64.h | 15 +- .../pal/src/libunwind/include/libunwind-arm.h | 10 + .../pal/src/libunwind/include/libunwind_i.h | 64 +- .../include/tdep-aarch64/libunwind_i.h | 19 +- .../libunwind/include/tdep-arm/libunwind_i.h | 19 +- .../libunwind/include/tdep-hppa/libunwind_i.h | 9 +- .../libunwind/include/tdep-ia64/libunwind_i.h | 7 +- .../src/libunwind/include/tdep-ia64/script.h | 8 +- .../libunwind/include/tdep-mips/libunwind_i.h | 9 +- .../include/tdep-ppc32/libunwind_i.h | 9 +- .../include/tdep-ppc64/libunwind_i.h | 9 +- .../include/tdep-s390x/libunwind_i.h | 9 +- .../libunwind/include/tdep-sh/libunwind_i.h | 9 +- .../include/tdep-tilegx/libunwind_i.h | 9 +- .../libunwind/include/tdep-x86/libunwind_i.h | 9 +- .../include/tdep-x86_64/libunwind_i.h | 23 +- .../src/pal/src/libunwind/include/unwind.h | 5 +- .../src/pal/src/libunwind/include/win/elf.h | 16 + .../pal/src/libunwind/include/win/endian.h | 16 + .../libunwind/include/win/fakestdalign.h.in | 9 + .../libunwind/include/win/fakestdatomic.h.in | 36 + .../src/libunwind/include/win/freebsd-elf32.h | 245 + .../src/libunwind/include/win/freebsd-elf64.h | 252 + .../include/win/freebsd-elf_common.h | 865 +++ .../pal/src/libunwind/include/win/pthread.h | 30 + .../pal/src/libunwind/include/win/signal.h | 40 + .../src/libunwind/include/win/stdatomic.h.in | 36 + .../pal/src/libunwind/include/win/sys/mman.h | 23 + .../src/libunwind/include/win/sys/syscall.h | 11 + .../pal/src/libunwind/include/win/sys/types.h | 19 + .../src/libunwind/include/win/sys/ucontext.h | 42 + .../pal/src/libunwind/include/win/ucontext.h | 13 + .../pal/src/libunwind/include/win/unistd.h | 28 + .../pal/src/libunwind/libunwind-version.txt | 9 +- .../pal/src/libunwind/src/aarch64/Gglobal.c | 6 +- .../src/libunwind/src/aarch64/Ginit_local.c | 2 +- .../src/libunwind/src/aarch64/Ginit_remote.c | 2 +- .../pal/src/libunwind/src/aarch64/Gtrace.c | 4 +- .../pal/src/libunwind/src/arm/Gex_tables.c | 6 +- .../src/pal/src/libunwind/src/arm/Gglobal.c | 6 +- .../pal/src/libunwind/src/arm/Ginit_local.c | 2 +- .../pal/src/libunwind/src/arm/Ginit_remote.c | 2 +- .../src/pal/src/libunwind/src/arm/Gtrace.c | 4 +- .../src/pal/src/libunwind/src/dwarf/Gexpr.c | 45 +- .../src/pal/src/libunwind/src/dwarf/Gparser.c | 8 +- .../src/pal/src/libunwind/src/hppa/Gglobal.c | 6 +- .../pal/src/libunwind/src/hppa/Ginit_local.c | 2 +- .../pal/src/libunwind/src/hppa/Ginit_remote.c | 2 +- .../src/libunwind/src/hppa/get_accessors.c | 2 +- .../src/pal/src/libunwind/src/ia64/Gglobal.c | 4 +- .../pal/src/libunwind/src/ia64/Ginit_local.c | 2 +- .../pal/src/libunwind/src/ia64/Ginit_remote.c | 2 +- .../src/pal/src/libunwind/src/ia64/Gscript.c | 44 +- .../pal/src/libunwind/src/mi/Gget_accessors.c | 3 +- .../src/libunwind/src/mi/Gset_cache_size.c | 2 +- .../libunwind/src/mi/Gset_caching_policy.c | 2 +- .../pal/src/libunwind/src/mi/flush_cache.c | 9 +- .../src/pal/src/libunwind/src/mi/mempool.c | 27 +- .../src/pal/src/libunwind/src/mips/Gglobal.c | 6 +- .../pal/src/libunwind/src/mips/Ginit_local.c | 2 +- .../pal/src/libunwind/src/mips/Ginit_remote.c | 2 +- .../src/pal/src/libunwind/src/os-linux.h | 4 +- .../pal/src/libunwind/src/ppc/Ginit_local.c | 2 +- .../pal/src/libunwind/src/ppc/Ginit_remote.c | 2 +- .../src/pal/src/libunwind/src/ppc32/Gglobal.c | 6 +- .../src/pal/src/libunwind/src/ppc64/Gglobal.c | 6 +- .../src/pal/src/libunwind/src/s390x/Gglobal.c | 6 +- .../pal/src/libunwind/src/s390x/Ginit_local.c | 2 +- .../src/libunwind/src/s390x/Ginit_remote.c | 2 +- .../src/pal/src/libunwind/src/sh/Gglobal.c | 6 +- .../pal/src/libunwind/src/sh/Ginit_local.c | 2 +- .../pal/src/libunwind/src/sh/Ginit_remote.c | 2 +- .../libunwind/src/tilegx/Gcreate_addr_space.c | 17 +- .../pal/src/libunwind/src/tilegx/Gglobal.c | 6 +- .../src/libunwind/src/tilegx/Ginit_local.c | 2 +- .../src/libunwind/src/tilegx/Ginit_remote.c | 2 +- .../libunwind/src/win/pal-single-threaded.c | 114 + .../src/pal/src/libunwind/src/x86/Gglobal.c | 6 +- .../pal/src/libunwind/src/x86/Ginit_local.c | 2 +- .../pal/src/libunwind/src/x86/Ginit_remote.c | 2 +- .../pal/src/libunwind/src/x86_64/Gglobal.c | 13 +- .../src/pal/src/libunwind/src/x86_64/Ginit.c | 40 +- .../src/libunwind/src/x86_64/Ginit_local.c | 2 +- .../src/libunwind/src/x86_64/Ginit_remote.c | 2 +- .../src/pal/src/libunwind/src/x86_64/Gtrace.c | 4 +- 97 files changed, 2080 insertions(+), 8274 deletions(-) delete mode 100644 src/coreclr/src/pal/src/libunwind/aux_/config.guess delete mode 100644 src/coreclr/src/pal/src/libunwind/aux_/config.sub delete mode 100644 src/coreclr/src/pal/src/libunwind/aux_/ltmain.sh create mode 100644 src/coreclr/src/pal/src/libunwind/include/config.h.cmake.in create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/elf.h create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/endian.h create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/fakestdalign.h.in create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/fakestdatomic.h.in create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/freebsd-elf32.h create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/freebsd-elf64.h create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/freebsd-elf_common.h create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/pthread.h create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/signal.h create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/stdatomic.h.in create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/sys/mman.h create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/sys/syscall.h create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/sys/types.h create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/sys/ucontext.h create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/ucontext.h create mode 100644 src/coreclr/src/pal/src/libunwind/include/win/unistd.h create mode 100644 src/coreclr/src/pal/src/libunwind/src/win/pal-single-threaded.c diff --git a/src/coreclr/src/pal/src/libunwind/.gitignore b/src/coreclr/src/pal/src/libunwind/.gitignore index 724a1f4882e2cc..cd3e197c7a6f00 100644 --- a/src/coreclr/src/pal/src/libunwind/.gitignore +++ b/src/coreclr/src/pal/src/libunwind/.gitignore @@ -4,6 +4,7 @@ *.lo *~ *.pc +bin .libs/ .deps/ @@ -15,6 +16,7 @@ Makefile.in INSTALL aclocal.m4 autom4te.cache/ +aux config.log config.status config/ diff --git a/src/coreclr/src/pal/src/libunwind/.travis.yml b/src/coreclr/src/pal/src/libunwind/.travis.yml index 7bf0f8d0638efa..90b828678e8271 100644 --- a/src/coreclr/src/pal/src/libunwind/.travis.yml +++ b/src/coreclr/src/pal/src/libunwind/.travis.yml @@ -21,6 +21,13 @@ linux-s390x: &linux-s390x - ulimit -c unlimited - make check -j32 +windows-remote-only: &windows-remote-only + os: windows + compiler: msvc + script: + - cmake -G "Visual Studio 15 2017" -A ${HOST} -S . -B bin/windows-${HOST}/${TARGET} + - cmake --build bin/windows-${HOST}/${TARGET} + script: - ./autogen.sh - ./configure --target=$TARGET --host=$HOST @@ -32,3 +39,9 @@ script: jobs: include: - <<: *linux-s390x + - <<: *windows-remote-only + env: TARGET=x86_64-linux-gnu HOST=x64 + - <<: *windows-remote-only + env: TARGET=arm-linux-gnueabihf HOST=Win32 + - <<: *windows-remote-only + env: TARGET=aarch64-linux-gnu HOST=x64 diff --git a/src/coreclr/src/pal/src/libunwind/README b/src/coreclr/src/pal/src/libunwind/README index b6d93ae4a68551..0dc8ccf9e741e1 100644 --- a/src/coreclr/src/pal/src/libunwind/README +++ b/src/coreclr/src/pal/src/libunwind/README @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/libunwind/libunwind.svg?branch=master)](https://travis-ci.org/libunwind/libunwind) -This is version 1.5 of the unwind library. This library supports +This is version 1.4 of the unwind library. This library supports several architecture/operating-system combinations: | System | Architecture | Status | diff --git a/src/coreclr/src/pal/src/libunwind/acinclude.m4 b/src/coreclr/src/pal/src/libunwind/acinclude.m4 index 497f7c2f215253..8b137891791fe9 100644 --- a/src/coreclr/src/pal/src/libunwind/acinclude.m4 +++ b/src/coreclr/src/pal/src/libunwind/acinclude.m4 @@ -1,32 +1 @@ -AC_DEFUN([LIBUNWIND___THREAD], -[dnl Check whether the compiler supports the __thread keyword. -if test "x$enable___thread" != xno; then - AC_CACHE_CHECK([for __thread], libc_cv_gcc___thread, - [cat > conftest.c <<\EOF - __thread int a = 42; -EOF - if AC_TRY_COMMAND([${CC-cc} $CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then - libc_cv_gcc___thread=yes - else - libc_cv_gcc___thread=no - fi - rm -f conftest*]) - if test "$libc_cv_gcc___thread" = yes; then - AC_DEFINE(HAVE___THREAD, 1, - [Define to 1 if __thread keyword is supported by the C compiler.]) - fi -else - libc_cv_gcc___thread=no -fi]) -AC_DEFUN([CHECK_ATOMIC_OPS], -[dnl Check whether the system has the atomic_ops package installed. - AC_CHECK_HEADERS(atomic_ops.h) -# -# Don't link against libatomic_ops for now. We don't want libunwind -# to depend on libatomic_ops.so. Fortunately, none of the platforms -# we care about so far need libatomic_ops.a (everything is done via -# inline macros). -# -# AC_CHECK_LIB(atomic_ops, main) -]) diff --git a/src/coreclr/src/pal/src/libunwind/aux_/config.guess b/src/coreclr/src/pal/src/libunwind/aux_/config.guess deleted file mode 100644 index ed2e03b7f2b96b..00000000000000 --- a/src/coreclr/src/pal/src/libunwind/aux_/config.guess +++ /dev/null @@ -1,1321 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002 Free Software Foundation, Inc. - -timestamp='2002-03-20' - -# This file 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; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -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." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - - -dummy=dummy-$$ -trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int dummy(){}" > $dummy.c ; - for c in cc gcc c89 c99 ; do - ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; - if test $? = 0 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - rm -f $dummy.c $dummy.o $dummy.rel ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit 0 ;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - macppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvmeppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mipseb-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sun3:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - alpha:OSF1:*:*) - if test $UNAME_RELEASE = "V4.0"; then - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - fi - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - cat <$dummy.s - .data -\$Lformat: - .byte 37,100,45,37,120,10,0 # "%d-%x\n" - - .text - .globl main - .align 4 - .ent main -main: - .frame \$30,16,\$26,0 - ldgp \$29,0(\$27) - .prologue 1 - .long 0x47e03d80 # implver \$0 - lda \$2,-1 - .long 0x47e20c21 # amask \$2,\$1 - lda \$16,\$Lformat - mov \$0,\$17 - not \$1,\$18 - jsr \$26,printf - ldgp \$29,0(\$26) - mov 0,\$16 - jsr \$26,exit - .end main -EOF - eval $set_cc_for_build - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - case `./$dummy` in - 0-0) - UNAME_MACHINE="alpha" - ;; - 1-0) - UNAME_MACHINE="alphaev5" - ;; - 1-1) - UNAME_MACHINE="alphaev56" - ;; - 1-101) - UNAME_MACHINE="alphapca56" - ;; - 2-303) - UNAME_MACHINE="alphaev6" - ;; - 2-307) - UNAME_MACHINE="alphaev67" - ;; - 2-1307) - UNAME_MACHINE="alphaev68" - ;; - esac - fi - rm -f $dummy.s $dummy - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit 0 ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit 0 ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit 0;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit 0 ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit 0 ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit 0;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit 0 ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit 0 ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit 0 ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit 0 ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy \ - && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit 0 ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit 0 ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit 0 ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit 0 ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit 0 ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit 0 ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit 0 ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit 0 ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit 0 ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit 0 ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit 0 ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo rs6000-ibm-aix3.2.5 - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit 0 ;; - *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit 0 ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit 0 ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit 0 ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit 0 ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit 0 ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy` - if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi - rm -f $dummy.c $dummy - fi ;; - esac - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit 0 ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo unknown-hitachi-hiuxwe2 - exit 0 ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit 0 ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit 0 ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit 0 ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit 0 ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit 0 ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit 0 ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit 0 ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit 0 ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit 0 ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit 0 ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit 0 ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3D:*:*:*) - echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit 0 ;; - x86:Interix*:3*) - echo i386-pc-interix3 - exit 0 ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i386-pc-interix - exit 0 ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit 0 ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - *:GNU:*:*) - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit 0 ;; - arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - rm -f $dummy.c - test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0 - ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit 0 ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit 0 ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit 0 ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac - exit 0 ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit 0 ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit 0 ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit 0 ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit 0 ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #ifdef __INTEL_COMPILER - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - rm -f $dummy.c - test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 - test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 - ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit 0 ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit 0 ;; - i*86:*:5:[78]*) - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit 0 ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` - (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit 0 ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit 0 ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit 0 ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit 0 ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit 0 ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit 0 ;; - M68*:*:R3V[567]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit 0 ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit 0 ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit 0 ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit 0 ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit 0 ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit 0 ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit 0 ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit 0 ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit 0 ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit 0 ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Darwin:*:*) - echo `uname -p`-apple-darwin${UNAME_RELEASE} - exit 0 ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit 0 ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit 0 ;; - NSR-[GKLNPTVW]:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit 0 ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit 0 ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit 0 ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit 0 ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit 0 ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit 0 ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit 0 ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit 0 ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit 0 ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit 0 ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit 0 ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit 0 ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit 0 ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 -rm -f $dummy.c $dummy - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit 0 ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - c34*) - echo c34-convex-bsd - exit 0 ;; - c38*) - echo c38-convex-bsd - exit 0 ;; - c4*) - echo c4-convex-bsd - exit 0 ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/src/coreclr/src/pal/src/libunwind/aux_/config.sub b/src/coreclr/src/pal/src/libunwind/aux_/config.sub deleted file mode 100644 index f3657978c7401e..00000000000000 --- a/src/coreclr/src/pal/src/libunwind/aux_/config.sub +++ /dev/null @@ -1,1443 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002 Free Software Foundation, Inc. - -timestamp='2002-03-07' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file 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; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -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." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit 0;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis) - os= - basic_machine=$1 - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ - | c4x | clipper \ - | d10v | d30v | dsp16xx \ - | fr30 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | m32r | m68000 | m68k | m88k | mcore \ - | mips | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el | mips64vr4300 \ - | mips64vr4300el | mips64vr5000 | mips64vr5000el \ - | mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \ - | mipsisa32 | mipsisa64 \ - | mn10200 | mn10300 \ - | ns16k | ns32k \ - | openrisc | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ - | sh | sh[34] | sh[34]eb | shbe | shle | sh64 \ - | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ - | strongarm \ - | tahoe | thumb | tic80 | tron \ - | v850 | v850e \ - | we32k \ - | x86 | xscale | xstormy16 | xtensa \ - | z8k) - basic_machine=$basic_machine-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armv*-* \ - | avr-* \ - | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c54x-* \ - | clipper-* | cydra-* \ - | d10v-* | d30v-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | m32r-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | mcore-* \ - | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ - | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \ - | mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* | sh64-* \ - | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ - | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ - | v850-* | v850e-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ - | xtensa-* \ - | ymp-* \ - | z8k-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - crds | unos) - basic_machine=m68k-crds - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - mmix*) - basic_machine=mmix-knuth - os=-mmixware - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - or32 | or32-*) - basic_machine=or32-unknown - os=-coff - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon) - basic_machine=i686-pc - ;; - pentiumii | pentium2) - basic_machine=i686-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3d) - basic_machine=alpha-cray - os=-unicos - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - windows32) - basic_machine=i386-pc - os=-windows32-msvcrt - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh3 | sh4 | sh3eb | sh4eb) - basic_machine=sh-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparc | sparcv9 | sparcv9b) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - c4x*) - basic_machine=c4x-none - os=-coff - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto*) - os=-nto-qnx - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-ibm) - os=-aix - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -vxsim* | -vxworks*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/src/coreclr/src/pal/src/libunwind/aux_/ltmain.sh b/src/coreclr/src/pal/src/libunwind/aux_/ltmain.sh deleted file mode 100644 index 6fc690018edbbb..00000000000000 --- a/src/coreclr/src/pal/src/libunwind/aux_/ltmain.sh +++ /dev/null @@ -1,5107 +0,0 @@ -# ltmain.sh - Provide generalized library-building support services. -# NOTE: Changing this file will not affect anything until you rerun configure. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. -# Originally by Gordon Matzigkeit , 1996 -# -# 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; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Check that we have a working $echo. -if test "X$1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X$1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then - # Yippee, $echo works! - : -else - # Restart under the correct shell, and then maybe $echo will work. - exec $SHELL "$0" --no-reexec ${1+"$@"} -fi - -if test "X$1" = X--fallback-echo; then - # used as fallback echo - shift - cat <&2 - echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit 1 -fi - -# Global variables. -mode=$default_mode -nonopt= -prev= -prevopt= -run= -show="$echo" -show_help= -execute_dlfiles= -lo2o="s/\\.lo\$/.${objext}/" -o2lo="s/\\.${objext}\$/.lo/" - -# Parse our command line options once, thoroughly. -while test $# -gt 0 -do - arg="$1" - shift - - case $arg in - -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - execute_dlfiles) - execute_dlfiles="$execute_dlfiles $arg" - ;; - *) - eval "$prev=\$arg" - ;; - esac - - prev= - prevopt= - continue - fi - - # Have we seen a non-optional argument yet? - case $arg in - --help) - show_help=yes - ;; - - --version) - echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" - exit 0 - ;; - - --config) - ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0 - exit 0 - ;; - - --debug) - echo "$progname: enabling shell trace mode" - set -x - ;; - - --dry-run | -n) - run=: - ;; - - --features) - echo "host: $host" - if test "$build_libtool_libs" = yes; then - echo "enable shared libraries" - else - echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then - echo "enable static libraries" - else - echo "disable static libraries" - fi - exit 0 - ;; - - --finish) mode="finish" ;; - - --mode) prevopt="--mode" prev=mode ;; - --mode=*) mode="$optarg" ;; - - --preserve-dup-deps) duplicate_deps="yes" ;; - - --quiet | --silent) - show=: - ;; - - -dlopen) - prevopt="-dlopen" - prev=execute_dlfiles - ;; - - -*) - $echo "$modename: unrecognized option \`$arg'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - - *) - nonopt="$arg" - break - ;; - esac -done - -if test -n "$prevopt"; then - $echo "$modename: option \`$prevopt' requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 -fi - -# If this variable is set in any of the actions, the command in it -# will be execed at the end. This prevents here-documents from being -# left over by shells. -exec_cmd= - -if test -z "$show_help"; then - - # Infer the operation mode. - if test -z "$mode"; then - case $nonopt in - *cc | *++ | gcc* | *-gcc* | g++* | xlc*) - mode=link - for arg - do - case $arg in - -c) - mode=compile - break - ;; - esac - done - ;; - *db | *dbx | *strace | *truss) - mode=execute - ;; - *install*|cp|mv) - mode=install - ;; - *rm) - mode=uninstall - ;; - *) - # If we have no mode, but dlfiles were specified, then do execute mode. - test -n "$execute_dlfiles" && mode=execute - - # Just use the default operation mode. - if test -z "$mode"; then - if test -n "$nonopt"; then - $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 - else - $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 - fi - fi - ;; - esac - fi - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$execute_dlfiles" && test "$mode" != execute; then - $echo "$modename: unrecognized option \`-dlopen'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$modename --help --mode=$mode' for more information." - - # These modes are in order of execution frequency so that they run quickly. - case $mode in - # libtool compile mode - compile) - modename="$modename: compile" - # Get the compilation command and the source file. - base_compile= - prev= - lastarg= - srcfile="$nonopt" - suppress_output= - - user_target=no - for arg - do - case $prev in - "") ;; - xcompiler) - # Aesthetically quote the previous argument. - prev= - lastarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - - case $arg in - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - - # Add the previous argument to base_compile. - if test -z "$base_compile"; then - base_compile="$lastarg" - else - base_compile="$base_compile $lastarg" - fi - continue - ;; - esac - - # Accept any command-line options. - case $arg in - -o) - if test "$user_target" != "no"; then - $echo "$modename: you cannot specify \`-o' more than once" 1>&2 - exit 1 - fi - user_target=next - ;; - - -static) - build_old_libs=yes - continue - ;; - - -prefer-pic) - pic_mode=yes - continue - ;; - - -prefer-non-pic) - pic_mode=no - continue - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Wc,*) - args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` - lastarg= - save_ifs="$IFS"; IFS=',' - for arg in $args; do - IFS="$save_ifs" - - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - lastarg="$lastarg $arg" - done - IFS="$save_ifs" - lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` - - # Add the arguments to base_compile. - if test -z "$base_compile"; then - base_compile="$lastarg" - else - base_compile="$base_compile $lastarg" - fi - continue - ;; - esac - - case $user_target in - next) - # The next one is the -o target name - user_target=yes - continue - ;; - yes) - # We got the output file - user_target=set - libobj="$arg" - continue - ;; - esac - - # Accept the current argument as the source file. - lastarg="$srcfile" - srcfile="$arg" - - # Aesthetically quote the previous argument. - - # Backslashify any backslashes, double quotes, and dollar signs. - # These are the only characters that are still specially - # interpreted inside of double-quoted scrings. - lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` - - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - case $lastarg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - lastarg="\"$lastarg\"" - ;; - esac - - # Add the previous argument to base_compile. - if test -z "$base_compile"; then - base_compile="$lastarg" - else - base_compile="$base_compile $lastarg" - fi - done - - case $user_target in - set) - ;; - no) - # Get the name of the library object. - libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` - ;; - *) - $echo "$modename: you must specify a target with \`-o'" 1>&2 - exit 1 - ;; - esac - - # Recognize several different file suffixes. - # If the user specifies -o file.o, it is replaced with file.lo - xform='[cCFSfmso]' - case $libobj in - *.ada) xform=ada ;; - *.adb) xform=adb ;; - *.ads) xform=ads ;; - *.asm) xform=asm ;; - *.c++) xform=c++ ;; - *.cc) xform=cc ;; - *.cpp) xform=cpp ;; - *.cxx) xform=cxx ;; - *.f90) xform=f90 ;; - *.for) xform=for ;; - esac - - libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` - - case $libobj in - *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; - *) - $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 - exit 1 - ;; - esac - - if test -z "$base_compile"; then - $echo "$modename: you must specify a compilation command" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Delete any leftover library objects. - if test "$build_old_libs" = yes; then - removelist="$obj $libobj" - else - removelist="$libobj" - fi - - $run $rm $removelist - trap "$run $rm $removelist; exit 1" 1 2 15 - - # On Cygwin there's no "real" PIC flag so we must build both object types - case $host_os in - cygwin* | mingw* | pw32* | os2*) - pic_mode=default - ;; - esac - if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then - # non-PIC code in shared libraries is not supported - pic_mode=default - fi - - # Calculate the filename of the output object if compiler does - # not support -o with -c - if test "$compiler_c_o" = no; then - output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} - lockfile="$output_obj.lock" - removelist="$removelist $output_obj $lockfile" - trap "$run $rm $removelist; exit 1" 1 2 15 - else - need_locks=no - lockfile= - fi - - # Lock this critical section if it is needed - # We use this script file to make the link, it avoids creating a new file - if test "$need_locks" = yes; then - until $run ln "$0" "$lockfile" 2>/dev/null; do - $show "Waiting for $lockfile to be removed" - sleep 2 - done - elif test "$need_locks" = warn; then - if test -f "$lockfile"; then - echo "\ -*** ERROR, $lockfile exists and contains: -`cat $lockfile 2>/dev/null` - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit 1 - fi - echo $srcfile > "$lockfile" - fi - - if test -n "$fix_srcfile_path"; then - eval srcfile=\"$fix_srcfile_path\" - fi - - # Only build a PIC object if we are building libtool libraries. - if test "$build_libtool_libs" = yes; then - # Without this assignment, base_compile gets emptied. - fbsd_hideous_sh_bug=$base_compile - - if test "$pic_mode" != no; then - # All platforms use -DPIC, to notify preprocessed assembler code. - command="$base_compile $srcfile $pic_flag -DPIC" - else - # Don't build PIC code - command="$base_compile $srcfile" - fi - if test "$build_old_libs" = yes; then - lo_libobj="$libobj" - dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$dir" = "X$libobj"; then - dir="$objdir" - else - dir="$dir/$objdir" - fi - libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` - - if test -d "$dir"; then - $show "$rm $libobj" - $run $rm $libobj - else - $show "$mkdir $dir" - $run $mkdir $dir - status=$? - if test $status -ne 0 && test ! -d $dir; then - exit $status - fi - fi - fi - if test "$compiler_o_lo" = yes; then - output_obj="$libobj" - command="$command -o $output_obj" - elif test "$compiler_c_o" = yes; then - output_obj="$obj" - command="$command -o $output_obj" - fi - - $run $rm "$output_obj" - $show "$command" - if $run eval "$command"; then : - else - test -n "$output_obj" && $run $rm $removelist - exit 1 - fi - - if test "$need_locks" = warn && - test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then - echo "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit 1 - fi - - # Just move the object if needed, then go on to compile the next one - if test x"$output_obj" != x"$libobj"; then - $show "$mv $output_obj $libobj" - if $run $mv $output_obj $libobj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # If we have no pic_flag, then copy the object into place and finish. - if (test -z "$pic_flag" || test "$pic_mode" != default) && - test "$build_old_libs" = yes; then - # Rename the .lo from within objdir to obj - if test -f $obj; then - $show $rm $obj - $run $rm $obj - fi - - $show "$mv $libobj $obj" - if $run $mv $libobj $obj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - - xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$obj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"` - libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` - # Now arrange that obj and lo_libobj become the same file - $show "(cd $xdir && $LN_S $baseobj $libobj)" - if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then - # Unlock the critical section if it was locked - if test "$need_locks" != no; then - $run $rm "$lockfile" - fi - exit 0 - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # Allow error messages only from the first compilation. - suppress_output=' >/dev/null 2>&1' - fi - - # Only build a position-dependent object if we build old libraries. - if test "$build_old_libs" = yes; then - if test "$pic_mode" != yes; then - # Don't build PIC code - command="$base_compile $srcfile" - else - # All platforms use -DPIC, to notify preprocessed assembler code. - command="$base_compile $srcfile $pic_flag -DPIC" - fi - if test "$compiler_c_o" = yes; then - command="$command -o $obj" - output_obj="$obj" - fi - - # Suppress compiler output if we already did a PIC compilation. - command="$command$suppress_output" - $run $rm "$output_obj" - $show "$command" - if $run eval "$command"; then : - else - $run $rm $removelist - exit 1 - fi - - if test "$need_locks" = warn && - test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then - echo "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit 1 - fi - - # Just move the object if needed - if test x"$output_obj" != x"$obj"; then - $show "$mv $output_obj $obj" - if $run $mv $output_obj $obj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # Create an invalid libtool object if no PIC, so that we do not - # accidentally link it into a program. - if test "$build_libtool_libs" != yes; then - $show "echo timestamp > $libobj" - $run eval "echo timestamp > \$libobj" || exit $? - else - # Move the .lo from within objdir - $show "$mv $libobj $lo_libobj" - if $run $mv $libobj $lo_libobj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - fi - - # Unlock the critical section if it was locked - if test "$need_locks" != no; then - $run $rm "$lockfile" - fi - - exit 0 - ;; - - # libtool link mode - link | relink) - modename="$modename: link" - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - # It is impossible to link a dll without this setting, and - # we shouldn't force the makefile maintainer to figure out - # which system we are compiling for in order to pass an extra - # flag for every libtool invokation. - # allow_undefined=no - - # FIXME: Unfortunately, there are problems with the above when trying - # to make a dll which has undefined symbols, in which case not - # even a static library is built. For now, we need to specify - # -no-undefined on the libtool link line when we can be certain - # that all symbols are satisfied, otherwise we get a static library. - allow_undefined=yes - ;; - *) - allow_undefined=yes - ;; - esac - libtool_args="$nonopt" - compile_command="$nonopt" - finalize_command="$nonopt" - - compile_rpath= - finalize_rpath= - compile_shlibpath= - finalize_shlibpath= - convenience= - old_convenience= - deplibs= - old_deplibs= - compiler_flags= - linker_flags= - dllsearchpath= - lib_search_path=`pwd` - inst_prefix_dir= - - avoid_version=no - dlfiles= - dlprefiles= - dlself=no - export_dynamic=no - export_symbols= - export_symbols_regex= - generated= - libobjs= - ltlibs= - module=no - no_install=no - objs= - prefer_static_libs=no - preload=no - prev= - prevarg= - release= - rpath= - xrpath= - perm_rpath= - temp_rpath= - thread_safe=no - vinfo= - - # We need to know -static, to get the right output filenames. - for arg - do - case $arg in - -all-static | -static) - if test "X$arg" = "X-all-static"; then - if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then - $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 - fi - if test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - else - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - fi - build_libtool_libs=no - build_old_libs=yes - prefer_static_libs=yes - break - ;; - esac - done - - # See if our shared archives depend on static archives. - test -n "$old_archive_from_new_cmds" && build_old_libs=yes - - # Go through the arguments, transforming them on the way. - while test $# -gt 0; do - arg="$1" - shift - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test - ;; - *) qarg=$arg ;; - esac - libtool_args="$libtool_args $qarg" - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - output) - compile_command="$compile_command @OUTPUT@" - finalize_command="$finalize_command @OUTPUT@" - ;; - esac - - case $prev in - dlfiles|dlprefiles) - if test "$preload" = no; then - # Add the symbol object into the linking commands. - compile_command="$compile_command @SYMFILE@" - finalize_command="$finalize_command @SYMFILE@" - preload=yes - fi - case $arg in - *.la | *.lo) ;; # We handle these cases below. - force) - if test "$dlself" = no; then - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - self) - if test "$prev" = dlprefiles; then - dlself=yes - elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then - dlself=yes - else - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - *) - if test "$prev" = dlfiles; then - dlfiles="$dlfiles $arg" - else - dlprefiles="$dlprefiles $arg" - fi - prev= - continue - ;; - esac - ;; - expsyms) - export_symbols="$arg" - if test ! -f "$arg"; then - $echo "$modename: symbol file \`$arg' does not exist" - exit 1 - fi - prev= - continue - ;; - expsyms_regex) - export_symbols_regex="$arg" - prev= - continue - ;; - inst_prefix) - inst_prefix_dir="$arg" - prev= - continue - ;; - release) - release="-$arg" - prev= - continue - ;; - rpath | xrpath) - # We need an absolute path. - case $arg in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - $echo "$modename: only absolute run-paths are allowed" 1>&2 - exit 1 - ;; - esac - if test "$prev" = rpath; then - case "$rpath " in - *" $arg "*) ;; - *) rpath="$rpath $arg" ;; - esac - else - case "$xrpath " in - *" $arg "*) ;; - *) xrpath="$xrpath $arg" ;; - esac - fi - prev= - continue - ;; - xcompiler) - compiler_flags="$compiler_flags $qarg" - prev= - compile_command="$compile_command $qarg" - finalize_command="$finalize_command $qarg" - continue - ;; - xlinker) - linker_flags="$linker_flags $qarg" - compiler_flags="$compiler_flags $wl$qarg" - prev= - compile_command="$compile_command $wl$qarg" - finalize_command="$finalize_command $wl$qarg" - continue - ;; - *) - eval "$prev=\"\$arg\"" - prev= - continue - ;; - esac - fi # test -n $prev - - prevarg="$arg" - - case $arg in - -all-static) - if test -n "$link_static_flag"; then - compile_command="$compile_command $link_static_flag" - finalize_command="$finalize_command $link_static_flag" - fi - continue - ;; - - -allow-undefined) - # FIXME: remove this flag sometime in the future. - $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 - continue - ;; - - -avoid-version) - avoid_version=yes - continue - ;; - - -dlopen) - prev=dlfiles - continue - ;; - - -dlpreopen) - prev=dlprefiles - continue - ;; - - -export-dynamic) - export_dynamic=yes - continue - ;; - - -export-symbols | -export-symbols-regex) - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - $echo "$modename: more than one -exported-symbols argument is not allowed" - exit 1 - fi - if test "X$arg" = "X-export-symbols"; then - prev=expsyms - else - prev=expsyms_regex - fi - continue - ;; - - -inst-prefix-dir) - prev=inst_prefix - continue - ;; - - # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* - # so, if we see these flags be careful not to treat them like -L - -L[A-Z][A-Z]*:*) - case $with_gcc/$host in - no/*-*-irix* | no/*-*-nonstopux*) - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - ;; - esac - continue - ;; - - -L*) - dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 - exit 1 - fi - dir="$absdir" - ;; - esac - case "$deplibs " in - *" -L$dir "*) ;; - *) - deplibs="$deplibs -L$dir" - lib_search_path="$lib_search_path $dir" - ;; - esac - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - case :$dllsearchpath: in - *":$dir:"*) ;; - *) dllsearchpath="$dllsearchpath:$dir";; - esac - ;; - esac - continue - ;; - - -l*) - if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then - case $host in - *-*-cygwin* | *-*-pw32* | *-*-beos*) - # These systems don't actually have a C or math library (as such) - continue - ;; - *-*-mingw* | *-*-os2*) - # These systems don't actually have a C library (as such) - test "X$arg" = "X-lc" && continue - ;; - *-*-openbsd* | *-*-freebsd*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; - esac - elif test "X$arg" = "X-lc_r"; then - case $host in - *-*-openbsd* | *-*-freebsd*) - # Do not include libc_r directly, use -pthread flag. - continue - ;; - esac - fi - deplibs="$deplibs $arg" - continue - ;; - - -module) - module=yes - continue - ;; - - -no-fast-install) - fast_install=no - continue - ;; - - -no-install) - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - # The PATH hackery in wrapper scripts is required on Windows - # in order for the loader to find any dlls it needs. - $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 - $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 - fast_install=no - ;; - *) no_install=yes ;; - esac - continue - ;; - - -no-undefined) - allow_undefined=no - continue - ;; - - -o) prev=output ;; - - -release) - prev=release - continue - ;; - - -rpath) - prev=rpath - continue - ;; - - -R) - prev=xrpath - continue - ;; - - -R*) - dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - $echo "$modename: only absolute run-paths are allowed" 1>&2 - exit 1 - ;; - esac - case "$xrpath " in - *" $dir "*) ;; - *) xrpath="$xrpath $dir" ;; - esac - continue - ;; - - -static) - # The effects of -static are defined in a previous loop. - # We used to do the same as -all-static on platforms that - # didn't have a PIC flag, but the assumption that the effects - # would be equivalent was wrong. It would break on at least - # Digital Unix and AIX. - continue - ;; - - -thread-safe) - thread_safe=yes - continue - ;; - - -version-info) - prev=vinfo - continue - ;; - - -Wc,*) - args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - case $flag in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - flag="\"$flag\"" - ;; - esac - arg="$arg $wl$flag" - compiler_flags="$compiler_flags $flag" - done - IFS="$save_ifs" - arg=`$echo "X$arg" | $Xsed -e "s/^ //"` - ;; - - -Wl,*) - args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - case $flag in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - flag="\"$flag\"" - ;; - esac - arg="$arg $wl$flag" - compiler_flags="$compiler_flags $wl$flag" - linker_flags="$linker_flags $flag" - done - IFS="$save_ifs" - arg=`$echo "X$arg" | $Xsed -e "s/^ //"` - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Xlinker) - prev=xlinker - continue - ;; - - # Some other compiler flag. - -* | +*) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - ;; - - *.lo | *.$objext) - # A library or standard object. - if test "$prev" = dlfiles; then - # This file was specified with -dlopen. - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - dlfiles="$dlfiles $arg" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"` - prev= - else - case $arg in - *.lo) libobjs="$libobjs $arg" ;; - *) objs="$objs $arg" ;; - esac - fi - ;; - - *.$libext) - # An archive. - deplibs="$deplibs $arg" - old_deplibs="$old_deplibs $arg" - continue - ;; - - *.la) - # A libtool-controlled library. - - if test "$prev" = dlfiles; then - # This library was specified with -dlopen. - dlfiles="$dlfiles $arg" - prev= - elif test "$prev" = dlprefiles; then - # The library was specified with -dlpreopen. - dlprefiles="$dlprefiles $arg" - prev= - else - deplibs="$deplibs $arg" - fi - continue - ;; - - # Some other compiler argument. - *) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - ;; - esac # arg - - # Now actually substitute the argument into the commands. - if test -n "$arg"; then - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - fi - done # argument parsing loop - - if test -n "$prev"; then - $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then - eval arg=\"$export_dynamic_flag_spec\" - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - fi - - # calculate the name of the file, without its directory - outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` - libobjs_save="$libobjs" - - if test -n "$shlibpath_var"; then - # get the directories listed in $shlibpath_var - eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` - else - shlib_search_path= - fi - eval sys_lib_search_path=\"$sys_lib_search_path_spec\" - eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" - - output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` - if test "X$output_objdir" = "X$output"; then - output_objdir="$objdir" - else - output_objdir="$output_objdir/$objdir" - fi - # Create the object directory. - if test ! -d $output_objdir; then - $show "$mkdir $output_objdir" - $run $mkdir $output_objdir - status=$? - if test $status -ne 0 && test ! -d $output_objdir; then - exit $status - fi - fi - - # Determine the type of output - case $output in - "") - $echo "$modename: you must specify an output file" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - *.$libext) linkmode=oldlib ;; - *.lo | *.$objext) linkmode=obj ;; - *.la) linkmode=lib ;; - *) linkmode=prog ;; # Anything else should be a program. - esac - - specialdeplibs= - libs= - # Find all interdependent deplibs by searching for libraries - # that are linked more than once (e.g. -la -lb -la) - for deplib in $deplibs; do - if test "X$duplicate_deps" = "Xyes" ; then - case "$libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - libs="$libs $deplib" - done - deplibs= - newdependency_libs= - newlib_search_path= - need_relink=no # whether we're linking any uninstalled libtool libraries - notinst_deplibs= # not-installed libtool libraries - notinst_path= # paths that contain not-installed libtool libraries - case $linkmode in - lib) - passes="conv link" - for file in $dlfiles $dlprefiles; do - case $file in - *.la) ;; - *) - $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 - exit 1 - ;; - esac - done - ;; - prog) - compile_deplibs= - finalize_deplibs= - alldeplibs=no - newdlfiles= - newdlprefiles= - passes="conv scan dlopen dlpreopen link" - ;; - *) passes="conv" - ;; - esac - for pass in $passes; do - if test $linkmode = prog; then - # Determine which files to process - case $pass in - dlopen) - libs="$dlfiles" - save_deplibs="$deplibs" # Collect dlpreopened libraries - deplibs= - ;; - dlpreopen) libs="$dlprefiles" ;; - link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; - esac - fi - for deplib in $libs; do - lib= - found=no - case $deplib in - -l*) - if test $linkmode = oldlib && test $linkmode = obj; then - $echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2 - continue - fi - if test $pass = conv; then - deplibs="$deplib $deplibs" - continue - fi - name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` - for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do - # Search the libtool library - lib="$searchdir/lib${name}.la" - if test -f "$lib"; then - found=yes - break - fi - done - if test "$found" != yes; then - # deplib doesn't seem to be a libtool library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test $linkmode = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - fi - ;; # -l - -L*) - case $linkmode in - lib) - deplibs="$deplib $deplibs" - test $pass = conv && continue - newdependency_libs="$deplib $newdependency_libs" - newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` - ;; - prog) - if test $pass = conv; then - deplibs="$deplib $deplibs" - continue - fi - if test $pass = scan; then - deplibs="$deplib $deplibs" - newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - ;; - *) - $echo "$modename: warning: \`-L' is ignored for archives/objects: $deplib" 1>&2 - ;; - esac # linkmode - continue - ;; # -L - -R*) - if test $pass = link; then - dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` - # Make sure the xrpath contains only unique directories. - case "$xrpath " in - *" $dir "*) ;; - *) xrpath="$xrpath $dir" ;; - esac - fi - deplibs="$deplib $deplibs" - continue - ;; - *.la) lib="$deplib" ;; - *.$libext) - if test $pass = conv; then - deplibs="$deplib $deplibs" - continue - fi - case $linkmode in - lib) - if test "$deplibs_check_method" != pass_all; then - echo - echo "*** Warning: Trying to link with static lib archive $deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because the file extensions .$libext of this argument makes me believe" - echo "*** that it is just a static archive that I should not used here." - else - echo - echo "*** Warning: Linking the shared library $output against the" - echo "*** static library $deplib is not portable!" - deplibs="$deplib $deplibs" - fi - continue - ;; - prog) - if test $pass != link; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - continue - ;; - esac # linkmode - ;; # *.$libext - *.lo | *.$objext) - if test $pass = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlopen support or we're linking statically, - # we need to preload. - newdlprefiles="$newdlprefiles $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - newdlfiles="$newdlfiles $deplib" - fi - continue - ;; - %DEPLIBS%) - alldeplibs=yes - continue - ;; - esac # case $deplib - if test $found = yes || test -f "$lib"; then : - else - $echo "$modename: cannot find the library \`$lib'" 1>&2 - exit 1 - fi - - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit 1 - fi - - ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` - test "X$ladir" = "X$lib" && ladir="." - - dlname= - dlopen= - dlpreopen= - libdir= - library_names= - old_library= - # If the library was installed with an old release of libtool, - # it will not redefine variable installed. - installed=yes - - # Read the .la file - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan" || - { test $linkmode = oldlib && test $linkmode = obj; }; then - # Add dl[pre]opened files of deplib - test -n "$dlopen" && dlfiles="$dlfiles $dlopen" - test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" - fi - - if test $pass = conv; then - # Only check for convenience libraries - deplibs="$lib $deplibs" - if test -z "$libdir"; then - if test -z "$old_library"; then - $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 - exit 1 - fi - # It is a libtool convenience library, so add in its objects. - convenience="$convenience $ladir/$objdir/$old_library" - old_convenience="$old_convenience $ladir/$objdir/$old_library" - tmp_libs= - for deplib in $dependency_libs; do - deplibs="$deplib $deplibs" - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done - elif test $linkmode != prog && test $linkmode != lib; then - $echo "$modename: \`$lib' is not a convenience library" 1>&2 - exit 1 - fi - continue - fi # $pass = conv - - # Get the name of the library we link against. - linklib= - for l in $old_library $library_names; do - linklib="$l" - done - if test -z "$linklib"; then - $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 - exit 1 - fi - - # This library was specified with -dlopen. - if test $pass = dlopen; then - if test -z "$libdir"; then - $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 - exit 1 - fi - if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlname, no dlopen support or we're linking - # statically, we need to preload. - dlprefiles="$dlprefiles $lib" - else - newdlfiles="$newdlfiles $lib" - fi - continue - fi # $pass = dlopen - - # We need an absolute path. - case $ladir in - [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; - *) - abs_ladir=`cd "$ladir" && pwd` - if test -z "$abs_ladir"; then - $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 - $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 - abs_ladir="$ladir" - fi - ;; - esac - laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - - # Find the relevant object directory and library name. - if test "X$installed" = Xyes; then - if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then - $echo "$modename: warning: library \`$lib' was moved." 1>&2 - dir="$ladir" - absdir="$abs_ladir" - libdir="$abs_ladir" - else - dir="$libdir" - absdir="$libdir" - fi - else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" - # Remove this search path later - notinst_path="$notinst_path $abs_ladir" - fi # $installed = yes - name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - - # This library was specified with -dlpreopen. - if test $pass = dlpreopen; then - if test -z "$libdir"; then - $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 - exit 1 - fi - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - newdlprefiles="$newdlprefiles $dir/$old_library" - # Otherwise, use the dlname, so that lt_dlopen finds it. - elif test -n "$dlname"; then - newdlprefiles="$newdlprefiles $dir/$dlname" - else - newdlprefiles="$newdlprefiles $dir/$linklib" - fi - fi # $pass = dlpreopen - - if test -z "$libdir"; then - # Link the convenience library - if test $linkmode = lib; then - deplibs="$dir/$old_library $deplibs" - elif test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$dir/$old_library $compile_deplibs" - finalize_deplibs="$dir/$old_library $finalize_deplibs" - else - deplibs="$lib $deplibs" - fi - continue - fi - - if test $linkmode = prog && test $pass != link; then - newlib_search_path="$newlib_search_path $ladir" - deplibs="$lib $deplibs" - - linkalldeplibs=no - if test "$link_all_deplibs" != no || test -z "$library_names" || - test "$build_libtool_libs" = no; then - linkalldeplibs=yes - fi - - tmp_libs= - for deplib in $dependency_libs; do - case $deplib in - -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test - esac - # Need to link against all dependency_libs? - if test $linkalldeplibs = yes; then - deplibs="$deplib $deplibs" - else - # Need to hardcode shared library paths - # or/and link against static libraries - newdependency_libs="$deplib $newdependency_libs" - fi - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done # for deplib - continue - fi # $linkmode = prog... - - link_static=no # Whether the deplib will be linked statically - if test -n "$library_names" && - { test "$prefer_static_libs" = no || test -z "$old_library"; }; then - # Link against this shared library - - if test "$linkmode,$pass" = "prog,link" || - { test $linkmode = lib && test $hardcode_into_libs = yes; }; then - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) compile_rpath="$compile_rpath $absdir" - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" - esac - ;; - esac - if test $linkmode = prog; then - # We need to hardcode the library path - if test -n "$shlibpath_var"; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath " in - *" $dir "*) ;; - *" $absdir "*) ;; - *) temp_rpath="$temp_rpath $dir" ;; - esac - fi - fi - fi # $linkmode,$pass = prog,link... - - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - - if test "$installed" = no; then - notinst_deplibs="$notinst_deplibs $lib" - need_relink=yes - fi - - if test -n "$old_archive_from_expsyms_cmds"; then - # figure out the soname - set dummy $library_names - realname="$2" - shift; shift - libname=`eval \\$echo \"$libname_spec\"` - # use dlname if we got it. it's perfectly good, no? - if test -n "$dlname"; then - soname="$dlname" - elif test -n "$soname_spec"; then - # bleh windows - case $host in - *cygwin*) - major=`expr $current - $age` - versuffix="-$major" - ;; - esac - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - - # Make a new name for the extract_expsyms_cmds to use - soroot="$soname" - soname=`echo $soroot | ${SED} -e 's/^.*\///'` - newlib="libimp-`echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" - - # If the library has no export list, then create one now - if test -f "$output_objdir/$soname-def"; then : - else - $show "extracting exported symbol list from \`$soname'" - save_ifs="$IFS"; IFS='~' - eval cmds=\"$extract_expsyms_cmds\" - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Create $newlib - if test -f "$output_objdir/$newlib"; then :; else - $show "generating import library for \`$soname'" - save_ifs="$IFS"; IFS='~' - eval cmds=\"$old_archive_from_expsyms_cmds\" - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - # make sure the library variables are pointing to the new library - dir=$output_objdir - linklib=$newlib - fi # test -n $old_archive_from_expsyms_cmds - - if test $linkmode = prog || test "$mode" != relink; then - add_shlibpath= - add_dir= - add= - lib_linked=yes - case $hardcode_action in - immediate | unsupported) - if test "$hardcode_direct" = no; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = no; then - case $host in - *-*-sunos*) add_shlibpath="$dir" ;; - esac - add_dir="-L$dir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = no; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - relink) - if test "$hardcode_direct" = yes; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$dir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case "$libdir" in - [\/]*) - add_dir="-L$inst_prefix_dir$libdir $add_dir" - ;; - esac - fi - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - *) lib_linked=no ;; - esac - - if test "$lib_linked" != yes; then - $echo "$modename: configuration error: unsupported hardcode properties" - exit 1 - fi - - if test -n "$add_shlibpath"; then - case :$compile_shlibpath: in - *":$add_shlibpath:"*) ;; - *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; - esac - fi - if test $linkmode = prog; then - test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" - test -n "$add" && compile_deplibs="$add $compile_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - if test "$hardcode_direct" != yes && \ - test "$hardcode_minus_L" != yes && \ - test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - fi - fi - fi - - if test $linkmode = prog || test "$mode" = relink; then - add_shlibpath= - add_dir= - add= - # Finalize command for both is simple: just hardcode it. - if test "$hardcode_direct" = yes; then - add="$libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$libdir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - add="-l$name" - else - # We cannot seem to hardcode it, guess we'll fake it. - add_dir="-L$libdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case "$libdir" in - [\/]*) - add_dir="-L$inst_prefix_dir$libdir $add_dir" - ;; - esac - fi - add="-l$name" - fi - - if test $linkmode = prog; then - test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" - test -n "$add" && finalize_deplibs="$add $finalize_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - fi - fi - elif test $linkmode = prog; then - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - - # Try to link the static library - # Here we assume that one of hardcode_direct or hardcode_minus_L - # is not unsupported. This is valid on all known static and - # shared platforms. - if test "$hardcode_direct" != unsupported; then - test -n "$old_library" && linklib="$old_library" - compile_deplibs="$dir/$linklib $compile_deplibs" - finalize_deplibs="$dir/$linklib $finalize_deplibs" - else - compile_deplibs="-l$name -L$dir $compile_deplibs" - finalize_deplibs="-l$name -L$dir $finalize_deplibs" - fi - elif test "$build_libtool_libs" = yes; then - # Not a shared library - if test "$deplibs_check_method" != pass_all; then - # We're trying link a shared library against a static one - # but the system doesn't support it. - - # Just print a warning and add the library to dependency_libs so - # that the program can be linked against the static library. - echo - echo "*** Warning: This system can not link to static lib archive $lib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." - if test "$module" = yes; then - echo "*** But as you try to build a module library, libtool will still create " - echo "*** a static module, that should work as long as the dlopening application" - echo "*** is linked with the -dlopen flag to resolve symbols at runtime." - if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - else - convenience="$convenience $dir/$old_library" - old_convenience="$old_convenience $dir/$old_library" - deplibs="$dir/$old_library $deplibs" - link_static=yes - fi - fi # link shared/static library? - - if test $linkmode = lib; then - if test -n "$dependency_libs" && - { test $hardcode_into_libs != yes || test $build_old_libs = yes || - test $link_static = yes; }; then - # Extract -R from dependency_libs - temp_deplibs= - for libdir in $dependency_libs; do - case $libdir in - -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` - case " $xrpath " in - *" $temp_xrpath "*) ;; - *) xrpath="$xrpath $temp_xrpath";; - esac;; - *) temp_deplibs="$temp_deplibs $libdir";; - esac - done - dependency_libs="$temp_deplibs" - fi - - newlib_search_path="$newlib_search_path $absdir" - # Link against this library - test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" - # ... and its dependency_libs - tmp_libs= - for deplib in $dependency_libs; do - newdependency_libs="$deplib $newdependency_libs" - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done - - if test $link_all_deplibs != no; then - # Add the search paths of all dependency libraries - for deplib in $dependency_libs; do - case $deplib in - -L*) path="$deplib" ;; - *.la) - dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$deplib" && dir="." - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 - absdir="$dir" - fi - ;; - esac - if grep "^installed=no" $deplib > /dev/null; then - path="-L$absdir/$objdir" - else - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 - exit 1 - fi - if test "$absdir" != "$libdir"; then - $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 - fi - path="-L$absdir" - fi - ;; - *) continue ;; - esac - case " $deplibs " in - *" $path "*) ;; - *) deplibs="$deplibs $path" ;; - esac - done - fi # link_all_deplibs != no - fi # linkmode = lib - done # for deplib in $libs - if test $pass = dlpreopen; then - # Link the dlpreopened libraries before other libraries - for deplib in $save_deplibs; do - deplibs="$deplib $deplibs" - done - fi - if test $pass != dlopen; then - test $pass != scan && dependency_libs="$newdependency_libs" - if test $pass != conv; then - # Make sure lib_search_path contains only unique directories. - lib_search_path= - for dir in $newlib_search_path; do - case "$lib_search_path " in - *" $dir "*) ;; - *) lib_search_path="$lib_search_path $dir" ;; - esac - done - newlib_search_path= - fi - - if test "$linkmode,$pass" != "prog,link"; then - vars="deplibs" - else - vars="compile_deplibs finalize_deplibs" - fi - for var in $vars dependency_libs; do - # Add libraries to $var in reverse order - eval tmp_libs=\"\$$var\" - new_libs= - for deplib in $tmp_libs; do - case $deplib in - -L*) new_libs="$deplib $new_libs" ;; - *) - case " $specialdeplibs " in - *" $deplib "*) new_libs="$deplib $new_libs" ;; - *) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$deplib $new_libs" ;; - esac - ;; - esac - ;; - esac - done - tmp_libs= - for deplib in $new_libs; do - case $deplib in - -L*) - case " $tmp_libs " in - *" $deplib "*) ;; - *) tmp_libs="$tmp_libs $deplib" ;; - esac - ;; - *) tmp_libs="$tmp_libs $deplib" ;; - esac - done - eval $var=\"$tmp_libs\" - done # for var - fi - if test "$pass" = "conv" && - { test "$linkmode" = "lib" || test "$linkmode" = "prog"; }; then - libs="$deplibs" # reset libs - deplibs= - fi - done # for pass - if test $linkmode = prog; then - dlfiles="$newdlfiles" - dlprefiles="$newdlprefiles" - fi - - case $linkmode in - oldlib) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 - fi - - if test -n "$rpath"; then - $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 - fi - - if test -n "$xrpath"; then - $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 - fi - - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 - fi - - # Now set the variables for building old libraries. - build_libtool_libs=no - oldlibs="$output" - objs="$objs$old_deplibs" - ;; - - lib) - # Make sure we only generate libraries of the form `libNAME.la'. - case $outputname in - lib*) - name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - eval libname=\"$libname_spec\" - ;; - *) - if test "$module" = no; then - $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - if test "$need_lib_prefix" != no; then - # Add the "lib" prefix for modules if required - name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` - eval libname=\"$libname_spec\" - else - libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` - fi - ;; - esac - - if test -n "$objs"; then - if test "$deplibs_check_method" != pass_all; then - $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 - exit 1 - else - echo - echo "*** Warning: Linking the shared library $output against the non-libtool" - echo "*** objects $objs is not portable!" - libobjs="$libobjs $objs" - fi - fi - - if test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 - fi - - set dummy $rpath - if test $# -gt 2; then - $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 - fi - install_libdir="$2" - - oldlibs= - if test -z "$rpath"; then - if test "$build_libtool_libs" = yes; then - # Building a libtool convenience library. - libext=al - oldlibs="$output_objdir/$libname.$libext $oldlibs" - build_libtool_libs=convenience - build_old_libs=yes - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 - fi - else - - # Parse the version information argument. - save_ifs="$IFS"; IFS=':' - set dummy $vinfo 0 0 0 - IFS="$save_ifs" - - if test -n "$8"; then - $echo "$modename: too many parameters to \`-version-info'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - current="$2" - revision="$3" - age="$4" - - # Check that each of the things are valid numbers. - case $current in - 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; - *) - $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - case $revision in - 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; - *) - $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - case $age in - 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; - *) - $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - if test $age -gt $current; then - $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - fi - - # Calculate the version variables. - major= - versuffix= - verstring= - case $version_type in - none) ;; - - darwin) - # Like Linux, but with the current version available in - # verstring for coding it into the library header - major=.`expr $current - $age` - versuffix="$major.$age.$revision" - # Darwin ld doesn't like 0 for these options... - minor_current=`expr $current + 1` - verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" - ;; - - freebsd-aout) - major=".$current" - versuffix=".$current.$revision"; - ;; - - freebsd-elf) - major=".$current" - versuffix=".$current"; - ;; - - irix | nonstopux) - major=`expr $current - $age + 1` - - case $version_type in - nonstopux) verstring_prefix=nonstopux ;; - *) verstring_prefix=sgi ;; - esac - verstring="$verstring_prefix$major.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$revision - while test $loop != 0; do - iface=`expr $revision - $loop` - loop=`expr $loop - 1` - verstring="$verstring_prefix$major.$iface:$verstring" - done - - # Before this point, $major must not contain `.'. - major=.$major - versuffix="$major.$revision" - ;; - - linux) - major=.`expr $current - $age` - versuffix="$major.$age.$revision" - ;; - - osf) - major=.`expr $current - $age` - versuffix=".$current.$age.$revision" - verstring="$current.$age.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$age - while test $loop != 0; do - iface=`expr $current - $loop` - loop=`expr $loop - 1` - verstring="$verstring:${iface}.0" - done - - # Make executables depend on our current version. - verstring="$verstring:${current}.0" - ;; - - sunos) - major=".$current" - versuffix=".$current.$revision" - ;; - - windows) - # Use '-' rather than '.', since we only want one - # extension on DOS 8.3 filesystems. - major=`expr $current - $age` - versuffix="-$major" - ;; - - *) - $echo "$modename: unknown library version type \`$version_type'" 1>&2 - echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit 1 - ;; - esac - - # Clear the version info if we defaulted, and they specified a release. - if test -z "$vinfo" && test -n "$release"; then - major= - verstring="0.0" - case $version_type in - darwin) - # we can't check for "0.0" in archive_cmds due to quoting - # problems, so we reset it completely - verstring="" - ;; - *) - verstring="0.0" - ;; - esac - if test "$need_version" = no; then - versuffix= - else - versuffix=".0.0" - fi - fi - - # Remove version info from name if versioning should be avoided - if test "$avoid_version" = yes && test "$need_version" = no; then - major= - versuffix= - verstring="" - fi - - # Check to see if the archive will have undefined symbols. - if test "$allow_undefined" = yes; then - if test "$allow_undefined_flag" = unsupported; then - $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 - build_libtool_libs=no - build_old_libs=yes - fi - else - # Don't allow undefined symbols. - allow_undefined_flag="$no_undefined_flag" - fi - fi - - if test "$mode" != relink; then - # Remove our outputs. - $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*" - $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.* - fi - - # Now set the variables for building old libraries. - if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then - oldlibs="$oldlibs $output_objdir/$libname.$libext" - - # Transform .lo files to .o files. - oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` - fi - - # Eliminate all temporary directories. - for path in $notinst_path; do - lib_search_path=`echo "$lib_search_path " | ${SED} -e 's% $path % %g'` - deplibs=`echo "$deplibs " | ${SED} -e 's% -L$path % %g'` - dependency_libs=`echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'` - done - - if test -n "$xrpath"; then - # If the user specified any rpath flags, then add them. - temp_xrpath= - for libdir in $xrpath; do - temp_xrpath="$temp_xrpath -R$libdir" - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; - esac - done - if test $hardcode_into_libs != yes || test $build_old_libs = yes; then - dependency_libs="$temp_xrpath $dependency_libs" - fi - fi - - # Make sure dlfiles contains only unique files that won't be dlpreopened - old_dlfiles="$dlfiles" - dlfiles= - for lib in $old_dlfiles; do - case " $dlprefiles $dlfiles " in - *" $lib "*) ;; - *) dlfiles="$dlfiles $lib" ;; - esac - done - - # Make sure dlprefiles contains only unique files - old_dlprefiles="$dlprefiles" - dlprefiles= - for lib in $old_dlprefiles; do - case "$dlprefiles " in - *" $lib "*) ;; - *) dlprefiles="$dlprefiles $lib" ;; - esac - done - - if test "$build_libtool_libs" = yes; then - if test -n "$rpath"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) - # these systems don't actually have a c library (as such)! - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C library is in the System framework - deplibs="$deplibs -framework System" - ;; - *-*-netbsd*) - # Don't link with libc until the a.out ld.so is fixed. - ;; - *-*-openbsd* | *-*-freebsd*) - # Do not include libc due to us having libc/libc_r. - ;; - *) - # Add libc to deplibs on all other systems if necessary. - if test $build_libtool_need_lc = "yes"; then - deplibs="$deplibs -lc" - fi - ;; - esac - fi - - # Transform deplibs into only deplibs that can be linked in shared. - name_save=$name - libname_save=$libname - release_save=$release - versuffix_save=$versuffix - major_save=$major - # I'm not sure if I'm treating the release correctly. I think - # release should show up in the -l (ie -lgmp5) so we don't want to - # add it in twice. Is that correct? - release="" - versuffix="" - major="" - newdeplibs= - droppeddeps=no - case $deplibs_check_method in - pass_all) - # Don't check for shared/static. Everything works. - # This might be a little naive. We might want to check - # whether the library exists or not. But this is on - # osf3 & osf4 and I'm not really sure... Just - # implementing what was already the behaviour. - newdeplibs=$deplibs - ;; - test_compile) - # This code stresses the "libraries are programs" paradigm to its - # limits. Maybe even breaks it. We compile a program, linking it - # against the deplibs as a proxy for the library. Then we can check - # whether they linked in statically or dynamically with ldd. - $rm conftest.c - cat > conftest.c </dev/null` - for potent_lib in $potential_libs; do - # Follow soft links. - if ls -lLd "$potent_lib" 2>/dev/null \ - | grep " -> " >/dev/null; then - continue - fi - # The statement above tries to avoid entering an - # endless loop below, in case of cyclic links. - # We might still enter an endless loop, since a link - # loop can be closed while we follow links, - # but so what? - potlib="$potent_lib" - while test -h "$potlib" 2>/dev/null; do - potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` - case $potliblink in - [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; - *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; - esac - done - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ - | ${SED} 10q \ - | egrep "$file_magic_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi - done - done - if test -n "$a_deplib" ; then - droppeddeps=yes - echo - echo "*** Warning: linker path does not have real file for library $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - echo "*** with $libname but no candidates were found. (...for file magic test)" - else - echo "*** with $libname and none of the candidates passed a file format test" - echo "*** using a file magic. Last file checked: $potlib" - fi - fi - else - # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" - fi - done # Gone through all deplibs. - ;; - match_pattern*) - set dummy $deplibs_check_method - match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` - for a_deplib in $deplibs; do - name="`expr $a_deplib : '-l\(.*\)'`" - # If $name is empty we are operating on a -L argument. - if test -n "$name" && test "$name" != "0"; then - libname=`eval \\$echo \"$libname_spec\"` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do - potlib="$potent_lib" # see symlink-check below in file_magic test - if eval echo \"$potent_lib\" 2>/dev/null \ - | ${SED} 10q \ - | egrep "$match_pattern_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi - done - done - if test -n "$a_deplib" ; then - droppeddeps=yes - echo - echo "*** Warning: linker path does not have real file for library $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - echo "*** with $libname but no candidates were found. (...for regex pattern test)" - else - echo "*** with $libname and none of the candidates passed a file format test" - echo "*** using a regex pattern. Last file checked: $potlib" - fi - fi - else - # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" - fi - done # Gone through all deplibs. - ;; - none | unknown | *) - newdeplibs="" - if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ - -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' | - grep . >/dev/null; then - echo - if test "X$deplibs_check_method" = "Xnone"; then - echo "*** Warning: inter-library dependencies are not supported in this platform." - else - echo "*** Warning: inter-library dependencies are not known to be supported." - fi - echo "*** All declared inter-library dependencies are being dropped." - droppeddeps=yes - fi - ;; - esac - versuffix=$versuffix_save - major=$major_save - release=$release_save - libname=$libname_save - name=$name_save - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` - ;; - esac - - if test "$droppeddeps" = yes; then - if test "$module" = yes; then - echo - echo "*** Warning: libtool could not satisfy all declared inter-library" - echo "*** dependencies of module $libname. Therefore, libtool will create" - echo "*** a static module, that should work as long as the dlopening" - echo "*** application is linked with the -dlopen flag." - if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - else - echo "*** The inter-library dependencies that have been dropped here will be" - echo "*** automatically added whenever a program is linked with this library" - echo "*** or is declared to -dlopen it." - - if test $allow_undefined = no; then - echo - echo "*** Since this library must not contain undefined symbols," - echo "*** because either the platform does not support them or" - echo "*** it was explicitly requested with -no-undefined," - echo "*** libtool will only create a static version of it." - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - fi - fi - # Done checking deplibs! - deplibs=$newdeplibs - fi - - # All the library-specific variables (install_libdir is set above). - library_names= - old_library= - dlname= - - # Test again, we may have decided not to build it any more - if test "$build_libtool_libs" = yes; then - if test $hardcode_into_libs = yes; then - # Hardcode the library paths - hardcode_libdirs= - dep_rpath= - rpath="$finalize_rpath" - test "$mode" != relink && rpath="$compile_rpath$rpath" - for libdir in $rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - dep_rpath="$dep_rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval dep_rpath=\"$hardcode_libdir_flag_spec\" - fi - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" - fi - test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" - fi - - shlibpath="$finalize_shlibpath" - test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" - if test -n "$shlibpath"; then - eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" - fi - - # Get the real and link names of the library. - eval library_names=\"$library_names_spec\" - set dummy $library_names - realname="$2" - shift; shift - - if test -n "$soname_spec"; then - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - test -z "$dlname" && dlname=$soname - - lib="$output_objdir/$realname" - for link - do - linknames="$linknames $link" - done - - # Ensure that we have .o objects for linkers which dislike .lo - # (e.g. aix) in case we are running --disable-static - for obj in $libobjs; do - xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$obj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` - oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` - if test ! -f $xdir/$oldobj; then - $show "(cd $xdir && ${LN_S} $baseobj $oldobj)" - $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $? - fi - done - - # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then - $show "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $run $rm $export_symbols - eval cmds=\"$export_symbols_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - if test -n "$export_symbols_regex"; then - $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" - $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - $show "$mv \"${export_symbols}T\" \"$export_symbols\"" - $run eval '$mv "${export_symbols}T" "$export_symbols"' - fi - fi - fi - - if test -n "$export_symbols" && test -n "$include_expsyms"; then - $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' - fi - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - else - gentop="$output_objdir/${outputname}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "mkdir $gentop" - $run mkdir "$gentop" - status=$? - if test $status -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - for xlib in $convenience; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "mkdir $xdir" - $run mkdir "$xdir" - status=$? - if test $status -ne 0 && test ! -d "$xdir"; then - exit $status - fi - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - - libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` - done - fi - fi - - if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then - eval flag=\"$thread_safe_flag_spec\" - linker_flags="$linker_flags $flag" - fi - - # Make a backup of the uninstalled library when relinking - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? - fi - - # Do each of the archive commands. - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval cmds=\"$archive_expsym_cmds\" - else - save_deplibs="$deplibs" - for conv in $convenience; do - tmp_deplibs= - for test_deplib in $deplibs; do - if test "$test_deplib" != "$conv"; then - tmp_deplibs="$tmp_deplibs $test_deplib" - fi - done - deplibs="$tmp_deplibs" - done - eval cmds=\"$archive_cmds\" - deplibs="$save_deplibs" - fi - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Restore the uninstalled library and exit - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? - exit 0 - fi - - # Create links to the real library. - for linkname in $linknames; do - if test "$realname" != "$linkname"; then - $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" - $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? - fi - done - - # If -module or -export-dynamic was specified, set the dlname. - if test "$module" = yes || test "$export_dynamic" = yes; then - # On all known operating systems, these are identical. - dlname="$soname" - fi - fi - ;; - - obj) - if test -n "$deplibs"; then - $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 - fi - - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 - fi - - if test -n "$rpath"; then - $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 - fi - - if test -n "$xrpath"; then - $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 - fi - - case $output in - *.lo) - if test -n "$objs$old_deplibs"; then - $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 - exit 1 - fi - libobj="$output" - obj=`$echo "X$output" | $Xsed -e "$lo2o"` - ;; - *) - libobj= - obj="$output" - ;; - esac - - # Delete the old objects. - $run $rm $obj $libobj - - # Objects from convenience libraries. This assumes - # single-version convenience libraries. Whenever we create - # different ones for PIC/non-PIC, this we'll have to duplicate - # the extraction. - reload_conv_objs= - gentop= - # reload_cmds runs $LD directly, so let us get rid of - # -Wl from whole_archive_flag_spec - wl= - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" - else - gentop="$output_objdir/${obj}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "mkdir $gentop" - $run mkdir "$gentop" - status=$? - if test $status -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - for xlib in $convenience; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "mkdir $xdir" - $run mkdir "$xdir" - status=$? - if test $status -ne 0 && test ! -d "$xdir"; then - exit $status - fi - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - - reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` - done - fi - fi - - # Create the old-style object. - reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test - - output="$obj" - eval cmds=\"$reload_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Exit if we aren't doing a library object file. - if test -z "$libobj"; then - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - exit 0 - fi - - if test "$build_libtool_libs" != yes; then - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - # Create an invalid libtool object if no PIC, so that we don't - # accidentally link it into a program. - $show "echo timestamp > $libobj" - $run eval "echo timestamp > $libobj" || exit $? - exit 0 - fi - - if test -n "$pic_flag" || test "$pic_mode" != default; then - # Only do commands if we really have different PIC objects. - reload_objs="$libobjs $reload_conv_objs" - output="$libobj" - eval cmds=\"$reload_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - else - # Just create a symlink. - $show $rm $libobj - $run $rm $libobj - xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$libobj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` - oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` - $show "(cd $xdir && $LN_S $oldobj $baseobj)" - $run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $? - fi - - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - exit 0 - ;; - - prog) - case $host in - *cygwin*) output=`echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; - esac - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 - fi - - if test "$preload" = yes; then - if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && - test "$dlopen_self_static" = unknown; then - $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." - fi - fi - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` - finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` - case $host in - *darwin*) - # Don't allow lazy linking, it breaks C++ global constructors - compile_command="$compile_command ${wl}-bind_at_load" - finalize_command="$finalize_command ${wl}-bind_at_load" - ;; - esac - ;; - esac - - compile_command="$compile_command $compile_deplibs" - finalize_command="$finalize_command $finalize_deplibs" - - if test -n "$rpath$xrpath"; then - # If the user specified any rpath flags, then add them. - for libdir in $rpath $xrpath; do - # This is the magic to use -rpath. - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; - esac - done - fi - - # Now hardcode the library paths - rpath= - hardcode_libdirs= - for libdir in $compile_rpath $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - case :$dllsearchpath: in - *":$libdir:"*) ;; - *) dllsearchpath="$dllsearchpath:$libdir";; - esac - ;; - esac - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - compile_rpath="$rpath" - - rpath= - hardcode_libdirs= - for libdir in $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$finalize_perm_rpath " in - *" $libdir "*) ;; - *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - finalize_rpath="$rpath" - - if test -n "$libobjs" && test "$build_old_libs" = yes; then - # Transform all the library objects into standard objects. - compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - fi - - dlsyms= - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - if test -n "$NM" && test -n "$global_symbol_pipe"; then - dlsyms="${outputname}S.c" - else - $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 - fi - fi - - if test -n "$dlsyms"; then - case $dlsyms in - "") ;; - *.c) - # Discover the nlist of each of the dlfiles. - nlist="$output_objdir/${outputname}.nm" - - $show "$rm $nlist ${nlist}S ${nlist}T" - $run $rm "$nlist" "${nlist}S" "${nlist}T" - - # Parse the name list into a source file. - $show "creating $output_objdir/$dlsyms" - - test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ -/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ -/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ - -#ifdef __cplusplus -extern \"C\" { -#endif - -/* Prevent the only kind of declaration conflicts we can make. */ -#define lt_preloaded_symbols some_other_symbol - -/* External symbol declarations for the compiler. */\ -" - - if test "$dlself" = yes; then - $show "generating symbol list for \`$output'" - - test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" - - # Add our own program objects to the symbol list. - progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - for arg in $progfiles; do - $show "extracting global C symbols from \`$arg'" - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - - if test -n "$exclude_expsyms"; then - $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' - $run eval '$mv "$nlist"T "$nlist"' - fi - - if test -n "$export_symbols_regex"; then - $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T' - $run eval '$mv "$nlist"T "$nlist"' - fi - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - export_symbols="$output_objdir/$output.exp" - $run $rm $export_symbols - $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' - else - $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' - $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' - $run eval 'mv "$nlist"T "$nlist"' - fi - fi - - for arg in $dlprefiles; do - $show "extracting global C symbols from \`$arg'" - name=`echo "$arg" | ${SED} -e 's%^.*/%%'` - $run eval 'echo ": $name " >> "$nlist"' - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - - if test -z "$run"; then - # Make sure we have at least an empty file. - test -f "$nlist" || : > "$nlist" - - if test -n "$exclude_expsyms"; then - egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T - $mv "$nlist"T "$nlist" - fi - - # Try sorting and uniquifying the output. - if grep -v "^: " < "$nlist" | - if sort -k 3 /dev/null 2>&1; then - sort -k 3 - else - sort +2 - fi | - uniq > "$nlist"S; then - : - else - grep -v "^: " < "$nlist" > "$nlist"S - fi - - if test -f "$nlist"S; then - eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' - else - echo '/* NONE */' >> "$output_objdir/$dlsyms" - fi - - $echo >> "$output_objdir/$dlsyms" "\ - -#undef lt_preloaded_symbols - -#if defined (__STDC__) && __STDC__ -# define lt_ptr void * -#else -# define lt_ptr char * -# define const -#endif - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - lt_ptr address; -} -lt_preloaded_symbols[] = -{\ -" - - eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" - - $echo >> "$output_objdir/$dlsyms" "\ - {0, (lt_ptr) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif\ -" - fi - - pic_flag_for_symtable= - case $host in - # compiling the symbol table file with pic_flag works around - # a FreeBSD bug that causes programs to crash when -lm is - # linked before any other PIC object. But we must not use - # pic_flag when linking with -static. The problem exists in - # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) - case "$compile_command " in - *" -static "*) ;; - *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";; - esac;; - *-*-hpux*) - case "$compile_command " in - *" -static "*) ;; - *) pic_flag_for_symtable=" $pic_flag -DPIC";; - esac - esac - - # Now compile the dynamic symbol file. - $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" - $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? - - # Clean up the generated files. - $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" - $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" - - # Transform the symbol file into the correct name. - compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` - ;; - *) - $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 - exit 1 - ;; - esac - else - # We keep going just in case the user didn't refer to - # lt_preloaded_symbols. The linker will fail if global_symbol_pipe - # really was required. - - # Nullify the symbol file. - compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` - fi - - if test $need_relink = no || test "$build_libtool_libs" != yes; then - # Replace the output file specification. - compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - link_command="$compile_command$compile_rpath" - - # We have no uninstalled library dependencies, so finalize right now. - $show "$link_command" - $run eval "$link_command" - status=$? - - # Delete the generated files. - if test -n "$dlsyms"; then - $show "$rm $output_objdir/${outputname}S.${objext}" - $run $rm "$output_objdir/${outputname}S.${objext}" - fi - - exit $status - fi - - if test -n "$shlibpath_var"; then - # We should set the shlibpath_var - rpath= - for dir in $temp_rpath; do - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) - # Absolute path. - rpath="$rpath$dir:" - ;; - *) - # Relative path: add a thisdir entry. - rpath="$rpath\$thisdir/$dir:" - ;; - esac - done - temp_rpath="$rpath" - fi - - if test -n "$compile_shlibpath$finalize_shlibpath"; then - compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" - fi - if test -n "$finalize_shlibpath"; then - finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" - fi - - compile_var= - finalize_var= - if test -n "$runpath_var"; then - if test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - compile_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - if test -n "$finalize_perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $finalize_perm_rpath; do - rpath="$rpath$dir:" - done - finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - fi - - if test "$no_install" = yes; then - # We don't need to create a wrapper script. - link_command="$compile_var$compile_command$compile_rpath" - # Replace the output file specification. - link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - # Delete the old output file. - $run $rm $output - # Link the executable and exit - $show "$link_command" - $run eval "$link_command" || exit $? - exit 0 - fi - - if test "$hardcode_action" = relink; then - # Fast installation is not supported - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - - $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 - $echo "$modename: \`$output' will be relinked during installation" 1>&2 - else - if test "$fast_install" != no; then - link_command="$finalize_var$compile_command$finalize_rpath" - if test "$fast_install" = yes; then - relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` - else - # fast_install is set to needless - relink_command= - fi - else - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - fi - fi - - # Replace the output file specification. - link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` - - # Delete the old output files. - $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname - - $show "$link_command" - $run eval "$link_command" || exit $? - - # Now create the wrapper script. - $show "creating $output" - - # Quote the relink command for shipping. - if test -n "$relink_command"; then - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` - relink_command="$var=\"$var_value\"; export $var; $relink_command" - fi - done - relink_command="(cd `pwd`; $relink_command)" - relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` - fi - - # Quote $echo for shipping. - if test "X$echo" = "X$SHELL $0 --fallback-echo"; then - case $0 in - [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; - *) qecho="$SHELL `pwd`/$0 --fallback-echo";; - esac - qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` - else - qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` - fi - - # Only actually do things if our run command is non-null. - if test -z "$run"; then - # win32 will think the script is a binary if it has - # a .exe suffix, so we strip it off here. - case $output in - *.exe) output=`echo $output|${SED} 's,.exe$,,'` ;; - esac - # test for cygwin because mv fails w/o .exe extensions - case $host in - *cygwin*) exeext=.exe ;; - *) exeext= ;; - esac - $rm $output - trap "$rm $output; exit 1" 1 2 15 - - $echo > $output "\ -#! $SHELL - -# $output - temporary wrapper script for $objdir/$outputname -# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP -# -# The $output program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of the build directory. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed="${SED}"' -e 1s/^X//' -sed_quote_subst='$sed_quote_subst' - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi - -relink_command=\"$relink_command\" - -# This environment variable determines our operation mode. -if test \"\$libtool_install_magic\" = \"$magic\"; then - # install mode needs the following variable: - notinst_deplibs='$notinst_deplibs' -else - # When we are sourced in execute mode, \$file and \$echo are already set. - if test \"\$libtool_execute_magic\" != \"$magic\"; then - echo=\"$qecho\" - file=\"\$0\" - # Make sure echo works. - if test \"X\$1\" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift - elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then - # Yippee, \$echo works! - : - else - # Restart under the correct shell, and then maybe \$echo will work. - exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} - fi - fi\ -" - $echo >> $output "\ - - # Find the directory that this script lives in. - thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` - - # If there was a directory component, then change thisdir. - if test \"x\$destdir\" != \"x\$file\"; then - case \"\$destdir\" in - [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; - *) thisdir=\"\$thisdir/\$destdir\" ;; - esac - fi - - file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` - done - - # Try to get the absolute directory name. - absdir=\`cd \"\$thisdir\" && pwd\` - test -n \"\$absdir\" && thisdir=\"\$absdir\" -" - - if test "$fast_install" = yes; then - echo >> $output "\ - program=lt-'$outputname'$exeext - progdir=\"\$thisdir/$objdir\" - - if test ! -f \"\$progdir/\$program\" || \\ - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ - test \"X\$file\" != \"X\$progdir/\$program\"; }; then - - file=\"\$\$-\$program\" - - if test ! -d \"\$progdir\"; then - $mkdir \"\$progdir\" - else - $rm \"\$progdir/\$file\" - fi" - - echo >> $output "\ - - # relink executable if necessary - if test -n \"\$relink_command\"; then - if relink_command_output=\`eval \$relink_command 2>&1\`; then : - else - $echo \"\$relink_command_output\" >&2 - $rm \"\$progdir/\$file\" - exit 1 - fi - fi - - $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || - { $rm \"\$progdir/\$program\"; - $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } - $rm \"\$progdir/\$file\" - fi" - else - echo >> $output "\ - program='$outputname' - progdir=\"\$thisdir/$objdir\" -" - fi - - echo >> $output "\ - - if test -f \"\$progdir/\$program\"; then" - - # Export our shlibpath_var if we have one. - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $echo >> $output "\ - # Add our own library path to $shlibpath_var - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" - - # Some systems cannot cope with colon-terminated $shlibpath_var - # The second colon is a workaround for a bug in BeOS R4 ${SED} - $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` - - export $shlibpath_var -" - fi - - # fixup the dll searchpath if we need to. - if test -n "$dllsearchpath"; then - $echo >> $output "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - - $echo >> $output "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. -" - case $host in - # win32 systems need to use the prog path for dll - # lookup to work - *-*-cygwin* | *-*-pw32*) - $echo >> $output "\ - exec \$progdir/\$program \${1+\"\$@\"} -" - ;; - - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2*) - $echo >> $output "\ - exec \$progdir\\\\\$program \${1+\"\$@\"} -" - ;; - - *) - $echo >> $output "\ - # Export the path to the program. - PATH=\"\$progdir:\$PATH\" - export PATH - - exec \$program \${1+\"\$@\"} -" - ;; - esac - $echo >> $output "\ - \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" - exit 1 - fi - else - # The program doesn't exist. - \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 - \$echo \"This script is just a wrapper for \$program.\" 1>&2 - echo \"See the $PACKAGE documentation for more information.\" 1>&2 - exit 1 - fi -fi\ -" - chmod +x $output - fi - exit 0 - ;; - esac - - # See if we need to build an old-fashioned archive. - for oldlib in $oldlibs; do - - if test "$build_libtool_libs" = convenience; then - oldobjs="$libobjs_save" - addlibs="$convenience" - build_libtool_libs=no - else - if test "$build_libtool_libs" = module; then - oldobjs="$libobjs_save" - build_libtool_libs=no - else - oldobjs="$objs$old_deplibs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP` - fi - addlibs="$old_convenience" - fi - - if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "mkdir $gentop" - $run mkdir "$gentop" - status=$? - if test $status -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - # Add in members from convenience archives. - for xlib in $addlibs; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "mkdir $xdir" - $run mkdir "$xdir" - status=$? - if test $status -ne 0 && test ! -d "$xdir"; then - exit $status - fi - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - - oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` - done - fi - - # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - eval cmds=\"$old_archive_from_new_cmds\" - else - # Ensure that we have .o objects in place in case we decided - # not to build a shared library, and have fallen back to building - # static libs even though --disable-static was passed! - for oldobj in $oldobjs; do - if test ! -f $oldobj; then - xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$oldobj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'` - obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` - $show "(cd $xdir && ${LN_S} $obj $baseobj)" - $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $? - fi - done - - eval cmds=\"$old_archive_cmds\" - fi - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - done - - if test -n "$generated"; then - $show "${rm}r$generated" - $run ${rm}r$generated - fi - - # Now create the libtool archive. - case $output in - *.la) - old_library= - test "$build_old_libs" = yes && old_library="$libname.$libext" - $show "creating $output" - - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` - relink_command="$var=\"$var_value\"; export $var; $relink_command" - fi - done - # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL $0 --mode=relink $libtool_args @inst_prefix_dir@)" - relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` - - # Only create the output if not a dry run. - if test -z "$run"; then - for installed in no yes; do - if test "$installed" = yes; then - if test -z "$install_libdir"; then - break - fi - output="$output_objdir/$outputname"i - # Replace all uninstalled libtool libraries with the installed ones - newdependency_libs= - for deplib in $dependency_libs; do - case $deplib in - *.la) - name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 - exit 1 - fi - newdependency_libs="$newdependency_libs $libdir/$name" - ;; - *) newdependency_libs="$newdependency_libs $deplib" ;; - esac - done - dependency_libs="$newdependency_libs" - newdlfiles= - for lib in $dlfiles; do - name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - if test -z "$libdir"; then - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit 1 - fi - newdlfiles="$newdlfiles $libdir/$name" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - if test -z "$libdir"; then - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit 1 - fi - newdlprefiles="$newdlprefiles $libdir/$name" - done - dlprefiles="$newdlprefiles" - fi - $rm $output - # place dlname in correct position for cygwin - tdlname=$dlname - case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; - esac - $echo > $output "\ -# $outputname - a libtool library file -# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='$tdlname' - -# Names of this library. -library_names='$library_names' - -# The name of the static archive. -old_library='$old_library' - -# Libraries that this one depends upon. -dependency_libs='$dependency_libs' - -# Version information for $libname. -current=$current -age=$age -revision=$revision - -# Is this an already installed library? -installed=$installed - -# Files to dlopen/dlpreopen -dlopen='$dlfiles' -dlpreopen='$dlprefiles' - -# Directory that this library needs to be installed in: -libdir='$install_libdir'" - if test "$installed" = no && test $need_relink = yes; then - $echo >> $output "\ -relink_command=\"$relink_command\"" - fi - done - fi - - # Do a symbolic link so that the libtool archive can be found in - # LD_LIBRARY_PATH before the program is installed. - $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" - $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? - ;; - esac - exit 0 - ;; - - # libtool install mode - install) - modename="$modename: install" - - # There may be an optional sh(1) argument at the beginning of - # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || - # Allow the use of GNU shtool's install command. - $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then - # Aesthetically quote it. - arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$arg " - arg="$1" - shift - else - install_prog= - arg="$nonopt" - fi - - # The real first argument should be the name of the installation program. - # Aesthetically quote it. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog$arg" - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir=no - stripme= - for arg - do - if test -n "$dest"; then - files="$files $dest" - dest="$arg" - continue - fi - - case $arg in - -d) isdir=yes ;; - -f) prev="-f" ;; - -g) prev="-g" ;; - -m) prev="-m" ;; - -o) prev="-o" ;; - -s) - stripme=" -s" - continue - ;; - -*) ;; - - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - prev= - else - dest="$arg" - continue - fi - ;; - esac - - # Aesthetically quote the argument. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog $arg" - done - - if test -z "$install_prog"; then - $echo "$modename: you must specify an install program" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test -n "$prev"; then - $echo "$modename: the \`$prev' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test -z "$files"; then - if test -z "$dest"; then - $echo "$modename: no file or destination specified" 1>&2 - else - $echo "$modename: you must specify a destination" 1>&2 - fi - $echo "$help" 1>&2 - exit 1 - fi - - # Strip any trailing slash from the destination. - dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` - - # Check to see that the destination is a directory. - test -d "$dest" && isdir=yes - if test "$isdir" = yes; then - destdir="$dest" - destname= - else - destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` - test "X$destdir" = "X$dest" && destdir=. - destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` - - # Not a directory, so check to see that there is only one file specified. - set dummy $files - if test $# -gt 2; then - $echo "$modename: \`$dest' is not a directory" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - fi - case $destdir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - for file in $files; do - case $file in - *.lo) ;; - *) - $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - esac - done - ;; - esac - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - staticlibs= - future_libdirs= - current_libdirs= - for file in $files; do - - # Do each installation. - case $file in - *.$libext) - # Do the static libraries later. - staticlibs="$staticlibs $file" - ;; - - *.la) - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - library_names= - old_library= - relink_command= - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Add the libdir to current_libdirs if it is the destination. - if test "X$destdir" = "X$libdir"; then - case "$current_libdirs " in - *" $libdir "*) ;; - *) current_libdirs="$current_libdirs $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) future_libdirs="$future_libdirs $libdir" ;; - esac - fi - - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ - test "X$dir" = "X$file/" && dir= - dir="$dir$objdir" - - if test -n "$relink_command"; then - # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$echo "$destdir" | sed "s%$libdir\$%%"` - - # Don't allow the user to place us outside of our expected - # location b/c this prevents finding dependent libraries that - # are installed to the same prefix. - if test "$inst_prefix_dir" = "$destdir"; then - $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 - exit 1 - fi - - if test -n "$inst_prefix_dir"; then - # Stick the inst_prefix_dir data into the link command. - relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` - else - relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%%"` - fi - - $echo "$modename: warning: relinking \`$file'" 1>&2 - $show "$relink_command" - if $run eval "$relink_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - exit 1 - fi - fi - - # See the names of the shared library. - set dummy $library_names - if test -n "$2"; then - realname="$2" - shift - shift - - srcname="$realname" - test -n "$relink_command" && srcname="$realname"T - - # Install the shared library and build the symlinks. - $show "$install_prog $dir/$srcname $destdir/$realname" - $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? - if test -n "$stripme" && test -n "$striplib"; then - $show "$striplib $destdir/$realname" - $run eval "$striplib $destdir/$realname" || exit $? - fi - - if test $# -gt 0; then - # Delete the old symlinks, and create new ones. - for linkname - do - if test "$linkname" != "$realname"; then - $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" - $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" - fi - done - fi - - # Do each command in the postinstall commands. - lib="$destdir/$realname" - eval cmds=\"$postinstall_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Install the pseudo-library for information purposes. - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - instname="$dir/$name"i - $show "$install_prog $instname $destdir/$name" - $run eval "$install_prog $instname $destdir/$name" || exit $? - - # Maybe install the static library, too. - test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" - ;; - - *.lo) - # Install (i.e. copy) a libtool object. - - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - destfile="$destdir/$destfile" - fi - - # Deduce the name of the destination old-style object file. - case $destfile in - *.lo) - staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` - ;; - *.$objext) - staticdest="$destfile" - destfile= - ;; - *) - $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - esac - - # Install the libtool object if requested. - if test -n "$destfile"; then - $show "$install_prog $file $destfile" - $run eval "$install_prog $file $destfile" || exit $? - fi - - # Install the old object if enabled. - if test "$build_old_libs" = yes; then - # Deduce the name of the old-style object file. - staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` - - $show "$install_prog $staticobj $staticdest" - $run eval "$install_prog \$staticobj \$staticdest" || exit $? - fi - exit 0 - ;; - - *) - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - destfile="$destdir/$destfile" - fi - - # Do a test to see if this is really a libtool program. - case $host in - *cygwin*|*mingw*) - wrapper=`echo $file | ${SED} -e 's,.exe$,,'` - ;; - *) - wrapper=$file - ;; - esac - if (${SED} -e '4q' $wrapper | egrep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then - notinst_deplibs= - relink_command= - - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $wrapper ;; - *) . ./$wrapper ;; - esac - - # Check the variables that should have been set. - if test -z "$notinst_deplibs"; then - $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 - exit 1 - fi - - finalize=yes - for lib in $notinst_deplibs; do - # Check to see that each library is installed. - libdir= - if test -f "$lib"; then - # If there is no directory component, then add one. - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - fi - libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test - if test -n "$libdir" && test ! -f "$libfile"; then - $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 - finalize=no - fi - done - - relink_command= - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $wrapper ;; - *) . ./$wrapper ;; - esac - - outputname= - if test "$fast_install" = no && test -n "$relink_command"; then - if test "$finalize" = yes && test -z "$run"; then - tmpdir="/tmp" - test -n "$TMPDIR" && tmpdir="$TMPDIR" - tmpdir="$tmpdir/libtool-$$" - if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : - else - $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 - continue - fi - file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - outputname="$tmpdir/$file" - # Replace the output file specification. - relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` - - $show "$relink_command" - if $run eval "$relink_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - ${rm}r "$tmpdir" - continue - fi - file="$outputname" - else - $echo "$modename: warning: cannot relink \`$file'" 1>&2 - fi - else - # Install the binary that we compiled earlier. - file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` - fi - fi - - # remove .exe since cygwin /usr/bin/install will append another - # one anyways - case $install_prog,$host in - /usr/bin/install*,*cygwin*) - case $file:$destfile in - *.exe:*.exe) - # this is ok - ;; - *.exe:*) - destfile=$destfile.exe - ;; - *:*.exe) - destfile=`echo $destfile | ${SED} -e 's,.exe$,,'` - ;; - esac - ;; - esac - $show "$install_prog$stripme $file $destfile" - $run eval "$install_prog\$stripme \$file \$destfile" || exit $? - test -n "$outputname" && ${rm}r "$tmpdir" - ;; - esac - done - - for file in $staticlibs; do - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - - # Set up the ranlib parameters. - oldlib="$destdir/$name" - - $show "$install_prog $file $oldlib" - $run eval "$install_prog \$file \$oldlib" || exit $? - - if test -n "$stripme" && test -n "$striplib"; then - $show "$old_striplib $oldlib" - $run eval "$old_striplib $oldlib" || exit $? - fi - - # Do each command in the postinstall commands. - eval cmds=\"$old_postinstall_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - done - - if test -n "$future_libdirs"; then - $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 - fi - - if test -n "$current_libdirs"; then - # Maybe just do a dry run. - test -n "$run" && current_libdirs=" -n$current_libdirs" - exec_cmd='$SHELL $0 --finish$current_libdirs' - else - exit 0 - fi - ;; - - # libtool finish mode - finish) - modename="$modename: finish" - libdirs="$nonopt" - admincmds= - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for dir - do - libdirs="$libdirs $dir" - done - - for libdir in $libdirs; do - if test -n "$finish_cmds"; then - # Do each command in the finish commands. - eval cmds=\"$finish_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || admincmds="$admincmds - $cmd" - done - IFS="$save_ifs" - fi - if test -n "$finish_eval"; then - # Do the single finish_eval. - eval cmds=\"$finish_eval\" - $run eval "$cmds" || admincmds="$admincmds - $cmds" - fi - done - fi - - # Exit here if they wanted silent mode. - test "$show" = ":" && exit 0 - - echo "----------------------------------------------------------------------" - echo "Libraries have been installed in:" - for libdir in $libdirs; do - echo " $libdir" - done - echo - echo "If you ever happen to want to link against installed libraries" - echo "in a given directory, LIBDIR, you must either use libtool, and" - echo "specify the full pathname of the library, or use the \`-LLIBDIR'" - echo "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - echo " during execution" - fi - if test -n "$runpath_var"; then - echo " - add LIBDIR to the \`$runpath_var' environment variable" - echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - - echo " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then - echo " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - echo - echo "See any operating system documentation about shared libraries for" - echo "more information, such as the ld(1) and ld.so(8) manual pages." - echo "----------------------------------------------------------------------" - exit 0 - ;; - - # libtool execute mode - execute) - modename="$modename: execute" - - # The first argument is the command name. - cmd="$nonopt" - if test -z "$cmd"; then - $echo "$modename: you must specify a COMMAND" 1>&2 - $echo "$help" - exit 1 - fi - - # Handle -dlopen flags immediately. - for file in $execute_dlfiles; do - if test ! -f "$file"; then - $echo "$modename: \`$file' is not a file" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - dir= - case $file in - *.la) - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Read the libtool library. - dlname= - library_names= - - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Skip this library if it cannot be dlopened. - if test -z "$dlname"; then - # Warn if it was a shared library. - test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" - continue - fi - - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - - if test -f "$dir/$objdir/$dlname"; then - dir="$dir/$objdir" - else - $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 - exit 1 - fi - ;; - - *.lo) - # Just add the directory containing the .lo file. - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - ;; - - *) - $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 - continue - ;; - esac - - # Get the absolute pathname. - absdir=`cd "$dir" && pwd` - test -n "$absdir" && dir="$absdir" - - # Now add the directory to shlibpath_var. - if eval "test -z \"\$$shlibpath_var\""; then - eval "$shlibpath_var=\"\$dir\"" - else - eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" - fi - done - - # This variable tells wrapper scripts just to set shlibpath_var - # rather than running their programs. - libtool_execute_magic="$magic" - - # Check if any of the arguments is a wrapper script. - args= - for file - do - case $file in - -*) ;; - *) - # Do a test to see if this is really a libtool program. - if (${SED} -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Transform arg to wrapped name. - file="$progdir/$program" - fi - ;; - esac - # Quote arguments (to preserve shell metacharacters). - file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` - args="$args \"$file\"" - done - - if test -z "$run"; then - if test -n "$shlibpath_var"; then - # Export the shlibpath_var. - eval "export $shlibpath_var" - fi - - # Restore saved enviroment variables - if test "${save_LC_ALL+set}" = set; then - LC_ALL="$save_LC_ALL"; export LC_ALL - fi - if test "${save_LANG+set}" = set; then - LANG="$save_LANG"; export LANG - fi - - # Now prepare to actually exec the command. - exec_cmd="\$cmd$args" - else - # Display what would be done. - if test -n "$shlibpath_var"; then - eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" - $echo "export $shlibpath_var" - fi - $echo "$cmd$args" - exit 0 - fi - ;; - - # libtool clean and uninstall mode - clean | uninstall) - modename="$modename: $mode" - rm="$nonopt" - files= - rmforce= - exit_status=0 - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - for arg - do - case $arg in - -f) rm="$rm $arg"; rmforce=yes ;; - -*) rm="$rm $arg" ;; - *) files="$files $arg" ;; - esac - done - - if test -z "$rm"; then - $echo "$modename: you must specify an RM program" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - rmdirs= - - for file in $files; do - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - if test "X$dir" = "X$file"; then - dir=. - objdir="$objdir" - else - objdir="$dir/$objdir" - fi - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - test $mode = uninstall && objdir="$dir" - - # Remember objdir for removal later, being careful to avoid duplicates - if test $mode = clean; then - case " $rmdirs " in - *" $objdir "*) ;; - *) rmdirs="$rmdirs $objdir" ;; - esac - fi - - # Don't error if the file doesn't exist and rm -f was used. - if (test -L "$file") >/dev/null 2>&1 \ - || (test -h "$file") >/dev/null 2>&1 \ - || test -f "$file"; then - : - elif test -d "$file"; then - exit_status=1 - continue - elif test "$rmforce" = yes; then - continue - fi - - rmfiles="$file" - - case $name in - *.la) - # Possibly a libtool archive, so verify it. - if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - . $dir/$name - - # Delete the libtool libraries and symlinks. - for n in $library_names; do - rmfiles="$rmfiles $objdir/$n" - done - test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" - test $mode = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" - - if test $mode = uninstall; then - if test -n "$library_names"; then - # Do each command in the postuninstall commands. - eval cmds=\"$postuninstall_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" - if test $? != 0 && test "$rmforce" != yes; then - exit_status=1 - fi - done - IFS="$save_ifs" - fi - - if test -n "$old_library"; then - # Do each command in the old_postuninstall commands. - eval cmds=\"$old_postuninstall_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" - if test $? != 0 && test "$rmforce" != yes; then - exit_status=1 - fi - done - IFS="$save_ifs" - fi - # FIXME: should reinstall the best remaining shared library. - fi - fi - ;; - - *.lo) - if test "$build_old_libs" = yes; then - oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` - rmfiles="$rmfiles $dir/$oldobj" - fi - ;; - - *) - # Do a test to see if this is a libtool program. - if test $mode = clean && - (${SED} -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - relink_command= - . $dir/$file - - rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then - rmfiles="$rmfiles $objdir/lt-$name" - fi - fi - ;; - esac - $show "$rm $rmfiles" - $run $rm $rmfiles || exit_status=1 - done - - # Try to remove the ${objdir}s in the directories where we deleted files - for dir in $rmdirs; do - if test -d "$dir"; then - $show "rmdir $dir" - $run rmdir $dir >/dev/null 2>&1 - fi - done - - exit $exit_status - ;; - - "") - $echo "$modename: you must specify a MODE" 1>&2 - $echo "$generic_help" 1>&2 - exit 1 - ;; - esac - - if test -z "$exec_cmd"; then - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$generic_help" 1>&2 - exit 1 - fi -fi # test -z "$show_help" - -if test -n "$exec_cmd"; then - eval exec $exec_cmd - exit 1 -fi - -# We need to display help for each of the modes. -case $mode in -"") $echo \ -"Usage: $modename [OPTION]... [MODE-ARG]... - -Provide generalized library-building support services. - - --config show all configuration variables - --debug enable verbose shell tracing --n, --dry-run display commands without modifying any files - --features display basic configuration information and exit - --finish same as \`--mode=finish' - --help display this help message and exit - --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] - --quiet same as \`--silent' - --silent don't print informational messages - --version print version information - -MODE must be one of the following: - - clean remove files from the build directory - compile compile a source file into a libtool object - execute automatically set library path, then run a program - finish complete the installation of libtool libraries - install install libraries or executables - link create a library or an executable - uninstall remove libraries from an installed directory - -MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for -a more detailed description of MODE." - exit 0 - ;; - -clean) - $echo \ -"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... - -Remove files from the build directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, object or program, all the files associated -with it are deleted. Otherwise, only FILE itself is deleted using RM." - ;; - -compile) - $echo \ -"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE - -Compile a source file into a libtool library object. - -This mode accepts the following additional options: - - -o OUTPUT-FILE set the output file name to OUTPUT-FILE - -prefer-pic try to building PIC objects only - -prefer-non-pic try to building non-PIC objects only - -static always build a \`.o' file suitable for static linking - -COMPILE-COMMAND is a command to be used in creating a \`standard' object file -from the given SOURCEFILE. - -The output file name is determined by removing the directory component from -SOURCEFILE, then substituting the C source code suffix \`.c' with the -library object suffix, \`.lo'." - ;; - -execute) - $echo \ -"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... - -Automatically set library path, then run a program. - -This mode accepts the following additional options: - - -dlopen FILE add the directory containing FILE to the library path - -This mode sets the library path environment variable according to \`-dlopen' -flags. - -If any of the ARGS are libtool executable wrappers, then they are translated -into their corresponding uninstalled binary, and any of their required library -directories are added to the library path. - -Then, COMMAND is executed, with ARGS as arguments." - ;; - -finish) - $echo \ -"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... - -Complete the installation of libtool libraries. - -Each LIBDIR is a directory that contains libtool libraries. - -The commands that this mode executes may require superuser privileges. Use -the \`--dry-run' option if you just want to see what would be executed." - ;; - -install) - $echo \ -"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... - -Install executables or libraries. - -INSTALL-COMMAND is the installation command. The first component should be -either the \`install' or \`cp' program. - -The rest of the components are interpreted as arguments to that command (only -BSD-compatible install options are recognized)." - ;; - -link) - $echo \ -"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... - -Link object files or libraries together to form another library, or to -create an executable program. - -LINK-COMMAND is a command using the C compiler that you would use to create -a program from several object files. - -The following components of LINK-COMMAND are treated specially: - - -all-static do not do any dynamic linking at all - -avoid-version do not add a version suffix if possible - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime - -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols - -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) - -export-symbols SYMFILE - try to export only the symbols listed in SYMFILE - -export-symbols-regex REGEX - try to export only the symbols matching REGEX - -LLIBDIR search LIBDIR for required installed libraries - -lNAME OUTPUT-FILE requires the installed library libNAME - -module build a library that can dlopened - -no-fast-install disable the fast-install mode - -no-install link a not-installable executable - -no-undefined declare that a library does not refer to external symbols - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects - -release RELEASE specify package release information - -rpath LIBDIR the created library will eventually be installed in LIBDIR - -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries - -static do not do any dynamic linking of libtool libraries - -version-info CURRENT[:REVISION[:AGE]] - specify library version info [each variable defaults to 0] - -All other options (arguments beginning with \`-') are ignored. - -Every other argument is treated as a filename. Files ending in \`.la' are -treated as uninstalled libtool libraries, other files are standard or library -object files. - -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, -only library objects (\`.lo' files) may be specified, and \`-rpath' is -required, except when creating a convenience library. - -If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created -using \`ar' and \`ranlib', or on Windows using \`lib'. - -If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file -is created, otherwise an executable program is created." - ;; - -uninstall) - $echo \ -"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... - -Remove libraries from an installation directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, all the files associated with it are deleted. -Otherwise, only FILE itself is deleted using RM." - ;; - -*) - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; -esac - -echo -$echo "Try \`$modename --help' for more information about other modes." - -exit 0 - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: diff --git a/src/coreclr/src/pal/src/libunwind/configure.ac b/src/coreclr/src/pal/src/libunwind/configure.ac index 226a10fb35047a..73d654c57548b3 100644 --- a/src/coreclr/src/pal/src/libunwind/configure.ac +++ b/src/coreclr/src/pal/src/libunwind/configure.ac @@ -32,8 +32,6 @@ case "$ac_cv_search_dlopen" in *) DLLIB="";; esac -CHECK_ATOMIC_OPS - dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(asm/ptrace_offsets.h endian.h sys/endian.h execinfo.h \ @@ -328,10 +326,8 @@ AC_ARG_ENABLE([per-thread-cache], AS_HELP_STRING([--enable-per-thread-cache], [build with support for UNW_CACHE_PER_THREAD (which imposes a hight TLS memory usage) (default: disabled)])) AC_MSG_RESULT([$enable_per_thread_cache]) AS_IF([test x$enable_per_thread_cache = xyes], [ - LIBUNWIND___THREAD - AS_IF([test x$libc_cv_gcc___thread = xno], [ - AC_MSG_FAILURE([UNW_CACHE_PER_THREAD requires __thread]) - ]) + AC_DEFINE(HAVE___CACHE_PER_THREAD, 1, + [Define to 1 if --enable-per-thread-cache]) ]) AC_MSG_CHECKING([for Intel compiler]) @@ -400,20 +396,6 @@ if test x$have__builtin_unreachable = xyes; then fi AC_MSG_RESULT([$have__builtin_unreachable]) -AC_MSG_CHECKING([for __sync atomics]) -AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[]], [[ - __sync_bool_compare_and_swap((int *)0, 0, 1); - __sync_fetch_and_add((int *)0, 1); - ]])], - [have_sync_atomics=yes], - [have_sync_atomics=no]) -if test x$have_sync_atomics = xyes; then - AC_DEFINE([HAVE_SYNC_ATOMICS], [1], - [Defined if __sync atomics are available]) -fi -AC_MSG_RESULT([$have_sync_atomics]) - CCASFLAGS="${CCASFLAGS} ${CPPFLAGS}" arch="$target_arch" diff --git a/src/coreclr/src/pal/src/libunwind/include/compiler.h b/src/coreclr/src/pal/src/libunwind/include/compiler.h index 2fa59eff7fbd86..22939483cddb1e 100644 --- a/src/coreclr/src/pal/src/libunwind/include/compiler.h +++ b/src/coreclr/src/pal/src/libunwind/include/compiler.h @@ -31,7 +31,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define COMPILER_H #ifdef __GNUC__ -# define ALIGNED(x) __attribute__((aligned(x))) # define CONST_ATTR __attribute__((__const__)) # define UNUSED __attribute__((unused)) # define NOINLINE __attribute__((noinline)) @@ -54,7 +53,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ # define unlikely(x) (x) # endif #else -# define ALIGNED(x) # define ALWAYS_INLINE # define CONST_ATTR # define UNUSED diff --git a/src/coreclr/src/pal/src/libunwind/include/config.h.cmake.in b/src/coreclr/src/pal/src/libunwind/include/config.h.cmake.in new file mode 100644 index 00000000000000..fc312ddb7d0079 --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/config.h.cmake.in @@ -0,0 +1,10 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#cmakedefine01 HAVE_ELF_H +#cmakedefine01 HAVE_ENDIAN_H + +#define PACKAGE_STRING "@PACKAGE_STRING@" +#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" + +#endif // CONFIG_H diff --git a/src/coreclr/src/pal/src/libunwind/include/dwarf-eh.h b/src/coreclr/src/pal/src/libunwind/include/dwarf-eh.h index 96002a1b9d2d23..f48e91905bebf8 100644 --- a/src/coreclr/src/pal/src/libunwind/include/dwarf-eh.h +++ b/src/coreclr/src/pal/src/libunwind/include/dwarf-eh.h @@ -107,6 +107,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define DW_EH_VERSION 1 /* The version we're implementing */ +#ifdef _MSC_VER +#pragma pack(push, 1) +#define __attribute__(x) +#endif + struct __attribute__((packed)) dwarf_eh_frame_hdr { unsigned char version; @@ -126,4 +131,9 @@ struct __attribute__((packed)) dwarf_eh_frame_hdr binary_search_table[fde_count]; */ }; +#ifdef _MSC_VER +#pragma pack(pop) +#undef __attribute__ +#endif + #endif /* dwarf_eh_h */ diff --git a/src/coreclr/src/pal/src/libunwind/include/dwarf.h b/src/coreclr/src/pal/src/libunwind/include/dwarf.h index 764f6f20ac22ba..6a56fe2d7e91d3 100644 --- a/src/coreclr/src/pal/src/libunwind/include/dwarf.h +++ b/src/coreclr/src/pal/src/libunwind/include/dwarf.h @@ -27,6 +27,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define dwarf_h #include +#include struct dwarf_cursor; /* forward-declaration */ struct elf_dyn_info; @@ -347,7 +348,7 @@ struct dwarf_rs_cache /* hash table that maps instruction pointer to rs index: */ unsigned short *hash; - uint32_t generation; /* generation number */ + _Atomic uint32_t generation; /* generation number */ /* rs cache: */ dwarf_reg_state_t *buckets; diff --git a/src/coreclr/src/pal/src/libunwind/include/libunwind-aarch64.h b/src/coreclr/src/pal/src/libunwind/include/libunwind-aarch64.h index 21cdb54562c043..d1bd8708f59f1f 100644 --- a/src/coreclr/src/pal/src/libunwind/include/libunwind-aarch64.h +++ b/src/coreclr/src/pal/src/libunwind/include/libunwind-aarch64.h @@ -34,7 +34,15 @@ extern "C" { #include #include #include -#include +#include + +#ifndef UNW_EMPTY_STRUCT +# ifdef __GNUC__ +# define UNW_EMPTY_STRUCT +# else +# define UNW_EMPTY_STRUCT uint8_t unused; +# endif +#endif #define UNW_TARGET aarch64 #define UNW_TARGET_AARCH64 1 @@ -61,6 +69,7 @@ typedef long double unw_tdep_fpreg_t; typedef struct { /* no aarch64-specific auxiliary proc-info */ + UNW_EMPTY_STRUCT } unw_tdep_proc_info_t; @@ -170,10 +179,10 @@ aarch64_regnum_t; typedef struct unw_tdep_save_loc { /* Additional target-dependent info on a save location. */ + UNW_EMPTY_STRUCT } unw_tdep_save_loc_t; - /* On AArch64, we can directly use ucontext_t as the unwind context, * however, the __reserved struct is quite large: tune it down to only * the necessary used fields. */ @@ -185,7 +194,7 @@ struct unw_sigcontext uint64_t sp; uint64_t pc; uint64_t pstate; - uint8_t __reserved[(66 * 8)] __attribute__((__aligned__(16))); + uint8_t alignas(16) __reserved[(66 * 8)]; }; typedef struct diff --git a/src/coreclr/src/pal/src/libunwind/include/libunwind-arm.h b/src/coreclr/src/pal/src/libunwind/include/libunwind-arm.h index 6709b7abaeefa4..1a6c6b6dadce98 100644 --- a/src/coreclr/src/pal/src/libunwind/include/libunwind-arm.h +++ b/src/coreclr/src/pal/src/libunwind/include/libunwind-arm.h @@ -32,6 +32,14 @@ extern "C" { #include #include +#ifndef UNW_EMPTY_STRUCT +# ifdef __GNUC__ +# define UNW_EMPTY_STRUCT +# else +# define UNW_EMPTY_STRUCT uint8_t unused; +# endif +#endif + #define UNW_TARGET arm #define UNW_TARGET_ARM 1 @@ -247,6 +255,7 @@ arm_regnum_t; typedef struct unw_tdep_save_loc { /* Additional target-dependent info on a save location. */ + UNW_EMPTY_STRUCT } unw_tdep_save_loc_t; @@ -288,6 +297,7 @@ unw_tdep_context_t; typedef struct { /* no arm-specific auxiliary proc-info */ + UNW_EMPTY_STRUCT } unw_tdep_proc_info_t; diff --git a/src/coreclr/src/pal/src/libunwind/include/libunwind_i.h b/src/coreclr/src/pal/src/libunwind/include/libunwind_i.h index e0f4540144230e..aca1ee315b1773 100644 --- a/src/coreclr/src/pal/src/libunwind/include/libunwind_i.h +++ b/src/coreclr/src/pal/src/libunwind/include/libunwind_i.h @@ -37,7 +37,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "compiler.h" -#if defined(HAVE___THREAD) && HAVE___THREAD +#if defined(HAVE___CACHE_PER_THREAD) && HAVE___CACHE_PER_THREAD #define UNWI_DEFAULT_CACHING_POLICY UNW_CACHE_PER_THREAD #else #define UNWI_DEFAULT_CACHING_POLICY UNW_CACHE_GLOBAL @@ -123,57 +123,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define mutex_unlock(l) \ (pthread_mutex_unlock != NULL ? pthread_mutex_unlock (l) : 0) -#ifdef HAVE_ATOMIC_OPS_H -# include -static inline int -cmpxchg_ptr (void *addr, void *old, void *new) -{ - union - { - void *vp; - AO_t *aop; - } - u; - - u.vp = addr; - return AO_compare_and_swap(u.aop, (AO_t) old, (AO_t) new); -} -# define fetch_and_add1(_ptr) AO_fetch_and_add1(_ptr) -# define fetch_and_add(_ptr, value) AO_fetch_and_add(_ptr, value) -# define atomic_read(ptr) (AO_load(ptr)) - /* GCC 3.2.0 on HP-UX crashes on cmpxchg_ptr() */ -# if !(defined(__hpux) && __GNUC__ == 3 && __GNUC_MINOR__ == 2) -# define HAVE_CMPXCHG -# endif -# define HAVE_FETCH_AND_ADD -#elif defined(HAVE_SYNC_ATOMICS) || defined(HAVE_IA64INTRIN_H) -# ifdef HAVE_IA64INTRIN_H -# include -# endif -static inline int -cmpxchg_ptr (void *addr, void *old, void *new) -{ - union - { - void *vp; - long *vlp; - } - u; - - u.vp = addr; - return __sync_bool_compare_and_swap(u.vlp, (long) old, (long) new); -} -# define fetch_and_add1(_ptr) __sync_fetch_and_add(_ptr, 1) -# define fetch_and_add(_ptr, value) __sync_fetch_and_add(_ptr, value) -# define atomic_read(ptr) (__atomic_load_n(ptr,__ATOMIC_RELAXED)) -# define HAVE_CMPXCHG -# define HAVE_FETCH_AND_ADD -#endif - -#ifndef atomic_read -#define atomic_read(ptr) (*(ptr)) -#endif - #define UNWI_OBJ(fn) UNW_PASTE(UNW_PREFIX,UNW_PASTE(I,fn)) #define UNWI_ARCH_OBJ(fn) UNW_PASTE(UNW_PASTE(UNW_PASTE(_UI,UNW_TARGET),_), fn) @@ -275,7 +224,7 @@ extern pthread_mutex_t _U_dyn_info_list_lock; extern long unwi_debug_level; # include -# define Debug(level,format...) \ +# define Debug(level, /* format */ ...) \ do { \ if (unwi_debug_level >= level) \ { \ @@ -283,13 +232,14 @@ do { \ if (_n > 16) \ _n = 16; \ fprintf (stderr, "%*c>%s: ", _n, ' ', __FUNCTION__); \ - fprintf (stderr, format); \ + fprintf (stderr, /* format */ __VA_ARGS__); \ } \ } while (0) -# define Dprintf(format...) fprintf (stderr, format) +# define Dprintf(/* format */ ...) \ + fprintf (stderr, /* format */ __VA_ARGS__) #else -# define Debug(level,format...) -# define Dprintf(format...) +# define Debug(level, /* format */ ...) +# define Dprintf( /* format */ ...) #endif static ALWAYS_INLINE int diff --git a/src/coreclr/src/pal/src/libunwind/include/tdep-aarch64/libunwind_i.h b/src/coreclr/src/pal/src/libunwind/include/tdep-aarch64/libunwind_i.h index b91273fa1c5525..fc4416069e9c94 100644 --- a/src/coreclr/src/pal/src/libunwind/include/tdep-aarch64/libunwind_i.h +++ b/src/coreclr/src/pal/src/libunwind/include/tdep-aarch64/libunwind_i.h @@ -32,6 +32,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include +#include #include "elf64.h" #include "mempool.h" @@ -78,11 +79,7 @@ struct unw_addr_space struct unw_accessors acc; int big_endian; unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif + _Atomic uint32_t cache_generation; unw_word_t dyn_generation; /* see dyn-common.h */ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ struct dwarf_rs_cache global_cache; @@ -160,8 +157,14 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) # define DWARF_LOC_TYPE_FP (1 << 0) # define DWARF_LOC_TYPE_REG (1 << 1) # define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) + +static inline int +dwarf_is_null_loc(dwarf_loc_t l) +{ + return l.val == 0 && l.type == 0; +} + +# define DWARF_IS_NULL_LOC(l) dwarf_is_null_loc(l) # define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) # define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) # define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) @@ -297,7 +300,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) #define tdep_get_ip(c) ((c)->dwarf.ip) #define tdep_big_endian(as) ((as)->big_endian) -extern int tdep_init_done; +extern atomic_bool tdep_init_done; extern void tdep_init (void); extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, diff --git a/src/coreclr/src/pal/src/libunwind/include/tdep-arm/libunwind_i.h b/src/coreclr/src/pal/src/libunwind/include/tdep-arm/libunwind_i.h index 2602f41c4f79fc..36ceca386c5352 100644 --- a/src/coreclr/src/pal/src/libunwind/include/tdep-arm/libunwind_i.h +++ b/src/coreclr/src/pal/src/libunwind/include/tdep-arm/libunwind_i.h @@ -30,6 +30,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include +#include #include "elf32.h" #include "mempool.h" @@ -64,11 +65,7 @@ struct unw_addr_space struct unw_accessors acc; int big_endian; unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif + _Atomic uint32_t cache_generation; unw_word_t dyn_generation; /* see dyn-common.h */ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ struct dwarf_rs_cache global_cache; @@ -151,8 +148,14 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) # define DWARF_LOC_TYPE_FP (1 << 0) # define DWARF_LOC_TYPE_REG (1 << 1) # define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) + +static inline int +dwarf_is_null_loc(dwarf_loc_t l) +{ + return l.val == 0 && l.type == 0; +} + +# define DWARF_IS_NULL_LOC(l) dwarf_is_null_loc(l) # define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) # define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) # define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) @@ -288,7 +291,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) #define tdep_get_ip(c) ((c)->dwarf.ip) #define tdep_big_endian(as) ((as)->big_endian) -extern int tdep_init_done; +extern atomic_bool tdep_init_done; extern void tdep_init (void); extern int arm_find_proc_info (unw_addr_space_t as, unw_word_t ip, diff --git a/src/coreclr/src/pal/src/libunwind/include/tdep-hppa/libunwind_i.h b/src/coreclr/src/pal/src/libunwind/include/tdep-hppa/libunwind_i.h index 72649aa3ecc559..fd5910d0125a34 100644 --- a/src/coreclr/src/pal/src/libunwind/include/tdep-hppa/libunwind_i.h +++ b/src/coreclr/src/pal/src/libunwind/include/tdep-hppa/libunwind_i.h @@ -31,6 +31,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include +#include #include "elf32.h" #include "mempool.h" @@ -46,11 +47,7 @@ struct unw_addr_space { struct unw_accessors acc; unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif + _Atomic uint32_t cache_generation; unw_word_t dyn_generation; /* see dyn-common.h */ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ struct dwarf_rs_cache global_cache; @@ -260,7 +257,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) #define tdep_get_ip(c) ((c)->dwarf.ip) #define tdep_big_endian(as) 1 -extern int tdep_init_done; +extern atomic_bool tdep_init_done; extern void tdep_init (void); extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, diff --git a/src/coreclr/src/pal/src/libunwind/include/tdep-ia64/libunwind_i.h b/src/coreclr/src/pal/src/libunwind/include/tdep-ia64/libunwind_i.h index 1d9770bab8564f..8cb8fea22792f6 100644 --- a/src/coreclr/src/pal/src/libunwind/include/tdep-ia64/libunwind_i.h +++ b/src/coreclr/src/pal/src/libunwind/include/tdep-ia64/libunwind_i.h @@ -31,6 +31,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "elf64.h" #include "mempool.h" +#include typedef struct { @@ -97,11 +98,7 @@ struct unw_addr_space int big_endian; int abi; /* abi < 0 => unknown, 0 => SysV, 1 => HP-UX, 2 => Windows */ unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif + _Atomic uint32_t cache_generation; unw_word_t dyn_generation; unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ #ifndef UNW_REMOTE_ONLY diff --git a/src/coreclr/src/pal/src/libunwind/include/tdep-ia64/script.h b/src/coreclr/src/pal/src/libunwind/include/tdep-ia64/script.h index fe3360bf5829d3..8a6ab9cc01d917 100644 --- a/src/coreclr/src/pal/src/libunwind/include/tdep-ia64/script.h +++ b/src/coreclr/src/pal/src/libunwind/include/tdep-ia64/script.h @@ -23,6 +23,8 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include + #define IA64_LOG_UNW_CACHE_SIZE 7 #define IA64_UNW_CACHE_SIZE (1 << IA64_LOG_UNW_CACHE_SIZE) @@ -59,11 +61,7 @@ struct ia64_script struct ia64_script_cache { -#ifdef HAVE_ATOMIC_OPS_H - AO_TS_t busy; /* is the script-cache busy? */ -#else - pthread_mutex_t lock; -#endif + atomic_flag busy; /* is the script-cache busy? */ unsigned short lru_head; /* index of lead-recently used script */ unsigned short lru_tail; /* index of most-recently used script */ diff --git a/src/coreclr/src/pal/src/libunwind/include/tdep-mips/libunwind_i.h b/src/coreclr/src/pal/src/libunwind/include/tdep-mips/libunwind_i.h index 0c0fd3cf47eb3b..343a195141be8d 100644 --- a/src/coreclr/src/pal/src/libunwind/include/tdep-mips/libunwind_i.h +++ b/src/coreclr/src/pal/src/libunwind/include/tdep-mips/libunwind_i.h @@ -30,6 +30,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include +#include #if !defined(UNW_REMOTE_ONLY) && _MIPS_SIM == _ABI64 # include "elf64.h" @@ -54,11 +55,7 @@ struct unw_addr_space unsigned int addr_size; unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif + _Atomic uint32_t cache_generation; unw_word_t dyn_generation; /* see dyn-common.h */ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ struct dwarf_rs_cache global_cache; @@ -320,7 +317,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) #define tdep_get_as_arg(c) ((c)->dwarf.as_arg) #define tdep_get_ip(c) ((c)->dwarf.ip) -extern int tdep_init_done; +extern atomic_bool tdep_init_done; extern void tdep_init (void); extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, diff --git a/src/coreclr/src/pal/src/libunwind/include/tdep-ppc32/libunwind_i.h b/src/coreclr/src/pal/src/libunwind/include/tdep-ppc32/libunwind_i.h index 4cf6d135f63ff6..b9100e6ac894c7 100644 --- a/src/coreclr/src/pal/src/libunwind/include/tdep-ppc32/libunwind_i.h +++ b/src/coreclr/src/pal/src/libunwind/include/tdep-ppc32/libunwind_i.h @@ -37,6 +37,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include +#include #include "elf32.h" #include "mempool.h" @@ -52,11 +53,7 @@ struct unw_addr_space { struct unw_accessors acc; unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif + _Atomic uint32_t cache_generation; unw_word_t dyn_generation; /* see dyn-common.h */ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ struct dwarf_rs_cache global_cache; @@ -292,7 +289,7 @@ extern int tdep_fetch_proc_info_post (struct dwarf_cursor *c, unw_word_t ip, #define tdep_get_ip(c) ((c)->dwarf.ip) #define tdep_big_endian(as) 1 -extern int tdep_init_done; +extern atomic_bool tdep_init_done; extern void tdep_init (void); extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, diff --git a/src/coreclr/src/pal/src/libunwind/include/tdep-ppc64/libunwind_i.h b/src/coreclr/src/pal/src/libunwind/include/tdep-ppc64/libunwind_i.h index 975f3bb3662add..48227c76e20916 100644 --- a/src/coreclr/src/pal/src/libunwind/include/tdep-ppc64/libunwind_i.h +++ b/src/coreclr/src/pal/src/libunwind/include/tdep-ppc64/libunwind_i.h @@ -37,6 +37,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include +#include #include "elf64.h" #include "mempool.h" @@ -54,11 +55,7 @@ struct unw_addr_space int big_endian; ppc64_abi_t abi; unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif + _Atomic uint32_t cache_generation; unw_word_t dyn_generation; /* see dyn-common.h */ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ struct dwarf_rs_cache global_cache; @@ -347,7 +344,7 @@ extern int tdep_fetch_proc_info_post (struct dwarf_cursor *c, unw_word_t ip, #define tdep_get_ip(c) ((c)->dwarf.ip) #define tdep_big_endian(as) ((as)->big_endian) -extern int tdep_init_done; +extern atomic_bool tdep_init_done; extern void tdep_init (void); extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, diff --git a/src/coreclr/src/pal/src/libunwind/include/tdep-s390x/libunwind_i.h b/src/coreclr/src/pal/src/libunwind/include/tdep-s390x/libunwind_i.h index 137a0b8a4f9282..8c34d6a9584670 100644 --- a/src/coreclr/src/pal/src/libunwind/include/tdep-s390x/libunwind_i.h +++ b/src/coreclr/src/pal/src/libunwind/include/tdep-s390x/libunwind_i.h @@ -33,6 +33,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include +#include #include "elf64.h" #include "mempool.h" @@ -42,11 +43,7 @@ struct unw_addr_space { struct unw_accessors acc; unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif + _Atomic uint32_t cache_generation; unw_word_t dyn_generation; /* see dyn-common.h */ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ struct dwarf_rs_cache global_cache; @@ -242,7 +239,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) #define tdep_get_ip(c) ((c)->dwarf.ip) #define tdep_big_endian(as) 1 -extern int tdep_init_done; +extern atomic_bool tdep_init_done; extern void tdep_init (void); extern void tdep_init_mem_validate (void); diff --git a/src/coreclr/src/pal/src/libunwind/include/tdep-sh/libunwind_i.h b/src/coreclr/src/pal/src/libunwind/include/tdep-sh/libunwind_i.h index 8ced49104b5c82..7b4fe0023b4d52 100644 --- a/src/coreclr/src/pal/src/libunwind/include/tdep-sh/libunwind_i.h +++ b/src/coreclr/src/pal/src/libunwind/include/tdep-sh/libunwind_i.h @@ -31,6 +31,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include +#include #include "elf32.h" #include "mempool.h" @@ -47,11 +48,7 @@ struct unw_addr_space struct unw_accessors acc; int big_endian; unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif + _Atomic uint32_t cache_generation; unw_word_t dyn_generation; /* see dyn-common.h */ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ struct dwarf_rs_cache global_cache; @@ -261,7 +258,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) #define tdep_get_ip(c) ((c)->dwarf.ip) #define tdep_big_endian(as) ((as)->big_endian) -extern int tdep_init_done; +extern atomic_bool tdep_init_done; extern void tdep_init (void); extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, diff --git a/src/coreclr/src/pal/src/libunwind/include/tdep-tilegx/libunwind_i.h b/src/coreclr/src/pal/src/libunwind/include/tdep-tilegx/libunwind_i.h index 2cfed456a70fdd..dc4cb7fdb2e0e1 100644 --- a/src/coreclr/src/pal/src/libunwind/include/tdep-tilegx/libunwind_i.h +++ b/src/coreclr/src/pal/src/libunwind/include/tdep-tilegx/libunwind_i.h @@ -31,6 +31,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include +#include # include "elf64.h" #include "mempool.h" @@ -50,11 +51,7 @@ struct unw_addr_space unsigned int addr_size; unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif + _Atomic uint32_t cache_generation; unw_word_t dyn_generation; /* see dyn-common.h */ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ struct dwarf_rs_cache global_cache; @@ -235,7 +232,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) #define tdep_get_as_arg(c) ((c)->dwarf.as_arg) #define tdep_get_ip(c) ((c)->dwarf.ip) -extern int tdep_init_done; +extern atomic_bool tdep_init_done; extern void tdep_init (void); extern int tdep_search_unwind_table (unw_addr_space_t as, diff --git a/src/coreclr/src/pal/src/libunwind/include/tdep-x86/libunwind_i.h b/src/coreclr/src/pal/src/libunwind/include/tdep-x86/libunwind_i.h index 5231189a499c16..d4c5ccdb172ad9 100644 --- a/src/coreclr/src/pal/src/libunwind/include/tdep-x86/libunwind_i.h +++ b/src/coreclr/src/pal/src/libunwind/include/tdep-x86/libunwind_i.h @@ -31,6 +31,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include +#include #include "elf32.h" #include "mempool.h" @@ -46,11 +47,7 @@ struct unw_addr_space { struct unw_accessors acc; unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif + _Atomic uint32_t cache_generation; unw_word_t dyn_generation; /* see dyn-common.h */ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ struct dwarf_rs_cache global_cache; @@ -274,7 +271,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) #define tdep_get_ip(c) ((c)->dwarf.ip) #define tdep_big_endian(as) 0 -extern int tdep_init_done; +extern atomic_bool tdep_init_done; extern void tdep_init (void); extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, diff --git a/src/coreclr/src/pal/src/libunwind/include/tdep-x86_64/libunwind_i.h b/src/coreclr/src/pal/src/libunwind/include/tdep-x86_64/libunwind_i.h index 6b798c7115f3c9..07a8a7ae2c7b30 100644 --- a/src/coreclr/src/pal/src/libunwind/include/tdep-x86_64/libunwind_i.h +++ b/src/coreclr/src/pal/src/libunwind/include/tdep-x86_64/libunwind_i.h @@ -32,6 +32,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ to be shared with target-independent code. */ #include +#include #include #include "elf64.h" @@ -64,11 +65,7 @@ struct unw_addr_space { struct unw_accessors acc; unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif + _Atomic uint32_t cache_generation; unw_word_t dyn_generation; /* see dyn-common.h */ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ struct dwarf_rs_cache global_cache; @@ -130,8 +127,14 @@ dwarf_get_uc(const struct dwarf_cursor *cursor) #else /* !UNW_LOCAL_ONLY */ # define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) + +static inline int +dwarf_is_null_loc(dwarf_loc_t l) +{ + return l.val == 0 && l.type == 0; +} + +# define DWARF_IS_NULL_LOC(l) dwarf_is_null_loc(l) # define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) # define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ | DWARF_LOC_TYPE_FP)) @@ -233,11 +236,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) #define tdep_get_ip(c) ((c)->dwarf.ip) #define tdep_big_endian(as) 0 -#ifdef HAVE_ATOMIC_OPS_H -extern AO_t tdep_init_done; -#else -extern int tdep_init_done; -#endif +extern atomic_bool tdep_init_done; extern void tdep_init (void); extern void tdep_init_mem_validate (void); diff --git a/src/coreclr/src/pal/src/libunwind/include/unwind.h b/src/coreclr/src/pal/src/libunwind/include/unwind.h index 7cf128deca3079..8eb5ff753de7b7 100644 --- a/src/coreclr/src/pal/src/libunwind/include/unwind.h +++ b/src/coreclr/src/pal/src/libunwind/include/unwind.h @@ -28,6 +28,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* For uint64_t */ #include +#include #ifdef __cplusplus extern "C" { @@ -76,11 +77,11 @@ typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) (int, _Unwind_Action, even on 32-bit machines for gcc compatibility. */ struct _Unwind_Exception { - uint64_t exception_class; + uint64_t alignas(8) exception_class; _Unwind_Exception_Cleanup_Fn exception_cleanup; unsigned long private_1; unsigned long private_2; - } __attribute__((__aligned__)); + }; extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *); extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *, diff --git a/src/coreclr/src/pal/src/libunwind/include/win/elf.h b/src/coreclr/src/pal/src/libunwind/include/win/elf.h new file mode 100644 index 00000000000000..5089ff6b0c512e --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/elf.h @@ -0,0 +1,16 @@ +// This is an incomplete & imprecice implementation +// It defers to the open source freebsd-elf implementations. + +// Since this is only intended for VC++ compilers +// use #pragma once instead of guard macros +#pragma once + +#ifdef _MSC_VER // Only for cross compilation to windows + +#include + +#include "freebsd-elf_common.h" +#include "freebsd-elf32.h" +#include "freebsd-elf64.h" + +#endif // _MSC_VER diff --git a/src/coreclr/src/pal/src/libunwind/include/win/endian.h b/src/coreclr/src/pal/src/libunwind/include/win/endian.h new file mode 100644 index 00000000000000..56fb68a7234632 --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/endian.h @@ -0,0 +1,16 @@ +// This is an incomplete & imprecice implementation of the +// standard file by the same name + + +// Since this is only intended for VC++ compilers +// use #pragma once instead of guard macros +#pragma once + +#ifdef _MSC_VER // Only for cross compilation to windows + +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 + +#define __BYTE_ORDER __LITTLE_ENDIAN + +#endif // _MSC_VER diff --git a/src/coreclr/src/pal/src/libunwind/include/win/fakestdalign.h.in b/src/coreclr/src/pal/src/libunwind/include/win/fakestdalign.h.in new file mode 100644 index 00000000000000..3e94006d8cae73 --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/fakestdalign.h.in @@ -0,0 +1,9 @@ +// This is a fake implementatino of stdaliagn.h for when +// compiler C11 stdaliagn.h support is missing + +#ifndef FAKE_STD_ALIGN_H +#define FAKE_STD_ALIGN_H + +#define alignas(x) + +#endif // FAKE_STD_ALIGN_H diff --git a/src/coreclr/src/pal/src/libunwind/include/win/fakestdatomic.h.in b/src/coreclr/src/pal/src/libunwind/include/win/fakestdatomic.h.in new file mode 100644 index 00000000000000..7b9dcd5a9d8ac9 --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/fakestdatomic.h.in @@ -0,0 +1,36 @@ +// This is a non-atomic fake implementatino of stdatomics for when +// compiler C11 stdatomic support is missing and only single threaded +// operation is required + +#ifndef FAKE_STD_ATOMICS_H +#define FAKE_STD_ATOMICS_H + +#include + +#define _Atomic volatile +#define ATOMIC_FLAG_INIT 0 + +typedef uint8_t atomic_bool; +typedef uint8_t atomic_flag; + +#define atomic_compare_and_exchange_strong(x, y, z) return ((*(x) == *(y)) ? ((*(x) = z), true) : ((*(y) = *(x)),false)) + +#define atomic_fetch_add(x, y) *(x) += (y), (*(x) - (y)) + +static inline void atomic_flag_clear(volatile atomic_flag* flag) +{ + *flag = ATOMIC_FLAG_INIT; +} + +static inline atomic_bool atomic_flag_test_and_set( volatile atomic_flag* flag ) +{ + atomic_bool result = *flag; + *flag = 1; + return result; +} + +#define atomic_load(x) (*(x)) +#define atomic_store(x, y) do { *(x) = (y); } while (0) + + +#endif // FAKE_STD_ATOMICS_H diff --git a/src/coreclr/src/pal/src/libunwind/include/win/freebsd-elf32.h b/src/coreclr/src/pal/src/libunwind/include/win/freebsd-elf32.h new file mode 100644 index 00000000000000..b4c0d94210d9c5 --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/freebsd-elf32.h @@ -0,0 +1,245 @@ +/*- + * Copyright (c) 1996-1998 John D. Polstra. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD: src/sys/sys/elf32.h,v 1.8.14.2.2.1 2008/10/02 02:57:24 kensmith Exp $ + */ + +#ifndef _SYS_ELF32_H_ +#define _SYS_ELF32_H_ 1 + +#include "freebsd-elf_common.h" + +/* + * ELF definitions common to all 32-bit architectures. + */ + +typedef uint32_t Elf32_Addr; +typedef uint16_t Elf32_Half; +typedef uint32_t Elf32_Off; +typedef int32_t Elf32_Sword; +typedef uint32_t Elf32_Word; +typedef uint64_t Elf32_Lword; + +typedef Elf32_Word Elf32_Hashelt; + +/* Non-standard class-dependent datatype used for abstraction. */ +typedef Elf32_Word Elf32_Size; +typedef Elf32_Sword Elf32_Ssize; + +/* + * ELF header. + */ + +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* File identification. */ + Elf32_Half e_type; /* File type. */ + Elf32_Half e_machine; /* Machine architecture. */ + Elf32_Word e_version; /* ELF format version. */ + Elf32_Addr e_entry; /* Entry point. */ + Elf32_Off e_phoff; /* Program header file offset. */ + Elf32_Off e_shoff; /* Section header file offset. */ + Elf32_Word e_flags; /* Architecture-specific flags. */ + Elf32_Half e_ehsize; /* Size of ELF header in bytes. */ + Elf32_Half e_phentsize; /* Size of program header entry. */ + Elf32_Half e_phnum; /* Number of program header entries. */ + Elf32_Half e_shentsize; /* Size of section header entry. */ + Elf32_Half e_shnum; /* Number of section header entries. */ + Elf32_Half e_shstrndx; /* Section name strings section. */ +} Elf32_Ehdr; + +/* + * Section header. + */ + +typedef struct { + Elf32_Word sh_name; /* Section name (index into the + section header string table). */ + Elf32_Word sh_type; /* Section type. */ + Elf32_Word sh_flags; /* Section flags. */ + Elf32_Addr sh_addr; /* Address in memory image. */ + Elf32_Off sh_offset; /* Offset in file. */ + Elf32_Word sh_size; /* Size in bytes. */ + Elf32_Word sh_link; /* Index of a related section. */ + Elf32_Word sh_info; /* Depends on section type. */ + Elf32_Word sh_addralign; /* Alignment in bytes. */ + Elf32_Word sh_entsize; /* Size of each entry in section. */ +} Elf32_Shdr; + +/* + * Program header. + */ + +typedef struct { + Elf32_Word p_type; /* Entry type. */ + Elf32_Off p_offset; /* File offset of contents. */ + Elf32_Addr p_vaddr; /* Virtual address in memory image. */ + Elf32_Addr p_paddr; /* Physical address (not used). */ + Elf32_Word p_filesz; /* Size of contents in file. */ + Elf32_Word p_memsz; /* Size of contents in memory. */ + Elf32_Word p_flags; /* Access permission flags. */ + Elf32_Word p_align; /* Alignment in memory and file. */ +} Elf32_Phdr; + +/* + * Dynamic structure. The ".dynamic" section contains an array of them. + */ + +typedef struct { + Elf32_Sword d_tag; /* Entry type. */ + union { + Elf32_Word d_val; /* Integer value. */ + Elf32_Addr d_ptr; /* Address value. */ + } d_un; +} Elf32_Dyn; + +/* + * Relocation entries. + */ + +/* Relocations that don't need an addend field. */ +typedef struct { + Elf32_Addr r_offset; /* Location to be relocated. */ + Elf32_Word r_info; /* Relocation type and symbol index. */ +} Elf32_Rel; + +/* Relocations that need an addend field. */ +typedef struct { + Elf32_Addr r_offset; /* Location to be relocated. */ + Elf32_Word r_info; /* Relocation type and symbol index. */ + Elf32_Sword r_addend; /* Addend. */ +} Elf32_Rela; + +/* Macros for accessing the fields of r_info. */ +#define ELF32_R_SYM(info) ((info) >> 8) +#define ELF32_R_TYPE(info) ((unsigned char)(info)) + +/* Macro for constructing r_info from field values. */ +#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) + +/* + * Note entry header + */ +typedef Elf_Note Elf32_Nhdr; + +/* + * Move entry + */ +typedef struct { + Elf32_Lword m_value; /* symbol value */ + Elf32_Word m_info; /* size + index */ + Elf32_Word m_poffset; /* symbol offset */ + Elf32_Half m_repeat; /* repeat count */ + Elf32_Half m_stride; /* stride info */ +} Elf32_Move; + +/* + * The macros compose and decompose values for Move.r_info + * + * sym = ELF32_M_SYM(M.m_info) + * size = ELF32_M_SIZE(M.m_info) + * M.m_info = ELF32_M_INFO(sym, size) + */ +#define ELF32_M_SYM(info) ((info)>>8) +#define ELF32_M_SIZE(info) ((unsigned char)(info)) +#define ELF32_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size)) + +/* + * Hardware/Software capabilities entry + */ +typedef struct { + Elf32_Word c_tag; /* how to interpret value */ + union { + Elf32_Word c_val; + Elf32_Addr c_ptr; + } c_un; +} Elf32_Cap; + +/* + * Symbol table entries. + */ + +typedef struct { + Elf32_Word st_name; /* String table index of name. */ + Elf32_Addr st_value; /* Symbol value. */ + Elf32_Word st_size; /* Size of associated object. */ + unsigned char st_info; /* Type and binding information. */ + unsigned char st_other; /* Reserved (not used). */ + Elf32_Half st_shndx; /* Section index of symbol. */ +} Elf32_Sym; + +/* Macros for accessing the fields of st_info. */ +#define ELF32_ST_BIND(info) ((info) >> 4) +#define ELF32_ST_TYPE(info) ((info) & 0xf) + +/* Macro for constructing st_info from field values. */ +#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) + +/* Macro for accessing the fields of st_other. */ +#define ELF32_ST_VISIBILITY(oth) ((oth) & 0x3) + +/* Structures used by Sun & GNU symbol versioning. */ +typedef struct +{ + Elf32_Half vd_version; + Elf32_Half vd_flags; + Elf32_Half vd_ndx; + Elf32_Half vd_cnt; + Elf32_Word vd_hash; + Elf32_Word vd_aux; + Elf32_Word vd_next; +} Elf32_Verdef; + +typedef struct +{ + Elf32_Word vda_name; + Elf32_Word vda_next; +} Elf32_Verdaux; + +typedef struct +{ + Elf32_Half vn_version; + Elf32_Half vn_cnt; + Elf32_Word vn_file; + Elf32_Word vn_aux; + Elf32_Word vn_next; +} Elf32_Verneed; + +typedef struct +{ + Elf32_Word vna_hash; + Elf32_Half vna_flags; + Elf32_Half vna_other; + Elf32_Word vna_name; + Elf32_Word vna_next; +} Elf32_Vernaux; + +typedef Elf32_Half Elf32_Versym; + +typedef struct { + Elf32_Half si_boundto; /* direct bindings - symbol bound to */ + Elf32_Half si_flags; /* per symbol flags */ +} Elf32_Syminfo; + +#endif /* !_SYS_ELF32_H_ */ diff --git a/src/coreclr/src/pal/src/libunwind/include/win/freebsd-elf64.h b/src/coreclr/src/pal/src/libunwind/include/win/freebsd-elf64.h new file mode 100644 index 00000000000000..0991fe356f97f0 --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/freebsd-elf64.h @@ -0,0 +1,252 @@ +/*- + * Copyright (c) 1996-1998 John D. Polstra. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD: src/sys/sys/elf64.h,v 1.10.14.2.2.1 2008/10/02 02:57:24 kensmith Exp $ + */ + +#ifndef _SYS_ELF64_H_ +#define _SYS_ELF64_H_ 1 + +#include "freebsd-elf_common.h" + +/* + * ELF definitions common to all 64-bit architectures. + */ + +typedef uint64_t Elf64_Addr; +typedef uint16_t Elf64_Half; +typedef uint64_t Elf64_Off; +typedef int32_t Elf64_Sword; +typedef int64_t Elf64_Sxword; +typedef uint32_t Elf64_Word; +typedef uint64_t Elf64_Lword; +typedef uint64_t Elf64_Xword; + +/* + * Types of dynamic symbol hash table bucket and chain elements. + * + * This is inconsistent among 64 bit architectures, so a machine dependent + * typedef is required. + */ + +#ifdef __alpha__ +typedef Elf64_Off Elf64_Hashelt; +#else +typedef Elf64_Word Elf64_Hashelt; +#endif + +/* Non-standard class-dependent datatype used for abstraction. */ +typedef Elf64_Xword Elf64_Size; +typedef Elf64_Sxword Elf64_Ssize; + +/* + * ELF header. + */ + +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* File identification. */ + Elf64_Half e_type; /* File type. */ + Elf64_Half e_machine; /* Machine architecture. */ + Elf64_Word e_version; /* ELF format version. */ + Elf64_Addr e_entry; /* Entry point. */ + Elf64_Off e_phoff; /* Program header file offset. */ + Elf64_Off e_shoff; /* Section header file offset. */ + Elf64_Word e_flags; /* Architecture-specific flags. */ + Elf64_Half e_ehsize; /* Size of ELF header in bytes. */ + Elf64_Half e_phentsize; /* Size of program header entry. */ + Elf64_Half e_phnum; /* Number of program header entries. */ + Elf64_Half e_shentsize; /* Size of section header entry. */ + Elf64_Half e_shnum; /* Number of section header entries. */ + Elf64_Half e_shstrndx; /* Section name strings section. */ +} Elf64_Ehdr; + +/* + * Section header. + */ + +typedef struct { + Elf64_Word sh_name; /* Section name (index into the + section header string table). */ + Elf64_Word sh_type; /* Section type. */ + Elf64_Xword sh_flags; /* Section flags. */ + Elf64_Addr sh_addr; /* Address in memory image. */ + Elf64_Off sh_offset; /* Offset in file. */ + Elf64_Xword sh_size; /* Size in bytes. */ + Elf64_Word sh_link; /* Index of a related section. */ + Elf64_Word sh_info; /* Depends on section type. */ + Elf64_Xword sh_addralign; /* Alignment in bytes. */ + Elf64_Xword sh_entsize; /* Size of each entry in section. */ +} Elf64_Shdr; + +/* + * Program header. + */ + +typedef struct { + Elf64_Word p_type; /* Entry type. */ + Elf64_Word p_flags; /* Access permission flags. */ + Elf64_Off p_offset; /* File offset of contents. */ + Elf64_Addr p_vaddr; /* Virtual address in memory image. */ + Elf64_Addr p_paddr; /* Physical address (not used). */ + Elf64_Xword p_filesz; /* Size of contents in file. */ + Elf64_Xword p_memsz; /* Size of contents in memory. */ + Elf64_Xword p_align; /* Alignment in memory and file. */ +} Elf64_Phdr; + +/* + * Dynamic structure. The ".dynamic" section contains an array of them. + */ + +typedef struct { + Elf64_Sxword d_tag; /* Entry type. */ + union { + Elf64_Xword d_val; /* Integer value. */ + Elf64_Addr d_ptr; /* Address value. */ + } d_un; +} Elf64_Dyn; + +/* + * Relocation entries. + */ + +/* Relocations that don't need an addend field. */ +typedef struct { + Elf64_Addr r_offset; /* Location to be relocated. */ + Elf64_Xword r_info; /* Relocation type and symbol index. */ +} Elf64_Rel; + +/* Relocations that need an addend field. */ +typedef struct { + Elf64_Addr r_offset; /* Location to be relocated. */ + Elf64_Xword r_info; /* Relocation type and symbol index. */ + Elf64_Sxword r_addend; /* Addend. */ +} Elf64_Rela; + +/* Macros for accessing the fields of r_info. */ +#define ELF64_R_SYM(info) ((info) >> 32) +#define ELF64_R_TYPE(info) ((info) & 0xffffffffL) + +/* Macro for constructing r_info from field values. */ +#define ELF64_R_INFO(sym, type) (((sym) << 32) + ((type) & 0xffffffffL)) + +#define ELF64_R_TYPE_DATA(info) (((Elf64_Xword)(info)<<32)>>40) +#define ELF64_R_TYPE_ID(info) (((Elf64_Xword)(info)<<56)>>56) +#define ELF64_R_TYPE_INFO(data, type) \ + (((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type)) + +/* + * Note entry header + */ +typedef Elf_Note Elf64_Nhdr; + +/* + * Move entry + */ +typedef struct { + Elf64_Lword m_value; /* symbol value */ + Elf64_Xword m_info; /* size + index */ + Elf64_Xword m_poffset; /* symbol offset */ + Elf64_Half m_repeat; /* repeat count */ + Elf64_Half m_stride; /* stride info */ +} Elf64_Move; + +#define ELF64_M_SYM(info) ((info)>>8) +#define ELF64_M_SIZE(info) ((unsigned char)(info)) +#define ELF64_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size)) + +/* + * Hardware/Software capabilities entry + */ +typedef struct { + Elf64_Xword c_tag; /* how to interpret value */ + union { + Elf64_Xword c_val; + Elf64_Addr c_ptr; + } c_un; +} Elf64_Cap; + +/* + * Symbol table entries. + */ + +typedef struct { + Elf64_Word st_name; /* String table index of name. */ + unsigned char st_info; /* Type and binding information. */ + unsigned char st_other; /* Reserved (not used). */ + Elf64_Half st_shndx; /* Section index of symbol. */ + Elf64_Addr st_value; /* Symbol value. */ + Elf64_Xword st_size; /* Size of associated object. */ +} Elf64_Sym; + +/* Macros for accessing the fields of st_info. */ +#define ELF64_ST_BIND(info) ((info) >> 4) +#define ELF64_ST_TYPE(info) ((info) & 0xf) + +/* Macro for constructing st_info from field values. */ +#define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) + +/* Macro for accessing the fields of st_other. */ +#define ELF64_ST_VISIBILITY(oth) ((oth) & 0x3) + +/* Structures used by Sun & GNU-style symbol versioning. */ +typedef struct { + Elf64_Half vd_version; + Elf64_Half vd_flags; + Elf64_Half vd_ndx; + Elf64_Half vd_cnt; + Elf64_Word vd_hash; + Elf64_Word vd_aux; + Elf64_Word vd_next; +} Elf64_Verdef; + +typedef struct { + Elf64_Word vda_name; + Elf64_Word vda_next; +} Elf64_Verdaux; + +typedef struct { + Elf64_Half vn_version; + Elf64_Half vn_cnt; + Elf64_Word vn_file; + Elf64_Word vn_aux; + Elf64_Word vn_next; +} Elf64_Verneed; + +typedef struct { + Elf64_Word vna_hash; + Elf64_Half vna_flags; + Elf64_Half vna_other; + Elf64_Word vna_name; + Elf64_Word vna_next; +} Elf64_Vernaux; + +typedef Elf64_Half Elf64_Versym; + +typedef struct { + Elf64_Half si_boundto; /* direct bindings - symbol bound to */ + Elf64_Half si_flags; /* per symbol flags */ +} Elf64_Syminfo; + +#endif /* !_SYS_ELF64_H_ */ diff --git a/src/coreclr/src/pal/src/libunwind/include/win/freebsd-elf_common.h b/src/coreclr/src/pal/src/libunwind/include/win/freebsd-elf_common.h new file mode 100644 index 00000000000000..7aef2d49667e4c --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/freebsd-elf_common.h @@ -0,0 +1,865 @@ +/*- + * Copyright (c) 1998 John D. Polstra. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD: src/sys/sys/elf_common.h,v 1.24 2008/08/02 01:20:10 imp Exp $ + */ + +#ifndef _SYS_ELF_COMMON_H_ +#define _SYS_ELF_COMMON_H_ 1 + +/* + * ELF definitions that are independent of architecture or word size. + */ + +/* + * Note header. The ".note" section contains an array of notes. Each + * begins with this header, aligned to a word boundary. Immediately + * following the note header is n_namesz bytes of name, padded to the + * next word boundary. Then comes n_descsz bytes of descriptor, again + * padded to a word boundary. The values of n_namesz and n_descsz do + * not include the padding. + */ + +typedef struct { + uint32_t n_namesz; /* Length of name. */ + uint32_t n_descsz; /* Length of descriptor. */ + uint32_t n_type; /* Type of this note. */ +} Elf_Note; + +/* Indexes into the e_ident array. Keep synced with + http://www.sco.com/developers/gabi/latest/ch4.eheader.html */ +#define EI_MAG0 0 /* Magic number, byte 0. */ +#define EI_MAG1 1 /* Magic number, byte 1. */ +#define EI_MAG2 2 /* Magic number, byte 2. */ +#define EI_MAG3 3 /* Magic number, byte 3. */ +#define EI_CLASS 4 /* Class of machine. */ +#define EI_DATA 5 /* Data format. */ +#define EI_VERSION 6 /* ELF format version. */ +#define EI_OSABI 7 /* Operating system / ABI identification */ +#define EI_ABIVERSION 8 /* ABI version */ +#define OLD_EI_BRAND 8 /* Start of architecture identification. */ +#define EI_PAD 9 /* Start of padding (per SVR4 ABI). */ +#define EI_NIDENT 16 /* Size of e_ident array. */ + +/* Values for the magic number bytes. */ +#define ELFMAG0 0x7f +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' +#define ELFMAG "\177ELF" /* magic string */ +#define SELFMAG 4 /* magic string size */ + +/* Values for e_ident[EI_VERSION] and e_version. */ +#define EV_NONE 0 +#define EV_CURRENT 1 + +/* Values for e_ident[EI_CLASS]. */ +#define ELFCLASSNONE 0 /* Unknown class. */ +#define ELFCLASS32 1 /* 32-bit architecture. */ +#define ELFCLASS64 2 /* 64-bit architecture. */ + +/* Values for e_ident[EI_DATA]. */ +#define ELFDATANONE 0 /* Unknown data format. */ +#define ELFDATA2LSB 1 /* 2's complement little-endian. */ +#define ELFDATA2MSB 2 /* 2's complement big-endian. */ + +/* Values for e_ident[EI_OSABI]. */ +#define ELFOSABI_NONE 0 /* UNIX System V ABI */ +#define ELFOSABI_HPUX 1 /* HP-UX operating system */ +#define ELFOSABI_NETBSD 2 /* NetBSD */ +#define ELFOSABI_LINUX 3 /* GNU/Linux */ +#define ELFOSABI_HURD 4 /* GNU/Hurd */ +#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */ +#define ELFOSABI_SOLARIS 6 /* Solaris */ +#define ELFOSABI_AIX 7 /* AIX */ +#define ELFOSABI_IRIX 8 /* IRIX */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD */ +#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto */ +#define ELFOSABI_OPENBSD 12 /* OpenBSD */ +#define ELFOSABI_OPENVMS 13 /* Open VMS */ +#define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +#define ELFOSABI_SYSV ELFOSABI_NONE /* symbol used in old spec */ +#define ELFOSABI_MONTEREY ELFOSABI_AIX /* Monterey */ + +/* e_ident */ +#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ + (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ + (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ + (ehdr).e_ident[EI_MAG3] == ELFMAG3) + +/* Values for e_type. */ +#define ET_NONE 0 /* Unknown type. */ +#define ET_REL 1 /* Relocatable. */ +#define ET_EXEC 2 /* Executable. */ +#define ET_DYN 3 /* Shared object. */ +#define ET_CORE 4 /* Core file. */ +#define ET_LOOS 0xfe00 /* First operating system specific. */ +#define ET_HIOS 0xfeff /* Last operating system-specific. */ +#define ET_LOPROC 0xff00 /* First processor-specific. */ +#define ET_HIPROC 0xffff /* Last processor-specific. */ + +/* Values for e_machine. */ +#define EM_NONE 0 /* Unknown machine. */ +#define EM_M32 1 /* AT&T WE32100. */ +#define EM_SPARC 2 /* Sun SPARC. */ +#define EM_386 3 /* Intel i386. */ +#define EM_68K 4 /* Motorola 68000. */ +#define EM_88K 5 /* Motorola 88000. */ +#define EM_860 7 /* Intel i860. */ +#define EM_MIPS 8 /* MIPS R3000 Big-Endian only. */ +#define EM_S370 9 /* IBM System/370. */ +#define EM_MIPS_RS3_LE 10 /* MIPS R3000 Little-Endian. */ +#define EM_PARISC 15 /* HP PA-RISC. */ +#define EM_VPP500 17 /* Fujitsu VPP500. */ +#define EM_SPARC32PLUS 18 /* SPARC v8plus. */ +#define EM_960 19 /* Intel 80960. */ +#define EM_PPC 20 /* PowerPC 32-bit. */ +#define EM_PPC64 21 /* PowerPC 64-bit. */ +#define EM_S390 22 /* IBM System/390. */ +#define EM_V800 36 /* NEC V800. */ +#define EM_FR20 37 /* Fujitsu FR20. */ +#define EM_RH32 38 /* TRW RH-32. */ +#define EM_RCE 39 /* Motorola RCE. */ +#define EM_ARM 40 /* ARM. */ +#define EM_SH 42 /* Hitachi SH. */ +#define EM_SPARCV9 43 /* SPARC v9 64-bit. */ +#define EM_TRICORE 44 /* Siemens TriCore embedded processor. */ +#define EM_ARC 45 /* Argonaut RISC Core. */ +#define EM_H8_300 46 /* Hitachi H8/300. */ +#define EM_H8_300H 47 /* Hitachi H8/300H. */ +#define EM_H8S 48 /* Hitachi H8S. */ +#define EM_H8_500 49 /* Hitachi H8/500. */ +#define EM_IA_64 50 /* Intel IA-64 Processor. */ +#define EM_MIPS_X 51 /* Stanford MIPS-X. */ +#define EM_COLDFIRE 52 /* Motorola ColdFire. */ +#define EM_68HC12 53 /* Motorola M68HC12. */ +#define EM_MMA 54 /* Fujitsu MMA. */ +#define EM_PCP 55 /* Siemens PCP. */ +#define EM_NCPU 56 /* Sony nCPU. */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor. */ +#define EM_STARCORE 58 /* Motorola Star*Core processor. */ +#define EM_ME16 59 /* Toyota ME16 processor. */ +#define EM_ST100 60 /* STMicroelectronics ST100 processor. */ +#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ processor. */ +#define EM_X86_64 62 /* Advanced Micro Devices x86-64 */ +#define EM_AMD64 EM_X86_64 /* Advanced Micro Devices x86-64 (compat) */ + +/* Non-standard or deprecated. */ +#define EM_486 6 /* Intel i486. */ +#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ +#define EM_ALPHA_STD 41 /* Digital Alpha (standard value). */ +#define EM_ALPHA 0x9026 /* Alpha (written in the absence of an ABI) */ + +/* Special section indexes. */ +#define SHN_UNDEF 0 /* Undefined, missing, irrelevant. */ +#define SHN_LORESERVE 0xff00 /* First of reserved range. */ +#define SHN_LOPROC 0xff00 /* First processor-specific. */ +#define SHN_HIPROC 0xff1f /* Last processor-specific. */ +#define SHN_LOOS 0xff20 /* First operating system-specific. */ +#define SHN_HIOS 0xff3f /* Last operating system-specific. */ +#define SHN_ABS 0xfff1 /* Absolute values. */ +#define SHN_COMMON 0xfff2 /* Common data. */ +#define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere. */ +#define SHN_HIRESERVE 0xffff /* Last of reserved range. */ + +/* sh_type */ +#define SHT_NULL 0 /* inactive */ +#define SHT_PROGBITS 1 /* program defined information */ +#define SHT_SYMTAB 2 /* symbol table section */ +#define SHT_STRTAB 3 /* string table section */ +#define SHT_RELA 4 /* relocation section with addends */ +#define SHT_HASH 5 /* symbol hash table section */ +#define SHT_DYNAMIC 6 /* dynamic section */ +#define SHT_NOTE 7 /* note section */ +#define SHT_NOBITS 8 /* no space section */ +#define SHT_REL 9 /* relocation section - no addends */ +#define SHT_SHLIB 10 /* reserved - purpose unknown */ +#define SHT_DYNSYM 11 /* dynamic symbol table section */ +#define SHT_INIT_ARRAY 14 /* Initialization function pointers. */ +#define SHT_FINI_ARRAY 15 /* Termination function pointers. */ +#define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs. */ +#define SHT_GROUP 17 /* Section group. */ +#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX). */ +#define SHT_LOOS 0x60000000 /* First of OS specific semantics */ +#define SHT_LOSUNW 0x6ffffff4 +#define SHT_SUNW_dof 0x6ffffff4 +#define SHT_SUNW_cap 0x6ffffff5 +#define SHT_SUNW_SIGNATURE 0x6ffffff6 +#define SHT_SUNW_ANNOTATE 0x6ffffff7 +#define SHT_SUNW_DEBUGSTR 0x6ffffff8 +#define SHT_SUNW_DEBUG 0x6ffffff9 +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_SUNW_verdef 0x6ffffffd +#define SHT_GNU_verdef 0x6ffffffd /* Symbol versions provided */ +#define SHT_SUNW_verneed 0x6ffffffe +#define SHT_GNU_verneed 0x6ffffffe /* Symbol versions required */ +#define SHT_SUNW_versym 0x6fffffff +#define SHT_GNU_versym 0x6fffffff /* Symbol version table */ +#define SHT_HISUNW 0x6fffffff +#define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */ +#define SHT_LOPROC 0x70000000 /* reserved range for processor */ +#define SHT_AMD64_UNWIND 0x70000001 /* unwind information */ +#define SHT_HIPROC 0x7fffffff /* specific section header types */ +#define SHT_LOUSER 0x80000000 /* reserved range for application */ +#define SHT_HIUSER 0xffffffff /* specific indexes */ + +/* Flags for sh_flags. */ +#define SHF_WRITE 0x1 /* Section contains writable data. */ +#define SHF_ALLOC 0x2 /* Section occupies memory. */ +#define SHF_EXECINSTR 0x4 /* Section contains instructions. */ +#define SHF_MERGE 0x10 /* Section may be merged. */ +#define SHF_STRINGS 0x20 /* Section contains strings. */ +#define SHF_INFO_LINK 0x40 /* sh_info holds section index. */ +#define SHF_LINK_ORDER 0x80 /* Special ordering requirements. */ +#define SHF_OS_NONCONFORMING 0x100 /* OS-specific processing required. */ +#define SHF_GROUP 0x200 /* Member of section group. */ +#define SHF_TLS 0x400 /* Section contains TLS data. */ +#define SHF_MASKOS 0x0ff00000 /* OS-specific semantics. */ +#define SHF_MASKPROC 0xf0000000 /* Processor-specific semantics. */ + +/* Values for p_type. */ +#define PT_NULL 0 /* Unused entry. */ +#define PT_LOAD 1 /* Loadable segment. */ +#define PT_DYNAMIC 2 /* Dynamic linking information segment. */ +#define PT_INTERP 3 /* Pathname of interpreter. */ +#define PT_NOTE 4 /* Auxiliary information. */ +#define PT_SHLIB 5 /* Reserved (not used). */ +#define PT_PHDR 6 /* Location of program header itself. */ +#define PT_TLS 7 /* Thread local storage segment */ +#define PT_LOOS 0x60000000 /* First OS-specific. */ +#define PT_SUNW_UNWIND 0x6464e550 /* amd64 UNWIND program header */ +#define PT_GNU_EH_FRAME 0x6474e550 +#define PT_GNU_STACK 0x6474e551 +#define PT_LOSUNW 0x6ffffffa +#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ +#define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */ +#define PT_SUNWDTRACE 0x6ffffffc /* private */ +#define PT_SUNWCAP 0x6ffffffd /* hard/soft capabilities segment */ +#define PT_HISUNW 0x6fffffff +#define PT_HIOS 0x6fffffff /* Last OS-specific. */ +#define PT_LOPROC 0x70000000 /* First processor-specific type. */ +#define PT_HIPROC 0x7fffffff /* Last processor-specific type. */ + +/* Values for p_flags. */ +#define PF_X 0x1 /* Executable. */ +#define PF_W 0x2 /* Writable. */ +#define PF_R 0x4 /* Readable. */ +#define PF_MASKOS 0x0ff00000 /* Operating system-specific. */ +#define PF_MASKPROC 0xf0000000 /* Processor-specific. */ + +/* Extended program header index. */ +#define PN_XNUM 0xffff + +/* Values for d_tag. */ +#define DT_NULL 0 /* Terminating entry. */ +#define DT_NEEDED 1 /* String table offset of a needed shared + library. */ +#define DT_PLTRELSZ 2 /* Total size in bytes of PLT relocations. */ +#define DT_PLTGOT 3 /* Processor-dependent address. */ +#define DT_HASH 4 /* Address of symbol hash table. */ +#define DT_STRTAB 5 /* Address of string table. */ +#define DT_SYMTAB 6 /* Address of symbol table. */ +#define DT_RELA 7 /* Address of ElfNN_Rela relocations. */ +#define DT_RELASZ 8 /* Total size of ElfNN_Rela relocations. */ +#define DT_RELAENT 9 /* Size of each ElfNN_Rela relocation entry. */ +#define DT_STRSZ 10 /* Size of string table. */ +#define DT_SYMENT 11 /* Size of each symbol table entry. */ +#define DT_INIT 12 /* Address of initialization function. */ +#define DT_FINI 13 /* Address of finalization function. */ +#define DT_SONAME 14 /* String table offset of shared object + name. */ +#define DT_RPATH 15 /* String table offset of library path. [sup] */ +#define DT_SYMBOLIC 16 /* Indicates "symbolic" linking. [sup] */ +#define DT_REL 17 /* Address of ElfNN_Rel relocations. */ +#define DT_RELSZ 18 /* Total size of ElfNN_Rel relocations. */ +#define DT_RELENT 19 /* Size of each ElfNN_Rel relocation. */ +#define DT_PLTREL 20 /* Type of relocation used for PLT. */ +#define DT_DEBUG 21 /* Reserved (not used). */ +#define DT_TEXTREL 22 /* Indicates there may be relocations in + non-writable segments. [sup] */ +#define DT_JMPREL 23 /* Address of PLT relocations. */ +#define DT_BIND_NOW 24 /* [sup] */ +#define DT_INIT_ARRAY 25 /* Address of the array of pointers to + initialization functions */ +#define DT_FINI_ARRAY 26 /* Address of the array of pointers to + termination functions */ +#define DT_INIT_ARRAYSZ 27 /* Size in bytes of the array of + initialization functions. */ +#define DT_FINI_ARRAYSZ 28 /* Size in bytes of the array of + terminationfunctions. */ +#define DT_RUNPATH 29 /* String table offset of a null-terminated + library search path string. */ +#define DT_FLAGS 30 /* Object specific flag values. */ +#define DT_ENCODING 32 /* Values greater than or equal to DT_ENCODING + and less than DT_LOOS follow the rules for + the interpretation of the d_un union + as follows: even == 'd_ptr', even == 'd_val' + or none */ +#define DT_PREINIT_ARRAY 32 /* Address of the array of pointers to + pre-initialization functions. */ +#define DT_PREINIT_ARRAYSZ 33 /* Size in bytes of the array of + pre-initialization functions. */ +#define DT_MAXPOSTAGS 34 /* number of positive tags */ +#define DT_LOOS 0x6000000d /* First OS-specific */ +#define DT_SUNW_AUXILIARY 0x6000000d /* symbol auxiliary name */ +#define DT_SUNW_RTLDINF 0x6000000e /* ld.so.1 info (private) */ +#define DT_SUNW_FILTER 0x6000000f /* symbol filter name */ +#define DT_SUNW_CAP 0x60000010 /* hardware/software */ +#define DT_HIOS 0x6ffff000 /* Last OS-specific */ + +/* + * DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the + * Dyn.d_un.d_val field of the Elf*_Dyn structure. + */ +#define DT_VALRNGLO 0x6ffffd00 +#define DT_CHECKSUM 0x6ffffdf8 /* elf checksum */ +#define DT_PLTPADSZ 0x6ffffdf9 /* pltpadding size */ +#define DT_MOVEENT 0x6ffffdfa /* move table entry size */ +#define DT_MOVESZ 0x6ffffdfb /* move table size */ +#define DT_FEATURE_1 0x6ffffdfc /* feature holder */ +#define DT_POSFLAG_1 0x6ffffdfd /* flags for DT_* entries, effecting */ + /* the following DT_* entry. */ + /* See DF_P1_* definitions */ +#define DT_SYMINSZ 0x6ffffdfe /* syminfo table size (in bytes) */ +#define DT_SYMINENT 0x6ffffdff /* syminfo entry size (in bytes) */ +#define DT_VALRNGHI 0x6ffffdff + +/* + * DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the + * Dyn.d_un.d_ptr field of the Elf*_Dyn structure. + * + * If any adjustment is made to the ELF object after it has been + * built, these entries will need to be adjusted. + */ +#define DT_ADDRRNGLO 0x6ffffe00 +#define DT_CONFIG 0x6ffffefa /* configuration information */ +#define DT_DEPAUDIT 0x6ffffefb /* dependency auditing */ +#define DT_AUDIT 0x6ffffefc /* object auditing */ +#define DT_PLTPAD 0x6ffffefd /* pltpadding (sparcv9) */ +#define DT_MOVETAB 0x6ffffefe /* move table */ +#define DT_SYMINFO 0x6ffffeff /* syminfo table */ +#define DT_ADDRRNGHI 0x6ffffeff + +#define DT_VERSYM 0x6ffffff0 /* Address of versym section. */ +#define DT_RELACOUNT 0x6ffffff9 /* number of RELATIVE relocations */ +#define DT_RELCOUNT 0x6ffffffa /* number of RELATIVE relocations */ +#define DT_FLAGS_1 0x6ffffffb /* state flags - see DF_1_* defs */ +#define DT_VERDEF 0x6ffffffc /* Address of verdef section. */ +#define DT_VERDEFNUM 0x6ffffffd /* Number of elems in verdef section */ +#define DT_VERNEED 0x6ffffffe /* Address of verneed section. */ +#define DT_VERNEEDNUM 0x6fffffff /* Number of elems in verneed section */ + +#define DT_LOPROC 0x70000000 /* First processor-specific type. */ +#define DT_DEPRECATED_SPARC_REGISTER 0x7000001 +#define DT_AUXILIARY 0x7ffffffd /* shared library auxiliary name */ +#define DT_USED 0x7ffffffe /* ignored - same as needed */ +#define DT_FILTER 0x7fffffff /* shared library filter name */ +#define DT_HIPROC 0x7fffffff /* Last processor-specific type. */ + +/* Values for DT_FLAGS */ +#define DF_ORIGIN 0x0001 /* Indicates that the object being loaded may + make reference to the $ORIGIN substitution + string */ +#define DF_SYMBOLIC 0x0002 /* Indicates "symbolic" linking. */ +#define DF_TEXTREL 0x0004 /* Indicates there may be relocations in + non-writable segments. */ +#define DF_BIND_NOW 0x0008 /* Indicates that the dynamic linker should + process all relocations for the object + containing this entry before transferring + control to the program. */ +#define DF_STATIC_TLS 0x0010 /* Indicates that the shared object or + executable contains code using a static + thread-local storage scheme. */ + +/* Values for n_type. Used in core files. */ +#define NT_PRSTATUS 1 /* Process status. */ +#define NT_FPREGSET 2 /* Floating point registers. */ +#define NT_PRPSINFO 3 /* Process state info. */ + +/* Symbol Binding - ELFNN_ST_BIND - st_info */ +#define STB_LOCAL 0 /* Local symbol */ +#define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* like global - lower precedence */ +#define STB_LOOS 10 /* Reserved range for operating system */ +#define STB_HIOS 12 /* specific semantics. */ +#define STB_LOPROC 13 /* reserved range for processor */ +#define STB_HIPROC 15 /* specific semantics. */ + +/* Symbol type - ELFNN_ST_TYPE - st_info */ +#define STT_NOTYPE 0 /* Unspecified type. */ +#define STT_OBJECT 1 /* Data object. */ +#define STT_FUNC 2 /* Function. */ +#define STT_SECTION 3 /* Section. */ +#define STT_FILE 4 /* Source file. */ +#define STT_COMMON 5 /* Uninitialized common block. */ +#define STT_TLS 6 /* TLS object. */ +#define STT_NUM 7 +#define STT_LOOS 10 /* Reserved range for operating system */ +#define STT_HIOS 12 /* specific semantics. */ +#define STT_LOPROC 13 /* reserved range for processor */ +#define STT_HIPROC 15 /* specific semantics. */ + +/* Symbol visibility - ELFNN_ST_VISIBILITY - st_other */ +#define STV_DEFAULT 0x0 /* Default visibility (see binding). */ +#define STV_INTERNAL 0x1 /* Special meaning in relocatable objects. */ +#define STV_HIDDEN 0x2 /* Not visible. */ +#define STV_PROTECTED 0x3 /* Visible but not preemptible. */ +#define STV_EXPORTED 0x4 +#define STV_SINGLETON 0x5 +#define STV_ELIMINATE 0x6 + +/* Special symbol table indexes. */ +#define STN_UNDEF 0 /* Undefined symbol index. */ + +/* Symbol versioning flags. */ +#define VER_DEF_CURRENT 1 +#define VER_DEF_IDX(x) VER_NDX(x) + +#define VER_FLG_BASE 0x01 +#define VER_FLG_WEAK 0x02 + +#define VER_NEED_CURRENT 1 +#define VER_NEED_WEAK (1u << 15) +#define VER_NEED_HIDDEN VER_NDX_HIDDEN +#define VER_NEED_IDX(x) VER_NDX(x) + +#define VER_NDX_LOCAL 0 +#define VER_NDX_GLOBAL 1 +#define VER_NDX_GIVEN 2 + +#define VER_NDX_HIDDEN (1u << 15) +#define VER_NDX(x) ((x) & ~(1u << 15)) + +#define CA_SUNW_NULL 0 +#define CA_SUNW_HW_1 1 /* first hardware capabilities entry */ +#define CA_SUNW_SF_1 2 /* first software capabilities entry */ + +/* + * Syminfo flag values + */ +#define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association */ + /* to object containing defn. */ +#define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */ +#define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */ +#define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be */ + /* lazily-loaded */ +#define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to */ + /* object containing defn. */ +#define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference */ + /* directly bind to this symbol */ +#define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */ +#define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */ + +/* + * Syminfo.si_boundto values. + */ +#define SYMINFO_BT_SELF 0xffff /* symbol bound to self */ +#define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */ +#define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */ +#define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */ +#define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */ + +/* + * Syminfo version values. + */ +#define SYMINFO_NONE 0 /* Syminfo version */ +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + +/* + * Relocation types. + * + * All machine architectures are defined here to allow tools on one to + * handle others. + */ + +#define R_386_NONE 0 /* No relocation. */ +#define R_386_32 1 /* Add symbol value. */ +#define R_386_PC32 2 /* Add PC-relative symbol value. */ +#define R_386_GOT32 3 /* Add PC-relative GOT offset. */ +#define R_386_PLT32 4 /* Add PC-relative PLT offset. */ +#define R_386_COPY 5 /* Copy data from shared object. */ +#define R_386_GLOB_DAT 6 /* Set GOT entry to data address. */ +#define R_386_JMP_SLOT 7 /* Set GOT entry to code address. */ +#define R_386_RELATIVE 8 /* Add load address of shared object. */ +#define R_386_GOTOFF 9 /* Add GOT-relative symbol address. */ +#define R_386_GOTPC 10 /* Add PC-relative GOT table address. */ +#define R_386_TLS_TPOFF 14 /* Negative offset in static TLS block */ +#define R_386_TLS_IE 15 /* Absolute address of GOT for -ve static TLS */ +#define R_386_TLS_GOTIE 16 /* GOT entry for negative static TLS block */ +#define R_386_TLS_LE 17 /* Negative offset relative to static TLS */ +#define R_386_TLS_GD 18 /* 32 bit offset to GOT (index,off) pair */ +#define R_386_TLS_LDM 19 /* 32 bit offset to GOT (index,zero) pair */ +#define R_386_TLS_GD_32 24 /* 32 bit offset to GOT (index,off) pair */ +#define R_386_TLS_GD_PUSH 25 /* pushl instruction for Sun ABI GD sequence */ +#define R_386_TLS_GD_CALL 26 /* call instruction for Sun ABI GD sequence */ +#define R_386_TLS_GD_POP 27 /* popl instruction for Sun ABI GD sequence */ +#define R_386_TLS_LDM_32 28 /* 32 bit offset to GOT (index,zero) pair */ +#define R_386_TLS_LDM_PUSH 29 /* pushl instruction for Sun ABI LD sequence */ +#define R_386_TLS_LDM_CALL 30 /* call instruction for Sun ABI LD sequence */ +#define R_386_TLS_LDM_POP 31 /* popl instruction for Sun ABI LD sequence */ +#define R_386_TLS_LDO_32 32 /* 32 bit offset from start of TLS block */ +#define R_386_TLS_IE_32 33 /* 32 bit offset to GOT static TLS offset entry */ +#define R_386_TLS_LE_32 34 /* 32 bit offset within static TLS block */ +#define R_386_TLS_DTPMOD32 35 /* GOT entry containing TLS index */ +#define R_386_TLS_DTPOFF32 36 /* GOT entry containing TLS offset */ +#define R_386_TLS_TPOFF32 37 /* GOT entry of -ve static TLS offset */ + +#define R_ARM_NONE 0 /* No relocation. */ +#define R_ARM_PC24 1 +#define R_ARM_ABS32 2 +#define R_ARM_REL32 3 +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 +#define R_ARM_ABS12 6 +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 +#define R_ARM_SBREL32 9 +#define R_ARM_THM_PC22 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_SWI24 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 +#define R_ARM_COPY 20 /* Copy data from shared object. */ +#define R_ARM_GLOB_DAT 21 /* Set GOT entry to data address. */ +#define R_ARM_JUMP_SLOT 22 /* Set GOT entry to code address. */ +#define R_ARM_RELATIVE 23 /* Add load address of shared object. */ +#define R_ARM_GOTOFF 24 /* Add GOT-relative symbol address. */ +#define R_ARM_GOTPC 25 /* Add PC-relative GOT table address. */ +#define R_ARM_GOT32 26 /* Add PC-relative GOT offset. */ +#define R_ARM_PLT32 27 /* Add PC-relative PLT offset. */ +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS32 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 + +/* Name Value Field Calculation */ +#define R_IA_64_NONE 0 /* None */ +#define R_IA_64_IMM14 0x21 /* immediate14 S + A */ +#define R_IA_64_IMM22 0x22 /* immediate22 S + A */ +#define R_IA_64_IMM64 0x23 /* immediate64 S + A */ +#define R_IA_64_DIR32MSB 0x24 /* word32 MSB S + A */ +#define R_IA_64_DIR32LSB 0x25 /* word32 LSB S + A */ +#define R_IA_64_DIR64MSB 0x26 /* word64 MSB S + A */ +#define R_IA_64_DIR64LSB 0x27 /* word64 LSB S + A */ +#define R_IA_64_GPREL22 0x2a /* immediate22 @gprel(S + A) */ +#define R_IA_64_GPREL64I 0x2b /* immediate64 @gprel(S + A) */ +#define R_IA_64_GPREL32MSB 0x2c /* word32 MSB @gprel(S + A) */ +#define R_IA_64_GPREL32LSB 0x2d /* word32 LSB @gprel(S + A) */ +#define R_IA_64_GPREL64MSB 0x2e /* word64 MSB @gprel(S + A) */ +#define R_IA_64_GPREL64LSB 0x2f /* word64 LSB @gprel(S + A) */ +#define R_IA_64_LTOFF22 0x32 /* immediate22 @ltoff(S + A) */ +#define R_IA_64_LTOFF64I 0x33 /* immediate64 @ltoff(S + A) */ +#define R_IA_64_PLTOFF22 0x3a /* immediate22 @pltoff(S + A) */ +#define R_IA_64_PLTOFF64I 0x3b /* immediate64 @pltoff(S + A) */ +#define R_IA_64_PLTOFF64MSB 0x3e /* word64 MSB @pltoff(S + A) */ +#define R_IA_64_PLTOFF64LSB 0x3f /* word64 LSB @pltoff(S + A) */ +#define R_IA_64_FPTR64I 0x43 /* immediate64 @fptr(S + A) */ +#define R_IA_64_FPTR32MSB 0x44 /* word32 MSB @fptr(S + A) */ +#define R_IA_64_FPTR32LSB 0x45 /* word32 LSB @fptr(S + A) */ +#define R_IA_64_FPTR64MSB 0x46 /* word64 MSB @fptr(S + A) */ +#define R_IA_64_FPTR64LSB 0x47 /* word64 LSB @fptr(S + A) */ +#define R_IA_64_PCREL60B 0x48 /* immediate60 form1 S + A - P */ +#define R_IA_64_PCREL21B 0x49 /* immediate21 form1 S + A - P */ +#define R_IA_64_PCREL21M 0x4a /* immediate21 form2 S + A - P */ +#define R_IA_64_PCREL21F 0x4b /* immediate21 form3 S + A - P */ +#define R_IA_64_PCREL32MSB 0x4c /* word32 MSB S + A - P */ +#define R_IA_64_PCREL32LSB 0x4d /* word32 LSB S + A - P */ +#define R_IA_64_PCREL64MSB 0x4e /* word64 MSB S + A - P */ +#define R_IA_64_PCREL64LSB 0x4f /* word64 LSB S + A - P */ +#define R_IA_64_LTOFF_FPTR22 0x52 /* immediate22 @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR64I 0x53 /* immediate64 @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR32MSB 0x54 /* word32 MSB @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR32LSB 0x55 /* word32 LSB @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR64MSB 0x56 /* word64 MSB @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR64LSB 0x57 /* word64 LSB @ltoff(@fptr(S + A)) */ +#define R_IA_64_SEGREL32MSB 0x5c /* word32 MSB @segrel(S + A) */ +#define R_IA_64_SEGREL32LSB 0x5d /* word32 LSB @segrel(S + A) */ +#define R_IA_64_SEGREL64MSB 0x5e /* word64 MSB @segrel(S + A) */ +#define R_IA_64_SEGREL64LSB 0x5f /* word64 LSB @segrel(S + A) */ +#define R_IA_64_SECREL32MSB 0x64 /* word32 MSB @secrel(S + A) */ +#define R_IA_64_SECREL32LSB 0x65 /* word32 LSB @secrel(S + A) */ +#define R_IA_64_SECREL64MSB 0x66 /* word64 MSB @secrel(S + A) */ +#define R_IA_64_SECREL64LSB 0x67 /* word64 LSB @secrel(S + A) */ +#define R_IA_64_REL32MSB 0x6c /* word32 MSB BD + A */ +#define R_IA_64_REL32LSB 0x6d /* word32 LSB BD + A */ +#define R_IA_64_REL64MSB 0x6e /* word64 MSB BD + A */ +#define R_IA_64_REL64LSB 0x6f /* word64 LSB BD + A */ +#define R_IA_64_LTV32MSB 0x74 /* word32 MSB S + A */ +#define R_IA_64_LTV32LSB 0x75 /* word32 LSB S + A */ +#define R_IA_64_LTV64MSB 0x76 /* word64 MSB S + A */ +#define R_IA_64_LTV64LSB 0x77 /* word64 LSB S + A */ +#define R_IA_64_PCREL21BI 0x79 /* immediate21 form1 S + A - P */ +#define R_IA_64_PCREL22 0x7a /* immediate22 S + A - P */ +#define R_IA_64_PCREL64I 0x7b /* immediate64 S + A - P */ +#define R_IA_64_IPLTMSB 0x80 /* function descriptor MSB special */ +#define R_IA_64_IPLTLSB 0x81 /* function descriptor LSB speciaal */ +#define R_IA_64_SUB 0x85 /* immediate64 A - S */ +#define R_IA_64_LTOFF22X 0x86 /* immediate22 special */ +#define R_IA_64_LDXMOV 0x87 /* immediate22 special */ +#define R_IA_64_TPREL14 0x91 /* imm14 @tprel(S + A) */ +#define R_IA_64_TPREL22 0x92 /* imm22 @tprel(S + A) */ +#define R_IA_64_TPREL64I 0x93 /* imm64 @tprel(S + A) */ +#define R_IA_64_TPREL64MSB 0x96 /* word64 MSB @tprel(S + A) */ +#define R_IA_64_TPREL64LSB 0x97 /* word64 LSB @tprel(S + A) */ +#define R_IA_64_LTOFF_TPREL22 0x9a /* imm22 @ltoff(@tprel(S+A)) */ +#define R_IA_64_DTPMOD64MSB 0xa6 /* word64 MSB @dtpmod(S + A) */ +#define R_IA_64_DTPMOD64LSB 0xa7 /* word64 LSB @dtpmod(S + A) */ +#define R_IA_64_LTOFF_DTPMOD22 0xaa /* imm22 @ltoff(@dtpmod(S+A)) */ +#define R_IA_64_DTPREL14 0xb1 /* imm14 @dtprel(S + A) */ +#define R_IA_64_DTPREL22 0xb2 /* imm22 @dtprel(S + A) */ +#define R_IA_64_DTPREL64I 0xb3 /* imm64 @dtprel(S + A) */ +#define R_IA_64_DTPREL32MSB 0xb4 /* word32 MSB @dtprel(S + A) */ +#define R_IA_64_DTPREL32LSB 0xb5 /* word32 LSB @dtprel(S + A) */ +#define R_IA_64_DTPREL64MSB 0xb6 /* word64 MSB @dtprel(S + A) */ +#define R_IA_64_DTPREL64LSB 0xb7 /* word64 LSB @dtprel(S + A) */ +#define R_IA_64_LTOFF_DTPREL22 0xba /* imm22 @ltoff(@dtprel(S+A)) */ + +#define R_MIPS_NONE 0 /* No reloc */ +#define R_MIPS_16 1 /* Direct 16 bit */ +#define R_MIPS_32 2 /* Direct 32 bit */ +#define R_MIPS_REL32 3 /* PC relative 32 bit */ +#define R_MIPS_26 4 /* Direct 26 bit shifted */ +#define R_MIPS_HI16 5 /* High 16 bit */ +#define R_MIPS_LO16 6 /* Low 16 bit */ +#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ +#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ +#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ +#define R_MIPS_PC16 10 /* PC relative 16 bit */ +#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ +#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ +#define R_MIPS_GOTHI16 21 /* GOT HI 16 bit */ +#define R_MIPS_GOTLO16 22 /* GOT LO 16 bit */ +#define R_MIPS_CALLHI16 30 /* upper 16 bit GOT entry for function */ +#define R_MIPS_CALLLO16 31 /* lower 16 bit GOT entry for function */ + +#define R_PPC_NONE 0 /* No relocation. */ +#define R_PPC_ADDR32 1 +#define R_PPC_ADDR24 2 +#define R_PPC_ADDR16 3 +#define R_PPC_ADDR16_LO 4 +#define R_PPC_ADDR16_HI 5 +#define R_PPC_ADDR16_HA 6 +#define R_PPC_ADDR14 7 +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 +#define R_PPC_REL14 11 +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 + +/* + * TLS relocations + */ +#define R_PPC_TLS 67 +#define R_PPC_DTPMOD32 68 +#define R_PPC_TPREL16 69 +#define R_PPC_TPREL16_LO 70 +#define R_PPC_TPREL16_HI 71 +#define R_PPC_TPREL16_HA 72 +#define R_PPC_TPREL32 73 +#define R_PPC_DTPREL16 74 +#define R_PPC_DTPREL16_LO 75 +#define R_PPC_DTPREL16_HI 76 +#define R_PPC_DTPREL16_HA 77 +#define R_PPC_DTPREL32 78 +#define R_PPC_GOT_TLSGD16 79 +#define R_PPC_GOT_TLSGD16_LO 80 +#define R_PPC_GOT_TLSGD16_HI 81 +#define R_PPC_GOT_TLSGD16_HA 82 +#define R_PPC_GOT_TLSLD16 83 +#define R_PPC_GOT_TLSLD16_LO 84 +#define R_PPC_GOT_TLSLD16_HI 85 +#define R_PPC_GOT_TLSLD16_HA 86 +#define R_PPC_GOT_TPREL16 87 +#define R_PPC_GOT_TPREL16_LO 88 +#define R_PPC_GOT_TPREL16_HI 89 +#define R_PPC_GOT_TPREL16_HA 90 + +/* + * The remaining relocs are from the Embedded ELF ABI, and are not in the + * SVR4 ELF ABI. + */ + +#define R_PPC_EMB_NADDR32 101 +#define R_PPC_EMB_NADDR16 102 +#define R_PPC_EMB_NADDR16_LO 103 +#define R_PPC_EMB_NADDR16_HI 104 +#define R_PPC_EMB_NADDR16_HA 105 +#define R_PPC_EMB_SDAI16 106 +#define R_PPC_EMB_SDA2I16 107 +#define R_PPC_EMB_SDA2REL 108 +#define R_PPC_EMB_SDA21 109 +#define R_PPC_EMB_MRKREF 110 +#define R_PPC_EMB_RELSEC16 111 +#define R_PPC_EMB_RELST_LO 112 +#define R_PPC_EMB_RELST_HI 113 +#define R_PPC_EMB_RELST_HA 114 +#define R_PPC_EMB_BIT_FLD 115 +#define R_PPC_EMB_RELSDA 116 + +#define R_SPARC_NONE 0 +#define R_SPARC_8 1 +#define R_SPARC_16 2 +#define R_SPARC_32 3 +#define R_SPARC_DISP8 4 +#define R_SPARC_DISP16 5 +#define R_SPARC_DISP32 6 +#define R_SPARC_WDISP30 7 +#define R_SPARC_WDISP22 8 +#define R_SPARC_HI22 9 +#define R_SPARC_22 10 +#define R_SPARC_13 11 +#define R_SPARC_LO10 12 +#define R_SPARC_GOT10 13 +#define R_SPARC_GOT13 14 +#define R_SPARC_GOT22 15 +#define R_SPARC_PC10 16 +#define R_SPARC_PC22 17 +#define R_SPARC_WPLT30 18 +#define R_SPARC_COPY 19 +#define R_SPARC_GLOB_DAT 20 +#define R_SPARC_JMP_SLOT 21 +#define R_SPARC_RELATIVE 22 +#define R_SPARC_UA32 23 +#define R_SPARC_PLT32 24 +#define R_SPARC_HIPLT22 25 +#define R_SPARC_LOPLT10 26 +#define R_SPARC_PCPLT32 27 +#define R_SPARC_PCPLT22 28 +#define R_SPARC_PCPLT10 29 +#define R_SPARC_10 30 +#define R_SPARC_11 31 +#define R_SPARC_64 32 +#define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 +#define R_SPARC_PC_HH22 37 +#define R_SPARC_PC_HM10 38 +#define R_SPARC_PC_LM22 39 +#define R_SPARC_WDISP16 40 +#define R_SPARC_WDISP19 41 +#define R_SPARC_GLOB_JMP 42 +#define R_SPARC_7 43 +#define R_SPARC_5 44 +#define R_SPARC_6 45 +#define R_SPARC_DISP64 46 +#define R_SPARC_PLT64 47 +#define R_SPARC_HIX22 48 +#define R_SPARC_LOX10 49 +#define R_SPARC_H44 50 +#define R_SPARC_M44 51 +#define R_SPARC_L44 52 +#define R_SPARC_REGISTER 53 +#define R_SPARC_UA64 54 +#define R_SPARC_UA16 55 +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 + +#define R_X86_64_NONE 0 /* No relocation. */ +#define R_X86_64_64 1 /* Add 64 bit symbol value. */ +#define R_X86_64_PC32 2 /* PC-relative 32 bit signed sym value. */ +#define R_X86_64_GOT32 3 /* PC-relative 32 bit GOT offset. */ +#define R_X86_64_PLT32 4 /* PC-relative 32 bit PLT offset. */ +#define R_X86_64_COPY 5 /* Copy data from shared object. */ +#define R_X86_64_GLOB_DAT 6 /* Set GOT entry to data address. */ +#define R_X86_64_JMP_SLOT 7 /* Set GOT entry to code address. */ +#define R_X86_64_RELATIVE 8 /* Add load address of shared object. */ +#define R_X86_64_GOTPCREL 9 /* Add 32 bit signed pcrel offset to GOT. */ +#define R_X86_64_32 10 /* Add 32 bit zero extended symbol value */ +#define R_X86_64_32S 11 /* Add 32 bit sign extended symbol value */ +#define R_X86_64_16 12 /* Add 16 bit zero extended symbol value */ +#define R_X86_64_PC16 13 /* Add 16 bit signed extended pc relative symbol value */ +#define R_X86_64_8 14 /* Add 8 bit zero extended symbol value */ +#define R_X86_64_PC8 15 /* Add 8 bit signed extended pc relative symbol value */ +#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */ +#define R_X86_64_DTPOFF64 17 /* Offset in TLS block */ +#define R_X86_64_TPOFF64 18 /* Offset in static TLS block */ +#define R_X86_64_TLSGD 19 /* PC relative offset to GD GOT entry */ +#define R_X86_64_TLSLD 20 /* PC relative offset to LD GOT entry */ +#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */ +#define R_X86_64_GOTTPOFF 22 /* PC relative offset to IE GOT entry */ +#define R_X86_64_TPOFF32 23 /* Offset in static TLS block */ + + +#endif /* !_SYS_ELF_COMMON_H_ */ diff --git a/src/coreclr/src/pal/src/libunwind/include/win/pthread.h b/src/coreclr/src/pal/src/libunwind/include/win/pthread.h new file mode 100644 index 00000000000000..8a0b0a1862c88d --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/pthread.h @@ -0,0 +1,30 @@ +// This is an incomplete & imprecice implementation of the Posix +// standard file by the same name + + +// Since this is only intended for VC++ compilers +// use #pragma once instead of guard macros +#pragma once + +#ifdef _MSC_VER // Only for cross compilation to windows + +// #include +#include + +#define PTHREAD_DESTRUCTOR_ITERATIONS 0 +#define PTHREAD_MUTEX_INITIALIZER 0 +#define PTHREAD_ONCE_INIT 0 + +typedef long pthread_key_t; +typedef long pthread_mutex_t; +typedef long pthread_mutexattr_t; +typedef long pthread_once_t; + +int pthread_key_create(pthread_key_t *, void (*)(void*)); +int pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *); +int pthread_mutex_lock(pthread_mutex_t *); +int pthread_mutex_unlock(pthread_mutex_t *); +int pthread_once(pthread_once_t *, void (*)(void)); +int pthread_setspecific(pthread_key_t, const void *); + +#endif // _MSC_VER diff --git a/src/coreclr/src/pal/src/libunwind/include/win/signal.h b/src/coreclr/src/pal/src/libunwind/include/win/signal.h new file mode 100644 index 00000000000000..48e8e3f927938a --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/signal.h @@ -0,0 +1,40 @@ +// This is an incomplete & imprecice implementation of the Posix +// standard file by the same name + + +// Since this is only intended for VC++ compilers +// use #pragma once instead of guard macros +#pragma once + +#ifdef _MSC_VER // Only for cross compilation to windows + +// Posix is a superset of the ISO C signal.h +// include ISO C version first +#include <../ucrt/signal.h> +#include +#include + +#if defined(__linux__) && defined(__x86_64__) +# define SIZEOF_SIGINFO 128 +#elif defined(__linux__) && defined(__aarch64__) +# define SIZEOF_SIGINFO 128 +#elif defined(__linux__) && defined(__arm__) +# define SIZEOF_SIGINFO 128 +#elif !defined(SIZEOF_SIGINFO) + // It is not clear whether the sizeof(siginfo_t) is important + // While compiling on Windows the members are not referenced... + // However the size maybe important during a case or a memcpy + // Barring a full audit it could be important so require the size to be defined +# error SIZEOF_SIGINFO is unknown for this target +#endif + +typedef struct siginfo +{ + uint8_t content[SIZEOF_SIGINFO]; +} siginfo_t; + +typedef long sigset_t; + +int sigfillset(sigset_t *set); + +#endif // _MSC_VER diff --git a/src/coreclr/src/pal/src/libunwind/include/win/stdatomic.h.in b/src/coreclr/src/pal/src/libunwind/include/win/stdatomic.h.in new file mode 100644 index 00000000000000..2607672b4f2d1a --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/stdatomic.h.in @@ -0,0 +1,36 @@ +// This is a non-atomic fake implementatino of stdatomics for when +// compiler C11 stdatomic support is missing and only single threaded +// operation is required + +#ifndef FAKE_STD_ATOMICS_H +#define FAKE_STD_ATOMICS_H + +#include + +#define _Atomic volatile +#define ATOMIC_FLAG_INIT 0 + +typedef unit8_t atomic_bool; +typedef unit8_t atomic_flag; + +#define atomic_compare_and_exchange_strong(x, y, z) return ((*(x) == *(y)) ? ((*(x) = z), true) : ((*(y) = *(x)),false)) + +#define atomic_fetch_add(x, y) *(x) += (y), (*(x) - (y)) + +static inline void atomic_flag_clear(volatile atomic_flag* flag) +{ + *flag = ATOMIC_FLAG_INIT; +} + +static inline atomic_bool atomic_flag_test_and_set( volatile atomic_flag* flag ) +{ + atomic_bool result = *flag; + flag = 1; + return result; +} + +#define atomic_load(x) (*(x)) +#define atomic_store(x, y) do { *(x) = (y); } while (0) + + +#endif // FAKE_STD_ATOMICS_H diff --git a/src/coreclr/src/pal/src/libunwind/include/win/sys/mman.h b/src/coreclr/src/pal/src/libunwind/include/win/sys/mman.h new file mode 100644 index 00000000000000..51d2d10853b841 --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/sys/mman.h @@ -0,0 +1,23 @@ +// This is an incomplete & imprecice implementation of the Posix +// standard file by the same name + + +// Since this is only intended for VC++ compilers +// use #pragma once instead of guard macros +#pragma once + +#ifdef _MSC_VER // Only for cross compilation to windows + +#include + +#define MAP_FAILED (void *) -1 +#define MAP_ANONYMOUS 1 +#define MAP_ANON MAP_ANONYMOUS +#define MAP_PRIVATE 2 +#define PROT_READ 4 +#define PROT_WRITE 8 + +void* mmap(void *, size_t, int, int, int, size_t); +int munmap(void *, size_t); + +#endif // _MSC_VER diff --git a/src/coreclr/src/pal/src/libunwind/include/win/sys/syscall.h b/src/coreclr/src/pal/src/libunwind/include/win/sys/syscall.h new file mode 100644 index 00000000000000..d655d1a81d71fb --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/sys/syscall.h @@ -0,0 +1,11 @@ +// This is an incomplete & imprecice implementation of the Posix +// standard file by the same name + + +// Since this is only intended for VC++ compilers +// use #pragma once instead of guard macros +#pragma once + +#ifdef _MSC_VER // Only for cross compilation to windows + +#endif // _MSC_VER diff --git a/src/coreclr/src/pal/src/libunwind/include/win/sys/types.h b/src/coreclr/src/pal/src/libunwind/include/win/sys/types.h new file mode 100644 index 00000000000000..fdfe8ffe642eff --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/sys/types.h @@ -0,0 +1,19 @@ +// This is an incomplete & imprecice implementation of the Posix +// standard file by the same name + + +// Since this is only intended for VC++ compilers +// use #pragma once instead of guard macros +#pragma once + +#ifdef _MSC_VER // Only for cross compilation to windows + +// Posix is a superset of the ISO C sys/types +// include ISO C version first +#include <../ucrt/sys/types.h> +#include + +typedef size_t pid_t; +typedef ptrdiff_t ssize_t; + +#endif // _MSC_VER diff --git a/src/coreclr/src/pal/src/libunwind/include/win/sys/ucontext.h b/src/coreclr/src/pal/src/libunwind/include/win/sys/ucontext.h new file mode 100644 index 00000000000000..c37c3aba8f739c --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/sys/ucontext.h @@ -0,0 +1,42 @@ +// This is an incomplete & imprecice implementation of the *nix file +// by the same name + + +// Since this is only intended for VC++ compilers +// use #pragma once instead of guard macros +#pragma once + +#ifdef _MSC_VER // Only for cross compilation to windows +#include + +#if defined(__linux__) && defined(__x86_64__) +# define SIZEOF_UCONTEXT 936 +#elif defined(__linux__) && defined(__aarch64__) +# define SIZEOF_UCONTEXT 4560 +#elif defined(__linux__) && defined(__arm__) +# define SIZEOF_UCONTEXT 744 +#elif !defined(SIZEOF_UCONTEXT) + // It is not clear whether the sizeof(ucontext_t) is important + // While compiling on Windows the members are not referenced... + // However the size maybe important during a case or a memcpy + // Barring a full audit it could be important so require the size to be defined +# error SIZEOF_UCONTEXT is unknown for this target +#endif + +typedef struct ucontext +{ + uint8_t content[SIZEOF_UCONTEXT]; +} ucontext_t; + +#ifdef __aarch64__ +// These types are used in the definition of the aarch64 unw_tdep_context_t +// They are not used in UNW_REMOTE_ONLY, so typedef them as something +typedef long sigset_t; +typedef long stack_t; + +// Windows SDK defines reserved. It conflicts with arm64 ucontext +// Undefine it +#undef __reserved +#endif + +#endif // _MSC_VER diff --git a/src/coreclr/src/pal/src/libunwind/include/win/ucontext.h b/src/coreclr/src/pal/src/libunwind/include/win/ucontext.h new file mode 100644 index 00000000000000..fb5aaf73bed755 --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/ucontext.h @@ -0,0 +1,13 @@ +// This is an incomplete & imprecice implementation of the *nix file +// by the same name + + +// Since this is only intended for VC++ compilers +// use #pragma once instead of guard macros +#pragma once + +#ifdef _MSC_VER // Only for cross compilation to windows + +#include + +#endif // _MSC_VER diff --git a/src/coreclr/src/pal/src/libunwind/include/win/unistd.h b/src/coreclr/src/pal/src/libunwind/include/win/unistd.h new file mode 100644 index 00000000000000..1a3aee5da70e7b --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/include/win/unistd.h @@ -0,0 +1,28 @@ +// This is an incomplete & imprecice implementation of the Posix +// standard file by the same name + + +// Since this is only intended for VC++ compilers +// use #pragma once instead of guard macros +#pragma once + +#ifdef _MSC_VER // Only for cross compilation to windows + +#ifndef UNW_REMOTE_ONLY +// This is solely intended to enable compilation of libunwind +// for UNW_REMOTE_ONLY on windows +#error Cross compilation of libunwind on Windows can only support UNW_REMOTE_ONLY +#endif + +#include +#include +#include +#include + +int close(int); +int getpagesize(void); +int open(const char *, int, ...); +ssize_t read(int fd, void *buf, size_t count); +ssize_t write(int, const void *, size_t); + +#endif // _MSC_VER diff --git a/src/coreclr/src/pal/src/libunwind/libunwind-version.txt b/src/coreclr/src/pal/src/libunwind/libunwind-version.txt index 500204b214de7c..20a01b125a1c08 100644 --- a/src/coreclr/src/pal/src/libunwind/libunwind-version.txt +++ b/src/coreclr/src/pal/src/libunwind/libunwind-version.txt @@ -1,4 +1,5 @@ -v1.5-rc2 -https://github.com/libunwind/libunwind/releases/tag/v1.5-rc2 -+https://git.alpinelinux.org/aports/tree/main/libunwind/fix-aarch64-sigset_t.patch -+https://github.com/libunwind/libunwind/pull/179 +v1.5-rc1-28-g9165d2a1 +https://github.com/libunwind/libunwind/commit/9165d2a150d707d3037c2045f2cdc0fabd5fee98 + +Remove upstream CMakelist.txt & src/CMakelist.txt, keep .NET Core custom version +Keep .NET Core oop directory diff --git a/src/coreclr/src/pal/src/libunwind/src/aarch64/Gglobal.c b/src/coreclr/src/pal/src/libunwind/src/aarch64/Gglobal.c index 72e36b2d4d67a8..854b54914db8b7 100644 --- a/src/coreclr/src/pal/src/libunwind/src/aarch64/Gglobal.c +++ b/src/coreclr/src/pal/src/libunwind/src/aarch64/Gglobal.c @@ -28,7 +28,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "dwarf_i.h" HIDDEN define_lock (aarch64_lock); -HIDDEN int tdep_init_done; +HIDDEN atomic_bool tdep_init_done = 0; HIDDEN void tdep_init (void) @@ -39,7 +39,7 @@ tdep_init (void) lock_acquire (&aarch64_lock, saved_mask); { - if (tdep_init_done) + if (atomic_load(&tdep_init_done)) /* another thread else beat us to it... */ goto out; @@ -50,7 +50,7 @@ tdep_init (void) #ifndef UNW_REMOTE_ONLY aarch64_local_addr_space_init (); #endif - tdep_init_done = 1; /* signal that we're initialized... */ + atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */ } out: lock_release (&aarch64_lock, saved_mask); diff --git a/src/coreclr/src/pal/src/libunwind/src/aarch64/Ginit_local.c b/src/coreclr/src/pal/src/libunwind/src/aarch64/Ginit_local.c index 69d4ed3861db9b..3f0080ade06cc2 100644 --- a/src/coreclr/src/pal/src/libunwind/src/aarch64/Ginit_local.c +++ b/src/coreclr/src/pal/src/libunwind/src/aarch64/Ginit_local.c @@ -41,7 +41,7 @@ unw_init_local_common (unw_cursor_t *cursor, unw_context_t *uc, unsigned use_pre { struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/aarch64/Ginit_remote.c b/src/coreclr/src/pal/src/libunwind/src/aarch64/Ginit_remote.c index 9b8ba5b89def1a..26d11ba942b18a 100644 --- a/src/coreclr/src/pal/src/libunwind/src/aarch64/Ginit_remote.c +++ b/src/coreclr/src/pal/src/libunwind/src/aarch64/Ginit_remote.c @@ -33,7 +33,7 @@ unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) #else /* !UNW_LOCAL_ONLY */ struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/aarch64/Gtrace.c b/src/coreclr/src/pal/src/libunwind/src/aarch64/Gtrace.c index c67faf0e357938..bcdf19296b31a1 100644 --- a/src/coreclr/src/pal/src/libunwind/src/aarch64/Gtrace.c +++ b/src/coreclr/src/pal/src/libunwind/src/aarch64/Gtrace.c @@ -52,8 +52,8 @@ static pthread_once_t trace_cache_once = PTHREAD_ONCE_INIT; static sig_atomic_t trace_cache_once_happen; static pthread_key_t trace_cache_key; static struct mempool trace_cache_pool; -static __thread unw_trace_cache_t *tls_cache; -static __thread int tls_cache_destroyed; +static _Thread_local unw_trace_cache_t *tls_cache; +static _Thread_local int tls_cache_destroyed; /* Free memory for a thread's trace cache. */ static void diff --git a/src/coreclr/src/pal/src/libunwind/src/arm/Gex_tables.c b/src/coreclr/src/pal/src/libunwind/src/arm/Gex_tables.c index d6573a65e0c7d9..5eb747581290a0 100644 --- a/src/coreclr/src/pal/src/libunwind/src/arm/Gex_tables.c +++ b/src/coreclr/src/pal/src/libunwind/src/arm/Gex_tables.c @@ -152,13 +152,13 @@ HIDDEN int arm_exidx_decode (const uint8_t *buf, uint8_t len, struct dwarf_cursor *c) { #define READ_OP() *buf++ + assert(buf != NULL); + assert(len > 0); + const uint8_t *end = buf + len; int ret; struct arm_exbuf_data edata; - assert(buf != NULL); - assert(len > 0); - while (buf < end) { uint8_t op = READ_OP (); diff --git a/src/coreclr/src/pal/src/libunwind/src/arm/Gglobal.c b/src/coreclr/src/pal/src/libunwind/src/arm/Gglobal.c index 7b93fbd89a1850..2fb1d21117b10a 100644 --- a/src/coreclr/src/pal/src/libunwind/src/arm/Gglobal.c +++ b/src/coreclr/src/pal/src/libunwind/src/arm/Gglobal.c @@ -26,7 +26,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "dwarf_i.h" HIDDEN define_lock (arm_lock); -HIDDEN int tdep_init_done; +HIDDEN atomic_bool tdep_init_done = 0; /* Unwinding methods to use. See UNW_METHOD_ enums */ HIDDEN int unwi_unwind_method = UNW_ARM_METHOD_ALL; @@ -40,7 +40,7 @@ tdep_init (void) lock_acquire (&arm_lock, saved_mask); { - if (tdep_init_done) + if (atomic_load(&tdep_init_done)) /* another thread else beat us to it... */ goto out; @@ -58,7 +58,7 @@ tdep_init (void) #ifndef UNW_REMOTE_ONLY arm_local_addr_space_init (); #endif - tdep_init_done = 1; /* signal that we're initialized... */ + atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */ } out: lock_release (&arm_lock, saved_mask); diff --git a/src/coreclr/src/pal/src/libunwind/src/arm/Ginit_local.c b/src/coreclr/src/pal/src/libunwind/src/arm/Ginit_local.c index e13519b79a9e6e..8679805dfa320a 100644 --- a/src/coreclr/src/pal/src/libunwind/src/arm/Ginit_local.c +++ b/src/coreclr/src/pal/src/libunwind/src/arm/Ginit_local.c @@ -41,7 +41,7 @@ unw_init_local_common (unw_cursor_t *cursor, unw_context_t *uc, unsigned use_pre { struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/arm/Ginit_remote.c b/src/coreclr/src/pal/src/libunwind/src/arm/Ginit_remote.c index 9b8ba5b89def1a..26d11ba942b18a 100644 --- a/src/coreclr/src/pal/src/libunwind/src/arm/Ginit_remote.c +++ b/src/coreclr/src/pal/src/libunwind/src/arm/Ginit_remote.c @@ -33,7 +33,7 @@ unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) #else /* !UNW_LOCAL_ONLY */ struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/arm/Gtrace.c b/src/coreclr/src/pal/src/libunwind/src/arm/Gtrace.c index 2f277520b36348..51fc281de352e6 100644 --- a/src/coreclr/src/pal/src/libunwind/src/arm/Gtrace.c +++ b/src/coreclr/src/pal/src/libunwind/src/arm/Gtrace.c @@ -52,8 +52,8 @@ static pthread_once_t trace_cache_once = PTHREAD_ONCE_INIT; static sig_atomic_t trace_cache_once_happen; static pthread_key_t trace_cache_key; static struct mempool trace_cache_pool; -static __thread unw_trace_cache_t *tls_cache; -static __thread int tls_cache_destroyed; +static _Thread_local unw_trace_cache_t *tls_cache; +static _Thread_local int tls_cache_destroyed; /* Free memory for a thread's trace cache. */ static void diff --git a/src/coreclr/src/pal/src/libunwind/src/dwarf/Gexpr.c b/src/coreclr/src/pal/src/libunwind/src/dwarf/Gexpr.c index 2af454332dd825..963a064def07c2 100644 --- a/src/coreclr/src/pal/src/libunwind/src/dwarf/Gexpr.c +++ b/src/coreclr/src/pal/src/libunwind/src/dwarf/Gexpr.c @@ -251,18 +251,26 @@ dwarf_eval_expr (struct dwarf_cursor *c, unw_word_t stack_val, unw_word_t *addr, uint32_t u32; uint64_t u64; int ret; + unw_word_t stackerror = 0; + +// pop() is either followed by a semicolon or +// used in a push() macro +// In either case we can sneak in an extra statement # define pop() \ -({ \ - if ((tos - 1) >= MAX_EXPR_STACK_SIZE) \ - { \ - Debug (1, "Stack underflow\n"); \ - return -UNW_EINVAL; \ - } \ - stack[--tos]; \ -}) +(((tos - 1) >= MAX_EXPR_STACK_SIZE) ? \ + stackerror++ : stack[--tos]); \ +if (stackerror) \ + { \ + Debug (1, "Stack underflow\n"); \ + return -UNW_EINVAL; \ + } + +// Removed the parentheses on the asignment +// to allow the extra stack error check +// when x is evaluated # define push(x) \ do { \ - unw_word_t _x = (x); \ + unw_word_t _x = x; \ if (tos >= MAX_EXPR_STACK_SIZE) \ { \ Debug (1, "Stack overflow\n"); \ @@ -270,16 +278,17 @@ do { \ } \ stack[tos++] = _x; \ } while (0) + +// Pick is always used in a push() macro +// In either case we can sneak in an extra statement # define pick(n) \ -({ \ - unsigned int _index = tos - 1 - (n); \ - if (_index >= MAX_EXPR_STACK_SIZE) \ - { \ - Debug (1, "Out-of-stack pick\n"); \ - return -UNW_EINVAL; \ - } \ - stack[_index]; \ -}) +(((tos - 1 - (n)) >= MAX_EXPR_STACK_SIZE) ? \ + stackerror++ : stack[tos - 1 - (n)]); \ +if (stackerror) \ + { \ + Debug (1, "Out-of-stack pick\n"); \ + return -UNW_EINVAL; \ + } as = c->as; arg = c->as_arg; diff --git a/src/coreclr/src/pal/src/libunwind/src/dwarf/Gparser.c b/src/coreclr/src/pal/src/libunwind/src/dwarf/Gparser.c index 28fd73c6b0f7f7..da170d4b35fe3d 100644 --- a/src/coreclr/src/pal/src/libunwind/src/dwarf/Gparser.c +++ b/src/coreclr/src/pal/src/libunwind/src/dwarf/Gparser.c @@ -601,10 +601,10 @@ get_rs_cache (unw_addr_space_t as, intrmask_t *saved_maskp) if (caching == UNW_CACHE_NONE) return NULL; -#if defined(HAVE___THREAD) && HAVE___THREAD +#if defined(HAVE___CACHE_PER_THREAD) && HAVE___CACHE_PER_THREAD if (likely (caching == UNW_CACHE_PER_THREAD)) { - static __thread struct dwarf_rs_cache tls_cache __attribute__((tls_model("initial-exec"))); + static _Thread_local struct dwarf_rs_cache tls_cache __attribute__((tls_model("initial-exec"))); Debug (16, "using TLS cache\n"); cache = &tls_cache; } @@ -617,14 +617,14 @@ get_rs_cache (unw_addr_space_t as, intrmask_t *saved_maskp) lock_acquire (&cache->lock, *saved_maskp); } - if ((atomic_read (&as->cache_generation) != atomic_read (&cache->generation)) + if ((atomic_load (&as->cache_generation) != atomic_load (&cache->generation)) || !cache->hash) { /* cache_size is only set in the global_cache, copy it over before flushing */ cache->log_size = as->global_cache.log_size; if (dwarf_flush_rs_cache (cache) < 0) return NULL; - cache->generation = as->cache_generation; + atomic_store (&cache->generation, atomic_load (&as->cache_generation)); } return cache; diff --git a/src/coreclr/src/pal/src/libunwind/src/hppa/Gglobal.c b/src/coreclr/src/pal/src/libunwind/src/hppa/Gglobal.c index 351a5015d6869b..a5935ffbac1505 100644 --- a/src/coreclr/src/pal/src/libunwind/src/hppa/Gglobal.c +++ b/src/coreclr/src/pal/src/libunwind/src/hppa/Gglobal.c @@ -26,7 +26,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "unwind_i.h" HIDDEN define_lock (hppa_lock); -HIDDEN int tdep_init_done; +HIDDEN atomic_bool tdep_init_done = 0; HIDDEN void tdep_init (void) @@ -37,7 +37,7 @@ tdep_init (void) lock_acquire (&hppa_lock, saved_mask); { - if (tdep_init_done) + if (atomic_load(&tdep_init_done)) /* another thread else beat us to it... */ goto out; @@ -48,7 +48,7 @@ tdep_init (void) #ifndef UNW_REMOTE_ONLY hppa_local_addr_space_init (); #endif - tdep_init_done = 1; /* signal that we're initialized... */ + atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */ } out: lock_release (&hppa_lock, saved_mask); diff --git a/src/coreclr/src/pal/src/libunwind/src/hppa/Ginit_local.c b/src/coreclr/src/pal/src/libunwind/src/hppa/Ginit_local.c index 1fdc7716fd5e09..73a716d15584c5 100644 --- a/src/coreclr/src/pal/src/libunwind/src/hppa/Ginit_local.c +++ b/src/coreclr/src/pal/src/libunwind/src/hppa/Ginit_local.c @@ -41,7 +41,7 @@ unw_init_local_common (unw_cursor_t *cursor, ucontext_t *uc, unsigned use_prev_i { struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/hppa/Ginit_remote.c b/src/coreclr/src/pal/src/libunwind/src/hppa/Ginit_remote.c index 71096ce0e61813..57691e3f2ab628 100644 --- a/src/coreclr/src/pal/src/libunwind/src/hppa/Ginit_remote.c +++ b/src/coreclr/src/pal/src/libunwind/src/hppa/Ginit_remote.c @@ -34,7 +34,7 @@ unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) #else /* !UNW_LOCAL_ONLY */ struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/hppa/get_accessors.c b/src/coreclr/src/pal/src/libunwind/src/hppa/get_accessors.c index 24795801b286e2..11e4ecfda674d3 100644 --- a/src/coreclr/src/pal/src/libunwind/src/hppa/get_accessors.c +++ b/src/coreclr/src/pal/src/libunwind/src/hppa/get_accessors.c @@ -31,7 +31,7 @@ unw_get_accessors_int (unw_addr_space_t as); unw_accessors_t * unw_get_accessors (unw_addr_space_t as) { - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); return &as->acc; diff --git a/src/coreclr/src/pal/src/libunwind/src/ia64/Gglobal.c b/src/coreclr/src/pal/src/libunwind/src/ia64/Gglobal.c index 5c6156f0e22f57..43dc1dcca53889 100644 --- a/src/coreclr/src/pal/src/libunwind/src/ia64/Gglobal.c +++ b/src/coreclr/src/pal/src/libunwind/src/ia64/Gglobal.c @@ -72,7 +72,7 @@ tdep_init (void) lock_acquire (&unw.lock, saved_mask); { - if (tdep_init_done) + if (atomic_load(&tdep_init_done)) /* another thread else beat us to it... */ goto out; @@ -115,7 +115,7 @@ tdep_init (void) #ifndef UNW_REMOTE_ONLY ia64_local_addr_space_init (); #endif - tdep_init_done = 1; /* signal that we're initialized... */ + atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */ } out: lock_release (&unw.lock, saved_mask); diff --git a/src/coreclr/src/pal/src/libunwind/src/ia64/Ginit_local.c b/src/coreclr/src/pal/src/libunwind/src/ia64/Ginit_local.c index 8fe1c679b29e94..ed993f02adc270 100644 --- a/src/coreclr/src/pal/src/libunwind/src/ia64/Ginit_local.c +++ b/src/coreclr/src/pal/src/libunwind/src/ia64/Ginit_local.c @@ -83,7 +83,7 @@ unw_init_local (unw_cursor_t *cursor, unw_context_t *uc) unw_word_t sp, bsp; int ret; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/ia64/Ginit_remote.c b/src/coreclr/src/pal/src/libunwind/src/ia64/Ginit_remote.c index b570c7eab39ead..8894a08666def9 100644 --- a/src/coreclr/src/pal/src/libunwind/src/ia64/Ginit_remote.c +++ b/src/coreclr/src/pal/src/libunwind/src/ia64/Ginit_remote.c @@ -36,7 +36,7 @@ unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) unw_word_t sp, bsp; int ret; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/ia64/Gscript.c b/src/coreclr/src/pal/src/libunwind/src/ia64/Gscript.c index 526aeaf299edc3..ea5ac15f53ed11 100644 --- a/src/coreclr/src/pal/src/libunwind/src/ia64/Gscript.c +++ b/src/coreclr/src/pal/src/libunwind/src/ia64/Gscript.c @@ -26,6 +26,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "offsets.h" #include "regs.h" #include "unwind_i.h" +#include enum ia64_script_insn_opcode { @@ -45,14 +46,10 @@ enum ia64_script_insn_opcode IA64_INSN_MOVE_SCRATCH_NO_NAT /* like above, but clear NaT info */ }; -#if defined(HAVE___THREAD) && HAVE___THREAD -static __thread struct ia64_script_cache ia64_per_thread_cache = +#if defined(HAVE___CACHE_PER_THREAD) && HAVE___CACHE_PER_THREAD +static _Thread_local struct ia64_script_cache ia64_per_thread_cache = { -#ifdef HAVE_ATOMIC_OPS_H - .busy = AO_TS_INITIALIZER -#else - .lock = PTHREAD_MUTEX_INITIALIZER -#endif + .busy = ATOMIC_FLAG_INIT }; #endif @@ -101,30 +98,18 @@ get_script_cache (unw_addr_space_t as, intrmask_t *saved_maskp) if (caching == UNW_CACHE_NONE) return NULL; -#ifdef HAVE_ATOMIC_H - if (!spin_trylock_irqsave (&cache->busy, *saved_maskp)) - return NULL; -#else -# if defined(HAVE___THREAD) && HAVE___THREAD +# if defined(HAVE___CACHE_PER_THREAD) && HAVE___CACHE_PER_THREAD if (as->caching_policy == UNW_CACHE_PER_THREAD) cache = &ia64_per_thread_cache; + else # endif -# ifdef HAVE_ATOMIC_OPS_H - if (AO_test_and_set (&cache->busy) == AO_TS_SET) + if (atomic_flag_test_and_set(&cache->busy)) return NULL; -# else - if (likely (caching == UNW_CACHE_GLOBAL)) - { - Debug (16, "acquiring lock\n"); - lock_acquire (&cache->lock, *saved_maskp); - } -# endif -#endif - if (atomic_read (&as->cache_generation) != atomic_read (&cache->generation)) + if (atomic_load (&as->cache_generation) != atomic_load (&cache->generation)) { flush_script_cache (cache); - cache->generation = as->cache_generation; + atomic_store(&cache->generation, atomic_load (&as->cache_generation)); } return cache; } @@ -136,16 +121,7 @@ put_script_cache (unw_addr_space_t as, struct ia64_script_cache *cache, assert (as->caching_policy != UNW_CACHE_NONE); Debug (16, "unmasking signals/interrupts and releasing lock\n"); -#ifdef HAVE_ATOMIC_H - spin_unlock_irqrestore (&cache->busy, *saved_maskp); -#else -# ifdef HAVE_ATOMIC_OPS_H - AO_CLEAR (&cache->busy); -# else - if (likely (as->caching_policy == UNW_CACHE_GLOBAL)) - lock_release (&cache->lock, *saved_maskp); -# endif -#endif + atomic_flag_clear(&cache->busy); } static struct ia64_script * diff --git a/src/coreclr/src/pal/src/libunwind/src/mi/Gget_accessors.c b/src/coreclr/src/pal/src/libunwind/src/mi/Gget_accessors.c index 31a6fbaf02f09e..8b8a72ea3d93c2 100644 --- a/src/coreclr/src/pal/src/libunwind/src/mi/Gget_accessors.c +++ b/src/coreclr/src/pal/src/libunwind/src/mi/Gget_accessors.c @@ -24,6 +24,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "libunwind_i.h" +#include HIDDEN ALIAS(unw_get_accessors) unw_accessors_t * unw_get_accessors_int (unw_addr_space_t as); @@ -31,7 +32,7 @@ unw_get_accessors_int (unw_addr_space_t as); unw_accessors_t * unw_get_accessors (unw_addr_space_t as) { - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); return &as->acc; } diff --git a/src/coreclr/src/pal/src/libunwind/src/mi/Gset_cache_size.c b/src/coreclr/src/pal/src/libunwind/src/mi/Gset_cache_size.c index 07b282e2c1dce2..014576a1be6309 100644 --- a/src/coreclr/src/pal/src/libunwind/src/mi/Gset_cache_size.c +++ b/src/coreclr/src/pal/src/libunwind/src/mi/Gset_cache_size.c @@ -32,7 +32,7 @@ unw_set_cache_size (unw_addr_space_t as, size_t size, int flag) size_t power = 1; unsigned short log_size = 0; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); if (flag != 0) diff --git a/src/coreclr/src/pal/src/libunwind/src/mi/Gset_caching_policy.c b/src/coreclr/src/pal/src/libunwind/src/mi/Gset_caching_policy.c index aa3d237146e7a8..8fe082983629d1 100644 --- a/src/coreclr/src/pal/src/libunwind/src/mi/Gset_caching_policy.c +++ b/src/coreclr/src/pal/src/libunwind/src/mi/Gset_caching_policy.c @@ -28,7 +28,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ int unw_set_caching_policy (unw_addr_space_t as, unw_caching_policy_t policy) { - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); #if !(defined(HAVE___THREAD) && HAVE___THREAD) diff --git a/src/coreclr/src/pal/src/libunwind/src/mi/flush_cache.c b/src/coreclr/src/pal/src/libunwind/src/mi/flush_cache.c index f2b01158a0ec7b..55ee8a3305edc7 100644 --- a/src/coreclr/src/pal/src/libunwind/src/mi/flush_cache.c +++ b/src/coreclr/src/pal/src/libunwind/src/mi/flush_cache.c @@ -24,6 +24,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "libunwind_i.h" +#include void unw_flush_cache (unw_addr_space_t as, unw_word_t lo, unw_word_t hi) @@ -52,11 +53,5 @@ unw_flush_cache (unw_addr_space_t as, unw_word_t lo, unw_word_t hi) ignores the flush range arguments (lo-hi). This is OK because unw_flush_cache() is allowed to flush more than the requested range. */ - -#ifdef HAVE_FETCH_AND_ADD - fetch_and_add1 (&as->cache_generation); -#else -# warning unw_flush_cache(): need a way to atomically increment an integer. - ++as->cache_generation; -#endif + atomic_fetch_add (&as->cache_generation, 1); } diff --git a/src/coreclr/src/pal/src/libunwind/src/mi/mempool.c b/src/coreclr/src/pal/src/libunwind/src/mi/mempool.c index 536b64e815760e..3e8da67611ed39 100644 --- a/src/coreclr/src/pal/src/libunwind/src/mi/mempool.c +++ b/src/coreclr/src/pal/src/libunwind/src/mi/mempool.c @@ -25,6 +25,8 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "libunwind_i.h" +#include +#include /* From GCC docs: ``Gcc also provides a target specific macro * __BIGGEST_ALIGNMENT__, which is the largest alignment ever used for any data @@ -39,8 +41,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ # define MAX_ALIGN MAX_ALIGN_(sizeof (long double)) #endif -static char sos_memory[SOS_MEMORY_SIZE] ALIGNED(MAX_ALIGN); -static size_t sos_memory_freepos; +static char alignas(MAX_ALIGN) sos_memory[SOS_MEMORY_SIZE]; +static _Atomic size_t sos_memory_freepos = 0; static size_t pg_size; HIDDEN void * @@ -50,29 +52,10 @@ sos_alloc (size_t size) size = UNW_ALIGN(size, MAX_ALIGN); -#if defined(__GNUC__) && defined(HAVE_FETCH_AND_ADD) /* Assume `sos_memory' is suitably aligned. */ assert(((uintptr_t) &sos_memory[0] & (MAX_ALIGN-1)) == 0); - pos = fetch_and_add (&sos_memory_freepos, size); -#else - static define_lock (sos_lock); - intrmask_t saved_mask; - - lock_acquire (&sos_lock, saved_mask); - { - /* No assumptions about `sos_memory' alignment. */ - if (sos_memory_freepos == 0) - { - unsigned align = UNW_ALIGN((uintptr_t) &sos_memory[0], MAX_ALIGN) - - (uintptr_t) &sos_memory[0]; - sos_memory_freepos = align; - } - pos = sos_memory_freepos; - sos_memory_freepos += size; - } - lock_release (&sos_lock, saved_mask); -#endif + pos = atomic_fetch_add (&sos_memory_freepos, size); assert (((uintptr_t) &sos_memory[pos] & (MAX_ALIGN-1)) == 0); assert ((pos+size) <= SOS_MEMORY_SIZE); diff --git a/src/coreclr/src/pal/src/libunwind/src/mips/Gglobal.c b/src/coreclr/src/pal/src/libunwind/src/mips/Gglobal.c index fa9478eebe7050..535fe990c7b5f7 100644 --- a/src/coreclr/src/pal/src/libunwind/src/mips/Gglobal.c +++ b/src/coreclr/src/pal/src/libunwind/src/mips/Gglobal.c @@ -26,7 +26,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "dwarf_i.h" HIDDEN define_lock (mips_lock); -HIDDEN int tdep_init_done; +HIDDEN atomic_bool tdep_init_done = 0; HIDDEN void tdep_init (void) @@ -37,7 +37,7 @@ tdep_init (void) lock_acquire (&mips_lock, saved_mask); { - if (tdep_init_done) + if (atomic_load(&tdep_init_done)) /* another thread else beat us to it... */ goto out; @@ -48,7 +48,7 @@ tdep_init (void) #ifndef UNW_REMOTE_ONLY mips_local_addr_space_init (); #endif - tdep_init_done = 1; /* signal that we're initialized... */ + atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */ } out: lock_release (&mips_lock, saved_mask); diff --git a/src/coreclr/src/pal/src/libunwind/src/mips/Ginit_local.c b/src/coreclr/src/pal/src/libunwind/src/mips/Ginit_local.c index f3153b5ba03b34..61af39ee904868 100644 --- a/src/coreclr/src/pal/src/libunwind/src/mips/Ginit_local.c +++ b/src/coreclr/src/pal/src/libunwind/src/mips/Ginit_local.c @@ -40,7 +40,7 @@ unw_init_local_common(unw_cursor_t *cursor, ucontext_t *uc, unsigned use_prev_in { struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/mips/Ginit_remote.c b/src/coreclr/src/pal/src/libunwind/src/mips/Ginit_remote.c index 9b8ba5b89def1a..26d11ba942b18a 100644 --- a/src/coreclr/src/pal/src/libunwind/src/mips/Ginit_remote.c +++ b/src/coreclr/src/pal/src/libunwind/src/mips/Ginit_remote.c @@ -33,7 +33,7 @@ unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) #else /* !UNW_LOCAL_ONLY */ struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/os-linux.h b/src/coreclr/src/pal/src/libunwind/src/os-linux.h index 3976b38cc293a1..5a9b0b405d96e9 100644 --- a/src/coreclr/src/pal/src/libunwind/src/os-linux.h +++ b/src/coreclr/src/pal/src/libunwind/src/os-linux.h @@ -38,7 +38,7 @@ struct map_iterator }; static inline char * -ltoa (char *buf, long val) +unw_ltoa (char *buf, long val) { char *cp = buf, tmp; ssize_t i, len; @@ -68,7 +68,7 @@ maps_init (struct map_iterator *mi, pid_t pid) char path[sizeof ("/proc/0123456789/maps")], *cp; memcpy (path, "/proc/", 6); - cp = ltoa (path + 6, pid); + cp = unw_ltoa (path + 6, pid); assert (cp + 6 < path + sizeof (path)); memcpy (cp, "/maps", 6); diff --git a/src/coreclr/src/pal/src/libunwind/src/ppc/Ginit_local.c b/src/coreclr/src/pal/src/libunwind/src/ppc/Ginit_local.c index 366cf5bdaf3e36..02632f9ca500c7 100644 --- a/src/coreclr/src/pal/src/libunwind/src/ppc/Ginit_local.c +++ b/src/coreclr/src/pal/src/libunwind/src/ppc/Ginit_local.c @@ -48,7 +48,7 @@ unw_init_local_common(unw_cursor_t *cursor, ucontext_t *uc, unsigned use_prev_in { struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/ppc/Ginit_remote.c b/src/coreclr/src/pal/src/libunwind/src/ppc/Ginit_remote.c index ed85be8971f061..fbca91857d2732 100644 --- a/src/coreclr/src/pal/src/libunwind/src/ppc/Ginit_remote.c +++ b/src/coreclr/src/pal/src/libunwind/src/ppc/Ginit_remote.c @@ -41,7 +41,7 @@ unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) #else /* !UNW_LOCAL_ONLY */ struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/ppc32/Gglobal.c b/src/coreclr/src/pal/src/libunwind/src/ppc32/Gglobal.c index a0f80beec6d95a..e0a2d55114c355 100644 --- a/src/coreclr/src/pal/src/libunwind/src/ppc32/Gglobal.c +++ b/src/coreclr/src/pal/src/libunwind/src/ppc32/Gglobal.c @@ -29,7 +29,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "dwarf_i.h" HIDDEN define_lock (ppc32_lock); -HIDDEN int tdep_init_done; +HIDDEN atomic_bool tdep_init_done = 0; /* The API register numbers are exactly the same as the .eh_frame registers, for now at least. */ @@ -117,7 +117,7 @@ tdep_init (void) lock_acquire (&ppc32_lock, saved_mask); { - if (tdep_init_done) + if (atomic_load(&tdep_init_done)) /* another thread else beat us to it... */ goto out; @@ -128,7 +128,7 @@ tdep_init (void) #ifndef UNW_REMOTE_ONLY ppc32_local_addr_space_init (); #endif - tdep_init_done = 1; /* signal that we're initialized... */ + atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */ } out: lock_release (&ppc32_lock, saved_mask); diff --git a/src/coreclr/src/pal/src/libunwind/src/ppc64/Gglobal.c b/src/coreclr/src/pal/src/libunwind/src/ppc64/Gglobal.c index 9d0b0f55a6c0d1..fd3a53b524e2e8 100644 --- a/src/coreclr/src/pal/src/libunwind/src/ppc64/Gglobal.c +++ b/src/coreclr/src/pal/src/libunwind/src/ppc64/Gglobal.c @@ -29,7 +29,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "dwarf_i.h" HIDDEN define_lock (ppc64_lock); -HIDDEN int tdep_init_done; +HIDDEN atomic_bool tdep_init_done = 0; /* The API register numbers are exactly the same as the .eh_frame registers, for now at least. */ @@ -164,7 +164,7 @@ tdep_init (void) lock_acquire (&ppc64_lock, saved_mask); { - if (tdep_init_done) + if (atomic_load(&tdep_init_done)) /* another thread else beat us to it... */ goto out; @@ -175,7 +175,7 @@ tdep_init (void) #ifndef UNW_REMOTE_ONLY ppc64_local_addr_space_init (); #endif - tdep_init_done = 1; /* signal that we're initialized... */ + atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */ } out: lock_release (&ppc64_lock, saved_mask); diff --git a/src/coreclr/src/pal/src/libunwind/src/s390x/Gglobal.c b/src/coreclr/src/pal/src/libunwind/src/s390x/Gglobal.c index e2abe89d30743a..be49c3f68227e3 100644 --- a/src/coreclr/src/pal/src/libunwind/src/s390x/Gglobal.c +++ b/src/coreclr/src/pal/src/libunwind/src/s390x/Gglobal.c @@ -31,7 +31,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "dwarf_i.h" HIDDEN define_lock (s390x_lock); -HIDDEN int tdep_init_done; +HIDDEN atomic_bool tdep_init_done = 0; /* The API register numbers are exactly the same as the .eh_frame registers, for now at least. */ @@ -81,7 +81,7 @@ tdep_init (void) lock_acquire (&s390x_lock, saved_mask); { - if (tdep_init_done) + if (atomic_load(&tdep_init_done)) /* another thread else beat us to it... */ goto out; @@ -94,7 +94,7 @@ tdep_init (void) #ifndef UNW_REMOTE_ONLY s390x_local_addr_space_init (); #endif - tdep_init_done = 1; /* signal that we're initialized... */ + atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */ } out: lock_release (&s390x_lock, saved_mask); diff --git a/src/coreclr/src/pal/src/libunwind/src/s390x/Ginit_local.c b/src/coreclr/src/pal/src/libunwind/src/s390x/Ginit_local.c index 5eaead0f840bb2..06a7c497415276 100644 --- a/src/coreclr/src/pal/src/libunwind/src/s390x/Ginit_local.c +++ b/src/coreclr/src/pal/src/libunwind/src/s390x/Ginit_local.c @@ -43,7 +43,7 @@ unw_init_local_common (unw_cursor_t *cursor, ucontext_t *uc, unsigned use_prev_i { struct cursor *c = (struct cursor *) cursor; - if (unlikely (!tdep_init_done)) + if (unlikely (!atomic_load(&tdep_init_done))) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/s390x/Ginit_remote.c b/src/coreclr/src/pal/src/libunwind/src/s390x/Ginit_remote.c index efd61d64d4b8f2..9ab1d6df11fc81 100644 --- a/src/coreclr/src/pal/src/libunwind/src/s390x/Ginit_remote.c +++ b/src/coreclr/src/pal/src/libunwind/src/s390x/Ginit_remote.c @@ -36,7 +36,7 @@ unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) #else /* !UNW_LOCAL_ONLY */ struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/sh/Gglobal.c b/src/coreclr/src/pal/src/libunwind/src/sh/Gglobal.c index ed2733397680f9..5fc546f70d3682 100644 --- a/src/coreclr/src/pal/src/libunwind/src/sh/Gglobal.c +++ b/src/coreclr/src/pal/src/libunwind/src/sh/Gglobal.c @@ -27,7 +27,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "dwarf_i.h" HIDDEN define_lock (sh_lock); -HIDDEN int tdep_init_done; +HIDDEN atomic_bool tdep_init_done = 0; HIDDEN void tdep_init (void) @@ -38,7 +38,7 @@ tdep_init (void) lock_acquire (&sh_lock, saved_mask); { - if (tdep_init_done) + if (atomic_load(&tdep_init_done)) /* another thread else beat us to it... */ goto out; @@ -49,7 +49,7 @@ tdep_init (void) #ifndef UNW_REMOTE_ONLY sh_local_addr_space_init (); #endif - tdep_init_done = 1; /* signal that we're initialized... */ + atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */ } out: lock_release (&sh_lock, saved_mask); diff --git a/src/coreclr/src/pal/src/libunwind/src/sh/Ginit_local.c b/src/coreclr/src/pal/src/libunwind/src/sh/Ginit_local.c index 45631306bcd814..76b64e73ba276d 100644 --- a/src/coreclr/src/pal/src/libunwind/src/sh/Ginit_local.c +++ b/src/coreclr/src/pal/src/libunwind/src/sh/Ginit_local.c @@ -41,7 +41,7 @@ unw_init_local_common (unw_cursor_t *cursor, unw_context_t *uc, unsigned use_pre { struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/sh/Ginit_remote.c b/src/coreclr/src/pal/src/libunwind/src/sh/Ginit_remote.c index 9b8ba5b89def1a..26d11ba942b18a 100644 --- a/src/coreclr/src/pal/src/libunwind/src/sh/Ginit_remote.c +++ b/src/coreclr/src/pal/src/libunwind/src/sh/Ginit_remote.c @@ -33,7 +33,7 @@ unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) #else /* !UNW_LOCAL_ONLY */ struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/tilegx/Gcreate_addr_space.c b/src/coreclr/src/pal/src/libunwind/src/tilegx/Gcreate_addr_space.c index 39acdc2c3d3abb..da66813bc091f0 100644 --- a/src/coreclr/src/pal/src/libunwind/src/tilegx/Gcreate_addr_space.c +++ b/src/coreclr/src/pal/src/libunwind/src/tilegx/Gcreate_addr_space.c @@ -33,15 +33,6 @@ unw_create_addr_space (unw_accessors_t *a, int byte_order) #ifdef UNW_LOCAL_ONLY return NULL; #else - unw_addr_space_t as = malloc (sizeof (*as)); - - if (!as) - return NULL; - - memset (as, 0, sizeof (*as)); - - as->acc = *a; - /* * Tilegx supports only big or little-endian, not weird stuff like * PDP_ENDIAN. @@ -51,6 +42,14 @@ unw_create_addr_space (unw_accessors_t *a, int byte_order) && byte_order != __BIG_ENDIAN) return NULL; + unw_addr_space_t as = malloc (sizeof (*as)); + if (!as) + return NULL; + + memset (as, 0, sizeof (*as)); + + as->acc = *a; + if (byte_order == 0) /* use host default: */ as->big_endian = (__BYTE_ORDER == __BIG_ENDIAN); diff --git a/src/coreclr/src/pal/src/libunwind/src/tilegx/Gglobal.c b/src/coreclr/src/pal/src/libunwind/src/tilegx/Gglobal.c index e18f50a50f3b3e..5232d41c23bba9 100644 --- a/src/coreclr/src/pal/src/libunwind/src/tilegx/Gglobal.c +++ b/src/coreclr/src/pal/src/libunwind/src/tilegx/Gglobal.c @@ -28,7 +28,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ __attribute__((weak)) pthread_mutex_t tilegx_lock = PTHREAD_MUTEX_INITIALIZER; -HIDDEN int tdep_init_done; +HIDDEN atomic_bool tdep_init_done = 0; HIDDEN const uint8_t dwarf_to_unw_regnum_map[] = { @@ -47,7 +47,7 @@ tdep_init (void) lock_acquire (&tilegx_lock, saved_mask); - if (tdep_init_done) + if (atomic_load(&tdep_init_done)) /* another thread else beat us to it... */ goto out; @@ -57,7 +57,7 @@ tdep_init (void) #ifndef UNW_REMOTE_ONLY tilegx_local_addr_space_init (); #endif - tdep_init_done = 1; /* signal that we're initialized... */ + atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */ out: lock_release (&tilegx_lock, saved_mask); diff --git a/src/coreclr/src/pal/src/libunwind/src/tilegx/Ginit_local.c b/src/coreclr/src/pal/src/libunwind/src/tilegx/Ginit_local.c index 31a716df348e3b..029558675fd99b 100644 --- a/src/coreclr/src/pal/src/libunwind/src/tilegx/Ginit_local.c +++ b/src/coreclr/src/pal/src/libunwind/src/tilegx/Ginit_local.c @@ -41,7 +41,7 @@ unw_init_local_common(unw_cursor_t *cursor, ucontext_t *uc, unsigned use_prev_in { struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); memset(c, 0, sizeof(unw_cursor_t)); diff --git a/src/coreclr/src/pal/src/libunwind/src/tilegx/Ginit_remote.c b/src/coreclr/src/pal/src/libunwind/src/tilegx/Ginit_remote.c index 2a31b18aaef78d..d6a874c13e82bd 100644 --- a/src/coreclr/src/pal/src/libunwind/src/tilegx/Ginit_remote.c +++ b/src/coreclr/src/pal/src/libunwind/src/tilegx/Ginit_remote.c @@ -34,7 +34,7 @@ unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) #else /* !UNW_LOCAL_ONLY */ struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/win/pal-single-threaded.c b/src/coreclr/src/pal/src/libunwind/src/win/pal-single-threaded.c new file mode 100644 index 00000000000000..88a57fdb14b6e8 --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/src/win/pal-single-threaded.c @@ -0,0 +1,114 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// This is minimal implementation of posix functions files required to cross compile +// libunwind on a Windows host for UNW_REMOTE_ONLY application. + +// This a completely thread unsafe implementation +// It is likely sufficient for a single thread's usage of UNW_REMOTE_ONLY debugging of +// a read-only dump. + +#include +#include +#include +#include +#include +#include "libunwind_i.h" +#include "compiler.h" + + +int getpagesize(void) +{ + // 4096 is truth for most targets + // Unlikely to matter in dump debugging + return 4096; +} + +void* mmap(void *addr, size_t length, int prot, int flags, int fd, size_t offset) +{ + // We shouldn't be doing anything other than anonymous mappings + if ((flags & MAP_ANONYMOUS) == 0) + return MAP_FAILED; + + return calloc(1, length); +} + +int munmap(void *addr, size_t length) +{ + free(addr); + return 0; +} + +int pthread_key_create(pthread_key_t *key, void (*destroy)(void*)) +{ + // We are not implementing pthread_getspecific so this sholdn't matter much + return 0; +} + +int pthread_setspecific(pthread_key_t key, const void *value) +{ + // We are not implementing pthread_getspecific so this sholdn't matter much + return 0; +} + +int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) +{ + // For dump debugging we don't need locking + // We expect to run in a single thread + return 0; +} + +int pthread_mutex_lock(pthread_mutex_t *mutex) +{ + // For dump debugging we don't need locking + // We expect to run in a single thread + return 0; +} + +int pthread_mutex_unlock(pthread_mutex_t *mutex) +{ + // For dump debugging we don't need locking + // We expect to run in a single thread + return 0; +} + +int pthread_once(pthread_once_t *control, void (*init)(void)) +{ + if (control == 0) + return -1; + + // We expect to run in a single thread + // We don't need atomics here + if (*control != PTHREAD_ONCE_INIT) + { + (*init)(); + *control = ~PTHREAD_ONCE_INIT; + } + return 0; +} + +int sigfillset(sigset_t *set) +{ + return 0; +} + +ssize_t read(int fd, void *buf, size_t count) +{ + // For dump debugging we shouldn't need to open files + // Especially since we didn't implement open() + return -1; +} + +int close(int fd) +{ + // For dump debugging we shouldn't need to open files + // Especially since we didn't implement open() + return -1; +} + +// ALIAS(x) is nop. We need this alias to link properly +unw_accessors_t * unw_get_accessors_int (unw_addr_space_t as) +{ + return unw_get_accessors(as); +} diff --git a/src/coreclr/src/pal/src/libunwind/src/x86/Gglobal.c b/src/coreclr/src/pal/src/libunwind/src/x86/Gglobal.c index 132b8249944115..f1d11d18f5b18a 100644 --- a/src/coreclr/src/pal/src/libunwind/src/x86/Gglobal.c +++ b/src/coreclr/src/pal/src/libunwind/src/x86/Gglobal.c @@ -27,7 +27,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "dwarf_i.h" HIDDEN define_lock (x86_lock); -HIDDEN int tdep_init_done; +HIDDEN atomic_bool tdep_init_done = 0; /* See comments for svr4_dbx_register_map[] in gcc/config/i386/i386.c. */ @@ -49,7 +49,7 @@ tdep_init (void) lock_acquire (&x86_lock, saved_mask); { - if (tdep_init_done) + if (atomic_load(&tdep_init_done)) /* another thread else beat us to it... */ goto out; @@ -60,7 +60,7 @@ tdep_init (void) #ifndef UNW_REMOTE_ONLY x86_local_addr_space_init (); #endif - tdep_init_done = 1; /* signal that we're initialized... */ + atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */ } out: lock_release (&x86_lock, saved_mask); diff --git a/src/coreclr/src/pal/src/libunwind/src/x86/Ginit_local.c b/src/coreclr/src/pal/src/libunwind/src/x86/Ginit_local.c index bff068704def7f..0342315d822b4e 100644 --- a/src/coreclr/src/pal/src/libunwind/src/x86/Ginit_local.c +++ b/src/coreclr/src/pal/src/libunwind/src/x86/Ginit_local.c @@ -41,7 +41,7 @@ unw_init_local_common(unw_cursor_t *cursor, ucontext_t *uc, unsigned use_prev_in { struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/x86/Ginit_remote.c b/src/coreclr/src/pal/src/libunwind/src/x86/Ginit_remote.c index 7c15096e4f7f75..18c46624bc26ff 100644 --- a/src/coreclr/src/pal/src/libunwind/src/x86/Ginit_remote.c +++ b/src/coreclr/src/pal/src/libunwind/src/x86/Ginit_remote.c @@ -34,7 +34,7 @@ unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) #else /* !UNW_LOCAL_ONLY */ struct cursor *c = (struct cursor *) cursor; - if (!tdep_init_done) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/x86_64/Gglobal.c b/src/coreclr/src/pal/src/libunwind/src/x86_64/Gglobal.c index 9a7b1957eb8d99..812cfb54298e8c 100644 --- a/src/coreclr/src/pal/src/libunwind/src/x86_64/Gglobal.c +++ b/src/coreclr/src/pal/src/libunwind/src/x86_64/Gglobal.c @@ -28,13 +28,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "config.h" #include "unwind_i.h" #include "dwarf_i.h" +#include HIDDEN define_lock (x86_64_lock); -#ifdef HAVE_ATOMIC_OPS_H - HIDDEN AO_t tdep_init_done; -#else - HIDDEN int tdep_init_done; -#endif +HIDDEN atomic_bool tdep_init_done = 0; /* See comments for svr4_dbx_register_map[] in gcc/config/i386/i386.c. */ @@ -87,7 +84,7 @@ tdep_init (void) SIGPROCMASK (SIG_SETMASK, &full_mask, &saved_mask); mutex_lock (&x86_64_lock); { - if (atomic_read(&tdep_init_done)) + if (atomic_load(&tdep_init_done)) /* another thread else beat us to it... */ goto out; @@ -96,12 +93,12 @@ tdep_init (void) dwarf_init (); +#ifndef UNW_REMOTE_ONLY tdep_init_mem_validate (); -#ifndef UNW_REMOTE_ONLY x86_64_local_addr_space_init (); #endif - fetch_and_add1(&tdep_init_done); /* signal that we're initialized... */ + atomic_store(&tdep_init_done, 1); /* signal that we're initialized... */ } out: mutex_unlock(&x86_64_lock); diff --git a/src/coreclr/src/pal/src/libunwind/src/x86_64/Ginit.c b/src/coreclr/src/pal/src/libunwind/src/x86_64/Ginit.c index fd8d418b1a5762..800c5f6fe0abf0 100644 --- a/src/coreclr/src/pal/src/libunwind/src/x86_64/Ginit.c +++ b/src/coreclr/src/pal/src/libunwind/src/x86_64/Ginit.c @@ -35,6 +35,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include #include +#include #include "unwind_i.h" @@ -163,7 +164,7 @@ static int mincore_validate (void *addr, size_t len) /* mincore could fail with EAGAIN but we conservatively return -1 instead of looping. */ - if (mincore (addr, len, (char *)mvec) != 0) + if (mincore (addr, len, (unsigned char *)mvec) != 0) { return -1; } @@ -186,7 +187,7 @@ tdep_init_mem_validate (void) unw_word_t addr = PAGE_START((unw_word_t)&present); unsigned char mvec[1]; int ret; - while ((ret = mincore ((void*)addr, PAGE_SIZE, (char *)mvec)) == -1 && + while ((ret = mincore ((void*)addr, PAGE_SIZE, (unsigned char *)mvec)) == -1 && errno == EAGAIN) {} if (ret == 0) { @@ -203,10 +204,10 @@ tdep_init_mem_validate (void) /* Cache of already validated addresses */ #define NLGA 4 -#if defined(HAVE___THREAD) && HAVE___THREAD +#if defined(HAVE___CACHE_PER_THREAD) && HAVE___CACHE_PER_THREAD // thread-local variant -static __thread unw_word_t last_good_addr[NLGA]; -static __thread int lga_victim; +static _Thread_local unw_word_t last_good_addr[NLGA]; +static _Thread_local int lga_victim; static int is_cached_valid_mem(unw_word_t addr) @@ -239,10 +240,10 @@ cache_valid_mem(unw_word_t addr) lga_victim = victim; } -#elif HAVE_ATOMIC_OPS_H +#else // global, thread safe variant -static AO_T last_good_addr[NLGA]; -static AO_T lga_victim; +static _Atomic unw_word_t last_good_addr[NLGA]; +static _Atomic int lga_victim; static int is_cached_valid_mem(unw_word_t addr) @@ -250,7 +251,7 @@ is_cached_valid_mem(unw_word_t addr) int i; for (i = 0; i < NLGA; i++) { - if (addr == AO_load(&last_good_addr[i])) + if (addr == atomic_load(&last_good_addr[i])) return 1; } return 0; @@ -260,30 +261,19 @@ static void cache_valid_mem(unw_word_t addr) { int i, victim; - victim = AO_load(&lga_victim); + victim = atomic_load(&lga_victim); + unw_word_t zero = 0; for (i = 0; i < NLGA; i++) { - if (AO_compare_and_swap(&last_good_addr[victim], 0, addr)) { + if (atomic_compare_exchange_strong(&last_good_addr[victim], &zero, addr)) { return; } victim = (victim + 1) % NLGA; } /* All slots full. Evict the victim. */ - AO_store(&last_good_addr[victim], addr); + atomic_store(&last_good_addr[victim], addr); victim = (victim + 1) % NLGA; - AO_store(&lga_victim, victim); -} -#else -// disabled, no cache -static int -is_cached_valid_mem(unw_word_t addr UNUSED) -{ - return 0; -} - -static void -cache_valid_mem(unw_word_t addr UNUSED) -{ + atomic_store(&lga_victim, victim); } #endif diff --git a/src/coreclr/src/pal/src/libunwind/src/x86_64/Ginit_local.c b/src/coreclr/src/pal/src/libunwind/src/x86_64/Ginit_local.c index 12a9e3e4c96aa8..06a7c497415276 100644 --- a/src/coreclr/src/pal/src/libunwind/src/x86_64/Ginit_local.c +++ b/src/coreclr/src/pal/src/libunwind/src/x86_64/Ginit_local.c @@ -43,7 +43,7 @@ unw_init_local_common (unw_cursor_t *cursor, ucontext_t *uc, unsigned use_prev_i { struct cursor *c = (struct cursor *) cursor; - if (unlikely (!atomic_read(&tdep_init_done))) + if (unlikely (!atomic_load(&tdep_init_done))) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/x86_64/Ginit_remote.c b/src/coreclr/src/pal/src/libunwind/src/x86_64/Ginit_remote.c index f411b233317823..9ab1d6df11fc81 100644 --- a/src/coreclr/src/pal/src/libunwind/src/x86_64/Ginit_remote.c +++ b/src/coreclr/src/pal/src/libunwind/src/x86_64/Ginit_remote.c @@ -36,7 +36,7 @@ unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) #else /* !UNW_LOCAL_ONLY */ struct cursor *c = (struct cursor *) cursor; - if (!atomic_read(&tdep_init_done)) + if (!atomic_load(&tdep_init_done)) tdep_init (); Debug (1, "(cursor=%p)\n", c); diff --git a/src/coreclr/src/pal/src/libunwind/src/x86_64/Gtrace.c b/src/coreclr/src/pal/src/libunwind/src/x86_64/Gtrace.c index 824527f9beaac0..40be17eb6e9fc8 100644 --- a/src/coreclr/src/pal/src/libunwind/src/x86_64/Gtrace.c +++ b/src/coreclr/src/pal/src/libunwind/src/x86_64/Gtrace.c @@ -50,8 +50,8 @@ static pthread_once_t trace_cache_once = PTHREAD_ONCE_INIT; static sig_atomic_t trace_cache_once_happen; static pthread_key_t trace_cache_key; static struct mempool trace_cache_pool; -static __thread unw_trace_cache_t *tls_cache; -static __thread int tls_cache_destroyed; +static _Thread_local unw_trace_cache_t *tls_cache; +static _Thread_local int tls_cache_destroyed; /* Free memory for a thread's trace cache. */ static void From 5800f608373fe7aa3039387780e8252d71ec6f29 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Thu, 4 Jun 2020 20:31:04 -0400 Subject: [PATCH 02/17] Add libunwind to cross DAC --- src/coreclr/CMakeLists.txt | 4 + src/coreclr/src/debug/daccess/dacfn.cpp | 12 +- src/coreclr/src/dlls/mscordac/CMakeLists.txt | 6 + .../src/pal/src/exception/remote-unwind.cpp | 75 ++++++--- .../src/pal/src/exception/seh-unwind.cpp | 59 ++++--- .../src/pal/src/libunwind/CMakeLists.txt | 145 ++++++++++++++++-- .../src/pal/src/libunwind/src/CMakeLists.txt | 107 ++++++------- 7 files changed, 295 insertions(+), 113 deletions(-) diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index e684f778d85f55..8ed459e8450beb 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -75,6 +75,10 @@ if(CLR_CMAKE_HOST_UNIX) add_subdirectory(src/pal) add_subdirectory(src/hosts) +else(CLR_CMAKE_HOST_UNIX) + if(CLR_CMAKE_TARGET_UNIX) + add_subdirectory(src/pal/src/libunwind) + endif(CLR_CMAKE_TARGET_UNIX) endif(CLR_CMAKE_HOST_UNIX) # Add this subdir. We install the headers for the jit. diff --git a/src/coreclr/src/debug/daccess/dacfn.cpp b/src/coreclr/src/debug/daccess/dacfn.cpp index 359e0f41dbc4b1..1ef7bdf0ff2a93 100644 --- a/src/coreclr/src/debug/daccess/dacfn.cpp +++ b/src/coreclr/src/debug/daccess/dacfn.cpp @@ -245,6 +245,16 @@ static BOOL DacReadAllAdapter(PVOID address, PVOID buffer, SIZE_T size) return TRUE; } +#ifdef HOST_WINDOWS +// For the cross OS dac, we don't have the full pal layer +// Use these minimal prototypes instead of the full pal header +typedef BOOL(*UnwindReadMemoryCallback)(PVOID address, PVOID buffer, SIZE_T size); + +extern +BOOL +PAL_VirtualUnwindOutOfProc(PT_CONTEXT context, PT_KNONVOLATILE_CONTEXT_POINTERS contextPointers, SIZE_T baseAddress, UnwindReadMemoryCallback readMemoryCallback); +#endif + HRESULT DacVirtualUnwind(ULONG32 threadId, PT_CONTEXT context, PT_KNONVOLATILE_CONTEXT_POINTERS contextPointers) { @@ -273,9 +283,7 @@ DacVirtualUnwind(ULONG32 threadId, PT_CONTEXT context, PT_KNONVOLATILE_CONTEXT_P #endif { SIZE_T baseAddress = DacGlobalBase(); -#ifdef HOST_UNIX if (baseAddress == 0 || !PAL_VirtualUnwindOutOfProc(context, contextPointers, baseAddress, DacReadAllAdapter)) -#endif { hr = E_FAIL; } diff --git a/src/coreclr/src/dlls/mscordac/CMakeLists.txt b/src/coreclr/src/dlls/mscordac/CMakeLists.txt index 692a803333bff8..c32c8d1cbe25c3 100644 --- a/src/coreclr/src/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscordac/CMakeLists.txt @@ -183,6 +183,12 @@ else(CLR_CMAKE_HOST_WIN32) ) endif(CLR_CMAKE_HOST_WIN32) +if(CLR_CMAKE_HOST_WIN32 AND CLR_CMAKE_TARGET_UNIX) + list(APPEND COREDAC_LIBRARIES + libunwind_xdac + ) +endif(CLR_CMAKE_HOST_WIN32 AND CLR_CMAKE_TARGET_UNIX) + target_link_libraries(mscordaccore PRIVATE ${COREDAC_LIBRARIES}) # Create the DAC module index header file containing the DAC build id diff --git a/src/coreclr/src/pal/src/exception/remote-unwind.cpp b/src/coreclr/src/pal/src/exception/remote-unwind.cpp index 355905e334736e..a6e66819fb7ff6 100644 --- a/src/coreclr/src/pal/src/exception/remote-unwind.cpp +++ b/src/coreclr/src/pal/src/exception/remote-unwind.cpp @@ -39,6 +39,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --*/ +#ifdef HOST_UNIX #include "config.h" #include "pal/palinternal.h" #include "pal/dbgmsg.h" @@ -64,18 +65,62 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); +#ifndef ElfW +#define ElfW(foo) Elf_ ## foo +#endif +#define Ehdr ElfW(Ehdr) +#define Phdr ElfW(Phdr) +#define Shdr ElfW(Shdr) +#define Nhdr ElfW(Nhdr) +#define Dyn ElfW(Dyn) + +#else // HOST_UNIX + +#include +#define __STDC_FORMAT_MACROS +#include +#include +#include "debugmacros.h" +#include "crosscomp.h" + +#define KNONVOLATILE_CONTEXT_POINTERS T_KNONVOLATILE_CONTEXT_POINTERS +#define CONTEXT T_CONTEXT + +typedef BOOL(*UnwindReadMemoryCallback)(PVOID address, PVOID buffer, SIZE_T size); + +#define ASSERT(x, ...) +#define TRACE(x, ...) + +#ifndef ElfW +#ifdef TARGET_64BIT +#define ElfW(foo) Elf64_ ## foo +#else // TARGET_64BIT +#define ElfW(foo) Elf32_ ## foo +#endif // TARGET_64BIT +#endif // ElfW + +#define Ehdr ElfW(Ehdr) +#define Phdr ElfW(Phdr) +#define Shdr ElfW(Shdr) +#define Nhdr ElfW(Nhdr) +#define Dyn ElfW(Dyn) + +#define PALAPI + +#endif // HOST_UNIX + #if defined(HAVE_UNW_GET_ACCESSORS) #include #include -#if defined(HOST_X86) || defined(HOST_ARM) +#if defined(TARGET_X86) || defined(TARGET_ARM) #define PRIx PRIx32 #define PRIu PRIu32 #define PRId PRId32 #define PRIA "08" #define PRIxA PRIA PRIx -#elif defined(HOST_AMD64) || defined(HOST_ARM64) +#elif defined(TARGET_AMD64) || defined(TARGET_ARM64) #define PRIx PRIx64 #define PRIu PRIu64 #define PRId PRId64 @@ -83,14 +128,6 @@ SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); #define PRIxA PRIA PRIx #endif -#ifndef ElfW -#define ElfW(foo) Elf_ ## foo -#endif -#define Ehdr ElfW(Ehdr) -#define Phdr ElfW(Phdr) -#define Shdr ElfW(Shdr) -#define Nhdr ElfW(Nhdr) -#define Dyn ElfW(Dyn) extern "C" int _OOP_find_proc_info( @@ -120,7 +157,7 @@ typedef struct _libunwindInfo static void UnwindContextToContext(unw_cursor_t *cursor, CONTEXT *winContext) { -#if defined(HOST_AMD64) +#if defined(TARGET_AMD64) unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Rip); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Rsp); unw_get_reg(cursor, UNW_X86_64_RBP, (unw_word_t *) &winContext->Rbp); @@ -129,14 +166,14 @@ static void UnwindContextToContext(unw_cursor_t *cursor, CONTEXT *winContext) unw_get_reg(cursor, UNW_X86_64_R13, (unw_word_t *) &winContext->R13); unw_get_reg(cursor, UNW_X86_64_R14, (unw_word_t *) &winContext->R14); unw_get_reg(cursor, UNW_X86_64_R15, (unw_word_t *) &winContext->R15); -#elif defined(HOST_X86) +#elif defined(TARGET_X86) unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Eip); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Esp); unw_get_reg(cursor, UNW_X86_EBP, (unw_word_t *) &winContext->Ebp); unw_get_reg(cursor, UNW_X86_EBX, (unw_word_t *) &winContext->Ebx); unw_get_reg(cursor, UNW_X86_ESI, (unw_word_t *) &winContext->Esi); unw_get_reg(cursor, UNW_X86_EDI, (unw_word_t *) &winContext->Edi); -#elif defined(HOST_ARM) +#elif defined(TARGET_ARM) unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Pc); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Sp); unw_get_reg(cursor, UNW_ARM_R4, (unw_word_t *) &winContext->R4); @@ -149,7 +186,7 @@ static void UnwindContextToContext(unw_cursor_t *cursor, CONTEXT *winContext) unw_get_reg(cursor, UNW_ARM_R11, (unw_word_t *) &winContext->R11); unw_get_reg(cursor, UNW_ARM_R14, (unw_word_t *) &winContext->Lr); TRACE("sp %p pc %p lr %p\n", winContext->Sp, winContext->Pc, winContext->Lr); -#elif defined(HOST_ARM64) +#elif defined(TARGET_ARM64) unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Pc); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Sp); unw_get_reg(cursor, UNW_AARCH64_X19, (unw_word_t *) &winContext->X19); @@ -210,7 +247,7 @@ access_reg(unw_addr_space_t as, unw_regnum_t regnum, unw_word_t *valp, int write switch (regnum) { -#if defined(HOST_AMD64) +#if defined(TARGET_AMD64) case UNW_REG_IP: *valp = (unw_word_t)winContext->Rip; break; case UNW_REG_SP: *valp = (unw_word_t)winContext->Rsp; break; case UNW_X86_64_RBP: *valp = (unw_word_t)winContext->Rbp; break; @@ -219,14 +256,14 @@ access_reg(unw_addr_space_t as, unw_regnum_t regnum, unw_word_t *valp, int write case UNW_X86_64_R13: *valp = (unw_word_t)winContext->R13; break; case UNW_X86_64_R14: *valp = (unw_word_t)winContext->R14; break; case UNW_X86_64_R15: *valp = (unw_word_t)winContext->R15; break; -#elif defined(HOST_X86) +#elif defined(TARGET_X86) case UNW_REG_IP: *valp = (unw_word_t)winContext->Eip; break; case UNW_REG_SP: *valp = (unw_word_t)winContext->Esp; break; case UNW_X86_EBX: *valp = (unw_word_t)winContext->Ebx; break; case UNW_X86_ESI: *valp = (unw_word_t)winContext->Esi; break; case UNW_X86_EDI: *valp = (unw_word_t)winContext->Edi; break; case UNW_X86_EBP: *valp = (unw_word_t)winContext->Ebp; break; -#elif defined(HOST_ARM) +#elif defined(TARGET_ARM) case UNW_ARM_R4: *valp = (unw_word_t)winContext->R4; break; case UNW_ARM_R5: *valp = (unw_word_t)winContext->R5; break; case UNW_ARM_R6: *valp = (unw_word_t)winContext->R6; break; @@ -238,7 +275,7 @@ access_reg(unw_addr_space_t as, unw_regnum_t regnum, unw_word_t *valp, int write case UNW_ARM_R13: *valp = (unw_word_t)winContext->Sp; break; case UNW_ARM_R14: *valp = (unw_word_t)winContext->Lr; break; case UNW_ARM_R15: *valp = (unw_word_t)winContext->Pc; break; -#elif defined(HOST_ARM64) +#elif defined(TARGET_ARM64) case UNW_AARCH64_X19: *valp = (unw_word_t)winContext->X19; break; case UNW_AARCH64_X20: *valp = (unw_word_t)winContext->X20; break; case UNW_AARCH64_X21: *valp = (unw_word_t)winContext->X21; break; @@ -479,4 +516,4 @@ PAL_VirtualUnwindOutOfProc(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *cont return FALSE; } -#endif // defined(HOST_AMD64) && defined(HAVE_UNW_GET_ACCESSORS) +#endif // defined(HAVE_UNW_GET_ACCESSORS) diff --git a/src/coreclr/src/pal/src/exception/seh-unwind.cpp b/src/coreclr/src/pal/src/exception/seh-unwind.cpp index 654e385dec40a6..38f43fd6991875 100644 --- a/src/coreclr/src/pal/src/exception/seh-unwind.cpp +++ b/src/coreclr/src/pal/src/exception/seh-unwind.cpp @@ -19,6 +19,7 @@ Module Name: --*/ +#ifdef HOST_UNIX #include "pal/context.h" #include "pal.h" #include @@ -35,6 +36,24 @@ Module Name: #ifdef __llvm__ #pragma clang diagnostic pop #endif +#else // HOST_UNIX + +#include +#define __STDC_FORMAT_MACROS +#include +#include +#include "debugmacros.h" +#include "crosscomp.h" + +#define KNONVOLATILE_CONTEXT_POINTERS T_KNONVOLATILE_CONTEXT_POINTERS +#define CONTEXT T_CONTEXT + +#define ASSERT(x, ...) +#define TRACE(x, ...) + +#define PALAPI + +#endif // HOST_UNIX //---------------------------------------------------------------------- // Virtual Unwinding @@ -42,7 +61,7 @@ Module Name: #if UNWIND_CONTEXT_IS_UCONTEXT_T -#if defined(HOST_AMD64) +#if defined(TARGET_AMD64) #define ASSIGN_UNWIND_REGS \ ASSIGN_REG(Rip) \ ASSIGN_REG(Rsp) \ @@ -52,7 +71,7 @@ Module Name: ASSIGN_REG(R13) \ ASSIGN_REG(R14) \ ASSIGN_REG(R15) -#elif defined(HOST_ARM64) +#elif defined(TARGET_ARM64) #define ASSIGN_UNWIND_REGS \ ASSIGN_REG(Pc) \ ASSIGN_REG(Sp) \ @@ -68,7 +87,7 @@ Module Name: ASSIGN_REG(X26) \ ASSIGN_REG(X27) \ ASSIGN_REG(X28) -#elif defined(HOST_X86) +#elif defined(TARGET_X86) #define ASSIGN_UNWIND_REGS \ ASSIGN_REG(Eip) \ ASSIGN_REG(Esp) \ @@ -89,7 +108,7 @@ static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwCon #else static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwContext) { -#if defined(HOST_ARM) +#if defined(TARGET_ARM) // Assuming that unw_set_reg() on cursor will point the cursor to the // supposed stack frame is dangerous for libunwind-arm in Linux. // It is because libunwind's unw_cursor_t has other data structure @@ -132,7 +151,7 @@ static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwCon static void WinContextToUnwindCursor(CONTEXT *winContext, unw_cursor_t *cursor) { -#if defined(HOST_AMD64) +#if defined(TARGET_AMD64) unw_set_reg(cursor, UNW_REG_IP, winContext->Rip); unw_set_reg(cursor, UNW_REG_SP, winContext->Rsp); unw_set_reg(cursor, UNW_X86_64_RBP, winContext->Rbp); @@ -141,7 +160,7 @@ static void WinContextToUnwindCursor(CONTEXT *winContext, unw_cursor_t *cursor) unw_set_reg(cursor, UNW_X86_64_R13, winContext->R13); unw_set_reg(cursor, UNW_X86_64_R14, winContext->R14); unw_set_reg(cursor, UNW_X86_64_R15, winContext->R15); -#elif defined(HOST_X86) +#elif defined(TARGET_X86) unw_set_reg(cursor, UNW_REG_IP, winContext->Eip); unw_set_reg(cursor, UNW_REG_SP, winContext->Esp); unw_set_reg(cursor, UNW_X86_EBP, winContext->Ebp); @@ -154,7 +173,7 @@ static void WinContextToUnwindCursor(CONTEXT *winContext, unw_cursor_t *cursor) void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext) { -#if defined(HOST_AMD64) +#if defined(TARGET_AMD64) unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Rip); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Rsp); unw_get_reg(cursor, UNW_X86_64_RBP, (unw_word_t *) &winContext->Rbp); @@ -163,14 +182,14 @@ void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext) unw_get_reg(cursor, UNW_X86_64_R13, (unw_word_t *) &winContext->R13); unw_get_reg(cursor, UNW_X86_64_R14, (unw_word_t *) &winContext->R14); unw_get_reg(cursor, UNW_X86_64_R15, (unw_word_t *) &winContext->R15); -#elif defined(HOST_X86) +#elif defined(TARGET_X86) unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Eip); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Esp); unw_get_reg(cursor, UNW_X86_EBP, (unw_word_t *) &winContext->Ebp); unw_get_reg(cursor, UNW_X86_EBX, (unw_word_t *) &winContext->Ebx); unw_get_reg(cursor, UNW_X86_ESI, (unw_word_t *) &winContext->Esi); unw_get_reg(cursor, UNW_X86_EDI, (unw_word_t *) &winContext->Edi); -#elif defined(HOST_ARM) +#elif defined(TARGET_ARM) unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Sp); unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Pc); unw_get_reg(cursor, UNW_ARM_R14, (unw_word_t *) &winContext->Lr); @@ -182,7 +201,7 @@ void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext) unw_get_reg(cursor, UNW_ARM_R9, (unw_word_t *) &winContext->R9); unw_get_reg(cursor, UNW_ARM_R10, (unw_word_t *) &winContext->R10); unw_get_reg(cursor, UNW_ARM_R11, (unw_word_t *) &winContext->R11); -#elif defined(HOST_ARM64) +#elif defined(TARGET_ARM64) unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Pc); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Sp); unw_get_reg(cursor, UNW_AARCH64_X29, (unw_word_t *) &winContext->Fp); @@ -222,19 +241,19 @@ static void GetContextPointer(unw_cursor_t *cursor, unw_context_t *unwContext, i void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOLATILE_CONTEXT_POINTERS *contextPointers) { -#if defined(HOST_AMD64) +#if defined(TARGET_AMD64) GetContextPointer(cursor, unwContext, UNW_X86_64_RBP, &contextPointers->Rbp); GetContextPointer(cursor, unwContext, UNW_X86_64_RBX, &contextPointers->Rbx); GetContextPointer(cursor, unwContext, UNW_X86_64_R12, &contextPointers->R12); GetContextPointer(cursor, unwContext, UNW_X86_64_R13, &contextPointers->R13); GetContextPointer(cursor, unwContext, UNW_X86_64_R14, &contextPointers->R14); GetContextPointer(cursor, unwContext, UNW_X86_64_R15, &contextPointers->R15); -#elif defined(HOST_X86) +#elif defined(TARGET_X86) GetContextPointer(cursor, unwContext, UNW_X86_EBX, &contextPointers->Ebx); GetContextPointer(cursor, unwContext, UNW_X86_EBP, &contextPointers->Ebp); GetContextPointer(cursor, unwContext, UNW_X86_ESI, &contextPointers->Esi); GetContextPointer(cursor, unwContext, UNW_X86_EDI, &contextPointers->Edi); -#elif defined(HOST_ARM) +#elif defined(TARGET_ARM) GetContextPointer(cursor, unwContext, UNW_ARM_R4, &contextPointers->R4); GetContextPointer(cursor, unwContext, UNW_ARM_R5, &contextPointers->R5); GetContextPointer(cursor, unwContext, UNW_ARM_R6, &contextPointers->R6); @@ -243,7 +262,7 @@ void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOL GetContextPointer(cursor, unwContext, UNW_ARM_R9, &contextPointers->R9); GetContextPointer(cursor, unwContext, UNW_ARM_R10, &contextPointers->R10); GetContextPointer(cursor, unwContext, UNW_ARM_R11, &contextPointers->R11); -#elif defined(HOST_ARM64) +#elif defined(TARGET_ARM64) GetContextPointer(cursor, unwContext, UNW_AARCH64_X19, &contextPointers->X19); GetContextPointer(cursor, unwContext, UNW_AARCH64_X20, &contextPointers->X20); GetContextPointer(cursor, unwContext, UNW_AARCH64_X21, &contextPointers->X21); @@ -260,6 +279,8 @@ void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOL #endif } +#ifndef HOST_WINDOWS + extern int g_common_signal_handler_context_locvar_offset; BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers) @@ -329,16 +350,16 @@ BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextP if (unw_is_signal_frame(&cursor) > 0) { context->ContextFlags |= CONTEXT_EXCEPTION_ACTIVE; -#if defined(HOST_ARM) || defined(HOST_ARM64) || defined(HOST_X86) +#if defined(TARGET_ARM) || defined(TARGET_ARM64) || defined(TARGET_X86) context->ContextFlags &= ~CONTEXT_UNWOUND_TO_CALL; -#endif // HOST_ARM || HOST_ARM64 +#endif // TARGET_ARM || TARGET_ARM64 } else { context->ContextFlags &= ~CONTEXT_EXCEPTION_ACTIVE; -#if defined(HOST_ARM) || defined(HOST_ARM64) || defined(HOST_X86) +#if defined(TARGET_ARM) || defined(TARGET_ARM64) || defined(TARGET_X86) context->ContextFlags |= CONTEXT_UNWOUND_TO_CALL; -#endif // HOST_ARM || HOST_ARM64 +#endif // TARGET_ARM || TARGET_ARM64 } // Update the passed in windows context to reflect the unwind @@ -535,3 +556,5 @@ RaiseException(IN DWORD dwExceptionCode, LOGEXIT("RaiseException returns\n"); } + +#endif // !HOST_WINDOWS diff --git a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt index fc47c89f640cf2..cba54895054fbb 100644 --- a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt @@ -1,21 +1,146 @@ -add_subdirectory(src) +project(unwind) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) # define variables for the configure_file below -if (CLR_CMAKE_HOST_ARCH_AMD64) - set(arch x86_64) -elseif(CLR_CMAKE_HOST_ARCH_ARM64) - set(arch aarch64) -elseif(CLR_CMAKE_PLATFROM_ARCH_ARM) - set(arch arm) -elseif(CLR_CMAKE_HOST_ARCH_I386) - set(arch x86) -endif() +if (CLR_CMAKE_TARGET_ARCH_AMD64) + set(TARGET_AMD64 1) + set(arch x86_64) + add_definitions(-D__x86_64__) + add_definitions(-D__amd64__) +elseif(CLR_CMAKE_TARGET_ARCH_ARM64) + set(TARGET_AARCH64 1) + set(arch aarch64) + add_definitions(-D__aarch64__) +elseif(CLR_CMAKE_TARGET_ARCH_ARM) + set(TARGET_ARM 1) + set(arch arm) + add_definitions(-D__arm__) +else () + message(FATAL_ERROR "Unrecognize value in environment variable TARGET") +endif () + +if(CLR_CMAKE_TARGET_LINUX) + add_definitions(-D__linux__) +endif () set(PKG_MAJOR "1") set(PKG_MINOR "5") set(PKG_EXTRA "-rc2") +set(PACKAGE_STRING "libunwind") +set(PACKAGE_BUGREPORT "") + +include(CheckCSourceCompiles) +include(CheckIncludeFiles) + +if (CLR_CMAKE_HOST_UNIX) + # Disable warning due to incorrect format specifier in debugging printf via the Debug macro + add_compile_options(-Wno-format -Wno-format-security) + + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wno-header-guard) + else() + add_compile_options(-Wno-unused-value) + add_compile_options(-Wno-unused-result) + add_compile_options(-Wno-implicit-function-declaration) + add_compile_options(-Wno-incompatible-pointer-types) + endif() + if(CLR_CMAKE_TARGET_ARCH_ARM) + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Disable warning due to labs function called on unsigned argument + add_compile_options(-Wno-absolute-value) + # Disable warning in asm: use of SP or PC in the list is deprecated + add_compile_options(-Wno-inline-asm) + endif() + # Disable warning for a bug in the libunwind source src/arm/Gtrace.c:529, but not in code that we exercise + add_compile_options(-Wno-implicit-function-declaration) + # Disable warning due to an unused function prel31_read + add_compile_options(-Wno-unused-function) + # The arm sources include ex_tables.h from include/tdep-arm without going through a redirection + # in include/tdep like it works for similar files on other architectures. So we need to add + # the include/tdep-arm to include directories + include_directories(../include/tdep-arm) + elseif(CLR_CMAKE_TARGET_ARCH_ARM64) + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Disable warning due to labs function called on unsigned argument + add_compile_options(-Wno-absolute-value) + endif() + elseif(CLR_CMAKE_TARGET_ARCH_I386) + # Disable warning for a bug in the libunwind source src/x86/Gos-linux.c, but not in code that we exercise + add_compile_options(-Wno-incompatible-pointer-types) + endif() + + add_definitions(-DPACKAGE_STRING="") + add_definitions(-DPACKAGE_BUGREPORT="") + +else (CLR_CMAKE_HOST_UNIX) + # Assume we are using default MSVC compiler + add_compile_options(/std:c++latest) + add_compile_options(/TC) # compile all files as C + add_compile_options(/permissive-) + + # files for cross os compilation + include_directories(include/win) + + # Warnings in release builds + add_compile_options(-wd4068) # ignore unknown pragma warnings (gcc pragmas) + add_compile_options(-wd4146) # minus operator applied to unsigned + add_compile_options(-wd4244) # possible loss of data + add_compile_options(-wd4267) # possible loss of data + add_compile_options(-wd4334) # 32-bit shift implicitly converted to 64 bits + + # Disable warning due to incorrect format specifier in debugging printf via the Debug macro + add_compile_options(-wd4311) # pointer truncation from 'unw_word_t *' to 'long' + add_compile_options(-wd4475) # 'fprintf' : length modifier 'L' cannot be used + add_compile_options(-wd4477) # fprintf argument type + + # Windows builds will only support remote unwind + add_definitions(-DUNW_REMOTE_ONLY) + + # Disable security warnings + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + + # Our posix abstraction layer will provide these headers + set(HAVE_ELF_H 1) + set(HAVE_ENDIAN_H 1) + + # MSVC compiler is currently missing C11 stdalign.h header + # Fake it until support is added + check_include_files(stdalign.h HAVE_STDALIGN_H) + if (NOT HAVE_STDALIGN_H) + configure_file(include/win/fakestdalign.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/stdalign.h) + endif (NOT HAVE_STDALIGN_H) + + # MSVC compiler is currently missing C11 stdatomic.h header + # Fake it until support is added + check_include_files(stdatomic.h HAVE_STDATOMIC_H) + if (NOT HAVE_STDATOMIC_H) + configure_file(include/win/fakestdatomic.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/stdatomic.h) + endif (NOT HAVE_STDATOMIC_H) + + # MSVC compiler is currently missing C11 _Thread_local + check_c_source_compiles("void main() { _Thread_local int a; }" HAVE_THREAD_LOCAL) + if (NOT HAVE_THREAD_LOCAL) + add_definitions(-D_Thread_local=) + endif (NOT HAVE_THREAD_LOCAL) + + configure_file(include/config.h.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h) +endif (CLR_CMAKE_HOST_UNIX) + +add_definitions(-DHAVE_CONFIG_H=1) + +# The HAVE___THREAD set to 1 causes creation of thread local variable with tls_model("initial-exec") +# which is incompatible with usage of the unwind code in a shared library. +add_definitions(-DHAVE___THREAD=0) + +add_definitions(-D_GNU_SOURCE) + configure_file(include/libunwind-common.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunwind-common.h) configure_file(include/libunwind.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunwind.h) configure_file(include/tdep/libunwind_i.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/tdep/libunwind_i.h) + +add_subdirectory(src) + + diff --git a/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt index 6014e9d80a574e..3e748ff628d00a 100644 --- a/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt @@ -1,61 +1,21 @@ -project(unwind) +# other source files +include_directories(../include/tdep) +include_directories(../include) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/../include/tdep) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/../include) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +if (CLR_CMAKE_HOST_UNIX) + include(configure.cmake) +endif (CLR_CMAKE_HOST_UNIX) -include(configure.cmake) - -# The HAVE___THREAD set to 1 causes creation of thread local variable with tls_model("initial-exec") -# which is incompatible with usage of the unwind code in a shared library. -add_definitions(-DHAVE___THREAD=0) -add_definitions(-DHAVE_CONFIG_H=1) - -add_definitions(-DPACKAGE_STRING="") -add_definitions(-DPACKAGE_BUGREPORT="") - -add_definitions(-D_GNU_SOURCE) - -# Disable warning due to incorrect format specifier in debugging printf via the Debug macro -add_compile_options(-Wno-format -Wno-format-security) - -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wno-header-guard) -else() - add_compile_options(-Wno-unused-value) - add_compile_options(-Wno-unused-result) - add_compile_options(-Wno-implicit-function-declaration) - add_compile_options(-Wno-incompatible-pointer-types) -endif() - -if(CLR_CMAKE_HOST_ARCH_ARM) +if(CLR_CMAKE_TARGET_ARCH_ARM) # Ensure that the remote and local unwind code can reside in the same binary without name clashing add_definitions("-Darm_search_unwind_table=UNW_OBJ(arm_search_unwind_table)") - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # Disable warning due to labs function called on unsigned argument - add_compile_options(-Wno-absolute-value) - # Disable warning in asm: use of SP or PC in the list is deprecated - add_compile_options(-Wno-inline-asm) - endif() - # Disable warning for a bug in the libunwind source src/arm/Gtrace.c:529, but not in code that we exercise - add_compile_options(-Wno-implicit-function-declaration) - # Disable warning due to an unused function prel31_read - add_compile_options(-Wno-unused-function) - # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension - add_definitions(-Dasm=__asm__) # The arm sources include ex_tables.h from include/tdep-arm without going through a redirection # in include/tdep like it works for similar files on other architectures. So we need to add # the include/tdep-arm to include directories include_directories(../include/tdep-arm) -elseif(CLR_CMAKE_HOST_ARCH_ARM64) - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # Disable warning due to labs function called on unsigned argument - add_compile_options(-Wno-absolute-value) - endif() - # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension - add_definitions(-Dasm=__asm__) -elseif(CLR_CMAKE_HOST_ARCH_I386) - # Disable warning for a bug in the libunwind source src/x86/Gos-linux.c, but not in code that we exercise - add_compile_options(-Wno-incompatible-pointer-types) endif() SET(libunwind_ptrace_la_SOURCES @@ -123,7 +83,7 @@ SET(libunwind_la_SOURCES_os_solaris_local # Nothing ) -if(CLR_CMAKE_HOST_LINUX) +if(CLR_CMAKE_TARGET_LINUX) SET(libunwind_la_SOURCES_os ${libunwind_la_SOURCES_os_linux}) SET(libunwind_la_SOURCES_os_local ${libunwind_la_SOURCES_os_linux_local}) SET(libunwind_la_SOURCES_x86_os x86/Gos-linux.c) @@ -134,7 +94,7 @@ if(CLR_CMAKE_HOST_LINUX) SET(libunwind_la_SOURCES_arm_os arm/Gos-linux.c) SET(libunwind_la_SOURCES_arm_os_local arm/Los-linux.c) list(APPEND libunwind_coredump_la_SOURCES coredump/_UCD_access_reg_linux.c) -elseif(CLR_CMAKE_HOST_FREEBSD) +elseif(CLR_CMAKE_TARGET_FREEBSD) SET(libunwind_la_SOURCES_os ${libunwind_la_SOURCES_os_freebsd}) SET(libunwind_la_SOURCES_os_local ${libunwind_la_SOURCES_os_freebsd_local}) SET(libunwind_la_SOURCES_x86_os x86/Gos-freebsd.c) @@ -333,35 +293,54 @@ SET(libunwind_x86_64_la_SOURCES_x86_64 x86_64/Gstash_frame.c x86_64/Gstep.c x86_64/Gtrace.c ) -if(CLR_CMAKE_HOST_ARCH_ARM64) +if(CLR_CMAKE_TARGET_ARCH_ARM64) SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_aarch64}) SET(libunwind_remote_la_SOURCES ${libunwind_aarch64_la_SOURCES_aarch64}) SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES}) list(APPEND libunwind_setjmp_la_SOURCES aarch64/siglongjmp.S) -elseif(CLR_CMAKE_HOST_ARCH_ARM) +elseif(CLR_CMAKE_TARGET_ARCH_ARM) SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_arm}) SET(libunwind_remote_la_SOURCES ${libunwind_arm_la_SOURCES_arm}) SET(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES}) list(APPEND libunwind_setjmp_la_SOURCES arm/siglongjmp.S) -elseif(CLR_CMAKE_HOST_ARCH_I386) +elseif(CLR_CMAKE_TARGET_ARCH_I386) SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_x86} ${libunwind_x86_la_SOURCES_os}) SET(libunwind_remote_la_SOURCES ${libunwind_x86_la_SOURCES_x86}) SET(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES}) list(APPEND libunwind_setjmp_la_SOURCES x86/longjmp.S x86/siglongjmp.S) -elseif(CLR_CMAKE_HOST_ARCH_AMD64) +elseif(CLR_CMAKE_TARGET_ARCH_AMD64) SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_x86_64}) SET(libunwind_remote_la_SOURCES ${libunwind_x86_64_la_SOURCES_x86_64}) SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES}) list(APPEND libunwind_setjmp_la_SOURCES x86_64/longjmp.S x86_64/siglongjmp.SA) endif() -add_library(libunwind - OBJECT - ${libunwind_la_SOURCES} - ${libunwind_remote_la_SOURCES} - ${libunwind_dwarf_local_la_SOURCES} - ${libunwind_dwarf_common_la_SOURCES} - ${libunwind_dwarf_generic_la_SOURCES} - ${libunwind_elf_la_SOURCES} -) +if(CLR_CMAKE_HOST_UNIX) + add_library(libunwind + OBJECT + ${libunwind_la_SOURCES} + ${libunwind_remote_la_SOURCES} + ${libunwind_dwarf_local_la_SOURCES} + ${libunwind_dwarf_common_la_SOURCES} + ${libunwind_dwarf_generic_la_SOURCES} + ${libunwind_elf_la_SOURCES} + ) +else(CLR_CMAKE_HOST_UNIX) + set_source_files_properties(${CLR_DIR}/src/pal/src/exception/remote-unwind.cpp PROPERTIES COMPILE_FLAGS /TP INCLUDE_DIRECTORIES ${CLR_DIR}/src/inc) + set_source_files_properties(${CLR_DIR}/src/pal/src/exception/seh-unwind.cpp PROPERTIES COMPILE_FLAGS /TP INCLUDE_DIRECTORIES ${CLR_DIR}/src/inc) + add_library(libunwind_xdac + OBJECT + ../../exception/remote-unwind.cpp + ../../exception/seh-unwind.cpp + win/pal-single-threaded.c + # ${libunwind_la_SOURCES} Local... + ${libunwind_remote_la_SOURCES} + # Commented out above for LOCAL + REMOTE runtime build + mi/Gget_accessors.c + # ${libunwind_dwarf_local_la_SOURCES} + ${libunwind_dwarf_common_la_SOURCES} + ${libunwind_dwarf_generic_la_SOURCES} + ${libunwind_elf_la_SOURCES} + ) +endif(CLR_CMAKE_HOST_UNIX) From 1bcd4415d930e93415114589530ce93aa21cfe52 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Mon, 8 Jun 2020 19:04:40 -0400 Subject: [PATCH 03/17] Fix linux build --- .../src/pal/src/exception/remote-unwind.cpp | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/coreclr/src/pal/src/exception/remote-unwind.cpp b/src/coreclr/src/pal/src/exception/remote-unwind.cpp index a6e66819fb7ff6..ddd41789ba5bef 100644 --- a/src/coreclr/src/pal/src/exception/remote-unwind.cpp +++ b/src/coreclr/src/pal/src/exception/remote-unwind.cpp @@ -65,15 +65,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); -#ifndef ElfW -#define ElfW(foo) Elf_ ## foo -#endif -#define Ehdr ElfW(Ehdr) -#define Phdr ElfW(Phdr) -#define Shdr ElfW(Shdr) -#define Nhdr ElfW(Nhdr) -#define Dyn ElfW(Dyn) - #else // HOST_UNIX #include @@ -91,19 +82,11 @@ typedef BOOL(*UnwindReadMemoryCallback)(PVOID address, PVOID buffer, SIZE_T size #define ASSERT(x, ...) #define TRACE(x, ...) -#ifndef ElfW #ifdef TARGET_64BIT #define ElfW(foo) Elf64_ ## foo #else // TARGET_64BIT #define ElfW(foo) Elf32_ ## foo #endif // TARGET_64BIT -#endif // ElfW - -#define Ehdr ElfW(Ehdr) -#define Phdr ElfW(Phdr) -#define Shdr ElfW(Shdr) -#define Nhdr ElfW(Nhdr) -#define Dyn ElfW(Dyn) #define PALAPI @@ -128,6 +111,15 @@ typedef BOOL(*UnwindReadMemoryCallback)(PVOID address, PVOID buffer, SIZE_T size #define PRIxA PRIA PRIx #endif +#ifndef ElfW +#define ElfW(foo) Elf_ ## foo +#endif +#define Ehdr ElfW(Ehdr) +#define Phdr ElfW(Phdr) +#define Shdr ElfW(Shdr) +#define Nhdr ElfW(Nhdr) +#define Dyn ElfW(Dyn) + extern "C" int _OOP_find_proc_info( From 49d647d51a589b69af7b3c0d57cf7259abe5b7e4 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Tue, 9 Jun 2020 15:51:31 -0400 Subject: [PATCH 04/17] Fix __asm__ --- src/coreclr/src/pal/src/libunwind/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt index cba54895054fbb..975cee4d12d687 100644 --- a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt @@ -61,11 +61,15 @@ if (CLR_CMAKE_HOST_UNIX) # in include/tdep like it works for similar files on other architectures. So we need to add # the include/tdep-arm to include directories include_directories(../include/tdep-arm) + # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension + add_definitions(-Dasm=__asm__) elseif(CLR_CMAKE_TARGET_ARCH_ARM64) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Disable warning due to labs function called on unsigned argument add_compile_options(-Wno-absolute-value) endif() + # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension + add_definitions(-Dasm=__asm__) elseif(CLR_CMAKE_TARGET_ARCH_I386) # Disable warning for a bug in the libunwind source src/x86/Gos-linux.c, but not in code that we exercise add_compile_options(-Wno-incompatible-pointer-types) From 8669565332aee19390e4538357962cff015349e9 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Tue, 9 Jun 2020 19:52:23 -0400 Subject: [PATCH 05/17] Revert unnecessary linux CMake changes --- .../src/pal/src/libunwind/CMakeLists.txt | 144 +++++++----------- .../src/pal/src/libunwind/src/CMakeLists.txt | 68 +++++++-- 2 files changed, 108 insertions(+), 104 deletions(-) diff --git a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt index 975cee4d12d687..a09c03159c0da6 100644 --- a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt @@ -1,7 +1,3 @@ -project(unwind) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - # define variables for the configure_file below if (CLR_CMAKE_TARGET_ARCH_AMD64) @@ -21,89 +17,16 @@ else () message(FATAL_ERROR "Unrecognize value in environment variable TARGET") endif () -if(CLR_CMAKE_TARGET_LINUX) - add_definitions(-D__linux__) -endif () - set(PKG_MAJOR "1") set(PKG_MINOR "5") set(PKG_EXTRA "-rc2") -set(PACKAGE_STRING "libunwind") -set(PACKAGE_BUGREPORT "") - -include(CheckCSourceCompiles) -include(CheckIncludeFiles) - -if (CLR_CMAKE_HOST_UNIX) - # Disable warning due to incorrect format specifier in debugging printf via the Debug macro - add_compile_options(-Wno-format -Wno-format-security) - - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wno-header-guard) - else() - add_compile_options(-Wno-unused-value) - add_compile_options(-Wno-unused-result) - add_compile_options(-Wno-implicit-function-declaration) - add_compile_options(-Wno-incompatible-pointer-types) - endif() - if(CLR_CMAKE_TARGET_ARCH_ARM) - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # Disable warning due to labs function called on unsigned argument - add_compile_options(-Wno-absolute-value) - # Disable warning in asm: use of SP or PC in the list is deprecated - add_compile_options(-Wno-inline-asm) - endif() - # Disable warning for a bug in the libunwind source src/arm/Gtrace.c:529, but not in code that we exercise - add_compile_options(-Wno-implicit-function-declaration) - # Disable warning due to an unused function prel31_read - add_compile_options(-Wno-unused-function) - # The arm sources include ex_tables.h from include/tdep-arm without going through a redirection - # in include/tdep like it works for similar files on other architectures. So we need to add - # the include/tdep-arm to include directories - include_directories(../include/tdep-arm) - # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension - add_definitions(-Dasm=__asm__) - elseif(CLR_CMAKE_TARGET_ARCH_ARM64) - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # Disable warning due to labs function called on unsigned argument - add_compile_options(-Wno-absolute-value) - endif() - # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension - add_definitions(-Dasm=__asm__) - elseif(CLR_CMAKE_TARGET_ARCH_I386) - # Disable warning for a bug in the libunwind source src/x86/Gos-linux.c, but not in code that we exercise - add_compile_options(-Wno-incompatible-pointer-types) - endif() - - add_definitions(-DPACKAGE_STRING="") - add_definitions(-DPACKAGE_BUGREPORT="") - -else (CLR_CMAKE_HOST_UNIX) - # Assume we are using default MSVC compiler - add_compile_options(/std:c++latest) - add_compile_options(/TC) # compile all files as C - add_compile_options(/permissive-) - # files for cross os compilation - include_directories(include/win) - - # Warnings in release builds - add_compile_options(-wd4068) # ignore unknown pragma warnings (gcc pragmas) - add_compile_options(-wd4146) # minus operator applied to unsigned - add_compile_options(-wd4244) # possible loss of data - add_compile_options(-wd4267) # possible loss of data - add_compile_options(-wd4334) # 32-bit shift implicitly converted to 64 bits +if(CLR_CMAKE_HOST_WIN32) + set(PACKAGE_STRING "libunwind") + set(PACKAGE_BUGREPORT "") - # Disable warning due to incorrect format specifier in debugging printf via the Debug macro - add_compile_options(-wd4311) # pointer truncation from 'unw_word_t *' to 'long' - add_compile_options(-wd4475) # 'fprintf' : length modifier 'L' cannot be used - add_compile_options(-wd4477) # fprintf argument type - - # Windows builds will only support remote unwind - add_definitions(-DUNW_REMOTE_ONLY) - - # Disable security warnings - add_definitions(-D_CRT_SECURE_NO_WARNINGS) + include(CheckCSourceCompiles) + include(CheckIncludeFiles) # Our posix abstraction layer will provide these headers set(HAVE_ELF_H 1) @@ -130,15 +53,58 @@ else (CLR_CMAKE_HOST_UNIX) endif (NOT HAVE_THREAD_LOCAL) configure_file(include/config.h.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h) -endif (CLR_CMAKE_HOST_UNIX) + add_definitions(-DHAVE_CONFIG_H=1) + + # Windows builds will only support remote unwind + add_definitions(-DUNW_REMOTE_ONLY) + + # Disable security warnings + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + + if(CLR_CMAKE_TARGET_LINUX) + add_definitions(-D__linux__) + endif () + + # The HAVE___THREAD set to 1 causes creation of thread local variable with tls_model("initial-exec") + # which is incompatible with usage of the unwind code in a shared library. + add_definitions(-DHAVE___THREAD=0) + + add_definitions(-D_GNU_SOURCE) + + # Assume we are using default MSVC compiler + add_compile_options(/std:c++latest) + add_compile_options(/TC) # compile all files as C + add_compile_options(/permissive-) + + # include paths + include_directories(include/tdep) + include_directories(include) + include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/tdep) + include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) + + if(CLR_CMAKE_TARGET_ARCH_ARM) + # The arm sources include ex_tables.h from include/tdep-arm without going through a redirection + # in include/tdep like it works for similar files on other architectures. So we need to add + # the include/tdep-arm to include directories + include_directories(../include/tdep-arm) + endif() -add_definitions(-DHAVE_CONFIG_H=1) + # files for cross os compilation + include_directories(include/win) -# The HAVE___THREAD set to 1 causes creation of thread local variable with tls_model("initial-exec") -# which is incompatible with usage of the unwind code in a shared library. -add_definitions(-DHAVE___THREAD=0) + # Warnings in release builds + add_compile_options(-wd4068) # ignore unknown pragma warnings (gcc pragmas) + add_compile_options(-wd4146) # minus operator applied to unsigned + add_compile_options(-wd4244) # possible loss of data + add_compile_options(-wd4267) # possible loss of data + add_compile_options(-wd4334) # 32-bit shift implicitly converted to 64 bits -add_definitions(-D_GNU_SOURCE) + # Disable warning due to incorrect format specifier in debugging printf via the Debug macro + add_compile_options(-wd4311) # pointer truncation from 'unw_word_t *' to 'long' + add_compile_options(-wd4475) # 'fprintf' : length modifier 'L' cannot be used + add_compile_options(-wd4477) # fprintf argument type + +endif (CLR_CMAKE_HOST_WIN32) configure_file(include/libunwind-common.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunwind-common.h) @@ -146,5 +112,3 @@ configure_file(include/libunwind.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunw configure_file(include/tdep/libunwind_i.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/tdep/libunwind_i.h) add_subdirectory(src) - - diff --git a/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt index 3e748ff628d00a..45395f8299d98d 100644 --- a/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt @@ -1,22 +1,62 @@ -# other source files -include_directories(../include/tdep) -include_directories(../include) -include_directories(${CMAKE_CURRENT_BINARY_DIR}/../include/tdep) -include_directories(${CMAKE_CURRENT_BINARY_DIR}/../include) +project(unwind) +set(CMAKE_INCLUDE_CURRENT_DIR ON) if (CLR_CMAKE_HOST_UNIX) include(configure.cmake) -endif (CLR_CMAKE_HOST_UNIX) -if(CLR_CMAKE_TARGET_ARCH_ARM) - # Ensure that the remote and local unwind code can reside in the same binary without name clashing - add_definitions("-Darm_search_unwind_table=UNW_OBJ(arm_search_unwind_table)") - # The arm sources include ex_tables.h from include/tdep-arm without going through a redirection - # in include/tdep like it works for similar files on other architectures. So we need to add - # the include/tdep-arm to include directories - include_directories(../include/tdep-arm) -endif() + # The HAVE___THREAD set to 1 causes creation of thread local variable with tls_model("initial-exec") + # which is incompatible with usage of the unwind code in a shared library. + add_definitions(-DHAVE___THREAD=0) + add_definitions(-DHAVE_CONFIG_H=1) + + add_definitions(-DPACKAGE_STRING="") + add_definitions(-DPACKAGE_BUGREPORT="") + + add_definitions(-D_GNU_SOURCE) + + # Disable warning due to incorrect format specifier in debugging printf via the Debug macro + add_compile_options(-Wno-format -Wno-format-security) + + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wno-header-guard) + else() + add_compile_options(-Wno-unused-value) + add_compile_options(-Wno-unused-result) + add_compile_options(-Wno-implicit-function-declaration) + add_compile_options(-Wno-incompatible-pointer-types) + endif() + if(CLR_CMAKE_TARGET_ARCH_ARM) + # Ensure that the remote and local unwind code can reside in the same binary without name clashing + add_definitions("-Darm_search_unwind_table=UNW_OBJ(arm_search_unwind_table)") + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Disable warning due to labs function called on unsigned argument + add_compile_options(-Wno-absolute-value) + # Disable warning in asm: use of SP or PC in the list is deprecated + add_compile_options(-Wno-inline-asm) + endif() + # Disable warning for a bug in the libunwind source src/arm/Gtrace.c:529, but not in code that we exercise + add_compile_options(-Wno-implicit-function-declaration) + # Disable warning due to an unused function prel31_read + add_compile_options(-Wno-unused-function) + # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension + add_definitions(-Dasm=__asm__) + # The arm sources include ex_tables.h from include/tdep-arm without going through a redirection + # in include/tdep like it works for similar files on other architectures. So we need to add + # the include/tdep-arm to include directories + include_directories(../include/tdep-arm) + elseif(CLR_CMAKE_TARGET_ARCH_ARM64) + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Disable warning due to labs function called on unsigned argument + add_compile_options(-Wno-absolute-value) + endif() + # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension + add_definitions(-Dasm=__asm__) + elseif(CLR_CMAKE_TARGET_ARCH_I386) + # Disable warning for a bug in the libunwind source src/x86/Gos-linux.c, but not in code that we exercise + add_compile_options(-Wno-incompatible-pointer-types) + endif() +endif (CLR_CMAKE_HOST_UNIX) SET(libunwind_ptrace_la_SOURCES ptrace/_UPT_elf.c From 8a92742368ed114ef2a374e173cf8acd96dfa76f Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Wed, 10 Jun 2020 21:17:47 -0400 Subject: [PATCH 06/17] Fix crossgen compile --- .../src/pal/src/exception/remote-unwind.cpp | 16 ++-- .../src/pal/src/exception/seh-unwind.cpp | 36 ++++----- .../src/pal/src/libunwind/CMakeLists.txt | 45 +++++++----- .../src/pal/src/libunwind/src/CMakeLists.txt | 73 ++++++++++++------- 4 files changed, 102 insertions(+), 68 deletions(-) diff --git a/src/coreclr/src/pal/src/exception/remote-unwind.cpp b/src/coreclr/src/pal/src/exception/remote-unwind.cpp index ddd41789ba5bef..f34549e7fc9ea5 100644 --- a/src/coreclr/src/pal/src/exception/remote-unwind.cpp +++ b/src/coreclr/src/pal/src/exception/remote-unwind.cpp @@ -149,7 +149,7 @@ typedef struct _libunwindInfo static void UnwindContextToContext(unw_cursor_t *cursor, CONTEXT *winContext) { -#if defined(TARGET_AMD64) +#if (defined(HOST_UNIX) && defined(HOST_AMD64)) || (defined(HOST_WINDOWS) && defined(TARGET_AMD64)) unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Rip); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Rsp); unw_get_reg(cursor, UNW_X86_64_RBP, (unw_word_t *) &winContext->Rbp); @@ -158,14 +158,14 @@ static void UnwindContextToContext(unw_cursor_t *cursor, CONTEXT *winContext) unw_get_reg(cursor, UNW_X86_64_R13, (unw_word_t *) &winContext->R13); unw_get_reg(cursor, UNW_X86_64_R14, (unw_word_t *) &winContext->R14); unw_get_reg(cursor, UNW_X86_64_R15, (unw_word_t *) &winContext->R15); -#elif defined(TARGET_X86) +#elif (defined(HOST_UNIX) && defined(HOST_X86)) || (defined(HOST_WINDOWS) && defined(TARGET_X86)) unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Eip); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Esp); unw_get_reg(cursor, UNW_X86_EBP, (unw_word_t *) &winContext->Ebp); unw_get_reg(cursor, UNW_X86_EBX, (unw_word_t *) &winContext->Ebx); unw_get_reg(cursor, UNW_X86_ESI, (unw_word_t *) &winContext->Esi); unw_get_reg(cursor, UNW_X86_EDI, (unw_word_t *) &winContext->Edi); -#elif defined(TARGET_ARM) +#elif (defined(HOST_UNIX) && defined(HOST_ARM)) || (defined(HOST_WINDOWS) && defined(TARGET_ARM)) unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Pc); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Sp); unw_get_reg(cursor, UNW_ARM_R4, (unw_word_t *) &winContext->R4); @@ -178,7 +178,7 @@ static void UnwindContextToContext(unw_cursor_t *cursor, CONTEXT *winContext) unw_get_reg(cursor, UNW_ARM_R11, (unw_word_t *) &winContext->R11); unw_get_reg(cursor, UNW_ARM_R14, (unw_word_t *) &winContext->Lr); TRACE("sp %p pc %p lr %p\n", winContext->Sp, winContext->Pc, winContext->Lr); -#elif defined(TARGET_ARM64) +#elif (defined(HOST_UNIX) && defined(HOST_ARM64)) || (defined(HOST_WINDOWS) && defined(TARGET_ARM64)) unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Pc); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Sp); unw_get_reg(cursor, UNW_AARCH64_X19, (unw_word_t *) &winContext->X19); @@ -239,7 +239,7 @@ access_reg(unw_addr_space_t as, unw_regnum_t regnum, unw_word_t *valp, int write switch (regnum) { -#if defined(TARGET_AMD64) +#if (defined(HOST_UNIX) && defined(HOST_AMD64)) || (defined(HOST_WINDOWS) && defined(TARGET_AMD64)) case UNW_REG_IP: *valp = (unw_word_t)winContext->Rip; break; case UNW_REG_SP: *valp = (unw_word_t)winContext->Rsp; break; case UNW_X86_64_RBP: *valp = (unw_word_t)winContext->Rbp; break; @@ -248,14 +248,14 @@ access_reg(unw_addr_space_t as, unw_regnum_t regnum, unw_word_t *valp, int write case UNW_X86_64_R13: *valp = (unw_word_t)winContext->R13; break; case UNW_X86_64_R14: *valp = (unw_word_t)winContext->R14; break; case UNW_X86_64_R15: *valp = (unw_word_t)winContext->R15; break; -#elif defined(TARGET_X86) +#elif (defined(HOST_UNIX) && defined(HOST_X86)) || (defined(HOST_WINDOWS) && defined(TARGET_X86)) case UNW_REG_IP: *valp = (unw_word_t)winContext->Eip; break; case UNW_REG_SP: *valp = (unw_word_t)winContext->Esp; break; case UNW_X86_EBX: *valp = (unw_word_t)winContext->Ebx; break; case UNW_X86_ESI: *valp = (unw_word_t)winContext->Esi; break; case UNW_X86_EDI: *valp = (unw_word_t)winContext->Edi; break; case UNW_X86_EBP: *valp = (unw_word_t)winContext->Ebp; break; -#elif defined(TARGET_ARM) +#elif (defined(HOST_UNIX) && defined(HOST_ARM)) || (defined(HOST_WINDOWS) && defined(TARGET_ARM)) case UNW_ARM_R4: *valp = (unw_word_t)winContext->R4; break; case UNW_ARM_R5: *valp = (unw_word_t)winContext->R5; break; case UNW_ARM_R6: *valp = (unw_word_t)winContext->R6; break; @@ -267,7 +267,7 @@ access_reg(unw_addr_space_t as, unw_regnum_t regnum, unw_word_t *valp, int write case UNW_ARM_R13: *valp = (unw_word_t)winContext->Sp; break; case UNW_ARM_R14: *valp = (unw_word_t)winContext->Lr; break; case UNW_ARM_R15: *valp = (unw_word_t)winContext->Pc; break; -#elif defined(TARGET_ARM64) +#elif (defined(HOST_UNIX) && defined(HOST_ARM64)) || (defined(HOST_WINDOWS) && defined(TARGET_ARM64)) case UNW_AARCH64_X19: *valp = (unw_word_t)winContext->X19; break; case UNW_AARCH64_X20: *valp = (unw_word_t)winContext->X20; break; case UNW_AARCH64_X21: *valp = (unw_word_t)winContext->X21; break; diff --git a/src/coreclr/src/pal/src/exception/seh-unwind.cpp b/src/coreclr/src/pal/src/exception/seh-unwind.cpp index 38f43fd6991875..42204786394ebf 100644 --- a/src/coreclr/src/pal/src/exception/seh-unwind.cpp +++ b/src/coreclr/src/pal/src/exception/seh-unwind.cpp @@ -61,7 +61,7 @@ Module Name: #if UNWIND_CONTEXT_IS_UCONTEXT_T -#if defined(TARGET_AMD64) +#if (defined(HOST_UNIX) && defined(HOST_AMD64)) || (defined(HOST_WINDOWS) && defined(TARGET_AMD64)) #define ASSIGN_UNWIND_REGS \ ASSIGN_REG(Rip) \ ASSIGN_REG(Rsp) \ @@ -71,7 +71,7 @@ Module Name: ASSIGN_REG(R13) \ ASSIGN_REG(R14) \ ASSIGN_REG(R15) -#elif defined(TARGET_ARM64) +#elif (defined(HOST_UNIX) && defined(HOST_ARM64)) || (defined(HOST_WINDOWS) && defined(TARGET_ARM64)) #define ASSIGN_UNWIND_REGS \ ASSIGN_REG(Pc) \ ASSIGN_REG(Sp) \ @@ -87,7 +87,7 @@ Module Name: ASSIGN_REG(X26) \ ASSIGN_REG(X27) \ ASSIGN_REG(X28) -#elif defined(TARGET_X86) +#elif (defined(HOST_UNIX) && defined(HOST_X86)) || (defined(HOST_WINDOWS) && defined(TARGET_X86)) #define ASSIGN_UNWIND_REGS \ ASSIGN_REG(Eip) \ ASSIGN_REG(Esp) \ @@ -108,7 +108,7 @@ static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwCon #else static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwContext) { -#if defined(TARGET_ARM) +#if (defined(HOST_UNIX) && defined(HOST_ARM)) || (defined(HOST_WINDOWS) && defined(TARGET_ARM)) // Assuming that unw_set_reg() on cursor will point the cursor to the // supposed stack frame is dangerous for libunwind-arm in Linux. // It is because libunwind's unw_cursor_t has other data structure @@ -151,7 +151,7 @@ static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwCon static void WinContextToUnwindCursor(CONTEXT *winContext, unw_cursor_t *cursor) { -#if defined(TARGET_AMD64) +#if (defined(HOST_UNIX) && defined(HOST_AMD64)) || (defined(HOST_WINDOWS) && defined(TARGET_AMD64)) unw_set_reg(cursor, UNW_REG_IP, winContext->Rip); unw_set_reg(cursor, UNW_REG_SP, winContext->Rsp); unw_set_reg(cursor, UNW_X86_64_RBP, winContext->Rbp); @@ -160,7 +160,7 @@ static void WinContextToUnwindCursor(CONTEXT *winContext, unw_cursor_t *cursor) unw_set_reg(cursor, UNW_X86_64_R13, winContext->R13); unw_set_reg(cursor, UNW_X86_64_R14, winContext->R14); unw_set_reg(cursor, UNW_X86_64_R15, winContext->R15); -#elif defined(TARGET_X86) +#elif (defined(HOST_UNIX) && defined(HOST_X86)) || (defined(HOST_WINDOWS) && defined(TARGET_X86)) unw_set_reg(cursor, UNW_REG_IP, winContext->Eip); unw_set_reg(cursor, UNW_REG_SP, winContext->Esp); unw_set_reg(cursor, UNW_X86_EBP, winContext->Ebp); @@ -173,7 +173,7 @@ static void WinContextToUnwindCursor(CONTEXT *winContext, unw_cursor_t *cursor) void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext) { -#if defined(TARGET_AMD64) +#if (defined(HOST_UNIX) && defined(HOST_AMD64)) || (defined(HOST_WINDOWS) && defined(TARGET_AMD64)) unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Rip); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Rsp); unw_get_reg(cursor, UNW_X86_64_RBP, (unw_word_t *) &winContext->Rbp); @@ -182,14 +182,14 @@ void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext) unw_get_reg(cursor, UNW_X86_64_R13, (unw_word_t *) &winContext->R13); unw_get_reg(cursor, UNW_X86_64_R14, (unw_word_t *) &winContext->R14); unw_get_reg(cursor, UNW_X86_64_R15, (unw_word_t *) &winContext->R15); -#elif defined(TARGET_X86) +#elif (defined(HOST_UNIX) && defined(HOST_X86)) || (defined(HOST_WINDOWS) && defined(TARGET_X86)) unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Eip); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Esp); unw_get_reg(cursor, UNW_X86_EBP, (unw_word_t *) &winContext->Ebp); unw_get_reg(cursor, UNW_X86_EBX, (unw_word_t *) &winContext->Ebx); unw_get_reg(cursor, UNW_X86_ESI, (unw_word_t *) &winContext->Esi); unw_get_reg(cursor, UNW_X86_EDI, (unw_word_t *) &winContext->Edi); -#elif defined(TARGET_ARM) +#elif (defined(HOST_UNIX) && defined(HOST_ARM)) || (defined(HOST_WINDOWS) && defined(TARGET_ARM)) unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Sp); unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Pc); unw_get_reg(cursor, UNW_ARM_R14, (unw_word_t *) &winContext->Lr); @@ -201,7 +201,7 @@ void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext) unw_get_reg(cursor, UNW_ARM_R9, (unw_word_t *) &winContext->R9); unw_get_reg(cursor, UNW_ARM_R10, (unw_word_t *) &winContext->R10); unw_get_reg(cursor, UNW_ARM_R11, (unw_word_t *) &winContext->R11); -#elif defined(TARGET_ARM64) +#elif (defined(HOST_UNIX) && defined(HOST_ARM64)) || (defined(HOST_WINDOWS) && defined(TARGET_ARM64)) unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Pc); unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Sp); unw_get_reg(cursor, UNW_AARCH64_X29, (unw_word_t *) &winContext->Fp); @@ -241,19 +241,19 @@ static void GetContextPointer(unw_cursor_t *cursor, unw_context_t *unwContext, i void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOLATILE_CONTEXT_POINTERS *contextPointers) { -#if defined(TARGET_AMD64) +#if (defined(HOST_UNIX) && defined(HOST_AMD64)) || (defined(HOST_WINDOWS) && defined(TARGET_AMD64)) GetContextPointer(cursor, unwContext, UNW_X86_64_RBP, &contextPointers->Rbp); GetContextPointer(cursor, unwContext, UNW_X86_64_RBX, &contextPointers->Rbx); GetContextPointer(cursor, unwContext, UNW_X86_64_R12, &contextPointers->R12); GetContextPointer(cursor, unwContext, UNW_X86_64_R13, &contextPointers->R13); GetContextPointer(cursor, unwContext, UNW_X86_64_R14, &contextPointers->R14); GetContextPointer(cursor, unwContext, UNW_X86_64_R15, &contextPointers->R15); -#elif defined(TARGET_X86) +#elif (defined(HOST_UNIX) && defined(HOST_X86)) || (defined(HOST_WINDOWS) && defined(TARGET_X86)) GetContextPointer(cursor, unwContext, UNW_X86_EBX, &contextPointers->Ebx); GetContextPointer(cursor, unwContext, UNW_X86_EBP, &contextPointers->Ebp); GetContextPointer(cursor, unwContext, UNW_X86_ESI, &contextPointers->Esi); GetContextPointer(cursor, unwContext, UNW_X86_EDI, &contextPointers->Edi); -#elif defined(TARGET_ARM) +#elif (defined(HOST_UNIX) && defined(HOST_ARM)) || (defined(HOST_WINDOWS) && defined(TARGET_ARM)) GetContextPointer(cursor, unwContext, UNW_ARM_R4, &contextPointers->R4); GetContextPointer(cursor, unwContext, UNW_ARM_R5, &contextPointers->R5); GetContextPointer(cursor, unwContext, UNW_ARM_R6, &contextPointers->R6); @@ -262,7 +262,7 @@ void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOL GetContextPointer(cursor, unwContext, UNW_ARM_R9, &contextPointers->R9); GetContextPointer(cursor, unwContext, UNW_ARM_R10, &contextPointers->R10); GetContextPointer(cursor, unwContext, UNW_ARM_R11, &contextPointers->R11); -#elif defined(TARGET_ARM64) +#elif (defined(HOST_UNIX) && defined(HOST_ARM64)) || (defined(HOST_WINDOWS) && defined(TARGET_ARM64)) GetContextPointer(cursor, unwContext, UNW_AARCH64_X19, &contextPointers->X19); GetContextPointer(cursor, unwContext, UNW_AARCH64_X20, &contextPointers->X20); GetContextPointer(cursor, unwContext, UNW_AARCH64_X21, &contextPointers->X21); @@ -350,16 +350,16 @@ BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextP if (unw_is_signal_frame(&cursor) > 0) { context->ContextFlags |= CONTEXT_EXCEPTION_ACTIVE; -#if defined(TARGET_ARM) || defined(TARGET_ARM64) || defined(TARGET_X86) +#if defined(CONTEXT_UNWOUND_TO_CALL) context->ContextFlags &= ~CONTEXT_UNWOUND_TO_CALL; -#endif // TARGET_ARM || TARGET_ARM64 +#endif // CONTEXT_UNWOUND_TO_CALL } else { context->ContextFlags &= ~CONTEXT_EXCEPTION_ACTIVE; -#if defined(TARGET_ARM) || defined(TARGET_ARM64) || defined(TARGET_X86) +#if defined(CONTEXT_UNWOUND_TO_CALL) context->ContextFlags |= CONTEXT_UNWOUND_TO_CALL; -#endif // TARGET_ARM || TARGET_ARM64 +#endif // CONTEXT_UNWOUND_TO_CALL } // Update the passed in windows context to reflect the unwind diff --git a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt index a09c03159c0da6..19a9be41f0a14f 100644 --- a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt @@ -1,27 +1,38 @@ # define variables for the configure_file below -if (CLR_CMAKE_TARGET_ARCH_AMD64) - set(TARGET_AMD64 1) - set(arch x86_64) - add_definitions(-D__x86_64__) - add_definitions(-D__amd64__) -elseif(CLR_CMAKE_TARGET_ARCH_ARM64) - set(TARGET_AARCH64 1) - set(arch aarch64) - add_definitions(-D__aarch64__) -elseif(CLR_CMAKE_TARGET_ARCH_ARM) - set(TARGET_ARM 1) - set(arch arm) - add_definitions(-D__arm__) -else () - message(FATAL_ERROR "Unrecognize value in environment variable TARGET") -endif () - set(PKG_MAJOR "1") set(PKG_MINOR "5") set(PKG_EXTRA "-rc2") +if(CLR_CMAKE_HOST_UNIX) + if (CLR_CMAKE_HOST_ARCH_AMD64) + set(arch x86_64) + elseif(CLR_CMAKE_HOST_ARCH_ARM64) + set(arch aarch64) + elseif(CLR_CMAKE_PLATFROM_ARCH_ARM) + set(arch arm) + elseif(CLR_CMAKE_HOST_ARCH_I386) + set(arch x86) + endif () +endif(CLR_CMAKE_HOST_UNIX) if(CLR_CMAKE_HOST_WIN32) + if (CLR_CMAKE_TARGET_ARCH_AMD64) + set(TARGET_AMD64 1) + set(arch x86_64) + add_definitions(-D__x86_64__) + add_definitions(-D__amd64__) + elseif(CLR_CMAKE_TARGET_ARCH_ARM64) + set(TARGET_AARCH64 1) + set(arch aarch64) + add_definitions(-D__aarch64__) + elseif(CLR_CMAKE_TARGET_ARCH_ARM) + set(TARGET_ARM 1) + set(arch arm) + add_definitions(-D__arm__) + else () + message(FATAL_ERROR "Unrecognize value in environment variable TARGET") + endif () + set(PACKAGE_STRING "libunwind") set(PACKAGE_BUGREPORT "") diff --git a/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt index 45395f8299d98d..0b921eee64d1b3 100644 --- a/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt @@ -26,7 +26,8 @@ if (CLR_CMAKE_HOST_UNIX) add_compile_options(-Wno-implicit-function-declaration) add_compile_options(-Wno-incompatible-pointer-types) endif() - if(CLR_CMAKE_TARGET_ARCH_ARM) + + if(CLR_CMAKE_HOST_ARCH_ARM) # Ensure that the remote and local unwind code can reside in the same binary without name clashing add_definitions("-Darm_search_unwind_table=UNW_OBJ(arm_search_unwind_table)") if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -45,14 +46,14 @@ if (CLR_CMAKE_HOST_UNIX) # in include/tdep like it works for similar files on other architectures. So we need to add # the include/tdep-arm to include directories include_directories(../include/tdep-arm) - elseif(CLR_CMAKE_TARGET_ARCH_ARM64) + elseif(CLR_CMAKE_HOST_ARCH_ARM64) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Disable warning due to labs function called on unsigned argument add_compile_options(-Wno-absolute-value) endif() # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension add_definitions(-Dasm=__asm__) - elseif(CLR_CMAKE_TARGET_ARCH_I386) + elseif(CLR_CMAKE_HOST_ARCH_I386) # Disable warning for a bug in the libunwind source src/x86/Gos-linux.c, but not in code that we exercise add_compile_options(-Wno-incompatible-pointer-types) endif() @@ -333,29 +334,29 @@ SET(libunwind_x86_64_la_SOURCES_x86_64 x86_64/Gstash_frame.c x86_64/Gstep.c x86_64/Gtrace.c ) -if(CLR_CMAKE_TARGET_ARCH_ARM64) - SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_aarch64}) - SET(libunwind_remote_la_SOURCES ${libunwind_aarch64_la_SOURCES_aarch64}) - SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES}) - list(APPEND libunwind_setjmp_la_SOURCES aarch64/siglongjmp.S) -elseif(CLR_CMAKE_TARGET_ARCH_ARM) - SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_arm}) - SET(libunwind_remote_la_SOURCES ${libunwind_arm_la_SOURCES_arm}) - SET(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES}) - list(APPEND libunwind_setjmp_la_SOURCES arm/siglongjmp.S) -elseif(CLR_CMAKE_TARGET_ARCH_I386) - SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_x86} ${libunwind_x86_la_SOURCES_os}) - SET(libunwind_remote_la_SOURCES ${libunwind_x86_la_SOURCES_x86}) - SET(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES}) - list(APPEND libunwind_setjmp_la_SOURCES x86/longjmp.S x86/siglongjmp.S) -elseif(CLR_CMAKE_TARGET_ARCH_AMD64) - SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_x86_64}) - SET(libunwind_remote_la_SOURCES ${libunwind_x86_64_la_SOURCES_x86_64}) - SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES}) - list(APPEND libunwind_setjmp_la_SOURCES x86_64/longjmp.S x86_64/siglongjmp.SA) -endif() - if(CLR_CMAKE_HOST_UNIX) + if(CLR_CMAKE_HOST_ARCH_ARM64) + SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_aarch64}) + SET(libunwind_remote_la_SOURCES ${libunwind_aarch64_la_SOURCES_aarch64}) + SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES}) + list(APPEND libunwind_setjmp_la_SOURCES aarch64/siglongjmp.S) + elseif(CLR_CMAKE_HOST_ARCH_ARM) + SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_arm}) + SET(libunwind_remote_la_SOURCES ${libunwind_arm_la_SOURCES_arm}) + SET(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES}) + list(APPEND libunwind_setjmp_la_SOURCES arm/siglongjmp.S) + elseif(CLR_CMAKE_HOST_ARCH_I386) + SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_x86} ${libunwind_x86_la_SOURCES_os}) + SET(libunwind_remote_la_SOURCES ${libunwind_x86_la_SOURCES_x86}) + SET(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES}) + list(APPEND libunwind_setjmp_la_SOURCES x86/longjmp.S x86/siglongjmp.S) + elseif(CLR_CMAKE_HOST_ARCH_AMD64) + SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_x86_64}) + SET(libunwind_remote_la_SOURCES ${libunwind_x86_64_la_SOURCES_x86_64}) + SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES}) + list(APPEND libunwind_setjmp_la_SOURCES x86_64/longjmp.S x86_64/siglongjmp.SA) + endif() + add_library(libunwind OBJECT ${libunwind_la_SOURCES} @@ -366,6 +367,28 @@ if(CLR_CMAKE_HOST_UNIX) ${libunwind_elf_la_SOURCES} ) else(CLR_CMAKE_HOST_UNIX) + if(CLR_CMAKE_TARGET_ARCH_ARM64) + SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_aarch64}) + SET(libunwind_remote_la_SOURCES ${libunwind_aarch64_la_SOURCES_aarch64}) + SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES}) + list(APPEND libunwind_setjmp_la_SOURCES aarch64/siglongjmp.S) + elseif(CLR_CMAKE_TARGET_ARCH_ARM) + SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_arm}) + SET(libunwind_remote_la_SOURCES ${libunwind_arm_la_SOURCES_arm}) + SET(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES}) + list(APPEND libunwind_setjmp_la_SOURCES arm/siglongjmp.S) + elseif(CLR_CMAKE_TARGET_ARCH_I386) + SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_x86} ${libunwind_x86_la_SOURCES_os}) + SET(libunwind_remote_la_SOURCES ${libunwind_x86_la_SOURCES_x86}) + SET(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES}) + list(APPEND libunwind_setjmp_la_SOURCES x86/longjmp.S x86/siglongjmp.S) + elseif(CLR_CMAKE_TARGET_ARCH_AMD64) + SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_x86_64}) + SET(libunwind_remote_la_SOURCES ${libunwind_x86_64_la_SOURCES_x86_64}) + SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES}) + list(APPEND libunwind_setjmp_la_SOURCES x86_64/longjmp.S x86_64/siglongjmp.SA) + endif() + set_source_files_properties(${CLR_DIR}/src/pal/src/exception/remote-unwind.cpp PROPERTIES COMPILE_FLAGS /TP INCLUDE_DIRECTORIES ${CLR_DIR}/src/inc) set_source_files_properties(${CLR_DIR}/src/pal/src/exception/seh-unwind.cpp PROPERTIES COMPILE_FLAGS /TP INCLUDE_DIRECTORIES ${CLR_DIR}/src/inc) add_library(libunwind_xdac From 92487294a93f94c0374f56962ac91f1c669b9eed Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Thu, 11 Jun 2020 14:15:17 -0400 Subject: [PATCH 07/17] Fix arm cross DAC build --- src/coreclr/src/pal/src/libunwind/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt index 19a9be41f0a14f..46082b6f4bb154 100644 --- a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt @@ -97,7 +97,7 @@ if(CLR_CMAKE_HOST_WIN32) # The arm sources include ex_tables.h from include/tdep-arm without going through a redirection # in include/tdep like it works for similar files on other architectures. So we need to add # the include/tdep-arm to include directories - include_directories(../include/tdep-arm) + include_directories(include/tdep-arm) endif() # files for cross os compilation From bf258d34aa8cff246605507ec3f7de1d2405cf3c Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Thu, 11 Jun 2020 18:38:16 -0400 Subject: [PATCH 08/17] Alignas and typos libunwind/libunwind#186 --- src/coreclr/src/pal/src/libunwind/include/libunwind-aarch64.h | 2 +- src/coreclr/src/pal/src/libunwind/include/unwind.h | 2 +- src/coreclr/src/pal/src/libunwind/include/win/fakestdalign.h.in | 2 +- .../src/pal/src/libunwind/include/win/fakestdatomic.h.in | 2 +- src/coreclr/src/pal/src/libunwind/include/win/sys/types.h | 2 +- src/coreclr/src/pal/src/libunwind/src/mi/mempool.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/coreclr/src/pal/src/libunwind/include/libunwind-aarch64.h b/src/coreclr/src/pal/src/libunwind/include/libunwind-aarch64.h index d1bd8708f59f1f..d78fbd44921f68 100644 --- a/src/coreclr/src/pal/src/libunwind/include/libunwind-aarch64.h +++ b/src/coreclr/src/pal/src/libunwind/include/libunwind-aarch64.h @@ -194,7 +194,7 @@ struct unw_sigcontext uint64_t sp; uint64_t pc; uint64_t pstate; - uint8_t alignas(16) __reserved[(66 * 8)]; + alignas(16) uint8_t __reserved[(66 * 8)]; }; typedef struct diff --git a/src/coreclr/src/pal/src/libunwind/include/unwind.h b/src/coreclr/src/pal/src/libunwind/include/unwind.h index 8eb5ff753de7b7..93780fade8fb73 100644 --- a/src/coreclr/src/pal/src/libunwind/include/unwind.h +++ b/src/coreclr/src/pal/src/libunwind/include/unwind.h @@ -77,7 +77,7 @@ typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) (int, _Unwind_Action, even on 32-bit machines for gcc compatibility. */ struct _Unwind_Exception { - uint64_t alignas(8) exception_class; + alignas(8) uint64_t exception_class; _Unwind_Exception_Cleanup_Fn exception_cleanup; unsigned long private_1; unsigned long private_2; diff --git a/src/coreclr/src/pal/src/libunwind/include/win/fakestdalign.h.in b/src/coreclr/src/pal/src/libunwind/include/win/fakestdalign.h.in index 3e94006d8cae73..6eb292c9f1dde2 100644 --- a/src/coreclr/src/pal/src/libunwind/include/win/fakestdalign.h.in +++ b/src/coreclr/src/pal/src/libunwind/include/win/fakestdalign.h.in @@ -1,4 +1,4 @@ -// This is a fake implementatino of stdaliagn.h for when +// This is a fake implementation of stdalign.h for when // compiler C11 stdaliagn.h support is missing #ifndef FAKE_STD_ALIGN_H diff --git a/src/coreclr/src/pal/src/libunwind/include/win/fakestdatomic.h.in b/src/coreclr/src/pal/src/libunwind/include/win/fakestdatomic.h.in index 7b9dcd5a9d8ac9..48cde8321b1452 100644 --- a/src/coreclr/src/pal/src/libunwind/include/win/fakestdatomic.h.in +++ b/src/coreclr/src/pal/src/libunwind/include/win/fakestdatomic.h.in @@ -1,4 +1,4 @@ -// This is a non-atomic fake implementatino of stdatomics for when +// This is a non-atomic fake implementation of stdatomic.h for when // compiler C11 stdatomic support is missing and only single threaded // operation is required diff --git a/src/coreclr/src/pal/src/libunwind/include/win/sys/types.h b/src/coreclr/src/pal/src/libunwind/include/win/sys/types.h index fdfe8ffe642eff..7b131f6ed950c5 100644 --- a/src/coreclr/src/pal/src/libunwind/include/win/sys/types.h +++ b/src/coreclr/src/pal/src/libunwind/include/win/sys/types.h @@ -13,7 +13,7 @@ #include <../ucrt/sys/types.h> #include -typedef size_t pid_t; +typedef int pid_t; typedef ptrdiff_t ssize_t; #endif // _MSC_VER diff --git a/src/coreclr/src/pal/src/libunwind/src/mi/mempool.c b/src/coreclr/src/pal/src/libunwind/src/mi/mempool.c index 3e8da67611ed39..7c5d27d0c2c309 100644 --- a/src/coreclr/src/pal/src/libunwind/src/mi/mempool.c +++ b/src/coreclr/src/pal/src/libunwind/src/mi/mempool.c @@ -41,7 +41,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ # define MAX_ALIGN MAX_ALIGN_(sizeof (long double)) #endif -static char alignas(MAX_ALIGN) sos_memory[SOS_MEMORY_SIZE]; +static alignas(MAX_ALIGN) char sos_memory[SOS_MEMORY_SIZE]; static _Atomic size_t sos_memory_freepos = 0; static size_t pg_size; From 87835fb6d3280027008c858affce51184e657ccb Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Thu, 11 Jun 2020 18:51:23 -0400 Subject: [PATCH 09/17] Add COPYONLY to configure_file --- src/coreclr/src/pal/src/libunwind/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt index 46082b6f4bb154..b3373e23a13e6a 100644 --- a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt @@ -47,14 +47,14 @@ if(CLR_CMAKE_HOST_WIN32) # Fake it until support is added check_include_files(stdalign.h HAVE_STDALIGN_H) if (NOT HAVE_STDALIGN_H) - configure_file(include/win/fakestdalign.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/stdalign.h) + configure_file(include/win/fakestdalign.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/stdalign.h COPYONLY) endif (NOT HAVE_STDALIGN_H) # MSVC compiler is currently missing C11 stdatomic.h header # Fake it until support is added check_include_files(stdatomic.h HAVE_STDATOMIC_H) if (NOT HAVE_STDATOMIC_H) - configure_file(include/win/fakestdatomic.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/stdatomic.h) + configure_file(include/win/fakestdatomic.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/stdatomic.h COPYONLY) endif (NOT HAVE_STDATOMIC_H) # MSVC compiler is currently missing C11 _Thread_local From 41928244efb0bd14f68aaf81ff67ca8765eb28ad Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Thu, 11 Jun 2020 18:51:43 -0400 Subject: [PATCH 10/17] Fix Unix typo --- src/coreclr/src/pal/src/libunwind/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt index b3373e23a13e6a..51381c4950f016 100644 --- a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt @@ -8,7 +8,7 @@ if(CLR_CMAKE_HOST_UNIX) set(arch x86_64) elseif(CLR_CMAKE_HOST_ARCH_ARM64) set(arch aarch64) - elseif(CLR_CMAKE_PLATFROM_ARCH_ARM) + elseif(CLR_CMAKE_HOST_ARCH_ARM) set(arch arm) elseif(CLR_CMAKE_HOST_ARCH_I386) set(arch x86) From 89ad2a21531c8f71e12eb54d6357fc5a8b818e55 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Thu, 11 Jun 2020 19:25:56 -0400 Subject: [PATCH 11/17] Colocate Unix/Windows compiler config --- .../src/pal/src/libunwind/CMakeLists.txt | 77 +++++++++++++++---- .../src/pal/src/libunwind/src/CMakeLists.txt | 57 -------------- 2 files changed, 62 insertions(+), 72 deletions(-) diff --git a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt index 51381c4950f016..535cf1286cb983 100644 --- a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt @@ -1,8 +1,20 @@ +project(unwind) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + # define variables for the configure_file below set(PKG_MAJOR "1") set(PKG_MINOR "5") set(PKG_EXTRA "-rc2") + +# The HAVE___THREAD set to 1 causes creation of thread local variable with tls_model("initial-exec") +# which is incompatible with usage of the unwind code in a shared library. +add_definitions(-DHAVE___THREAD=0) +add_definitions(-DHAVE_CONFIG_H=1) + +add_definitions(-D_GNU_SOURCE) + if(CLR_CMAKE_HOST_UNIX) if (CLR_CMAKE_HOST_ARCH_AMD64) set(arch x86_64) @@ -13,6 +25,48 @@ if(CLR_CMAKE_HOST_UNIX) elseif(CLR_CMAKE_HOST_ARCH_I386) set(arch x86) endif () + + add_definitions(-DPACKAGE_STRING="") + add_definitions(-DPACKAGE_BUGREPORT="") + + # Disable warning due to incorrect format specifier in debugging printf via the Debug macro + add_compile_options(-Wno-format -Wno-format-security) + + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wno-header-guard) + else() + add_compile_options(-Wno-unused-value) + add_compile_options(-Wno-unused-result) + add_compile_options(-Wno-implicit-function-declaration) + add_compile_options(-Wno-incompatible-pointer-types) + endif() + + if(CLR_CMAKE_HOST_ARCH_ARM) + # Ensure that the remote and local unwind code can reside in the same binary without name clashing + add_definitions("-Darm_search_unwind_table=UNW_OBJ(arm_search_unwind_table)") + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Disable warning due to labs function called on unsigned argument + add_compile_options(-Wno-absolute-value) + # Disable warning in asm: use of SP or PC in the list is deprecated + add_compile_options(-Wno-inline-asm) + endif() + # Disable warning for a bug in the libunwind source src/arm/Gtrace.c:529, but not in code that we exercise + add_compile_options(-Wno-implicit-function-declaration) + # Disable warning due to an unused function prel31_read + add_compile_options(-Wno-unused-function) + # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension + add_definitions(-Dasm=__asm__) + elseif(CLR_CMAKE_HOST_ARCH_ARM64) + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Disable warning due to labs function called on unsigned argument + add_compile_options(-Wno-absolute-value) + endif() + # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension + add_definitions(-Dasm=__asm__) + elseif(CLR_CMAKE_HOST_ARCH_I386) + # Disable warning for a bug in the libunwind source src/x86/Gos-linux.c, but not in code that we exercise + add_compile_options(-Wno-incompatible-pointer-types) + endif() endif(CLR_CMAKE_HOST_UNIX) if(CLR_CMAKE_HOST_WIN32) @@ -30,7 +84,7 @@ if(CLR_CMAKE_HOST_WIN32) set(arch arm) add_definitions(-D__arm__) else () - message(FATAL_ERROR "Unrecognize value in environment variable TARGET") + message(FATAL_ERROR "Unrecognized TARGET") endif () set(PACKAGE_STRING "libunwind") @@ -64,7 +118,6 @@ if(CLR_CMAKE_HOST_WIN32) endif (NOT HAVE_THREAD_LOCAL) configure_file(include/config.h.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h) - add_definitions(-DHAVE_CONFIG_H=1) # Windows builds will only support remote unwind add_definitions(-DUNW_REMOTE_ONLY) @@ -76,12 +129,6 @@ if(CLR_CMAKE_HOST_WIN32) add_definitions(-D__linux__) endif () - # The HAVE___THREAD set to 1 causes creation of thread local variable with tls_model("initial-exec") - # which is incompatible with usage of the unwind code in a shared library. - add_definitions(-DHAVE___THREAD=0) - - add_definitions(-D_GNU_SOURCE) - # Assume we are using default MSVC compiler add_compile_options(/std:c++latest) add_compile_options(/TC) # compile all files as C @@ -93,13 +140,6 @@ if(CLR_CMAKE_HOST_WIN32) include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/tdep) include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) - if(CLR_CMAKE_TARGET_ARCH_ARM) - # The arm sources include ex_tables.h from include/tdep-arm without going through a redirection - # in include/tdep like it works for similar files on other architectures. So we need to add - # the include/tdep-arm to include directories - include_directories(include/tdep-arm) - endif() - # files for cross os compilation include_directories(include/win) @@ -117,6 +157,13 @@ if(CLR_CMAKE_HOST_WIN32) endif (CLR_CMAKE_HOST_WIN32) +if(CLR_CMAKE_TARGET_ARCH_ARM) + # The arm sources include ex_tables.h from include/tdep-arm without going through a redirection + # in include/tdep like it works for similar files on other architectures. So we need to add + # the include/tdep-arm to include directories + include_directories(include/tdep-arm) +endif() + configure_file(include/libunwind-common.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunwind-common.h) configure_file(include/libunwind.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunwind.h) diff --git a/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt index 0b921eee64d1b3..918945cefb1c54 100644 --- a/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt @@ -1,62 +1,5 @@ -project(unwind) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - if (CLR_CMAKE_HOST_UNIX) include(configure.cmake) - - # The HAVE___THREAD set to 1 causes creation of thread local variable with tls_model("initial-exec") - # which is incompatible with usage of the unwind code in a shared library. - add_definitions(-DHAVE___THREAD=0) - add_definitions(-DHAVE_CONFIG_H=1) - - add_definitions(-DPACKAGE_STRING="") - add_definitions(-DPACKAGE_BUGREPORT="") - - add_definitions(-D_GNU_SOURCE) - - # Disable warning due to incorrect format specifier in debugging printf via the Debug macro - add_compile_options(-Wno-format -Wno-format-security) - - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wno-header-guard) - else() - add_compile_options(-Wno-unused-value) - add_compile_options(-Wno-unused-result) - add_compile_options(-Wno-implicit-function-declaration) - add_compile_options(-Wno-incompatible-pointer-types) - endif() - - if(CLR_CMAKE_HOST_ARCH_ARM) - # Ensure that the remote and local unwind code can reside in the same binary without name clashing - add_definitions("-Darm_search_unwind_table=UNW_OBJ(arm_search_unwind_table)") - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # Disable warning due to labs function called on unsigned argument - add_compile_options(-Wno-absolute-value) - # Disable warning in asm: use of SP or PC in the list is deprecated - add_compile_options(-Wno-inline-asm) - endif() - # Disable warning for a bug in the libunwind source src/arm/Gtrace.c:529, but not in code that we exercise - add_compile_options(-Wno-implicit-function-declaration) - # Disable warning due to an unused function prel31_read - add_compile_options(-Wno-unused-function) - # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension - add_definitions(-Dasm=__asm__) - # The arm sources include ex_tables.h from include/tdep-arm without going through a redirection - # in include/tdep like it works for similar files on other architectures. So we need to add - # the include/tdep-arm to include directories - include_directories(../include/tdep-arm) - elseif(CLR_CMAKE_HOST_ARCH_ARM64) - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # Disable warning due to labs function called on unsigned argument - add_compile_options(-Wno-absolute-value) - endif() - # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension - add_definitions(-Dasm=__asm__) - elseif(CLR_CMAKE_HOST_ARCH_I386) - # Disable warning for a bug in the libunwind source src/x86/Gos-linux.c, but not in code that we exercise - add_compile_options(-Wno-incompatible-pointer-types) - endif() endif (CLR_CMAKE_HOST_UNIX) SET(libunwind_ptrace_la_SOURCES From c77e8a7bf51a68e5a0cae57c14566f30cb2c421e Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Thu, 11 Jun 2020 19:56:19 -0400 Subject: [PATCH 12/17] Update libunwind-version.txt --- src/coreclr/src/pal/src/libunwind/libunwind-version.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/src/pal/src/libunwind/libunwind-version.txt b/src/coreclr/src/pal/src/libunwind/libunwind-version.txt index 20a01b125a1c08..9ebc86f5b15a7d 100644 --- a/src/coreclr/src/pal/src/libunwind/libunwind-version.txt +++ b/src/coreclr/src/pal/src/libunwind/libunwind-version.txt @@ -3,3 +3,4 @@ https://github.com/libunwind/libunwind/commit/9165d2a150d707d3037c2045f2cdc0fabd Remove upstream CMakelist.txt & src/CMakelist.txt, keep .NET Core custom version Keep .NET Core oop directory +Apply https://github.com/libunwind/libunwind/pull/186 From 0a2f19eb9d91245d547c2ef851bcc9fe915f408f Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Thu, 11 Jun 2020 20:48:44 -0400 Subject: [PATCH 13/17] Remove stray file --- .../src/libunwind/include/win/stdatomic.h.in | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 src/coreclr/src/pal/src/libunwind/include/win/stdatomic.h.in diff --git a/src/coreclr/src/pal/src/libunwind/include/win/stdatomic.h.in b/src/coreclr/src/pal/src/libunwind/include/win/stdatomic.h.in deleted file mode 100644 index 2607672b4f2d1a..00000000000000 --- a/src/coreclr/src/pal/src/libunwind/include/win/stdatomic.h.in +++ /dev/null @@ -1,36 +0,0 @@ -// This is a non-atomic fake implementatino of stdatomics for when -// compiler C11 stdatomic support is missing and only single threaded -// operation is required - -#ifndef FAKE_STD_ATOMICS_H -#define FAKE_STD_ATOMICS_H - -#include - -#define _Atomic volatile -#define ATOMIC_FLAG_INIT 0 - -typedef unit8_t atomic_bool; -typedef unit8_t atomic_flag; - -#define atomic_compare_and_exchange_strong(x, y, z) return ((*(x) == *(y)) ? ((*(x) = z), true) : ((*(y) = *(x)),false)) - -#define atomic_fetch_add(x, y) *(x) += (y), (*(x) - (y)) - -static inline void atomic_flag_clear(volatile atomic_flag* flag) -{ - *flag = ATOMIC_FLAG_INIT; -} - -static inline atomic_bool atomic_flag_test_and_set( volatile atomic_flag* flag ) -{ - atomic_bool result = *flag; - flag = 1; - return result; -} - -#define atomic_load(x) (*(x)) -#define atomic_store(x, y) do { *(x) = (y); } while (0) - - -#endif // FAKE_STD_ATOMICS_H From df02abed9e02dda89f591dd38603885dbb34e35c Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Thu, 11 Jun 2020 20:51:41 -0400 Subject: [PATCH 14/17] Fix indentation --- src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt index 918945cefb1c54..e859093ff82eae 100644 --- a/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt @@ -341,8 +341,8 @@ else(CLR_CMAKE_HOST_UNIX) win/pal-single-threaded.c # ${libunwind_la_SOURCES} Local... ${libunwind_remote_la_SOURCES} - # Commented out above for LOCAL + REMOTE runtime build - mi/Gget_accessors.c + # Commented out above for LOCAL + REMOTE runtime build + mi/Gget_accessors.c # ${libunwind_dwarf_local_la_SOURCES} ${libunwind_dwarf_common_la_SOURCES} ${libunwind_dwarf_generic_la_SOURCES} From 67b8cc259a434884af49ab010903dabf6d178456 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Thu, 11 Jun 2020 21:45:21 -0400 Subject: [PATCH 15/17] Unify Windows/Unix configure.cmake --- .../src/pal/src/libunwind/CMakeLists.txt | 49 ++------------ .../pal/src/libunwind/{src => }/config.h.in | 2 + .../src/pal/src/libunwind/configure.cmake | 67 +++++++++++++++++++ .../src/pal/src/libunwind/src/CMakeLists.txt | 5 +- .../src/pal/src/libunwind/src/configure.cmake | 33 --------- 5 files changed, 78 insertions(+), 78 deletions(-) rename src/coreclr/src/pal/src/libunwind/{src => }/config.h.in (84%) create mode 100644 src/coreclr/src/pal/src/libunwind/configure.cmake delete mode 100644 src/coreclr/src/pal/src/libunwind/src/configure.cmake diff --git a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt index 535cf1286cb983..be7f5035ff6c90 100644 --- a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt @@ -1,3 +1,6 @@ +# This is a custom file written for .NET Core's build system +# It overwrites the one found in upstream + project(unwind) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -11,10 +14,12 @@ set(PKG_EXTRA "-rc2") # The HAVE___THREAD set to 1 causes creation of thread local variable with tls_model("initial-exec") # which is incompatible with usage of the unwind code in a shared library. add_definitions(-DHAVE___THREAD=0) -add_definitions(-DHAVE_CONFIG_H=1) add_definitions(-D_GNU_SOURCE) +add_definitions(-DPACKAGE_STRING="") +add_definitions(-DPACKAGE_BUGREPORT="") + if(CLR_CMAKE_HOST_UNIX) if (CLR_CMAKE_HOST_ARCH_AMD64) set(arch x86_64) @@ -26,9 +31,6 @@ if(CLR_CMAKE_HOST_UNIX) set(arch x86) endif () - add_definitions(-DPACKAGE_STRING="") - add_definitions(-DPACKAGE_BUGREPORT="") - # Disable warning due to incorrect format specifier in debugging printf via the Debug macro add_compile_options(-Wno-format -Wno-format-security) @@ -87,38 +89,6 @@ if(CLR_CMAKE_HOST_WIN32) message(FATAL_ERROR "Unrecognized TARGET") endif () - set(PACKAGE_STRING "libunwind") - set(PACKAGE_BUGREPORT "") - - include(CheckCSourceCompiles) - include(CheckIncludeFiles) - - # Our posix abstraction layer will provide these headers - set(HAVE_ELF_H 1) - set(HAVE_ENDIAN_H 1) - - # MSVC compiler is currently missing C11 stdalign.h header - # Fake it until support is added - check_include_files(stdalign.h HAVE_STDALIGN_H) - if (NOT HAVE_STDALIGN_H) - configure_file(include/win/fakestdalign.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/stdalign.h COPYONLY) - endif (NOT HAVE_STDALIGN_H) - - # MSVC compiler is currently missing C11 stdatomic.h header - # Fake it until support is added - check_include_files(stdatomic.h HAVE_STDATOMIC_H) - if (NOT HAVE_STDATOMIC_H) - configure_file(include/win/fakestdatomic.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/stdatomic.h COPYONLY) - endif (NOT HAVE_STDATOMIC_H) - - # MSVC compiler is currently missing C11 _Thread_local - check_c_source_compiles("void main() { _Thread_local int a; }" HAVE_THREAD_LOCAL) - if (NOT HAVE_THREAD_LOCAL) - add_definitions(-D_Thread_local=) - endif (NOT HAVE_THREAD_LOCAL) - - configure_file(include/config.h.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h) - # Windows builds will only support remote unwind add_definitions(-DUNW_REMOTE_ONLY) @@ -154,7 +124,6 @@ if(CLR_CMAKE_HOST_WIN32) add_compile_options(-wd4311) # pointer truncation from 'unw_word_t *' to 'long' add_compile_options(-wd4475) # 'fprintf' : length modifier 'L' cannot be used add_compile_options(-wd4477) # fprintf argument type - endif (CLR_CMAKE_HOST_WIN32) if(CLR_CMAKE_TARGET_ARCH_ARM) @@ -164,9 +133,5 @@ if(CLR_CMAKE_TARGET_ARCH_ARM) include_directories(include/tdep-arm) endif() - -configure_file(include/libunwind-common.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunwind-common.h) -configure_file(include/libunwind.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunwind.h) -configure_file(include/tdep/libunwind_i.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/tdep/libunwind_i.h) - +include(configure.cmake) add_subdirectory(src) diff --git a/src/coreclr/src/pal/src/libunwind/src/config.h.in b/src/coreclr/src/pal/src/libunwind/config.h.in similarity index 84% rename from src/coreclr/src/pal/src/libunwind/src/config.h.in rename to src/coreclr/src/pal/src/libunwind/config.h.in index 1bc7c931597a5d..5ac6201e08b501 100644 --- a/src/coreclr/src/pal/src/libunwind/src/config.h.in +++ b/src/coreclr/src/pal/src/libunwind/config.h.in @@ -1,3 +1,5 @@ +// This is a custom file written for .NET Core's build system + #ifndef __LIBUNWIND_CONFIG_H__ #define __LIBUNWIND_CONFIG_H__ diff --git a/src/coreclr/src/pal/src/libunwind/configure.cmake b/src/coreclr/src/pal/src/libunwind/configure.cmake new file mode 100644 index 00000000000000..ef56247ae166a2 --- /dev/null +++ b/src/coreclr/src/pal/src/libunwind/configure.cmake @@ -0,0 +1,67 @@ +# This is a custom file written for .NET Core's build system + + +include(CheckCSourceCompiles) +include(CheckIncludeFiles) + +if(CLR_CMAKE_HOST_WIN32) + # Our posix abstraction layer will provide these headers + set(HAVE_ELF_H 1) + set(HAVE_ENDIAN_H 1) + + # MSVC compiler is currently missing C11 stdalign.h header + # Fake it until support is added + check_include_files(stdalign.h HAVE_STDALIGN_H) + if (NOT HAVE_STDALIGN_H) + configure_file(include/win/fakestdalign.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/stdalign.h COPYONLY) + endif (NOT HAVE_STDALIGN_H) + + # MSVC compiler is currently missing C11 stdatomic.h header + # Fake it until support is added + check_include_files(stdatomic.h HAVE_STDATOMIC_H) + if (NOT HAVE_STDATOMIC_H) + configure_file(include/win/fakestdatomic.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/stdatomic.h COPYONLY) + endif (NOT HAVE_STDATOMIC_H) + + # MSVC compiler is currently missing C11 _Thread_local + check_c_source_compiles("void main() { _Thread_local int a; }" HAVE_THREAD_LOCAL) + if (NOT HAVE_THREAD_LOCAL) + add_definitions(-D_Thread_local=) + endif (NOT HAVE_THREAD_LOCAL) +else(CLR_CMAKE_HOST_WIN32) + check_include_files(elf.h HAVE_ELF_H) + check_include_files(sys/elf.h HAVE_SYS_ELF_H) + + check_include_files(endian.h HAVE_ENDIAN_H) + check_include_files(sys/endian.h HAVE_SYS_ENDIAN_H) +endif(CLR_CMAKE_HOST_WIN32) + +check_include_files(link.h HAVE_LINK_H) +check_include_files(sys/link.h HAVE_SYS_LINK_H) + +check_include_files(atomic_ops.h HAVE_ATOMIC_OPS_H) + +check_c_source_compiles(" +int main(int argc, char **argv) +{ + __sync_bool_compare_and_swap((int *)0, 0, 1); + __sync_fetch_and_add((int *)0, 1); + + return 0; +}" HAVE_SYNC_ATOMICS) + + +check_c_source_compiles(" +int main(int argc, char **argv) +{ + __builtin_unreachable(); + + return 0; +}" HAVE__BUILTIN_UNREACHABLE) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h) +add_definitions(-DHAVE_CONFIG_H=1) + +configure_file(include/libunwind-common.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunwind-common.h) +configure_file(include/libunwind.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunwind.h) +configure_file(include/tdep/libunwind_i.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/tdep/libunwind_i.h) diff --git a/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt index e859093ff82eae..c7cc497f310951 100644 --- a/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt @@ -1,6 +1,5 @@ -if (CLR_CMAKE_HOST_UNIX) - include(configure.cmake) -endif (CLR_CMAKE_HOST_UNIX) +# This is a custom file written for .NET Core's build system +# It overwrites the one found in upstream SET(libunwind_ptrace_la_SOURCES ptrace/_UPT_elf.c diff --git a/src/coreclr/src/pal/src/libunwind/src/configure.cmake b/src/coreclr/src/pal/src/libunwind/src/configure.cmake deleted file mode 100644 index a6d37b5ed9e5e6..00000000000000 --- a/src/coreclr/src/pal/src/libunwind/src/configure.cmake +++ /dev/null @@ -1,33 +0,0 @@ -include(CheckCXXSourceCompiles) -include(CheckIncludeFiles) - -check_include_files(elf.h HAVE_ELF_H) -check_include_files(sys/elf.h HAVE_SYS_ELF_H) - -check_include_files(endian.h HAVE_ENDIAN_H) -check_include_files(sys/endian.h HAVE_SYS_ENDIAN_H) - -check_include_files(link.h HAVE_LINK_H) -check_include_files(sys/link.h HAVE_SYS_LINK_H) - -check_include_files(atomic_ops.h HAVE_ATOMIC_OPS_H) - -check_cxx_source_compiles(" -int main(int argc, char **argv) -{ - __sync_bool_compare_and_swap((int *)0, 0, 1); - __sync_fetch_and_add((int *)0, 1); - - return 0; -}" HAVE_SYNC_ATOMICS) - - -check_cxx_source_compiles(" -int main(int argc, char **argv) -{ - __builtin_unreachable(); - - return 0; -}" HAVE__BUILTIN_UNREACHABLE) - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) From ff20845d5cf047b07d7cf40e3a05844ed4fe3538 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Tue, 16 Jun 2020 12:16:12 -0400 Subject: [PATCH 16/17] Fix Windows --- src/coreclr/src/pal/src/exception/remote-unwind.cpp | 6 +++++- src/coreclr/src/pal/src/libunwind/CMakeLists.txt | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/coreclr/src/pal/src/exception/remote-unwind.cpp b/src/coreclr/src/pal/src/exception/remote-unwind.cpp index f34549e7fc9ea5..5eb3d2e345a6e0 100644 --- a/src/coreclr/src/pal/src/exception/remote-unwind.cpp +++ b/src/coreclr/src/pal/src/exception/remote-unwind.cpp @@ -65,6 +65,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); +#include + #else // HOST_UNIX #include @@ -81,6 +83,9 @@ typedef BOOL(*UnwindReadMemoryCallback)(PVOID address, PVOID buffer, SIZE_T size #define ASSERT(x, ...) #define TRACE(x, ...) +#undef ERROR +#define ERROR(x, ...) + #ifdef TARGET_64BIT #define ElfW(foo) Elf64_ ## foo @@ -95,7 +100,6 @@ typedef BOOL(*UnwindReadMemoryCallback)(PVOID address, PVOID buffer, SIZE_T size #if defined(HAVE_UNW_GET_ACCESSORS) #include -#include #if defined(TARGET_X86) || defined(TARGET_ARM) #define PRIx PRIx32 diff --git a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt index be7f5035ff6c90..169023e12b8f02 100644 --- a/src/coreclr/src/pal/src/libunwind/CMakeLists.txt +++ b/src/coreclr/src/pal/src/libunwind/CMakeLists.txt @@ -92,6 +92,8 @@ if(CLR_CMAKE_HOST_WIN32) # Windows builds will only support remote unwind add_definitions(-DUNW_REMOTE_ONLY) + add_definitions(-DHAVE_UNW_GET_ACCESSORS) + # Disable security warnings add_definitions(-D_CRT_SECURE_NO_WARNINGS) From 332c4763106188320ce1bdfe873a38dae472564f Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Tue, 16 Jun 2020 19:09:17 -0400 Subject: [PATCH 17/17] Fix OSX build --- src/coreclr/src/pal/src/exception/remote-unwind.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/coreclr/src/pal/src/exception/remote-unwind.cpp b/src/coreclr/src/pal/src/exception/remote-unwind.cpp index 5eb3d2e345a6e0..26a9194f6de46e 100644 --- a/src/coreclr/src/pal/src/exception/remote-unwind.cpp +++ b/src/coreclr/src/pal/src/exception/remote-unwind.cpp @@ -65,8 +65,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); -#include - #else // HOST_UNIX #include @@ -99,6 +97,10 @@ typedef BOOL(*UnwindReadMemoryCallback)(PVOID address, PVOID buffer, SIZE_T size #if defined(HAVE_UNW_GET_ACCESSORS) +#ifdef HOST_UNIX +#include +#endif // HOST_UNIX + #include #if defined(TARGET_X86) || defined(TARGET_ARM)