master: arm64: fix arch_do_displaced_inst for LDR

stassats via Sbcl-commits <[email protected]> Wed, 20 May 2026 22:49:32 +0000
Newsgroups gmane.lisp.steel-bank.cvs
Message-ID <[email protected]>
The branch "master" has been updated in SBCL:
       via  8225c3f22bc7ea599a57235e92eb765e9eb8a68e (commit)
      from  a7ee5386610dfd6605b8ae896556dbeb9d4b3709 (commit)

- Log -----------------------------------------------------------------
commit 8225c3f22bc7ea599a57235e92eb765e9eb8a68e
Author: Stas Boukarev <[email protected]>
Date:   Thu May 21 01:49:04 2026 +0300

    arm64: fix arch_do_displaced_inst for LDR
---
 src/runtime/arm64-arch.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/runtime/arm64-arch.c b/src/runtime/arm64-arch.c
index 20787de74..f1eebad19 100644
--- a/src/runtime/arm64-arch.c
+++ b/src/runtime/arm64-arch.c
@@ -194,20 +194,17 @@ void arch_do_displaced_inst(os_context_t *context, unsigned int orig_inst)
         else
             next_pc += 1;
     }
-    else if (((orig_inst >> 24) & 0b11111) == 0b11000) {
+    else if (((orig_inst >> 24) & 0b111111) == 0b011000) {
         // LDR (literal)
         int opc = (orig_inst >> 30) & 0b11;
         int rt = orig_inst & 0b11111;
         int offset = sign_extend((orig_inst >> 5) & ~(1 << 19), 19);
         if (opc == 0b01)
-          *os_context_register_addr(context, rt) = *((uint64_t *)(pc + offset));
+            *os_context_register_addr(context, rt) = *((uint64_t *)(pc + offset));
         else if (opc == 0b00)
-          *os_context_register_addr(context, rt) = *((uint32_t *)(pc + offset));
-        else if (opc == 0b10)
-          *os_context_register_addr(context, rt) = (uint64_t)(int64_t)(*(int32_t *)(pc + offset));
-        // FIXME: Why does Windows crash out here?
-        // else
-          // lose("Unsupported LDR (literal) variant.");
+            *os_context_register_addr(context, rt) = *((uint32_t *)(pc + offset));
+        else
+            lose("Unsupported LDR (literal) variant. %x", orig_inst);
         next_pc += 1;
     }
     else if (((orig_inst >> 24) & 0b11111) == 0b10000) {

-----------------------------------------------------------------------


hooks/post-receive
-- 
SBCL