[libunwind] [libunwind][Haiku] Fix signal frame unwinding (PR #135367)
Trung Nguyen via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 12 07:27:05 PDT 2025
================
@@ -3032,6 +2983,162 @@ int UnwindCursor<A, R>::stepThroughSigReturn(Registers_s390x &) {
#endif // defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) &&
// defined(_LIBUNWIND_TARGET_S390X)
+#if defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN)
+
+#if defined(B_HAIKU_32_BIT)
+typedef Elf32_Sym elf_sym;
+#define ELF_ST_TYPE ELF32_ST_TYPE
+#elif defined(B_HAIKU_64_BIT)
+typedef Elf64_Sym elf_sym;
+#define ELF_ST_TYPE ELF64_ST_TYPE
+#endif
+
+// Private syscall declared as a weak symbol to prevent ABI breaks.
+extern "C" status_t __attribute__((weak))
+_kern_read_kernel_image_symbols(image_id id, elf_sym *symbolTable,
+ int32 *_symbolCount, char *stringTable,
+ size_t *_stringTableSize, addr_t *_imageDelta);
+
+static addr_t signalHandlerBegin = 0;
+static addr_t signalHandlerEnd = 0;
+
+template <typename A, typename R>
+bool UnwindCursor<A, R>::setInfoForSigReturn() {
+ if (signalHandlerBegin == 0) {
+ // If we do not have the addresses yet, find them now.
+
+ // Determine if the private function is there and usable.
+ if (_kern_read_kernel_image_symbols == nullptr) {
+ signalHandlerBegin = (addr_t)-1;
+ return false;
+ }
+
+ // Get the system commpage and enumerate its symbols.
+ image_id commpageImage = -1;
+ image_info info;
+ int32 cookie = 0;
+ while (get_next_image_info(B_SYSTEM_TEAM, &cookie, &info) == B_OK) {
----------------
trungnt2910 wrote:
Same goes to including private headers because any of them can be changed anytime. And I'd say the probability of Haiku devs moving headers around is way higher than them implementing multiuser concerns.
https://github.com/llvm/llvm-project/pull/135367
More information about the cfe-commits
mailing list