File 0453-Handle-ludicrous-sizes-in-binary-tails.patch of Package erlang

From c221727f9b3b6e9102d80c6f35b95b042026aed3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Fri, 19 Aug 2022 13:37:02 +0200
Subject: [PATCH] Handle ludicrous sizes in binary tails

The test case added to bs_match_tail_SUITE in 4a9c112248fe would make
it impossible to load that module on 32-bit computers. Loading would
fail with the following message:

    Error loading function bs_match_tail_SUITE:huge_tail_2/1: op bs_test_tail2 x o:
      no specific operation found

Be sure to handle tails size that don't fit into a machine word
on both 32 and 64 bit computers.
---
 erts/emulator/beam/emu/ops.tab             | 2 ++
 erts/emulator/beam/jit/arm/ops.tab         | 2 ++
 erts/emulator/beam/jit/x86/ops.tab         | 2 ++
 erts/emulator/test/bs_match_tail_SUITE.erl | 5 +++++
 4 files changed, 11 insertions(+)

diff --git a/erts/emulator/beam/emu/ops.tab b/erts/emulator/beam/emu/ops.tab
index f1c9fe2415..814fd23b1b 100644
--- a/erts/emulator/beam/emu/ops.tab
+++ b/erts/emulator/beam/emu/ops.tab
@@ -1160,8 +1160,10 @@ bs_skip_bits2 Fail=f Ms=xy Sz=sq Unit=u Flags=u =>
 i_bs_skip_bits_imm2 f? xy W
 i_bs_skip_bits2 xy xy f? t
 
+bs_test_tail2 Fail=f Ms=xy o => jump Fail
 bs_test_tail2 Fail=f Ms=xy Bits=u==0 => bs_test_zero_tail2 Fail Ms
 bs_test_tail2 Fail=f Ms=xy Bits=u => bs_test_tail_imm2 Fail Ms Bits
+
 bs_test_zero_tail2 f? xy
 bs_test_tail_imm2 f? xy W
 
diff --git a/erts/emulator/beam/jit/x86/ops.tab b/erts/emulator/beam/jit/x86/ops.tab
index a0fa7124cd..15e55c8626 100644
--- a/erts/emulator/beam/jit/x86/ops.tab
+++ b/erts/emulator/beam/jit/x86/ops.tab
@@ -858,6 +858,8 @@ bs_skip_bits2 Fail=f Ms=xy Sz=sq Unit=u Flags=u =>
 i_bs_skip_bits_imm2 f? S W
 i_bs_skip_bits2 S S f? t
 
+bs_test_tail2 Fail=f Ms=xy o => jump Fail
+
 bs_test_tail2 f? S t
 
 bs_test_unit f? S t
-- 
2.35.3

openSUSE Build Service is sponsored by