GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ms-sysv

ms-sysv: Add call_do_test_unaligned helper for unaligned stacks

Introduces an assembly wrapper to correctly call functions with the ms_abi attribute when the stack is unaligned.

The ms-sysv ABI has specific stack alignment requirements. Direct calls to functions marked with ms_abi, like do_test_unaligned, can fail when the stack is not properly aligned due to GCC’s potential stack adjustments for argument saving. This change adds a new assembly function, call_do_test_unaligned, to ensure correct stack alignment before calling do_test_unaligned, thus fixing PR126927.

In Details

The ms_abi attribute on x86_64 requires a 16-byte stack alignment for function arguments. Direct calls to functions with this attribute may fail if GCC internally adjusts the stack (e.g., saving arguments via stack), leading to incorrect argument values for the callee. This commit introduces call_do_test_unaligned as an assembly wrapper that explicitly manages stack adjustments, ensuring correct alignment for calls to do_test_unaligned.

For Context
ms_abi
Microsoft x64 calling convention. It has stricter stack alignment requirements than the System V AMD64 ABI.
stack alignment
Ensuring that the stack pointer is aligned to a specific boundary (e.g., 16 bytes) before certain operations, which is crucial for performance and correctness on some architectures and calling conventions.
Filed Under: x86_64abicompiler