1010// Ensure that libunwind doesn't crash on invalid info; the Linux aarch64
1111// sigreturn frame check would previously attempt to access invalid memory in
1212// this scenario.
13- // REQUIRES: linux && (target={{aarch64-.+}} || target={{x86_64-.+}})
13+ // REQUIRES: linux && (target={{aarch64-.+}} || target={{s390x-.+}} || target={{ x86_64-.+}})
1414
1515// GCC doesn't support __attribute__((naked)) on AArch64.
1616// UNSUPPORTED: gcc
@@ -36,6 +36,20 @@ __attribute__((naked)) void bad_unwind_info() {
3636 " .cfi_def_cfa_offset 0\n "
3737 " .cfi_restore x30\n "
3838 " ret\n " );
39+ #elif defined(__s390x__)
40+ __asm__ (" stmg %r14,%r15,112(%r15)\n "
41+ " mvghi 104(%r15),4\n "
42+ " # purposely use incorrect offset for %r14\n "
43+ " .cfi_offset 14, -56\n "
44+ " .cfi_offset 15, -40\n "
45+ " lay %r15,-160(%r15)\n "
46+ " .cfi_def_cfa_offset 320\n "
47+ " brasl %r14,stepper\n "
48+ " lmg %r14,%r15,272(%r15)\n "
49+ " .cfi_restore 15\n "
50+ " .cfi_restore 14\n "
51+ " .cfi_def_cfa_offset 160\n "
52+ " br %r14\n " );
3953#elif defined(__x86_64__)
4054 __asm__ (" pushq %rbx\n "
4155 " .cfi_def_cfa_offset 16\n "
@@ -48,7 +62,7 @@ __attribute__((naked)) void bad_unwind_info() {
4862 " .cfi_def_cfa_offset 8\n "
4963 " ret\n " );
5064#else
51- #error This test is only supported on aarch64 or x86-64
65+ #error This test is only supported on aarch64, s390x, or x86-64
5266#endif
5367}
5468
0 commit comments