aboutsummaryrefslogtreecommitdiff
path: root/libunwind
AgeCommit message (Collapse)AuthorFilesLines
2026-01-05[libunwind][WebAssembly] Fix typos (NFC) (#173745)Heejin Ahn1-7/+7
2026-01-02[PAC][libunwind] Pass ptrauth-qualified values as const references (#173765)Daniil Kovalev6-63/+108
For Apple's arm64e or Linux's pauthtest, `Registers_arm64::link_reg_t` type is `__ptrauth`-qualified. When passing a value of such a type to a function accepting non-`__ptrauth`-qualified parameter with `pint_t` type, an authentication is performed. So, the corresponding callee argument does not contain an embedded signature, making it prone to substitution if spilled to the stack. This patch prevents early authentication of signed values of `link_reg_t` type by passing them as const l-value references instead of passing by value with type `pint_t`. This way, the callee would operate with a `__ptrauth`-qualified value containing a signature, allowing to detect a substitution if the value is spilled to the stack. Note that this approach was introduced previously in #143230 for some other functions. In this patch, we apply the approach to the functions which were not considered previously.
2025-12-29[PAC][libunwind] Enhance PAuth-related comments in `__unw_set_reg` (#173769)Daniil Kovalev1-6/+9
The PAuth-related checks performed for arm64e are also performed for other PAuth-enabled ABIs such as Linux's pauthtest. This patch introduces use of 'PAuth-enabled ABI' phrase instead of 'arm64e' term for non-arm64e specific things. Also, on non-arm64e we cannot assume that we have FPAC, so an additional explanation regarding resign function guarantees is provided. Note that other comments mentioning arm64e while not being arm64e-specific are fixed as part of #171717. Fixes #160117
2025-12-16[libc++] Enable -Wmissing-prototypes (#116261)Nikolas Klauser4-2/+6
2025-12-12[runtimes] Remove dependencies on cxx_experimental for test-suite installs ↵Louis Dionne1-1/+1
(#171678) This patch removes explicit dependencies on cxx_experimental for installations that are local to the test suite. Such dependencies are not required anymore from the test-suite installation targets since the proper dependency is now encoded between cxx and cxx_experimental.
2025-12-11[runtimes] Modernize installation targets (#171677)Louis Dionne2-30/+26
This patch moves away from using cmake_install scripts to install the various targets when building runtimes, since those have been deprecated by CMake. Instead, we use `cmake --install` which is the prefered method. This patch also localizes how we set dependencies on the various installation targets, allowing the removal of a few global variables that were used as lists. Finally, it makes the way we set up installation targets for libc++, libc++abi and libunwind consistent again.
2025-12-10[libunwind] fix building on Haiku i386 (#171586)Brad Smith1-2/+3
Co-authored-by: Jérôme Duval <jerome.duval@gmail.com>
2025-12-10[libunwind] Make sure libunwind test dependencies are installed before ↵Louis Dionne2-13/+19
running tests (#171474) This patch adds an installation step where we install libc++ in a fake installation tree before testing libunwind. This is necessary because some configurations (in particular "generic-merged") require libc++ to be installed, since the libunwind tests are actually linking libc++.so in which libc++abi.a and libunwind.a have been merged. Without this, we were actually failing to find `libc++.so` to link against and then linking against whatever system library we'd find in the provided search directories. While this happens to work in the current CI configuration, this breaks down when updating to newer build tools.
2025-12-03[libunwind](TestOnly) Mark failing tests as unsupported on Apple targets ↵Nathan Corbyn5-0/+5
(#170488) #167642 introduced a number of test failures on one of our stage 2 builds: https://ci.swift.org/job/llvm.org/job/clang-stage2-Rthinlto/1403/. This PR marks these tests as unsupported on `.*-apple.*` targets.
2025-12-01libunwind: Remove OS requirements from tests to make them run on more OSes ↵Gleb Popov10-11/+21
(#167642) There might be a cleaner way to enable these tests running on FreeBSD, I'm open to suggestions. Co-authored-by: Alexander Richardson <mail@alexrichardson.me>
2025-11-15[Unwind][AArch64] Match sigreturn instructions in big endian (#167139)hstk30-hw1-1/+16
Since insns are always stored LE, on a BE system the opcodes will be loaded byte-reversed. Therefore, define two sets of opcodes, one for LE and one for BE.
2025-11-13[libunwind] Ensure zaDisable() is called in jumpto/returnto (NFC) (#167674)Benjamin Maxwell1-8/+5
This is an NFC for now, as the SME checks for macOS platforms are not implemented, so zaDisable() is a no-op, but both paths for resuming from an exception should disable ZA. This is a fixup for a recent change in #165066.
2025-11-12[libunwind] Fix build error because of wrong register size (#167743)Med Ismail Bennani1-1/+1
2025-11-11libunwind: Implement the unw_strerror function for better nongnu libunwind ↵Gleb Popov3-0/+37
compatibility (#160887) As it was explained to me in https://discourse.llvm.org/t/libunwinds-raison-detre/88283/2 the LLVM version of libunwind is mostly compatible with nongnu one. This change improves the compatibility a bit further.
2025-11-11[libunwind] Fix execution flow imbalance when using C++ Exceptions (#165066)Med Ismail Bennani8-19/+143
2025-11-11[libunwind][AArch64] Disable ZA before resuming from unwinding (on Linux) ↵Benjamin Maxwell3-15/+217
(#165451) This patch reimplements the SME ABI `__arm_za_disable` routine within libunwind. This routine must be called before resuming from unwinding on AArch64 platforms with SME support. Before calling the routine, we need to check that SME is available. In this patch, this is implemented for Linux-based platforms by checking HWCAP2. It should be possible to implement this check for other platforms as required. This patch includes a test for this functionality. This test requires SME, so on platforms without it, it will simply pass.
2025-11-08[libc++abi][libunwind] Enable AT&T syntax explicitly (#166818)Raul Tambre1-0/+1
Implementation files using the Intel syntax typically explicitly specify it. Do the same for the few files where applicable for AT&T. This enables building LLVM with `-mllvm -x86-asm-syntax=intel` in one's Clang config files (i.e. a global preference for Intel syntax).
2025-11-07[libunwind] Add CMake option to enable execute-only code generation on ↵Csanád Hajdú3-0/+8
AArch64 (#140554) For a full toolchain supporting execute-only code generation the runtime libraries also need to be pre-compiled with it enabled. The generic `RUNTIMES_EXECUTE_ONLY_CODE` CMake option can now be used during build configuration to enable execute-only code generation in libunwind. Related RFC: https://discourse.llvm.org/t/rfc-execute-only-code-support-for-runtime-libraries-on-aarch64/86180
2025-10-29[libunwind][PAuthLR] Remove PC offset when using FEAT_PAuthLR (#164224)Jack Styles1-6/+4
When originally introduced to libunwind as part of #112171, FEAT_PAuthLR had its Call Frame Instruction's (CFI's) in a different location to other Signing Authentication methods. To incorporate this in libunwind, a 4 byte offset was introduced to work with this. However, this design was reversed in #121551 so the CFI's are emitted in the same location as other methods. When making this change, the offset in libunwind was not removed, so libunwind's PC value would be incorrect. As the 4 byte offset is no longer needed, that adjustment can be removed. results->ptrAuthDiversifier will still be set.
2025-10-25[compiler-rt][libunwind] Allow for CET on OpenBSD (#164341)Brad Smith2-3/+3
2025-10-22[PAC][libunwind] Fix gcc build of libunwind and compiler-rt (#164535)Oliver Hunt3-5/+15
This adds guards on the ptrauth feature checks so that they are only performed if __has_feature is actually available.
2025-10-21[NFCI][asm][i386/x86-64] Enable AT&T syntax explicitly (#164453)Raul Tambre2-0/+5
Implementation files using the Intel syntax explicitly specify it. Do the same for the few files using AT&T syntax. This also enables building LLVM with `-mllvm -x86-asm-syntax=intel` in one's Clang config files (i.e. a global preference for Intel syntax). No functional change intended.
2025-10-20[runtimes][PAC] Harden unwinding when possible (#143230)Oliver Hunt12-78/+498
This hardens the unwinding logic and datastructures on systems that support pointer authentication. The approach taken to hardening is to harden the schemas of as many high value fields in the myriad structs as possible, and then also explicitly qualify local variables referencing privileged or security critical values. This does introduce ABI linkage between libcxx, libcxxabi, and libunwind but those are in principle separate from the OS itself so we've kept the schema definitions in the library specific headers rather than ptrauth.h
2025-10-16[libunwind] Fix aarch64 SEH unwinding with a debugger attached (#162867)Martin Storsjö1-1/+2
See https://github.com/LuaJIT/LuaJIT/issues/593#issuecomment-1717728494 for the original explanation of the problem. In short; when a debugger is attached, there's a function KiUserExceptionDispatcher in the stack that is being unwound. The function KiUserExceptionDispatcher contains a CONTEXT, with a copy of the context from where the exception was raised. When unwinding through this function, this whole CONTEXT gets restored. This CONTEXT is what we receive a pointer to in the callbacks, as the ms_ctx pointer. When we unwind manually using RtlUnwindEx, the unwinding overwrites the CONTEXT that is passed to it. Thus, to avoid clobbering the CONTEXT that needs to be restored by KiUserExceptionDispatcher, we could either declare a new temporary CONTEXT on the stack before calling RtlUnwindEx, or just use disp->ContextRecord as we already have available. Fixes: https://github.com/llvm/llvm-project/issues/161851 Co-authored-by: Peter Cawley <corsix@corsix.org> Co-authored-by: Hannes Domani <ssbssa@yahoo.de>
2025-10-12Fix typo: IsGlobaLinkage -> IsGlobalLinkage in XCOFF (#161960)小钟1-2/+2
Corrects the spelling of 'IsGlobaLinkage' to 'IsGlobalLinkage' in XCOFF-related code, comments, and tests across the codebase.
2025-10-10[WebAssembly] Support for new target `wasm32-linux-muslwali` (#162581)Arjun Ramesh2-4/+11
Add toolchain support for the [WALI](https://doc.rust-lang.org/rustc/platform-support/wasm32-wali-linux.html) target as per its corresponding [RFC](https://discourse.llvm.org/t/rfc-new-wasm-linux-target-support/88203)
2025-10-09[libcxx] Use %{temp} instead of %T (#162323)Aiden Grossman8-8/+8
Based on review feedback in #160026. This makes the substitution a lot more clear now that there is no documentation around %T. --------- Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2025-10-09[runtimes][NFC] Consistently declare main() functions in tests (#162548)Louis Dionne8-10/+20
In the libc++ test suite, we consistently declare main() functions with full parameters and explicitly return from the function. This helps code that compiles the tests with -ffreestanding, where main() is not a special function (with an implicit return and special mangling). This patch fixes a few stray declarations, including in libunwind and libc++abi.
2025-10-02[libunwind][test] Add check for objcopy to improve test compatibility (#161112)Wu Yingcong2-4/+14
Previously, we only used `objcopy`, which is not available for some build configurations. With this patch, we not only try to use `objcopy`, but also try to use `llvm-objcopy` if available. This is a follow-up of https://github.com/llvm/llvm-project/pull/156383.
2025-09-25[Mips] Fixed libunwind::Registers_mips_o32::jumpto to allow for load delay ↵Jade Marker1-2/+5
(#152942) Fix #152922 MIPS III also has load delay, so libunwind::Registers_mips_newabi::jumpto() is also fixed.
2025-09-15[libcxx][CI] Use lld for everything in the ARM picolib builds (#158320)David Spickett1-1/+1
Our host compiler is a clang install that will default to ld if not told otherwise. We were telling meson to use lld, but the way that we did it was outdated, which lead to picolib producing a linker script that lld could not use. The tests were in fact linking with ld instead. Using the `c_ld` setting fixes this problem. See: https://mesonbuild.com/Machine-files.html#binaries Then to use lld in tests we need `-fuse-ld=lld` in the config files. Some of these options were not needed for clang 19.1.7, but were for clang 21.1.1. We will soon update to 21.1.1 so I have included all of the required options in this PR.
2025-09-02[libunwind][test] set fed test to require x86 as others arch may have cross ↵Wu Yingcong1-1/+3
toolchain build (#156383) In https://github.com/llvm/llvm-project/pull/154902, the test failed with llvm-clang-win-x-aarch64(it is a cross-build, which builds on Windows and run on Linux, "Win to Aarch64 Linux Ubuntu Cross Toolchain"), and objdump is not available on Windows(the build env). Set to require x86 Linux instead.
2025-09-01[libunwind] fix pc range condition check bug (#154902)Wu Yingcong2-1/+59
There is an off-by-one error with current condition check for PC fallen into the range or not. There is another check within libunwind that use the correct checks in https://github.com/llvm/llvm-project/blob/5050da7ba18fc876f80fbeaaca3564d3b4483bb8/libunwind/src/UnwindCursor.hpp#L2757 ``` if ((fdeInfo.pcStart <= pc) && (pc < fdeInfo.pcEnd)) ```
2025-08-21[libunwind] Add support for the AArch64 "Vector Granule" (VG) register (#153565)Benjamin Maxwell4-4/+102
The vector granule (AArch64 DWARF register 46) is a pseudo-register that contains the available size in bits of SVE vector registers in the current call frame, divided by 64. The vector granule can be used in DWARF expressions to describe SVE/SME stack frame layouts (e.g., the location of SVE callee-saves). The first time VG is evaluated (if not already set), it is initialized to the result of evaluating a "CNTD" instruction (this assumes SVE is available). To support SME, the value of VG can change per call frame; this is currently handled like any other callee-save and is intended to support the unwind information implemented in #152283. This limits how VG is used in the CFI information of functions with "streaming-mode changes" (mode changes that change the SVE vector length), to make the unwinder's job easier.
2025-08-20[NFC][CMake] quote ${CMAKE_SYSTEM_NAME} consistently (#154537)David Tenty1-1/+1
A CMake change included in CMake 4.0 makes `AIX` into a variable (similar to `APPLE`, etc.) https://gitlab.kitware.com/cmake/cmake/-/commit/ff03db6657c38c8cf992877ea66174c33d0bcb0b However, `${CMAKE_SYSTEM_NAME}` unfortunately also expands exactly to `AIX` and `if` auto-expands variable names in CMake. That means you get a double expansion if you write: `if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")` which becomes: `if (AIX MATCHES "AIX")` which is as if you wrote: `if (ON MATCHES "AIX")` You can prevent this by quoting the expansion of "${CMAKE_SYSTEM_NAME}", due to policy [CMP0054](https://cmake.org/cmake/help/latest/policy/CMP0054.html#policy:CMP0054) which is on by default in 4.0+. Most of the LLVM CMake already does this, but this PR fixes the remaining cases where we do not.
2025-07-23[libunwind] Fix return type of `DwarfFDECache::findFDE()` in definition ↵Alex Rønne Petersen1-1/+2
(#146308) Needed to resolve this compilation error on some systems: lib/libunwind/src/UnwindCursor.hpp:153:38: error: return type of out-of-line definition of 'libunwind::DwarfFDECache::findFDE' differs from that in the declaration typename A::pint_t DwarfFDECache<A>::findFDE(pint_t mh, pint_t pc) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ lib/libunwind/src/libunwind.cpp:31:10: note: in file included from lib/libunwind/src/libunwind.cpp:31: #include "UnwindCursor.hpp" ^ lib/libunwind/src/UnwindCursor.hpp:100:17: note: previous declaration is here static pint_t findFDE(pint_t mh, pint_t pc); ~~~~~~~^
2025-07-09[libcxxabi][libunwind] Support for using LLVM libc (#134893)Petr Hosek2-6/+10
This generalizes the support added in #99287 renaming the option to RUNTIMES_USE_LIBC and integrating the module into libc++abi and libunwind as well.
2025-06-11libunwind: Do not use __attribute__((target("gcs"))) with non-clang ↵Khem Raj1-6/+6
compilers (#138077) This attribute is unsupported in GCC, so far it worked because before GCC15 did not define this macros in _CHKFEAT_GCS in arm_acle.h [1] With gcc15 compiler libunwind's check for this macros is succeeding and it ends up enabling 'gcs' by using function attribute, this works with clang but not with gcc. We can see this in rust compiler bootstrap for aarch64/musl when system uses gcc15, it ends up with these errors Building libunwind.a for aarch64-poky-linux-musl ``` cargo:warning=/mnt/b/yoe/master/sources/poky/build/tmp/work/cortexa57-poky-linux-musl/rust/1.85.1/rustc-1.85.1-src/src/llvm-project/libunwind/src/UnwindLevel1.c:191:1: error: arch extension 'gcs' should be prefixed by '+' cargo:warning= 191 | unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) { cargo:warning= | ^~~~~~~~~~~~~ cargo:warning=/mnt/b/yoe/master/sources/poky/build/tmp/work/cortexa57-poky-linux-musl/rust/1.85.1/rustc-1.85.1-src/src/llvm-project/libunwind/src/UnwindLevel1.c:337:22: error: arch extension 'gcs' should be prefixed by '+' cargo:warning= 337 | _Unwind_Stop_Fn stop, void *stop_parameter) { cargo:warning= | ^~~~~~~~~~~~~~~ ``` [1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5a6af707f0af Signed-off-by: Khem Raj <raj.khem@gmail.com>
2025-06-11[libunwind] Remove checks for -nostdlib++ (#143162)Nikolas Klauser2-68/+0
libunwind uses a C linker, so it's never even trying to link against any C++ libraries. This removes the code which tries to drop C++ libraries, which makes the CMake configuration simpler and allows for upgrading GCC.
2025-05-28[libunwind][Haiku] Fix signal frame unwinding (#135367)Trung Nguyen2-77/+100
The current unwinding implementation on Haiku is messy and broken. 1. It searches weird paths for private headers, which is breaking builds in consuming projects, such as dotnet/runtime. 2. It does not even work, due to relying on incorrect private offsets. This commit strips all references to private headers and ports a working signal frame implementation. It has been tested against `tests/signal_unwind.pass.cpp` and can go pass the signal frame.
2025-05-13[libunwind] Add initial ARM64EC support (#138583)Jacek Caban2-1/+50
ARM64EC defines `__x86_64__`, which is sufficient to make most C/C++ code behave correctly. To preserve an external ABI compatible with x86_64, this patch uses the x86_64 context layout and implements `unw_getcontext` by storing the appropriate aarch64 registers according to the mapping defined by the ARM64EC ABI.
2025-05-12[cmake] Normalize TARGET_SUBDIR paths (#138524)Raul Tambre1-0/+1
Some code paths normalize ".." and thus don't create the directory. But some execute in a shell thus requiring the directory to exist to be able to take the parent directory. This patch normalizes all the `TARGET_SUBDIR` variables to avoid this issue.
2025-05-09[libunwind] [SEH] Set NonVolatileRegisters before calling a personality ↵Martin Storsjö1-0/+41
function (#137951) The CRT __C_specific_handler function uses this for restoring registers before calling the filter function. This fixes the libunwind/libcxxabi forced unwind testcases on ARM and AArch64.
2025-05-09[libunwind] [SEH] Implement parsing of ARM pdata/xdata (#137950)Martin Storsjö1-6/+31
This is generally very similar to the aarch64 case. Contrary to aarch64, the public headers don't contain any definition of a struct for interpreting this data, so we provide our own.
2025-05-09[libunwind] [SEH] Implement parsing of aarch64 pdata/xdata (#137949)Martin Storsjö1-0/+46
This is needed for forced unwind, for some testcases in libunwind/libcxxabi. This adds an aarch64 case for extracting the LanguageHandler and HandlerData fields from unwind info, in UnwindCursor::getInfoFromSEH, corresponding to the existing case for x86_64. This uses the struct IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA; this only became available in WinSDK 10.0.19041.0 and mingw-w64 v11.0 (or a mingw-w64 git snapshot after April 2023). (This is only a build-time requirement though; the format for the unwind data has been fixed since the start of Windows 10 on ARM64, so this doesn't impose any runtime requirement.)
2025-04-13Update LIBUNWIND_ENABLE_WERROR default value in BuildingLibunwind.rst (#135546)Firas Khalil Khana1-1/+1
`LIBUNWIND_ENABLE_WERROR` defaults to `OFF` according to [CMakeLists.txt](https://github.com/llvm/llvm-project/blob/main/libunwind/CMakeLists.txt#L43).
2025-03-10[libunwind][RISCV] Make asm statement volatile (#130286)Gergely Futo1-1/+1
Compiling with `O3`, the `early-machinelicm` pass hoisted the asm statement to a path that has been executed unconditionally during stack unwinding. On hardware without vector extension support, this resulted in reading a nonexistent register.
2025-02-20[libunwind][NFC] Remove the CET keyword in shadow stack-related stuffs (#126663)Ming-Yi Lai5-43/+46
libunwind currently supports shadow stack based on the Intel CET and AArch64 GCS technology, but throughout related codes, the Intel-specific keyword, "CET", is used to refer to the generic concept of control-flow integrity/shadow stack. This patch replaces such wordings with architecture-neutral term "shadow stack" (abbr. "shstk") to allow future implementation to avoid using the Intel-specific "CET" term.
2025-02-17[libunwind] Silence -Wunused-parameter warnings in Unwind-wasm.c (#125412)Yuriy Chernyshov1-4/+2
2025-02-08[libunwind] Unwind through loongarch64/Linux sigreturn frame (#123682)Ami-zhang3-4/+64
Similar to D90898 (Linux AArch64), D124765 (SystemZ), and D148499 (RISCV). In this commit, I enabled two test cases, while zhuqizheng supported with the source code development. Co-Authored-By: zhuqizheng <zhuqizheng@loongson.cn> Co-authored-by: zhuqizheng <zhuqizheng@loongson.cn>