Skip to content

Commit

Permalink
Update libunwind to v1.6.2 (#62092)
Browse files Browse the repository at this point in the history
* Update libunwind to v1.6.2

* Apply libunwind changes from 1b5719c

Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>

* Suppress Wincompatible-pointer-types on arm64

* Fix remote unwinding on win-arm64

* Mark base as both input and output

Co-authored-by: Jan Vorlicek <jan.vorlicek@volny.cz>

Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
Co-authored-by: Jan Vorlicek <jan.vorlicek@volny.cz>
  • Loading branch information
3 people authored Dec 15, 2021
1 parent 8151740 commit 74e6d01
Show file tree
Hide file tree
Showing 153 changed files with 4,412 additions and 619 deletions.
71 changes: 54 additions & 17 deletions src/coreclr/pal/src/libunwind/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,35 @@ sudo: required
language: c
compiler: gcc
env:
- TARGET=x86_64-linux-gnu
- TARGET=x86-linux-gnu
- TARGET=arm-linux-gnueabihf
- TARGET=aarch64-linux-gnu
- TARGET=mipsel-unknown-linux-gnu
# Currently experiencing build failures here
#- TARGET=powerpc64-linux-gnu
- HOST=x86_64-linux-gnu OPT=-O0
- HOST=x86-linux-gnu OPT=-O0
- HOST=arm-linux-gnueabihf OPT=-O0
- HOST=aarch64-linux-gnu OPT=-O0
- HOST=mipsel-linux-gnu OPT=-O0
- HOST=powerpc64-linux-gnu OPT=-O0
- HOST=x86_64-linux-gnu OPT=-O2
- HOST=x86-linux-gnu OPT=-O2
- HOST=arm-linux-gnueabihf OPT=-O2
- HOST=aarch64-linux-gnu OPT=-O2
- HOST=mipsel-linux-gnu OPT=-O2
- HOST=powerpc64-linux-gnu OPT=-O2
- HOST=x86_64-linux-gnu OPT=-O3
- HOST=x86-linux-gnu OPT=-O3
- HOST=arm-linux-gnueabihf OPT=-O3
- HOST=aarch64-linux-gnu OPT=-O3
- HOST=mipsel-linux-gnu OPT=-O3
- HOST=powerpc64-linux-gnu OPT=-O3

linux-s390x: &linux-s390x
os: linux
arch: s390x
env: TARGET=s390x-linux-gnu
env: HOST=s390x-linux-gnu BUILD=s390x-linux-gnu
script:
- ./autogen.sh
- |
CFLAGS="$OPT"
CXXFLAGS="$OPT"
export CFLAGS CXXFLAGS
- autoreconf -i
- ./configure
- make -j32
- ulimit -c unlimited
Expand All @@ -25,23 +40,45 @@ 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}
- cmake -G "Visual Studio 15 2017" -A ${WINHOST} -S . -B bin/windows-${WINHOST}/${TARGET}
- cmake --build bin/windows-${WINHOST}/${TARGET}

script:
- ./autogen.sh
- ./configure --target=$TARGET --host=$HOST
- |
BUILD=x86_64-linux-gnu
export BUILD
if [ $HOST = 'x86-linux-gnu' ]; then
sudo apt-get update
sudo apt-get install -yqq -o=Dpkg::Use-Pty=0 g++-multilib
CFLAGS=" -m32"
CXXFLAGS=" -m32"
export CFLAGS CXXFLAGS
elif [ $HOST != 'x86_64-linux-gnu' ]; then
sudo apt-get update
sudo apt-get install -yqq -o=Dpkg::Use-Pty=0 g++-$HOST
CC=$HOST-gcc
CXX=$HOST-g++
export CC CXX
fi
- |
CFLAGS="$CFLAGS $OPT"
CXXFLAGS="$CXXFLAGS $OPT"
export CFLAGS CXXFLAGS
- autoreconf -i
- ./configure CC=$CC CXX=$CXX CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" --build=$BUILD --host=$HOST
- make -j32
- sudo bash -c 'echo core.%p.%p > /proc/sys/kernel/core_pattern'
- ulimit -c unlimited
- if [ $TARGET == 'x86_64-linux-gnu' ]; then make check -j32; fi
- if [ $HOST = 'x86_64-linux-gnu' ]; then make check -j32; fi

after_failure: cat tests/test-suite.log 2>/dev/null

jobs:
include:
- <<: *linux-s390x
- <<: *windows-remote-only
env: TARGET=x86_64-linux-gnu HOST=x64
env: WINHOST=x64 TARGET=x86_64-linux-gnu
- <<: *windows-remote-only
env: TARGET=arm-linux-gnueabihf HOST=Win32
env: WINHOST=Win32 TARGET=arm-linux-gnueabihf
- <<: *windows-remote-only
env: TARGET=aarch64-linux-gnu HOST=x64
env: WINHOST=x64 TARGET=aarch64-linux-gnu
2 changes: 2 additions & 0 deletions src/coreclr/pal/src/libunwind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ if(CLR_CMAKE_HOST_UNIX)
endif()
# We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension
add_definitions(-Dasm=__asm__)
# Disable warning for a bug in the libunwind source src/aarch64/Ginit.c, but not in code that we exercise
add_compile_options(-Wno-incompatible-pointer-types)
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)
Expand Down
52 changes: 2 additions & 50 deletions src/coreclr/pal/src/libunwind/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,55 +1,7 @@
***********************************************************

Discontinued. See git log instead at
Discontinued. See git log instead at

http://www.kernel.org/git/gitweb.cgi?p=libs/libunwind/libunwind.git;a=log
https://github.com/libunwind/libunwind/commits/master

***********************************************************

2002-11-08 David Mosberger-Tang <David.Mosberger@acm.org>

* src/ia64/unwind_i.h (ia64_getfp): Change from macro to inline
function. Check "loc" argument for being NULL before dereferencing it.
(ia64_putfp): Ditto.
(ia64_get): Ditto.
(ia64_put): Ditto.

2002-01-18 David Mosberger-Tang <David.Mosberger@acm.org>

* src/ia64/parser.c (__ia64_unw_create_state_record): Set
IA64_FLAG_HAS_HANDLER if the unwind info descriptors indicate that
there a handler.

* src/ia64/regs.c (__ia64_access_reg): Return zero for UNW_REG_HANDLER
in frames that don't have a personality routine.

* src/ia64/unwind_i.h (IA64_FLAG_HAS_HANDLER): New flag.

* src/ia64/regs.c (__ia64_access_reg): When reading UNW_REG_HANDLER,
account for the fact that the personality address is gp-relative.

* src/ia64/parser.c (__ia64_unw_create_state_record): Fix
initialization of segbase and len.

2002-01-17 David Mosberger-Tang <David.Mosberger@acm.org>

* include/unwind-ia64.h: Include via "unwind.h" to ensure
the file is picked up from same directory.

2002-01-16 David Mosberger-Tang <David.Mosberger@acm.org>

* include/unwind.h: Define UNW_ESTOPUNWIND. This error code may
be returned by acquire_unwind_info() to force termination of
unwinding. An application may want to do this when encountering a
call frame for dynamically generated code, for example.

* unwind.h: Pass opaque argument pointer to acquire_unwind_info()
and release_unwind_info() like we do for access_mem() etc.

2002-01-14 David Mosberger-Tang <David.Mosberger@acm.org>

* Version 0.0 released.

2002-01-11 David Mosberger-Tang <David.Mosberger@acm.org>

* ChangeLog created.
10 changes: 9 additions & 1 deletion src/coreclr/pal/src/libunwind/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ endif
if ARCH_S390X
include_HEADERS += include/libunwind-s390x.h
endif
if ARCH_RISCV
include_HEADERS += include/libunwind-riscv.h
endif

if !REMOTE_ONLY
include_HEADERS += include/libunwind.h include/unwind.h
include_HEADERS += include/libunwind.h
if BUILD_UNWIND_HEADER
include_HEADERS += include/unwind.h
endif
endif

nodist_include_HEADERS = include/libunwind-common.h
Expand Down Expand Up @@ -89,6 +95,8 @@ noinst_HEADERS = include/dwarf.h include/dwarf_i.h include/dwarf-eh.h \
include/tdep-sh/jmpbuf.h include/tdep-sh/libunwind_i.h \
include/tdep-s390x/dwarf-config.h \
include/tdep-s390x/jmpbuf.h include/tdep-s390x/libunwind_i.h \
include/tdep-riscv/dwarf-config.h \
include/tdep-riscv/jmpbuf.h include/tdep-riscv/libunwind_i.h \
include/tdep/libunwind_i.h \
include/tdep/jmpbuf.h include/tdep/dwarf-config.h

Expand Down
10 changes: 6 additions & 4 deletions src/coreclr/pal/src/libunwind/README
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@

[![Build Status](https://travis-ci.org/libunwind/libunwind.svg?branch=master)](https://travis-ci.org/libunwind/libunwind)

This is version 1.4 of the unwind library. This library supports
several architecture/operating-system combinations:
This library supports several architecture/operating-system combinations:

| System | Architecture | Status |
| :------ | :----------- | :----- |
| Linux | x86-64 | ✓ |
| Linux | x86 | ✓ |
| Linux | ARM | ✓ |
| Linux | AArch64 | ✓ |
| Linux | PPC32 | ✓ |
| Linux | PPC64 | ✓ |
| Linux | SuperH | ✓ |
| Linux | IA-64 | ✓ |
| Linux | PARISC | Works well, but C library missing unwind-info |
| Linux | Tilegx | 64-bit mode only |
| Linux | MIPS | Newly added |
| Linux | RISC-V | 64-bit only |
| HP-UX | IA-64 | Mostly works, but known to have serious limitations |
| FreeBSD | x86-64 | ✓ |
| FreeBSD | x86 | ✓ |
Expand All @@ -34,7 +35,7 @@ such dependencies
- p, provides its own implementation
- empty, no requirement

| Archtecture | getcontext | setcontext |
| Architecture | getcontext | setcontext |
|--------------|------------|------------|
| aarch64 | p | |
| arm | p | |
Expand All @@ -43,6 +44,7 @@ such dependencies
| mips | p | |
| ppc32 | r | |
| ppc64 | r | r |
| riscv | p | p |
| s390x | p | p |
| sh | r | |
| tilegx | r | r |
Expand All @@ -54,7 +56,7 @@ such dependencies
In general, this library can be built and installed with the following
commands:

$ ./autogen.sh # Needed only for building from git. Depends on libtool.
$ autoreconf -i # Needed only for building from git. Depends on libtool.
$ ./configure
$ make
$ make install prefix=PREFIX
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/pal/src/libunwind/README.md

This file was deleted.

1 change: 1 addition & 0 deletions src/coreclr/pal/src/libunwind/README.md
9 changes: 0 additions & 9 deletions src/coreclr/pal/src/libunwind/autogen.sh

This file was deleted.

39 changes: 24 additions & 15 deletions src/coreclr/pal/src/libunwind/configure.ac
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
define(pkg_major, 1)
define(pkg_minor, 5)
define(pkg_extra, -rc1)
define(pkg_minor, 6)
define(pkg_extra, 2)
define(pkg_maintainer, libunwind-devel@nongnu.org)
define(mkvers, $1.$2$3)
define(mkvers, $1.$2.$3)
dnl Process this file with autoconf to produce a configure script.
AC_INIT([libunwind],[mkvers(pkg_major, pkg_minor, pkg_extra)],[pkg_maintainer])
AC_CONFIG_SRCDIR(src/mi/backtrace.c)
Expand Down Expand Up @@ -34,9 +34,10 @@ esac

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(asm/ptrace_offsets.h endian.h sys/endian.h execinfo.h \
ia64intrin.h sys/uc_access.h unistd.h signal.h sys/types.h \
sys/procfs.h sys/ptrace.h byteswap.h elf.h sys/elf.h link.h sys/link.h)
AC_CHECK_HEADERS(asm/ptrace_offsets.h asm/ptrace.h endian.h sys/endian.h sys/param.h \
execinfo.h ia64intrin.h sys/uc_access.h unistd.h signal.h sys/types.h \
sys/procfs.h sys/ptrace.h sys/syscall.h byteswap.h elf.h sys/elf.h \
link.h sys/link.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
Expand Down Expand Up @@ -96,6 +97,7 @@ AC_DEFUN([SET_ARCH],[
[sh*],[$2=sh],
[amd64],[$2=x86_64],
[tile*],[$2=tilegx],
[riscv*],[$2=riscv],
[$2=$1])
]) dnl SET_ARCH

Expand All @@ -118,7 +120,7 @@ esac

AC_ARG_ENABLE(coredump,
AS_HELP_STRING([--enable-coredump],[building libunwind-coredump library]),,
[AS_CASE([$host_arch], [aarch64*|arm*|mips*|sh*|x86*|tile*], [enable_coredump=yes], [enable_coredump=no])]
[AS_CASE([$host_arch], [aarch64*|arm*|mips*|sh*|x86*|tile*|riscv*], [enable_coredump=yes], [enable_coredump=no])]
)

AC_MSG_CHECKING([if we should build libunwind-coredump])
Expand All @@ -134,7 +136,7 @@ AC_MSG_RESULT([$enable_ptrace])

AC_ARG_ENABLE(setjmp,
AS_HELP_STRING([--enable-setjmp],[building libunwind-setjmp library]),,
[AS_IF([test x$target_arch == x$host_arch], [enable_setjmp=yes], [enable_setjmp=no])]
[AS_IF([test x$target_arch = x$host_arch], [enable_setjmp=yes], [enable_setjmp=no])]
)

AC_ARG_ENABLE(documentation,
Expand All @@ -149,6 +151,13 @@ AC_ARG_ENABLE(weak-backtrace,
AS_HELP_STRING([--disable-weak-backtrace],[Do not provide the weak 'backtrace' symbol.]),,
[enable_weak_backtrace=yes])

AC_ARG_ENABLE(unwind-header,
AS_HELP_STRING([--disable-unwind-header],[Do not export the 'unwind.h' header]),,
[enable_unwind_header=yes])

AC_MSG_CHECKING([if we should export unwind.h])
AC_MSG_RESULT([$enable_unwind_header])

AC_MSG_CHECKING([if we should build libunwind-setjmp])
AC_MSG_RESULT([$enable_setjmp])

Expand All @@ -164,6 +173,7 @@ AC_MSG_RESULT([$target_os])
AM_CONDITIONAL(BUILD_COREDUMP, test x$enable_coredump = xyes)
AM_CONDITIONAL(BUILD_PTRACE, test x$enable_ptrace = xyes)
AM_CONDITIONAL(BUILD_SETJMP, test x$enable_setjmp = xyes)
AM_CONDITIONAL(BUILD_UNWIND_HEADER, test "x$enable_unwind_header" = xyes)
AM_CONDITIONAL(NO_PTRACE_TEST, test x$build_arch != x$host_arch)
AM_CONDITIONAL(REMOTE_ONLY, test x$target_arch != x$host_arch)
AM_CONDITIONAL(ARCH_AARCH64, test x$target_arch = xaarch64)
Expand All @@ -178,6 +188,7 @@ AM_CONDITIONAL(ARCH_PPC64, test x$target_arch = xppc64)
AM_CONDITIONAL(ARCH_SH, test x$target_arch = xsh)
AM_CONDITIONAL(ARCH_TILEGX, test x$target_arch = xtilegx)
AM_CONDITIONAL(ARCH_S390X, test x$target_arch = xs390x)
AM_CONDITIONAL(ARCH_RISCV, test x$target_arch = xriscv)
AM_CONDITIONAL(OS_LINUX, expr x$target_os : xlinux >/dev/null)
AM_CONDITIONAL(OS_HPUX, expr x$target_os : xhpux >/dev/null)
AM_CONDITIONAL(OS_FREEBSD, expr x$target_os : xfreebsd >/dev/null)
Expand All @@ -188,7 +199,7 @@ AC_MSG_CHECKING([for ELF helper width])
case "${target_arch}" in
(arm|hppa|ppc32|x86|sh) use_elf32=yes; AC_MSG_RESULT([32]);;
(aarch64|ia64|ppc64|x86_64|s390x|tilegx) use_elf64=yes; AC_MSG_RESULT([64]);;
(mips) use_elfxx=yes; AC_MSG_RESULT([xx]);;
(mips|riscv) use_elfxx=yes; AC_MSG_RESULT([xx]);;
*) AC_MSG_ERROR([Unknown ELF target: ${target_arch}])
esac
AM_CONDITIONAL(USE_ELF32, [test x$use_elf32 = xyes])
Expand All @@ -204,12 +215,6 @@ fi
AM_CONDITIONAL(USE_DWARF, [test x$use_dwarf = xyes])
AC_MSG_RESULT([$use_dwarf])

if test x$target_arch = xppc64; then
libdir='${exec_prefix}/lib64'
AC_MSG_NOTICE([PowerPC64 detected, lib will be installed ${libdir}]);
AC_SUBST([libdir])
fi

AC_MSG_CHECKING([whether to restrict build to remote support])
if test x$target_arch != x$host_arch; then
CPPFLAGS="${CPPFLAGS} -DUNW_REMOTE_ONLY"
Expand Down Expand Up @@ -240,6 +245,7 @@ case $target_arch in
arm*) enable_cxx_exceptions=no;;
mips*) enable_cxx_exceptions=no;;
tile*) enable_cxx_exceptions=no;;
s390x*) enable_cxx_exceptions=no;;
*) enable_cxx_exceptions=yes;;
esac
])
Expand All @@ -255,6 +261,9 @@ case "${target_arch}" in
(aarch64) enable_debug_frame=yes;;
(*) enable_debug_frame=no;;
esac])
if test x$remote_only = xyes; then
enable_debug_frame=no
fi
if test x$enable_debug_frame = xyes; then
AC_DEFINE([CONFIG_DEBUG_FRAME], [], [Enable Debug Frame])
fi
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/pal/src/libunwind/include/dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ struct elf_dyn_info;
#else
#error Could not find <link.h>
#endif
#if defined(__ANDROID__) && defined(__arm__) && __ANDROID_API__ < 21
int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), void *);
#endif
#endif

#include <pthread.h>
Expand Down Expand Up @@ -367,6 +370,8 @@ struct unw_debug_frame_list
/* The start (inclusive) and end (exclusive) of the described region. */
unw_word_t start;
unw_word_t end;
/* ELF load offset */
unw_word_t load_offset;
/* The debug frame itself. */
char *debug_frame;
size_t debug_frame_size;
Expand Down
Loading

0 comments on commit 74e6d01

Please sign in to comment.