[lld] [lld][MachO] Preserve __eh_frame ordering during BP section sorting (PR #191412)

Karim Alweheshy via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 11:14:07 PDT 2026


================
@@ -0,0 +1,102 @@
+# REQUIRES: x86 || aarch64
+## Test that __eh_frame CIE/FDE ordering is preserved even when
+## priority-based section sorting (from BP compression sort, order files,
+## etc.) would otherwise reorder input sections. CIE records must precede
+## the FDE records that reference them; reordering breaks CIE pointer
+## resolution.
+
+## x86_64
+# RUN: llvm-mc -filetype=obj -emit-compact-unwind-non-canonical=true -triple=x86_64-apple-macos10.15 %s -o %t-x86_64.o
+# RUN: %lld -lSystem -lc++ %t-x86_64.o -o %t-x86_64 --bp-compression-sort=both
+# RUN: llvm-objdump --dwarf=frames %t-x86_64 2>&1 | FileCheck %s --implicit-check-not=error --implicit-check-not=warning
+
+## arm64
+# RUN: llvm-mc -filetype=obj -emit-compact-unwind-non-canonical=true -triple=arm64-apple-macos11.0 %s -o %t-arm64.o
+# RUN: %lld -arch arm64 -lSystem -lc++ %t-arm64.o -o %t-arm64 --bp-compression-sort=both
+# RUN: llvm-objdump --dwarf=frames %t-arm64 2>&1 | FileCheck %s --implicit-check-not=error --implicit-check-not=warning
+
+## Verify that CIE records precede their FDE records and that
+## FDE records successfully reference their CIEs (no parse errors).
+# CHECK: .eh_frame contents:
+# CHECK: {{[0-9a-f]+}} {{.*}} CIE
+# CHECK: {{[0-9a-f]+}} {{.*}} FDE
+# CHECK: {{[0-9a-f]+}} {{.*}} FDE
----------------
karim-alweheshy wrote:

done

https://github.com/llvm/llvm-project/pull/191412


More information about the llvm-commits mailing list