diff --git a/backport-Ltest-mem-validate-Disable-inlining-for-consume_and_.patch b/backport-Ltest-mem-validate-Disable-inlining-for-consume_and_.patch new file mode 100644 index 0000000000000000000000000000000000000000..6e17e6f0eb434727f7fe8e2f4d3d18e343ad3fa8 --- /dev/null +++ b/backport-Ltest-mem-validate-Disable-inlining-for-consume_and_.patch @@ -0,0 +1,81 @@ +From 62de804cb8f20a7cd6933a2fcf7b3394fec103de Mon Sep 17 00:00:00 2001 +From: Zhaofeng Li +Date: Sun, 27 Jun 2021 18:40:24 +0000 +Subject: [PATCH] Ltest-mem-validate: Disable inlining for consume_and_run + +See #222 and #227. The tests are so fragile :( +--- + tests/Ltest-mem-validate.c | 22 ++++++++++++++++++---- + 1 file changed, 18 insertions(+), 4 deletions(-) + +diff --git a/tests/Ltest-mem-validate.c b/tests/Ltest-mem-validate.c +index e5127b90..251c34ea 100644 +--- a/tests/Ltest-mem-validate.c ++++ b/tests/Ltest-mem-validate.c +@@ -47,8 +47,11 @@ void * stack_start; + + void do_backtrace (void) + { +- void* buffer[1024]; +- int size = 1024; ++ /* ++ We make the assumption that we are able to rewind far enough ++ (steps > 5) before touching the forbidden region in the stack, ++ at which point the unwinding should stop gracefully. ++ */ + mprotect((void*)((uintptr_t)stack_start & ~(PAGE_SIZE - 1)), + PAGE_SIZE, PROT_NONE); + +@@ -68,6 +71,7 @@ void do_backtrace (void) + unw_get_reg (&cursor, UNW_REG_SP, &sp); + + ret = unw_step (&cursor); ++ printf("ip=%lx, sp=%lx -> %d\n", ip, sp, ret); + if (ret < 0) + { + unw_get_reg (&cursor, UNW_REG_IP, &ip); +@@ -78,14 +82,16 @@ void do_backtrace (void) + + if (steps < 5) + { ++ printf("not enough steps: %d, need 5\n", steps); + exit(-1); + } ++ printf("success, steps: %d\n", steps); + + mprotect((void*)((uintptr_t)stack_start & ~(PAGE_SIZE - 1)), + PAGE_SIZE, PROT_READ|PROT_WRITE); + } + +-void consume_and_run (int depth) ++void NOINLINE consume_and_run (int depth) + { + unw_cursor_t cursor; + unw_context_t uc; +@@ -108,6 +114,14 @@ main (int argc, char **argv UNUSED) + + stack_start = &start; + ++ /* ++ We need to make the frame at least the size protected by ++ the mprotect call so we are not forbidding access to ++ unrelated regions. ++ */ ++ char string[PAGE_SIZE]; ++ sprintf (string, "hello\n"); ++ + // Initialize pipe mem validate check, opens file descriptors + unw_getcontext(&uc); + if (unw_init_local (&cursor, &uc) < 0) +@@ -121,7 +135,7 @@ main (int argc, char **argv UNUSED) + if (!childpid) + { + /* Close fds and make sure we still work */ +- int ret = close(i); ++ close(i); + } + + int status; +-- +2.27.0 + diff --git a/backport-check-namespace.sh-adjust-aarch64-symbols.patch b/backport-check-namespace.sh-adjust-aarch64-symbols.patch new file mode 100644 index 0000000000000000000000000000000000000000..f5ece6910d7378c7f63951a8cd3ce0d96513208f --- /dev/null +++ b/backport-check-namespace.sh-adjust-aarch64-symbols.patch @@ -0,0 +1,139 @@ +From e8fa8d0ca5349d01cf5505eb0d952ef26c62cc94 Mon Sep 17 00:00:00 2001 +From: Stephen Webb +Date: Fri, 21 Oct 2022 15:52:22 -0400 +Subject: [PATCH] check-namespace.sh: adjust aarch64 symbols + +Some symbols for aarch64 were missing, and some were marked as +extraneous in this ABI checker. + +Fixes #389. +--- + tests/check-namespace.sh.in | 46 ++++++++++++++++--------------------- + 1 file changed, 20 insertions(+), 26 deletions(-) + +diff --git a/tests/check-namespace.sh.in b/tests/check-namespace.sh.in +index 14bfdfd..34c3b8f 100644 +--- a/tests/check-namespace.sh.in ++++ b/tests/check-namespace.sh.in +@@ -117,7 +117,8 @@ check_local_unw_abi () { + + match _U${plat}_flush_cache + match _U${plat}_get_accessors +- match _U${plat}_getcontext ++ match _U${plat}_get_elf_image ++ match _U${plat}_get_exe_image_path + match _U${plat}_regname + match _U${plat}_strerror + +@@ -130,67 +131,58 @@ check_local_unw_abi () { + + case ${plat} in + arm) +- match _U${plat}_get_elf_image +- match _U${plat}_get_exe_image_path ++ match _U${plat}_getcontext + match _U${plat}_is_fpreg + match _UL${plat}_search_unwind_table + match _UL${plat}_dwarf_search_unwind_table + match _UL${plat}_dwarf_find_unwind_table + ;; + hppa) ++ match _U${plat}_getcontext + match _UL${plat}_dwarf_search_unwind_table + match _UL${plat}_dwarf_find_unwind_table +- match _U${plat}_get_elf_image +- match _U${plat}_get_exe_image_path + match _U${plat}_setcontext + ;; + ia64) ++ match _U${plat}_getcontext + match _UL${plat}_search_unwind_table +- match _U${plat}_get_elf_image +- match _U${plat}_get_exe_image_path + ;; + x86) +- match _U${plat}_get_elf_image +- match _U${plat}_get_exe_image_path ++ match _U${plat}_getcontext + match _U${plat}_is_fpreg + match _UL${plat}_dwarf_search_unwind_table + match _UL${plat}_dwarf_find_unwind_table + ;; + x86_64) +- match _U${plat}_get_elf_image +- match _U${plat}_get_exe_image_path ++ match _U${plat}_getcontext + match _U${plat}_is_fpreg + match _UL${plat}_dwarf_search_unwind_table + match _UL${plat}_dwarf_find_unwind_table + match _U${plat}_setcontext + ;; + sw_64) +- match _U${plat}_get_elf_image +- match _U${plat}_get_exe_image_path ++ match _U${plat}_getcontext + match _U${plat}_is_fpreg + match _UL${plat}_dwarf_search_unwind_table + match _UL${plat}_dwarf_find_unwind_table + ;; + ppc*) ++ match _U${plat}_getcontext + match _U${plat}_get_func_addr +- match _U${plat}_get_elf_image +- match _U${plat}_get_exe_image_path + match _U${plat}_is_fpreg + match _UL${plat}_dwarf_search_unwind_table + match _UL${plat}_dwarf_find_unwind_table + ;; + tilegx) ++ match _U${plat}_getcontext + match _U${plat}_is_fpreg + match _UL${plat}_dwarf_search_unwind_table + match _UL${plat}_dwarf_find_unwind_table + match _UL${plat}_local_addr_space_init +- match _U${plat}_get_elf_image +- match _U${plat}_get_exe_image_path + match ${plat}_lock + ;; + s390x) +- match _U${plat}_get_elf_image +- match _U${plat}_get_exe_image_path ++ match _U${plat}_getcontext + match _U${plat}_is_fpreg + match _UL${plat}_dwarf_search_unwind_table + match _UL${plat}_dwarf_find_unwind_table +@@ -294,15 +286,15 @@ check_generic_unw_abi () { + match _U${plat}_dwarf_search_unwind_table + match _U${plat}_dwarf_find_unwind_table + ;; +- tilegx) +- match _U${plat}_dwarf_search_unwind_table ++ tilegx) ++ match _U${plat}_dwarf_search_unwind_table + match _U${plat}_dwarf_find_unwind_table +- match _U${plat}_get_elf_image ++ match _U${plat}_get_elf_image + match _U${plat}_get_exe_image_path +- match _U${plat}_is_fpreg +- match _U${plat}_local_addr_space_init +- match ${plat}_lock +- ;; ++ match _U${plat}_is_fpreg ++ match _U${plat}_local_addr_space_init ++ match ${plat}_lock ++ ;; + s390x) + match _U${plat}_is_fpreg + match _U${plat}_get_elf_image +@@ -314,6 +306,8 @@ check_generic_unw_abi () { + match _U${plat}_is_fpreg + match _U${plat}_dwarf_search_unwind_table + match _U${plat}_dwarf_find_unwind_table ++ match _U${plat}_get_elf_image ++ match _U${plat}_get_exe_image_path + ;; + esac + +-- +2.27.0 + diff --git a/backport-tests-run-coredump-unwind-Skip-test-if-no-coredump-h.patch b/backport-tests-run-coredump-unwind-Skip-test-if-no-coredump-h.patch new file mode 100644 index 0000000000000000000000000000000000000000..917bce955fb4cb8fd96bf692edc564c31357476d --- /dev/null +++ b/backport-tests-run-coredump-unwind-Skip-test-if-no-coredump-h.patch @@ -0,0 +1,31 @@ +From fedff5ac77c945fc0c5df534074163a784bfa5b3 Mon Sep 17 00:00:00 2001 +From: Florian Weimer +Date: Wed, 7 Sep 2022 14:01:36 +0200 +Subject: [PATCH] tests/run-coredump-unwind: Skip test if no coredump has been + created + +In some build environments, coredumps are not created even if the +corresponding ulimit is positive. This change skips the test if +the coredump is missing. +--- + tests/run-coredump-unwind | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/tests/run-coredump-unwind b/tests/run-coredump-unwind +index 8d07742..0c2b28c 100755 +--- a/tests/run-coredump-unwind ++++ b/tests/run-coredump-unwind +@@ -48,6 +48,10 @@ fi + ./crasher backing_files + ) 2>/dev/null + COREFILE=$TEMPDIR/core* ++if ! test -f "$COREFILE"; then ++ echo "crasher process did not produce coredump, test skipped" ++ exit 77 ++fi + + # magic option -testcase enables checking for the specific contents of the stack + ./test-coredump-unwind $COREFILE -testcase `cat $TEMPDIR/backing_files` +-- +2.33.0 + diff --git a/libunwind.spec b/libunwind.spec index 876515e433af55b1738761faab509b09feee062d..d8c02173af7d1bc006e91a3ec09da003859a56f5 100644 --- a/libunwind.spec +++ b/libunwind.spec @@ -1,16 +1,19 @@ Name: libunwind Epoch: 2 Version: 1.5.0 -Release: 4 +Release: 5 Summary: Libunwind provides a C ABI to determine the call-chain of a program License: BSD URL: http://savannah.nongnu.org/projects/libunwind Source: http://download-mirror.savannah.gnu.org/releases/libunwind/libunwind-%{version}.tar.gz Patch1: libunwind-Add-sw64-architecture.patch +Patch2: backport-check-namespace.sh-adjust-aarch64-symbols.patch +Patch3: backport-Ltest-mem-validate-Disable-inlining-for-consume_and_.patch +Patch4: backport-tests-run-coredump-unwind-Skip-test-if-no-coredump-h.patch ExclusiveArch: aarch64 %{ix86} x86_64 sw_64 -BuildRequires: automake libtool autoconf texlive-latex2man +BuildRequires: automake libtool autoconf texlive-latex2man gcc-c++ %description Libunwind defines a portable and efficient C programming interface (API) to @@ -56,7 +59,6 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/libunwind-ptrace*.so* touch -r NEWS $RPM_BUILD_ROOT%{_includedir}/libunwind.h %check -#make check may wrong make check || true %pre @@ -87,6 +89,9 @@ make check || true %endif %changelog +* Sat Feb 18 2023 shixuantong - 2:1.5.0-5 +- enable check + * Fri Nov 11 2022 wuzx - 2:1.5.0-4 - Add sw64 architecture