aboutsummaryrefslogtreecommitdiff
path: root/libunwind
AgeCommit message (Collapse)AuthorFilesLines
2022-11-10[CMake] Fix -Wstrict-prototypesSam James1-1/+1
Fixes warnings (or errors, if someone injects -Werror in their build system, which happens in fact with some folks vendoring LLVM too) with Clang 16: ``` +/var/tmp/portage.notmp/portage/sys-devel/llvm-15.0.4/work/llvm_build-abi_x86_64.amd64/CMakeFiles/CMakeTmp/src.c:3:9: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes] -/var/tmp/portage.notmp/portage/sys-devel/llvm-14.0.4/work/llvm_build-abi_x86_64.amd64/CMakeFiles/CMakeTmp/src.c:3:9: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] int main() {return 0;} ^ void ``` Differential Revision: https://reviews.llvm.org/D137503 (cherry picked from commit 32a2af44e1e882f13d1cc2817f0a8d4d8b375d4d)
2022-07-18[libunwind][SystemZ] Use process_vm_readv to avoid potential segfaultsUlrich Weigand2-4/+24
Fix potential crashes during unwind when checking for signal frames and the current PC is invalid. The same bug was fixed for aarch64 in https://reviews.llvm.org/D126343. Reviewed by: MaskRay Differential Revision: https://reviews.llvm.org/D129856
2022-06-27[libunwind,EHABI,ARM] Fix get/set of RA_AUTH_CODE.Simon Tatham1-4/+2
According to EHABI32 §8.5.2, the PAC for the return address of a function described in an exception table is supposed to be addressed in the _Unwind_VRS_{Get,Set} API by setting regclass=_UVRSC_PSEUDO and regno=0. (The space of 'regno' values is independent for each regclass, and for _UVRSC_PSEUDO, there is only one valid regno so far.) That is indeed what libunwind's _Unwind_VRS_{Get,Set} functions expect to receive. But at two call sites, the wrong values are passed in: regno is being set to UNW_ARM_RA_AUTH_CODE (0x8F) instead of 0, and in one case, regclass is _UVRSC_CORE instead of _UVRSC_PSEUDO. As a result, those calls to _Unwind_VRS_{Get,Set} return _UVRSR_FAILED, which their callers ignore. So if you compile in the AUTG instruction that actually validates the PAC, it will try to validate what's effectively an uninitialised register as an authentication code, and trigger a CPU fault even on correct exception unwinding. Reviewed By: danielkiss Differential Revision: https://reviews.llvm.org/D128522
2022-06-20[libunwind] Ensure test/libunwind_01.pass is not completely inlinedAlex Richardson1-7/+22
By adding noinline and calling fprintf before returning we ensure that every function will have a distinct call frame and that the return address will always be saved instead of saving the target in main as the result. Before this change all backtraces were always backtrace -> main -> _start, i.e. always exactly three entries. This happenend because all calls were inlined in main() and the test just happenend to pass because there is at least _start before main. I found this while fixing some bugs in libunwind for CHERI and noticed that the test was passing even though the code was completely broken. Obtained from: https://github.com/CTSRD-CHERI/llvm-project Reviewed By: #libunwind, ldionne, MaskRay Differential Revision: https://reviews.llvm.org/D126611
2022-06-06[libunwind] Don't store a predecremented PC when using SEHMartin Storsjö2-1/+9
This fixes unwinding in boundary cases on ARM with SEH. In the case of ARM/Thumb, disp->ControlPc points at the following instruction, with the thumb bit set. Thus by decrementing 1, it still points at the next instruction. To achieve the desired effect of pointing at the previous instruction, one first has to strip out the thumb bit, then do the decrement by 1 to reach the previous instruction. When libcxxabi looks for call site ranges, it already does `_Unwind_GetIP(context) - 1` (in `scan_eh_tab` in libcxxabi/src/cxa_personality.cpp), so we shouldn't do the corresponding `- 1` multiple times. In the case of libcxxabi on Thumb, `funcStart` (still in `scan_eh_tab`) may have the thumb bit set. If the program counter address is decremented both in libunwind (first removing the thumb bit, then decremented), and then libcxxabi decrements it further, and compares with a `funcStart` with the thumb bit set, it could point to one byte before the start of the call site. Thus: This modification makes libunwind with SEH work with libcxxabi on Thumb, in settings where libunwind and libcxxabi worked fine with Dwarf before. For existing cases with libunwind with SEH (on x86_64 and aarch64), this modification doesn't break any of my testcases. Differential Revision: https://reviews.llvm.org/D126869
2022-06-06[libunwind] Remove unused ARM SEH placeholder codeMartin Storsjö1-4/+0
There's no such corresponding code for ARM64 (which has been working in production for years). The SEH version of the Unwind functions (e.g. `_Unwind_GetLanguageSpecificData`) doesn't use these fields. The `_Unwind_ForcedUnwind` function would need these bits though, but that's not used in normal C++ exception unwinding. Differential Revision: https://reviews.llvm.org/D126868
2022-06-06[libunwind] Fix SEH unwinding on ARMMartin Storsjö4-5/+5
Check `__SEH__` when checking if ARM EHABI should be implied, similarly to 4a3722a2c3dff1fe885cc38bf43d3c095c9851e7 / D126866. Fix a warning by using the right format specifier (PRIxPTR instead of PRIx64), and add a double->float cast in a codepath that hasn't been built so far. This is enough to make SEH unwinding of itanium ABI exceptions on ARM mostly work - one specific issue is fixed in a separate follow-up patch. Differential Revision: https://reviews.llvm.org/D126867
2022-06-03[NFC] [libunwind] turn assert into static_assertFlorian Mayer2-18/+47
Reviewed By: #libunwind, MaskRay Differential Revision: https://reviews.llvm.org/D126987
2022-06-02[libunwind][ci][AIX] Add libunwind to buildbot CIXing Xue1-0/+25
Summary: This patch changes scripts to add libunwind CI on AIX. Test config file ibm-libunwind-shared.cfg.in is introduced for testing on AIX. Reviewed by: ldionne, MaskRay, libunwind, ibc++abi Differential Revision: https://reviews.llvm.org/D126017
2022-06-01[libunwind] Add more information to eh_frame_hdr version errorFlorian Mayer1-1/+2
This makes it easier to find the offending ELF file. Reviewed By: #libunwind, MaskRay Differential Revision: https://reviews.llvm.org/D126841
2022-05-27[runtimes] Officially deprecate the legacy testing configuration systemLouis Dionne1-0/+3
Add a warning and tweak the release note to explain that the deprecation targets libc++, libc++abi and libuwnind as well. Also, as a fly-by, ensure that our CI runs the legacy testing configuration for libc++, libc++abi and libunwind. This doesn't matter too much since it's deprecated, but we might as well test it properly. Differential Revision: https://reviews.llvm.org/D126478
2022-05-27[libunwind][CMake] Fix name of LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAGPavel Samolysov1-1/+1
The CMake variable LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG has been renamed into C_SUPPORTS_NODEFAULTLIBS_FLAG because the last one is used in the confix-ix.cmake file while the variable with the original name is not used at al. Differential Revision: https://reviews.llvm.org/D126466
2022-05-26[libunwind] Tidy-up the testing configuration for libunwindLouis Dionne3-4/+68
Start testing Apple backdeployment with older libunwinds, and stop explicitly specifying the libunwind testing config, since it is already selected correctly by default. Differential Revision: https://reviews.llvm.org/D126470
2022-05-26[libunwind] Use process_vm_readv to avoid potential segfaultsShoaib Meenai2-9/+90
We've observed segfaults in libunwind when attempting to check for the Linux aarch64 sigreturn frame, presumably because of bad unwind info leading to an incorrect PC that we attempt to read from. Use process_vm_readv to read the memory safely instead. The s390x code path should likely follow suit, but I don't have the hardware to be able to test that, so I didn't modify it here either. Reviewed By: MaskRay, rprichard, #libunwind Differential Revision: https://reviews.llvm.org/D126343
2022-05-26[libunwind] Factor out sigreturn check condition. NFCShoaib Meenai1-13/+22
Create a macro for this instead of duplicating the architecture checks everywhere. (It's a little redundant to use it when we're checking for a specific architecture, but I'm also applying it there for consistency.) Reviewed By: rprichard, MaskRay, #libunwind Differential Revision: https://reviews.llvm.org/D126342
2022-05-20[libunwind] Introduce a cmake-bridge.cfg.in file to reduce test config ↵Louis Dionne5-89/+54
duplication Differential Revision: https://reviews.llvm.org/D125981
2022-05-19[libunwind] Remove unused _LIBUNWIND_HAS_NO_THREADS macro in testsLouis Dionne3-3/+0
The _LIBUNWIND_HAS_NO_THREADS macro is only picked up by libunwind inside its sources, so it is only required when it builds. It doesn't need to be defined when running the tests.
2022-05-19[runtimes] Fix the build of merged ABI/unwinder librariesLouis Dionne1-0/+65
Also, add a CI job that tests this configuration. The exact configuration is that we build a shared libc++ and merge objects for the ABI library and the unwinder library into it. Differential Revision: https://reviews.llvm.org/D125903
2022-05-19[libunwind] Remove -Wsign-conversion warningDaniel Kiss1-1/+1
Reland after dependent change reland.
2022-05-18[runtimes] Default LIB*_HERMETIC_STATIC_LIBRARY to ON on WindowsMartin Storsjö1-6/+6
(In the case of libunwind, the cmake option is called LIBUNWIND_HIDE_SYMBOLS, but it has the same effect as LIBCXX_HERMETIC_STATIC_LIBRARY and LIBCXXABI_HERMETIC_STATIC_LIBRARY.) Previously, the same issue was dealt with by setting a project wide define (_LIBUNWIND_HIDE_SYMBOLS, _LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS and _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) if only building a static library. If building both static and shared at the same time, this wasn't set, and the static library would contain dllexport directives. The LIB*_HERMETIC_STATIC_LIBRARY and LIBUNWIND_HIDE_SYMBOLS cmake options only apply the defines to the static library in the build, even if building both static and shared at the same time. (This could only be done use after the object libraries were enabled, as a shared libcxx needs libcxxabi object files built with dllexports included.) This allows removing inelegant code for deciding how to build the libcxxabi static library and a TODO comment that suggested that users should need to start setting an option, which they shouldn't need to. Finally, this gets rid of two XFAILs in tests. Differential Revision: https://reviews.llvm.org/D125715
2022-05-18[libunwind][AArch64] Add support for DWARF expression for RA_SIGN_STATE.Daniel Kiss1-1/+20
Program may set the RA_SIGN_STATE pseudo register by expressions. Libunwind expected only the DW_CFA_AARCH64_negate_ra_state could change the value of the register which leads to runtime errors on PAC enabled systems. In the recent version of the aadwarf64[1] a limitation is added[2] to forbid the mixing the DW_CFA_AARCH64_negate_ra_state with other DWARF Register Rule Instructions. [1] https://github.com/ARM-software/abi-aa/releases/tag/2022Q1 [2] https://github.com/ARM-software/abi-aa/pull/129 Reviewed By: #libunwind, MaskRay Differential Revision: https://reviews.llvm.org/D123692 Reland: test moved because it depends on exceptions.
2022-05-16[runtimes] Introduce object librariesLouis Dionne2-31/+56
This is a variant of D116689 rebased on top of the new (proposed) ABI refactoring in D120727. It should conserve the basic properties of the original patch by @phosek, except it also allows cleaning up the merging of libc++abi into libc++ from the libc++ side. Differential Revision: https://reviews.llvm.org/D125393
2022-05-15Revert "[libunwind][AArch64] Add support for DWARF expression for ↵Daniel Kiss2-83/+1
RA_SIGN_STATE." This reverts commit f6366ef7f4f3cf1182fd70e0c50a9fa54374b612.
2022-05-13[runtimes][NFC] Remove dead code for Standalone buildsLouis Dionne1-37/+0
Standalone builds have been deprecated and then removed for a while now. Trying to use standalone builds leads to a fatal CMake error, so this code is all dead. Remove it to clean things up. Differential Revision: https://reviews.llvm.org/D125561
2022-05-13[libunwind] Remove -Wsign-conversion warningLouis Dionne1-1/+1
2022-05-13[libunwind][AArch64] Add support for DWARF expression for RA_SIGN_STATE.Daniel Kiss2-1/+83
Program may set the RA_SIGN_STATE pseudo register by expressions. Libunwind expected only the DW_CFA_AARCH64_negate_ra_state could change the value of the register which leads to runtime errors on PAC enabled systems. In the recent version of the aadwarf64[1] a limitation is added[2] to forbid the mixing the DW_CFA_AARCH64_negate_ra_state with other DWARF Register Rule Instructions. [1] https://github.com/ARM-software/abi-aa/releases/tag/2022Q1 [2] https://github.com/ARM-software/abi-aa/pull/129 Reviewed By: #libunwind, MaskRay Differential Revision: https://reviews.llvm.org/D123692
2022-05-12[runtimes] [cmake] Fix -Werror detection in common build configsMartin Storsjö1-3/+0
We add `--unwindlib=none` to `CMAKE_REQUIRED_FLAGS` to make sure that builds with a yet-incomplete toolchain succeed, to avoid linker failures about missing unwindlib. When this option is added to `CMAKE_REQUIRED_FLAGS`, it gets added to both compile and link commands in CMake compile tests. If `--unwindlib=none` is included in compilation commands, it causes warnings about unused arguments, as the flag only is relevant for linking. Due to the warnings in CMake tests, the later CMake test for the `-Werror` option failed (as the tested `-Werror` option caused the preexisting warning due to unused `--unwindlib=none` to become a hard error). Therefore, most CI configurations that build with `LIBCXX_ENABLE_WERROR` didn't actually end up enabling `-Werror` after all. When looking at the CI build log of recent CI builds, they do end up printing: -- Performing Test LIBCXX_SUPPORTS_WERROR_FLAG -- Performing Test LIBCXX_SUPPORTS_WERROR_FLAG - Failed -- Performing Test LIBCXX_SUPPORTS_WX_FLAG -- Performing Test LIBCXX_SUPPORTS_WX_FLAG - Failed Thus while the configurations are meant to error out on warnings, they actually haven't done that, due to the interaction of these options. To fix this, remove the individual cases of adding `--unwindlib=none` into `CMAKE_REQUIRED_FLAGS` in libcxx and libunwind. `runtimes/CMakeLists.txt` still adds `--unwindlib=none` if needed, but not otherwise. (The same issue with enabling `-Werror` does remain if `--unwindlib=none` strictly is needed though - that can be fixed separately afterwards.) These individual cases in libunwind and libcxx were added while standalone builds of the runtimes still were supported - but no longer are necessary now. Differential Revision: https://reviews.llvm.org/D124375
2022-05-11[runtimes] Print the testing configuration in use in libunwind and libc++abiLouis Dionne1-0/+1
We do it for libc++, and it's rather useful for debugging e.g. CI.
2022-05-04[libunwind] Silence warnings about unused variables. NFC.Martin Storsjö1-0/+1
This variable was considered unused when NDEBUG was defined. Differential Revision: https://reviews.llvm.org/D124911
2022-05-04[libunwind] [CMake] Handle the RelWithDebInfo configuration similarly to ReleaseMartin Storsjö1-2/+2
This makes sure to include libunwind log messages in the build if LIBUNWIND_ENABLE_ASSERTIONS is set (which it is by default), when building in RelWithDebInfo configurations. Differential Revision: https://reviews.llvm.org/D124912
2022-05-04[libunwind][SystemZ] Unwind out of signal handlersUlrich Weigand3-7/+111
Unwinding out of signal handlers currently does not work since the sigreturn trampoline is not annotated with CFI data. Fix this by detecting the sigreturn trampoline during unwinding and providing appropriate unwind data manually. This follows closely the approach used by existing code for the AArch64 target. Reviewed by: MaskRay Differential Revision: https://reviews.llvm.org/D124765
2022-05-02[libunwind] Add SystemZ supportUlrich Weigand8-1/+426
Add support for the SystemZ (s390x) architecture to libunwind. Support should be feature-complete with the exception of unwinding from signal handlers (to be added later). Reviewed by: MaskRay Differential Revision: https://reviews.llvm.org/D124248
2022-04-28[libunwind][AArch64] Fix _Unwind_ForcedUnwind via sigreturn.Daniel Kiss1-0/+2
When the sigreturn trampoline is found the unw_proc_info_t.end_ip need to be set to indicate a stack frame is found. Reviewed By: cjdb, #libunwind, MaskRay Differential Revision: https://reviews.llvm.org/D124522
2022-04-25[libunwind] Update the test configuration files to support the remote execution.Vladimir Vereschaka2-4/+19
These changes allow remote execution for the libunwind library tests. Differential Revision: https://reviews.llvm.org/D123890
2022-04-25[libunwind] [CMake] Remove leftover no-op cmake variable setting. NFC.Martin Storsjö1-9/+0
The setting and restoring of this variable became unused in 3ee0cec88effc88285732c8bec2a8f0e4e37c0b1 / D112155. Differential Revision: https://reviews.llvm.org/D124372
2022-04-25[libunwind] Fix build warnings in Unwind-EHABI.cpp. NFC.Martin Storsjö1-0/+3
Differential Revision: https://reviews.llvm.org/D124371
2022-04-24[runtimes] [CMake] Unify variable namesPetr Hosek4-30/+30
Avoid repeating CMake checks across runtimes by unifying names of variables used for results to leverage CMake caching. Differential Revision: https://reviews.llvm.org/D110005
2022-04-13[libunwind][AIX] implementation of the unwinder for AIXXing Xue1-5/+5
NFC - revert identation changes in AddressSpace.hpp from the previous commit Differential Revision: https://reviews.llvm.org/D100132
2022-04-13[libunwind][AIX] implementation of the unwinder for AIXXing Xue2-8/+8
Summary: This is an add-on patch to address comments. - Replace #elif in file <assembly.h> with #else as suggested; - Reversed the indentation changes in the main patch. Differential Revision: https://reviews.llvm.org/D100132
2022-04-13[libunwind][AIX] implementation of the unwinder for AIXXing Xue15-81/+848
Summary: This patch contains the implementation of the unwinder for IBM AIX. AIX does not support the eh_frame section. Instead, the traceback table located at the end of each function provides the information for stack unwinding and EH. In this patch macro _LIBUNWIND_SUPPORT_TBTAB_UNWIND is used to guard code for AIX traceback table based unwinding. Function getInfoFromTBTable() and stepWithTBTable() are added to get the EH information from the traceback table and to step up the stack respectively. There are two kinds of LSDA information for EH on AIX, the state table and the range table. The state table is used by the previous version of the IBM XL compiler, i.e., xlC and xlclang++. The DWARF based range table is used by AIX clang++. The traceback table has flags to differentiate these cases. For the range table, relative addresses are calculated using a base of DW_EH_PE_datarel, which is the TOC base of the module where the function of the current frame belongs. Two personality routines are employed to handle these two different LSDAs, __xlcxx_personality_v0() for the state table and __xlcxx_personality_v1() for the range table. Since the traceback table does not have the information of the personality for the state table approach, its personality __xlcxx_personality_v0() is dynamically resolved as the handler for the state table. For the range table, the locations of the LSDA and its associated personality routine are found in the traceback table. Assembly code for 32- and 64-bit PowerPC in UnwindRegistersRestore.S and UnwindRegistersSave.S are modified so that it can be consumed by the GNU flavor assembler and the AIX assembler. The restoration of vector registers does not check VRSAVE on AIX because VRSAVE is not used in the AIX ABI. Reviewed by: MaskRay, compnerd, cebowleratibm, sfertile, libunwind Differential Revision: https://reviews.llvm.org/D100132
2022-04-09Add some prototypes to fix -Wstrict-prototypes. NFCFangrui Song2-4/+4
2022-04-08NFC: Avoid unused variable warning in UnwindLevel1.ckristina1-1/+5
2022-04-03[libunwind] Add missing licenses in test filesLouis Dionne5-2/+46
2022-03-31[libc++] Add a CI job running MSANLouis Dionne7-0/+22
For some reason, we've been going without a MSAN CI job, even though even run-buildbot defined a generic-msan job. This must have been an oversight that went unnoticed. Thanks to @EricWF for the catch. Differential Revision: https://reviews.llvm.org/D120851
2022-03-30[libunwind] Add a _LIBUNWIND_VERSION macroLouis Dionne1-0/+2
This allows us to detect whether we're being compiled with LLVM's libunwind more easily, without CMake having to set explicit variables. As discussed in https://llvm.org/D119538. Differential Revision: https://reviews.llvm.org/D121015
2022-03-23Replace links to archived mailing lists by links to Discourse forumsDanny Mösch1-10/+8
2022-03-01[runtimes] Remove FOO_TARGET_TRIPLE, FOO_SYSROOT and FOO_GCC_TOOLCHAINLouis Dionne4-44/+11
Instead, folks can use the equivalent variables provided by CMake to set those. This removal aims to reduce complexity and potential for confusion when setting the target triple for building the runtimes, and make it correct when `CMAKE_OSX_ARCHITECTURES` is used (right now both `-arch` and `--target=` will end up being passed, which is downright incorrect). Differential Revision: https://reviews.llvm.org/D112155
2022-02-25[libunwind][test] remember_state_leak.pass.sh.s: link with -no-pieFangrui Song1-1/+1
The no-pic large code model style `movabsq $callback, %rsi` does not work with -pie.
2022-02-21[libunwind] Further fix for 32-bit PowerPC processors without AltiVecGeorge Koehler1-0/+2
https://reviews.llvm.org/D91906 did most of the work necessary to fix libunwind on 32-bit PowerPC processors without AltiVec, but there was one more piece necessary. Reviewed By: luporl Differential Revision: https://reviews.llvm.org/D120197
2022-02-16[runtimes] Move warning messages for FOO_SYSROOT & friends above their ↵Louis Dionne1-10/+10
default value Otherwise, the warnings always trigger.