Commit Graph

422 Commits

Author SHA1 Message Date
xgupta
94fac81fcc [Branch-Rename] Fix some links
According to the [[ https://foundation.llvm.org/docs/branch-rename/ | status of branch rename ]], the master branch of the LLVM repository is removed on 28 Jan 2021.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D95766
2021-02-01 16:43:21 +05:30
Tom Stellard
5369517d20 Bump the trunk major version to 13
and clear the release notes.
2021-01-26 19:37:55 -08:00
Raul Tambre
480643a95c [CMake] Remove dead code setting policies to NEW
cmake_minimum_required(VERSION) calls cmake_policy(VERSION),
which sets all policies up to VERSION to NEW.
LLVM started requiring CMake 3.13 last year, so we can remove
a bunch of code setting policies prior to 3.13 to NEW as it
no longer has any effect.

Reviewed By: phosek, #libunwind, #libc, #libc_abi, ldionne

Differential Revision: https://reviews.llvm.org/D94374
2021-01-19 17:19:36 +02:00
Kazushi (Jam) Marukawa
3cbd476c54 [VE] Support VE in libunwind
Modify libunwind to support SjLj exception handling routines for VE.
In order to do that, we need to implement not only SjLj exception
handling routines but also a Registers_ve class.  This implementation
of Registers_ve is incomplete.  We will work on it later when we need
backtrace in libunwind.

Reviewed By: #libunwind, compnerd

Differential Revision: https://reviews.llvm.org/D94591
2021-01-17 15:35:02 +09:00
Ryan Prichard
c82deed676 [libunwind] Unwind through aarch64/Linux sigreturn frame
An AArch64 sigreturn trampoline frame can't currently be described
in a DWARF .eh_frame section, because the AArch64 DWARF spec currently
doesn't define a constant for the PC register. (PC and LR may need to
be restored to different values.)

Instead, use the same technique as libgcc or github.com/libunwind and
detect the sigreturn frame by looking for the sigreturn instructions:

    mov x8, #0x8b
    svc #0x0

If a sigreturn frame is detected, libunwind restores all the GPRs by
assuming that sp points at an rt_sigframe Linux kernel struct. This
behavior is a fallback mode that is only used if there is no ordinary
unwind info for sigreturn.

If libunwind can't find unwind info for a PC, it assumes that the PC is
readable, and would crash if it isn't. This could happen if:
 - The PC points at a function compiled without unwind info, and which
   is part of an execute-only mapping (e.g. using -Wl,--execute-only).
 - The PC is invalid and happens to point to unreadable or unmapped
   memory.

In the tests, ignore a failed dladdr call so that the tests can run on
user-mode qemu for AArch64, which uses a stack-allocated trampoline
instead of a vDSO.

Reviewed By: danielkiss, compnerd, #libunwind

Differential Revision: https://reviews.llvm.org/D90898
2021-01-13 16:38:36 -08:00
Brandon Bergren
bb13411614 [libunwind] Multiple preprocessor fixes on PowerPC*
* Remove misnamed `PPC64_HAS_VMX` in preference of directly checking `defined(__VSX__)`.

libunwind was using "VMX" to mean "VSX". "VMX" is just another name for Altivec, while "VSX" is the vector-scalar extensions first used in POWER7. Exposing a "PPC64_HAS_VMX" define was misleading and incorrect.

* Add `defined(__ALTIVEC__)` guards around vector register operations to fix non-altivec CPUS such as the e5500.

When compiling for certain Book-E processors such as the e5500, we want to skip vector save/restore, as the Altivec registers are illegal on non-Altivec implementations.

* Add `!defined(__NO_FPRS__)` guards around traditional floating-point save/restore.

When compiling for powerpcspe, we cannot access floating point registers, as there aren't any. (The SPE on e500v2 is a 64-bit extension of the GPRs, and it doesn't have the normal floating-point registers at all.)
This fixes building for powerpcspe, although no actual handling for SPE save/restore is written yet.

Reviewed By: MaskRay, #libunwind, compnerd

Differential Revision: https://reviews.llvm.org/D91906
2020-11-23 19:07:21 -08:00
Fangrui Song
3324fd8a7b [libunwind] Delete unused handlerNotFound in unwind_phase1 2020-11-21 12:38:00 -08:00
Daniel Kiss
e7b8d3776f [libunwind] LIBUNWIND_REMEMBER_HEAP_ALLOC to cmake.
Missed it originally in https://reviews.llvm.org/D85005.

Reviewed By: gargaroff

Differential Revision: https://reviews.llvm.org/D91182
2020-11-11 11:21:17 +01:00
Louis Dionne
8d51969bd4 [runtimes] Avoid overwriting the rpath unconditionally
When building the runtimes, it's very important not to add rpaths unless
the user explicitly asks for them (the standard way being CMAKE_INSTALL_RPATH),
or to change the install name dir unless the user requests it (via
CMAKE_INSTALL_NAME_DIR).

llvm_setup_rpath() would override the install_name_dir of the runtimes
even if CMAKE_INSTALL_NAME_DIR was specified to something, which is wrong
and in fact even "dangerous" for the runtimes.

This issue was discovered when trying to build libc++ and libc++abi as
system libraries for Apple, where we set the install name dir to /usr/lib
explicitly. llvm_setup_rpath() would cause libc++ to have the wrong install
name dir, and for basically everything on the system to fail to load.
This was discovered just now because we previously used something closer
to a standalone build, where llvm_setup_rpath() wouldn't exist, and hence
not be used.

This is a revert of the following commits:

  libunwind: 3a667b9bd8
  libc++abi: 4877063e19
  libc++: 88434fe05f

Those added llvm_setup_rpath() for consistency, so it seems reasonable
to revert.

Differential Revision: https://reviews.llvm.org/D91099
2020-11-09 16:56:03 -05:00
Fangrui Song
2c481f128c [libunwind] Delete unused codeOffsetAtStackDecrement/registersInOtherRegisters/sameValueUsed
ld64 uses them to create compact unwind from DWARF call frame information.
When the code was ported to libunwind, the variables were not deleted.

Reviewed By: #libunwind, compnerd

Differential Revision: https://reviews.llvm.org/D91039
2020-11-09 10:19:12 -08:00
Louis Dionne
c1887e3f15 Revert "Allow running back-deployment testing against libc++abi"
This reverts commit 4d79ef814a, which broke a few build bots.
I'm reverting until I have time to investigate.
2020-11-06 17:26:42 -05:00
Louis Dionne
4d79ef814a Allow running back-deployment testing against libc++abi
Summary:
Before this patch, we could only link against the back-deployment libc++abi
dylib. This patch allows linking against the just-built libc++abi, but
running against the back-deployment one -- just like we do for libc++.

Also, add XFAIL markup to flag expected errors.
2020-11-06 08:12:46 -05:00
Daniel Kiss
1d7786d45f [libunwind] Support DW_CFA_remember/restore_state without heap allocation.
This patch just reorganises the code to make possible to use alloca
instead of malloc. This makes possible to use `.cfi_remember_state`/`.cfi_restore_state` on
platforms without heap allocation.
Also it will be safe to backtrace/unwind faults related to the allocator behind malloc.
`_LIBUNWIND_REMEMBER_HEAP_ALLOC ` option reenables the heap usage for `.cfi_remember_state`/`.cfi_restore_state`.
Define _LIBUNWIND_REMEMBER_STACK_ALLOC to force stack allocation.

Reviewed By: #libunwind, mstorsjo

Differential Revision: https://reviews.llvm.org/D85005
2020-10-30 17:45:20 +01:00
Daniel Kiss
05598e3d30 [libunwind] Fix linker flag handling in the tests.
--export-dynamic is not always available on all targets.
-funwind-tables was a duplicate in the lit.site.cfg.in.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D90202
2020-10-29 14:02:44 +01:00
Martin Storsjö
df6d2e8ab1 [libunwind] Add -Wno-dll-attribute-on-redeclaration when building for windows
It's not worth trying to fix these warnings within libunwind, instead
silence them.

Differential Revision: https://reviews.llvm.org/D90075
2020-10-26 23:23:01 +02:00
Louis Dionne
48e4b0fd3a [runtimes] Revert the libc++ __config_site change
This is a massive revert of the following commits (from most revent to oldest):

	2b9b7b5775.
	529ac33197
	28270234f1
	69c2087283
	b5aa67446e
	5d796645d6

After checking-in the __config_site change, a lot of things started breaking
due to widespread reliance on various aspects of libc++'s build, notably the
fact that we can include the headers from the source tree, but also reliance
on various "internal" CMake variables used by the runtimes build and compiler-rt.

These were unintended consequences of the change, and after two days, we
still haven't restored all the bots to being green. Instead, now that I
understand what specific areas this will blow up in, I should be able to
chop up the patch into smaller ones that are easier to digest.

See https://reviews.llvm.org/D89041 for more details on this adventure.
2020-10-23 09:41:48 -04:00
Louis Dionne
5d796645d6 [take 2] [libc++] Include <__config_site> from <__config>
Prior to this patch, we would generate a fancy <__config> header by
concatenating <__config_site> and <__config>. This complexifies the
build system and also increases the difference between what's tested
and what's actually installed.

This patch removes that complexity and instead simply installs <__config_site>
alongside the libc++ headers. <__config_site> is then included by <__config>,
which is much simpler. Doing this also opens the door to having different
<__config_site> headers depending on the target, which was impossible before.

It does change the workflow for testing header-only changes to libc++.
Previously, we would run `lit` against the headers in libcxx/include.
After this patch, we run it against a fake installation root of the
headers (containing a proper <__config_site> header). This makes use
closer to testing what we actually install, which is good, however it
does mean that we have to update that root before testing header changes.
Thus, we now need to run `ninja check-cxx-deps` before running `lit` by
hand.

This commit was originally applied in 1e46d1aa3 and reverted in eb60c487
because it broke the libc++abi and libunwind test suites. This has now
been fixed.

Differential Revision: https://reviews.llvm.org/D89041
2020-10-21 10:40:33 -04:00
Dominik Montada
8c03fdf34a [libcxxabi,libunwind] support running tests in standalone mode
Remove check for standalone and shared library mode in libcxxabi to
allow including tests in said mode. This check prevented running the
tests in standalone mode with static libraries, which is the case for
baremetal targets.

Fix check-unwind target trying to use a non-existent llvm-lit executable
in standalone mode. Copy the HandleOutOfTreeLLVM logic from libcxxabi to
libunwind in order to make the tests work in standalone mode.

Reviewed By: ldionne, #libc_abi, #libc

Differential Revision: https://reviews.llvm.org/D86540
2020-10-14 09:10:20 +02:00
Raphael Isemann
6b7a49bb43 Fix all the CMake code that can only handle -stdlib= but not --stdlib=
There are several places in LLVM's CMake setup that try to remove the
`stdlib=...` flag from the CMake flags. All this code however only considered
the `-stdlib=` variant of the flag but not the alternative spelling with a
double dash. This causes that when one adds `--stdlib=...` to the user-provided
CMake flags that this gets transformed into just `-` which ends up causing the
build system to think it should read the source from stdin (which then lead to
very confusing build errors).

This just adds the alternative spelling before the`-stdlib=` variant in all
these places

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D87133
2020-10-13 16:05:21 +02:00
Martin Storsjö
fc5e68fab9 [libunwind] [SEH] Don't interact with foreign exceptions
This unfortunately means that we don't execute C++ destructors when
unwinding past such frames for a different SEH unwind purpose (e.g.
as part of setjmp/longjmp), but that case isn't handled properly at
the moment (the original unwind intent is lost and we end up with an
unhandled exception). This patch makes sure the foreign unwind terminates
as intended.

After executing a handler, _Unwind_Resume doesn't have access to
the target frame parameter of the original foreign unwind. We also
currently blindly set ExceptionCode to STATUS_GCC_THROW - we could
set that correctly by storing the original code in _GCC_specific_handler,
but we don't have access to the original target frame value.

This also matches what libgcc's SEH unwinding code does in this case.

Differential Revision: https://reviews.llvm.org/D89231
2020-10-12 23:28:22 +03:00
Louis Dionne
504bc07d1a [runtimes] Use int main(int, char**) consistently in tests
This is needed when running the tests in Freestanding mode, where main()
isn't treated specially. In Freestanding, main() doesn't get mangled as
extern "C", so whatever runtime we're using fails to find the entry point.

One way to solve this problem is to define a symbol alias from __Z4mainiPPc
to _main, however this requires all definitions of main() to have the same
mangling. Hence this commit.
2020-10-08 14:28:13 -04:00
Daniel Kiss
f34ae1b9de [AArch64] Add v8.5 Branch Target Identification support.
The .note.gnu.property must be in the assembly file to indicate the
support for BTI otherwise BTI will be disabled for the whole library.
__unw_getcontext and libunwind::Registers_arm64::jumpto() may be called
indirectly therefore they should start with a landing pad.

Reviewed By: tamas.petz, #libunwind, compnerd

Differential Revision: https://reviews.llvm.org/D77786
2020-09-29 15:51:01 +02:00
Ryan Prichard
881aba7071 [libunwind] Optimize dl_iterate_phdr's findUnwindSectionsByPhdr
Currently, findUnwindSectionsByPhdr is slightly micro-optimized for the
case where the first callback has the target address, and is otherwise
very inefficient -- it decodes .eh_frame_hdr even when no PT_LOAD
matches the PC. (If the FrameHeaderCache is enabled, then the
micro-optimization only helps the first time unwind info is looked up.)

Instead, it makes more sense to optimize for the case where the
callback *doesn't* find the target address, so search for a PT_LOAD
segment first, and only look for the unwind info section if a matching
PT_LOAD is found.

This change helps on an Android benchmark with 100 shared objects,
where the DSO at the end of the dl_iterate_phdr list throws 10000
exceptions. Assuming the frame cache is disabled, this change cuts
about 30-40% off the benchmark's runtime.

Reviewed By: compnerd, saugustine, #libunwind

Differential Revision: https://reviews.llvm.org/D87881
2020-09-23 15:40:39 -07:00
Ryan Prichard
b16d6653c0 [libunwind] Combine dl_iterate_phdr codepaths for DWARF and EHABI
dl_iterate_phdr is used to search for unwind info provided by either
PT_GNU_EH_FRAME or PT_ARM_EXIDX. Most of the code between the two is
the same, so combine them, and factor out what's different into
checkForUnwindInfoSegment.

Details:
 - The FrameHeaderCache can now be enabled for ARM EHABI.
 - findUnwindSectionsByPhdr now finds the last PT_ARM_EXIDX rather than
   the first. There should only be one segment.
 - The dso_base and text_segment_length fields of UnwindInfoSections
   are now needed for dl_iterate_phdr when using EHABI, to hold the
   low and high PC values for a cache entry.

Reviewed By: compnerd, danielkiss, #libunwind, saugustine

Differential Revision: https://reviews.llvm.org/D87880
2020-09-23 15:40:39 -07:00
Dave Lee
b36bdfe5ca [cmake] Centralize LLVM_ENABLE_WARNINGS option
Configure default value of `LLVM_ENABLE_WARNINGS` in `HandleLLVMOptions.cmake`.

`LLVM_ENABLE_WARNINGS` is documented as ON by default, but `HandleLLVMOptions` assumes the default has been set somewhere else. If it has not been explicitly set, then `HandleLLVMOptions` implicitly uses OFF as a default.

This removes the various `option()` declarations in favor of a single declaration in `HandleLLVMOptions`. This will prevent the unwanted use of `-w` that is mentioned in a couple of the comments.

Reviewed By: DavidTruby, #libunwind, JDevlieghere, compnerd

Differential Revision: https://reviews.llvm.org/D87243
2020-09-21 10:23:17 -07:00
Daniel Kiss
22b615a965 [libunwind] Support for leaf function unwinding.
Unwinding leaf function is useful in cases when the backtrace finds a
leaf function for example when it caused a signal.
This patch also add the support for the DW_CFA_undefined because it marks
the end of the frames.

Ryan Prichard provided code for the tests.

Reviewed By: #libunwind, mstorsjo

Differential Revision: https://reviews.llvm.org/D83573

Reland with limit the test to the x86_64-linux target.
2020-09-18 15:09:42 +02:00
Daniel Kiss
5831adb8c3 Revert "[libunwind] Support for leaf function unwinding."
This reverts commit 23bef7ee99.
2020-09-18 11:37:54 +02:00
Ryan Prichard
fb1abe0063 [libunwind][DWARF] Fix end of .eh_frame calculation
* When .eh_frame is located using .eh_frame_hdr (PT_GNU_EH_FRAME), the
   start of .eh_frame is known, but not the size. In this case, the
   unwinder must rely on a terminator present at the end of .eh_frame.
   Set dwarf_section_length to UINTPTR_MAX to indicate this.

 * Add a new field, text_segment_length, that the FrameHeaderCache uses
   to track the size of the PT_LOAD segment indicated by dso_base.

 * Compute ehSectionEnd by adding sectionLength to ehSectionStart,
   never to fdeHint.

Fixes PR46829.

Differential Revision: https://reviews.llvm.org/D87750
2020-09-16 19:00:57 -07:00
Daniel Kiss
23bef7ee99 [libunwind] Support for leaf function unwinding.
Unwinding leaf function is useful in cases when the backtrace finds a
leaf function for example when it caused a signal.
This patch also add the support for the DW_CFA_undefined because it marks
the end of the frames.

Ryan Prichard provided code for the tests.

Reviewed By: #libunwind, mstorsjo

Differential Revision: https://reviews.llvm.org/D83573
2020-09-16 23:53:36 +02:00
Louis Dionne
ec46cfefe8 [libcxx] Simplify back-deployment testing
The needs of back-deployment testing currently require two different
ways of running the test suite: one based on the deployment target,
and one based on the target triple. Since the triple includes all the
information we need, it's better to have just one way of doing things.

Furthermore, `--param platform=XXX` is also supersedded by using the
target triple. Previously, this parameter would serve the purpose of
controling XFAILs for availability markup errors, however it is possible
to achieve the same thing by using with_system_cxx_lib only and using
.verify.cpp tests instead, as explained in the documentation changes.

The motivation for this change is twofold:
1. This part of the Lit config has always been really confusing and
   complicated, and it has been a source of bugs in the past. I have
   simplified it iteratively in the past, but the complexity is still
   there.
2. The deployment-target detection started failing in weird ways in
   recent Clangs, breaking our CI. Instead of band-aid patching the
   issue, I decided to remove the complexity altogether by using target
   triples even on Apple platforms.

A follow-up to this commit will bring the test suite in line with
the recommended way of handling availability markup tests.
2020-09-10 08:17:26 -04:00
Ryan Prichard
09d492902f [libunwind] Bare-metal DWARF: set dso_base to 0
Previously, DwarfFDECache::findFDE used 0 as a special value meaning
"search the entire cache, including dynamically-registered FDEs".
Switch this special value to -1, which doesn't make sense as a DSO
base.

Fixes PR47335.

Reviewed By: compnerd, #libunwind

Differential Revision: https://reviews.llvm.org/D86748
2020-09-09 15:43:35 -07:00
Ryan Prichard
88bf133c99 [libunwind] Replace chain-of-ifdefs for dl_iterate_phdr
Define a _LIBUNWIND_USE_DL_ITERATE_PHDR macro in config.h when there is
no other unwind info lookup method. Also define a
_LIBUNWIND_USE_DL_UNWIND_FIND_EXIDX macro to factor out
(__BIONIC__ and _LIBUNWIND_ARM_EHABI).

Differential Revision: https://reviews.llvm.org/D86768
2020-09-08 15:49:35 -07:00
Ryan Prichard
673484b341 [libunwind] Minor SJLJ config cleanup. NFCI.
Simplify:

    defined(__ARM_DWARF_EH__) || !defined(__arm__)

to:

    !defined(_LIBUNWIND_ARM_EHABI)

A later patch benefits from the simplicity. This change will result in
the two DWARF macros being defined when __USING_SJLJ_EXCEPTIONS__ is
defined, but:

 * That's already the case with the __APPLE__ and _WIN32 clauses.
 * That's also already the case with other architectures.
 * With __USING_SJLJ_EXCEPTIONS__, most of the unwinder is #ifdef'ed
   away.

Generally, when __USING_SJLJ_EXCEPTIONS__ is defined, most of the
libunwind code is removed by the preprocessor. e.g. None of the hpp
files are included, and almost all of the .c and .cpp files are defined
away, except in Unwind-sjlj.c. Unwind_AppleExtras.cpp is an exception
because it includes two hpp files, which it doesn't use. Remove the
unneeded includes for consistency with the general rule.

Reviewed By: steven_wu

Differential Revision: https://reviews.llvm.org/D86767
2020-09-03 15:59:45 -07:00
Raul Tambre
45344cf7ac [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify workarounds
It isn't very wise to pass an assembly file to the compiler and tell it to compile as a C file and hope that the compiler recognizes it as assembly instead.
Simply don't mark the file as C and CMake will recognize the rest.

This was attempted earlier in https://reviews.llvm.org/D85706, but reverted due to architecture issues on Apple.
Subsequent digging revealed a similar change was done earlier for libunwind in https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09.
Afterwards workarounds were added for MinGW and Apple:
* https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09
* https://reviews.llvm.org/rGd4ded05ba851304b26a437896bc3962ef56f62cb

The workarounds in libunwind and compiler-rt are unified and comments added pointing to each other.
The workaround is updated to only be used for MinGW for CMake versions before 3.17, which fixed the issue (https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4287).

Additionally fixed Clang not being passed as the assembly compiler for compiler-rt runtime build.

Example error:
[525/634] Building C object lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o
FAILED: lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o
/opt/tooling/drive/host/bin/clang --target=aarch64-linux-gnu -I/opt/tooling/drive/llvm/compiler-rt/lib/tsan/.. -isystem /opt/tooling/drive/toolchain/opt/drive/toolchain/include -x c -Wall -Wno-unused-parameter -fno-lto -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fPIE -fno-rtti -Wframe-larger-than=530 -Wglobal-constructors --sysroot=. -MD -MT lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o -MF lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o.d -o lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o -c /opt/tooling/drive/llvm/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
/opt/tooling/drive/llvm/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S:29:1: error: expected identifier or '('
.section .text
^
1 error generated.

Differential Revision: https://reviews.llvm.org/D86308
2020-08-27 15:40:15 +03:00
Ryan Prichard
3071d5ffba [libunwind] Factor out getInfoFromFdeCie. NFCI.
Differential Revision: https://reviews.llvm.org/D86255
2020-08-26 18:22:06 -07:00
Ryan Prichard
7a457593ef [libunwind] Minor fixes in libunwind
* When _LIBUNWIND_SUPPORT_COMPACT_UNWIND is defined in config.h,
   define it to "1" like the other macros. These macros are still
   checked using "#if defined(...)", however.

 * Include libunwind.h in AddressSpace.hpp before using
   _LIBUNWIND_ARM_EHABI.

 * Rename ProcessFrameHeaderCache to TheFrameHeaderCache, because some
   configurations (e.g. Android / hermetic static libraries) can have
   one cache per shared object in the process. (When there are more
   copies, it's more important not to waste memory in the cache.)

 * Add 3 missing header files to LIBUNWIND_HEADERS.

Differential Revision: https://reviews.llvm.org/D86254
2020-08-26 18:22:03 -07:00
Martin Storsjö
e524daa7e8 [libunwind] Convert x86, x86_64, arm64 register restore functions to C calling convention and name mangling
Currently, the assembly functions for restoring register state have
been direct implementations of the Registers_*::jumpto() method
(contrary to the functions for saving register state, which are
implementations of the extern C function __unw_getcontext). This has
included having the assembly function name match the C++ mangling of
that method name (and having the function match the C++ member
function calling convention). To simplify the interface of the assembly
implementations, make the functions have C calling conventions and
name mangling.

This fixes building the library in with a MSVC C++ ABI with clang-cl,
which uses a significantly different method name mangling scheme.
(The library might not be of much use as C++ exception unwinder in such
an environment, but the libunwind.h interface for stepwise unwinding
still is usable, as is the _Unwind_Backtrace function.)

Differential Revision: https://reviews.llvm.org/D86041
2020-08-26 14:32:32 +03:00
Mikael Holmen
1c39ffecd8 [libunwind] Fix warning when building without frameheader cache
Without the fix the compiler warns with

/data/repo/master/libunwind/src/AddressSpace.hpp:436:44: warning: unused parameter 'pinfo_size' [-Wunused-parameter]
                                    size_t pinfo_size, void *data) {
                                           ^
1 warning generated.
2020-08-25 12:58:39 +02:00
Ryan Prichard
9e32d7b6e7 [libunwind] Remove static_assert / __has_feature macros
The static_assert macro broke on GCC when a scope had two asserts and a
condition that depended on a template parameter. Remove the macro and
rely on the compiler's C++11 static_assert feature.

The __has_feature macro was only used here to determine whether to
define the static_assert macro.

Reviewed By: mstorsjo, #libunwind

Differential Revision: https://reviews.llvm.org/D86411
2020-08-24 14:07:20 -07:00
Ryan Prichard
3c1b2e338d [libunwind] Make findUnwindSectionsByPhdr static
Currently, this function is present in the dynsym table of
libunwind.so (on ELF targets). Make the function static instead.

In the previous release (LLVM 10.x), this function was instead a lambda
function inside LocalAddressSpace::findUnwindSections, and because
LocalAddressSpace was marked with _LIBUNWIND_HIDDEN, the lambda
function was also a hidden symbol.

Differential Revision: https://reviews.llvm.org/D86372
2020-08-22 17:12:52 -07:00
Martin Storsjö
542db87f1a [libunwind] Ensure enough alignment for unw_cursor_t for SEH build configurations
When built in SEH mode, UnwindCursor contains a CONTEXT struct,
which is aligned to 16 bytes in most configurations, causing the
whole UnwindCursor object to have 16 byte alignment.

This fixes backtraces using _Unwind_Backtrace on x86_64 mingw,
where an unw_cursor_t allocated on the stack was misaligned before.

This is an ABI break for this struct for this configuration, but very
few callers call libunwind directly (and even fewer directly allocate
an unw_cursor_t anyway).

Differential Revision: https://reviews.llvm.org/D86102
2020-08-22 22:48:57 +03:00
Sterling Augustine
a20f5fe708 Default to disabling the libunwind frameheader cache.
Although it works fine with glibc, as currently implemented the
frameheader cache is incompatible with certain platforms with
slightly different locking semantics inside dl_iterate_phdr.

Therefore only enable it when it is turned on explicitly with
a configure-time option.

Differential Revision: https://reviews.llvm.org/D86163
2020-08-18 14:37:36 -07:00
Steven Wu
4cd09374cd [libunwind] Remove compatibility support for macOS 10.6
Remove `_dyld_find_unwind_sections` implementation for macOS that is
10.6 or previous. 10.6 is no longer supported for TOT libunwind after
removing its libkeymgr dependency.

Reviewed By: mstorsjo, pete, #libunwind

Differential Revision: https://reviews.llvm.org/D86104
2020-08-17 14:09:03 -07:00
Louis Dionne
9b211a5076 [libunwind] Fix incorrect check for out-of-boundedness
If the personalityIndex (which is 0-based) is equal to the length of
the personality array, we should error out.

rdar://18013273
2020-08-11 15:37:57 -04:00
Louis Dionne
e8dac8b3db [libunwind][NFC] Fix typo in comment 2020-08-11 15:24:52 -04:00
Daniel Kiss
9c3f6fb688 [libunwind] Make the test depend on the libunwind explicitly.
Before this patch the `ninja check-unwind` won't rebuild the unwind library.

Reviewed By: jroelofs

Differential Revision: https://reviews.llvm.org/D85004
2020-08-03 09:46:23 +02:00
kristina
46591b9536 [libunwind] Add -Wno-suggest-override to CMakeLists.txt.
Set -Wno-suggest-override where such warning is provided
by the compiler when building libunwind, alongside libcxx
and libcxxabi, using recent Clang. This extends behavior
introduced in 77e0e9e17d
to libunwind, avoiding a large amount of warnings during
builds. See D84126 for the original patch.
2020-07-31 19:04:13 +01:00
Hafiz Abid Qadeer
380fee34d2 [libunwind] Provide a way to set '_LIBUNWIND_IS_BAREMETAL' through cmake.
Libunwind uses _LIBUNWIND_IS_BAREMETAL in a lot of places but there is no cmake variable to set it. This patch adds such a variable. It is quite like what LIBCXXABI_BAREMETAL does in libcxxabi.

Reviewed By: compnerd, #libunwind

Differential Revision: https://reviews.llvm.org/D84759
2020-07-29 11:48:28 +01:00
Louis Dionne
145acacaea [libunwind] Remove old keymgr related logic
keymgr used to be used on MacOSX <= 10.6, however we don't build libunwind
from scratch for such old systems anymore. Hence, this code isn't useful
anymore.

Differential Revision: https://reviews.llvm.org/D84677
2020-07-27 16:12:59 -04:00
Louis Dionne
afa1afd410 [CMake] Bump CMake minimum version to 3.13.4
This upgrade should be friction-less because we've already been ensuring
that CMake >= 3.13.4 is used.

This is part of the effort discussed on llvm-dev here:

  http://lists.llvm.org/pipermail/llvm-dev/2020-April/140578.html

Differential Revision: https://reviews.llvm.org/D78648
2020-07-22 14:25:07 -04:00