[PATCH v12 0/1] Implement Structured Exception Handling (SEH) on AArch64

Evgeny Karpov evgeny.karpov@arm.com
Thu Jul 16 15:49:18 GMT 2026


Hello,

Thank you for reviewing v11!
v12 removes redundant logic and fixes endianness issue.

Changes in v12:
- Remove prologue_size.
- Fix a typo.
- Add gas_assert for seh_function_size.
- Move is_fragmented_function slightly below.
- Fix endianness issue.
- Remove redundant logic. 

Changes in v11 2026-07-06:
- Apply different renaming.
- Fix typos.
- Support big endian host.
- Fix phantom prologue encoding.
- Inline some conditions.
- Add seh_aarch64_context::has_exception_data.
- Remove seh_aarch64_xdata_header.
- Update tests.
https://sourceware.org/pipermail/binutils/2026-July/150023.html

Changes in v10 2026-06-26:
- Fix the indentations.
- Extend the description with limitations for the current implementation.
- Reorder aarch64_unwind_info.
- Use reg_pair to validate the correct register range.
- Rename offset_shift/reg_shift to offset_multiplier/reg_multiplier.
- Move some code to seh_aarch64_emit_xdata_record.
- Fix a typo for .seh_set_fp in the test's comment.
- Update the error message for offset.
https://sourceware.org/pipermail/binutils/2026-June/149827.html

Changes in v9 2026-06-17:
- Align backslashes only with tabs.
- Replace links with text that can help find proper resources.
- Replace binary literals with hex.
- Correct whitespace.
https://sourceware.org/pipermail/binutils/2026-June/149662.html

Changes in v8 2026-06-15:
- Refactor and simplify some conditions.
- Move .xdata record writing to a separate
  function (seh_aarch64_emit_xdata_record).
- Add documentation link to obj-coff-seh-aarch64.h.
- Add a minor change to the patch description.
- Use only prologue/epilogue.
- Add SEH tests.
- Use unsigned char instead of unsigned for aarch64_unwind_info.
- Rename offset/reg_offset to offset_addend/reg_addend.
- Remove shift direction from the names.
- Correct typos and comments locations.
- Add more comments and extend some of them.
- Reorder aarch64_unwind_code_data declarations.
- Remove AARCH64_UNOP_* and use code inside the declaration.
- Remove members that are NULL or 0.
- Rename unwind_code_pack_info to info.
- Rename aarch64_element to element and move 4 lines to the end of the function.
- Add validations for offset and reg.
- Drop the condition for code_bits.
- Inline some constants to the conditions.
- Check the register name for SEH directives.
- Modify style by changing line wrapping.
- Optimize some calculations.
- Remove some comments to avoid confusion.
- Add clarification for missing implementation.
- Move seh_aarch64_write_data under OBJ_COFF scope.
- Support .seh_code to simplify porting from x86_64.
https://sourceware.org/pipermail/binutils/2026-June/149639.html

Changes in v7 2026-03-19:
- Rename sort_x64_pdata to sort_pdata.
- Move obj_coff_seh_do_final implementation to a separate function.
- Merge patch 3/4 with 4/4.
https://sourceware.org/pipermail/binutils/2026-March/148657.html

Changes in v6 2026-03-11:
- Revert changes in frag_offset_ignore_align_p.
- Relax the code segment to be able to calculate the function sizes.
- Add seh_function_size that implements the calculation of the function size
  and replace frag_offset_ignore_align_p call with this implementation.
https://sourceware.org/pipermail/binutils/2026-March/148488.html

Changes in v5 2026-02-24:
- In many places int, uint32_t and int32_t have been replaced to unsigned.
- Refactor and move SEH aarch64 implementation to separate files.
- Replace uintptr_t with bfd_vma.
- Update comments.
- Add dedicated initializers.
- Move some variables inside loops.
- Fix the definition for packing some unwinding codes.
- Add description to seh commands.
- Rename prolog_instruction_count to prolog_insn_count.
- Relocate variable initilization closer to place of use.
- Add unwind_ prefix to unwind type enumerator.
https://sourceware.org/pipermail/binutils/2026-February/148332.html

Changes in v3(v4) 2025-08-14:
- Make the AArch64 implementation fully static.
- Fix ARM64_MAX_UNWIND_CODES and introduce AARCH64_MAX_UNWIND_CODES_SIZE.
- Add validation for the epilogue_scope array.
- Add an upper bound for the register number.
- Exclude changes in md_do_align.
- Refactor the AArch64 SEH implementation to emit .pdata/.xdata records at
  the end of assembly.
- Declare md_finish for AArch64 to trigger obj_coff_generate_pdata.
- Support different fragment ordering in frag_offset_ignore_align_p
- Change signed to unsigned.
- Replace Arm64 / arm64 with AArch64 / aarch64.
- Add references to the official documentation to clarify
  implementation.
- Add static and aarch64_ prefix.
- Rebase onto the current master.
- Fix comments.
- Correct code style and naming.
https://sourceware.org/pipermail/binutils/2025-August/143401.html

Changes in v2 2025-05-09:
- Add guards for different architectures
- Fix code style issues and typos
- Move Arm64-specific code to pdata/xdata functions
- Prefer unsigned int over uint32_t in some places
- Revert memory release to the original implementation
- Refactor long function fragmentation
- Fix the function size calculation issue related to code alignment
https://sourceware.org/pipermail/binutils/2025-May/140961.html

v1 2025-04-09:
This patch series supports the GCC patch series that implements SEH
support for the aarch64-w64-mingw32 target.
https://gcc.gnu.org/pipermail/gcc-patches/2024-November/669003.html
The patch series has been tested by applying internal tests and passing
all Boost library tests that involve exception handling.
https://sourceware.org/pipermail/binutils/2025-April/140495.html

Regards,
Evgeny

Evgeny Karpov (1):
  aarch64: Implement Structured Exception Handling (SEH) on AArch64

 gas/config/obj-coff-seh-aarch64.c             | 886 ++++++++++++++++++
 gas/config/obj-coff-seh-aarch64.h             | 237 +++++
 gas/config/obj-coff-seh-shared.c              |   8 +-
 gas/config/obj-coff.c                         |   4 +
 gas/config/tc-aarch64.c                       |  10 +
 gas/config/tc-aarch64.h                       |   6 +
 gas/testsuite/gas/pe/pe.exp                   |   3 +
 gas/testsuite/gas/pe/seh-aarch64-error.l      | 110 +++
 gas/testsuite/gas/pe/seh-aarch64-error.s      | 128 +++
 gas/testsuite/gas/pe/seh-aarch64-large-func.d |  53 ++
 gas/testsuite/gas/pe/seh-aarch64-large-func.s |  13 +
 gas/testsuite/gas/pe/seh-aarch64.d            |  66 ++
 gas/testsuite/gas/pe/seh-aarch64.s            |  49 +
 gas/write.c                                   |   2 +-
 gas/write.h                                   |   1 +
 15 files changed, 1574 insertions(+), 2 deletions(-)
 create mode 100644 gas/config/obj-coff-seh-aarch64.c
 create mode 100644 gas/config/obj-coff-seh-aarch64.h
 create mode 100644 gas/testsuite/gas/pe/seh-aarch64-error.l
 create mode 100644 gas/testsuite/gas/pe/seh-aarch64-error.s
 create mode 100644 gas/testsuite/gas/pe/seh-aarch64-large-func.d
 create mode 100644 gas/testsuite/gas/pe/seh-aarch64-large-func.s
 create mode 100644 gas/testsuite/gas/pe/seh-aarch64.d
 create mode 100644 gas/testsuite/gas/pe/seh-aarch64.s



More information about the Binutils mailing list