https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113321
Bug ID: 113321 Summary: x86-64: Make __attribute__((interrupt)) more robust Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: hpa at zytor dot com Target Milestone: --- __attribute__((interrupt)) on x86 has two prototypes, and picking the wrong type "probably will cause a system crash." It turns out that this is unavoidable on i386, but on x86-64 we can do better: - On x86-64, an exception/interrupt carries an error code if and only if the stack is 16-byte aligned (specifically, RSP[3] = 0) on exception entry. The proper stack pointer for using with IRET is therefore always given by: RSP |= 8 ... and the error code, if present, will be located at offset -8 from this address.