From aecec88fb68a29e53906136702020a510fffbf8e Mon Sep 17 00:00:00 2001 From: Connor-GH Date: Thu, 2 Apr 2026 19:14:42 -0500 Subject: [PATCH] Fix regression caused in e553e9e4 In the process of converting the assembly from AT&T syntax to Intel syntax, bjorn3 made some mistakes. Firstly, `A+B(%reg)` is translated to `[reg + A + B]`, and not `[reg * B + A]`. I can see how this was confused because x86 also has an addressing mode that takes up to 4 arguments, where `A(%r1,%r2,B)` is translated to `[r1 + A + r2 * B]` with the constraints that `B` must be a power of two <= 8, and `A` (if present), must be an immediate. In this case, the `72+8` and such is constfolded by the assembler into `80`. This commit and the previous AT&T syntax version produce the exact same assembly output now. --- src/header/setjmp/impl/i386/sigsetjmp.s | 6 +++--- src/header/setjmp/impl/x86_64/sigsetjmp.s | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/header/setjmp/impl/i386/sigsetjmp.s b/src/header/setjmp/impl/i386/sigsetjmp.s index 0ef1e1b4ec..e1be3b444f 100644 --- a/src/header/setjmp/impl/i386/sigsetjmp.s +++ b/src/header/setjmp/impl/i386/sigsetjmp.s @@ -9,7 +9,7 @@ __sigsetjmp: mov eax, dword ptr [esp + 4] pop [eax + 24] - mov dword ptr [eax * 8 + 28], ebx + mov dword ptr [eax + 8 + 28], ebx mov ebx, eax .hidden ___setjmp @@ -17,8 +17,8 @@ __sigsetjmp: push [ebx + 24] mov dword ptr [esp + 4], ebx - mov dword ptr [esp + 4], eax - mov ebx, dword ptr [ebx * 8 + 28] + mov dword ptr [esp + 8], eax + mov ebx, dword ptr [ebx + 8 + 28] .hidden __sigsetjmp_tail jmp __sigsetjmp_tail diff --git a/src/header/setjmp/impl/x86_64/sigsetjmp.s b/src/header/setjmp/impl/x86_64/sigsetjmp.s index ab19b2b2d9..41bd05b518 100644 --- a/src/header/setjmp/impl/x86_64/sigsetjmp.s +++ b/src/header/setjmp/impl/x86_64/sigsetjmp.s @@ -8,7 +8,7 @@ __sigsetjmp: jz 1f pop [rdi + 64] - mov qword ptr [rdi * 8 + 72], rbx + mov qword ptr [rdi + 8 + 72], rbx mov rbx, rdi call setjmp @@ -16,7 +16,7 @@ __sigsetjmp: push [rbx + 64] mov rdi, rbx mov esi, eax - mov rbx, qword ptr [rbx * 8 + 72] + mov rbx, qword ptr [rbx + 8 + 72] .hidden __sigsetjmp_tail jmp __sigsetjmp_tail