Blame SOURCES/538.patch

99c1c0
From c3476c3207efef576a185a047e6596b3b0cbcb42 Mon Sep 17 00:00:00 2001
99c1c0
From: Tzu-ping Chung <uranusjr@gmail.com>
99c1c0
Date: Wed, 20 Apr 2022 10:00:07 +0800
99c1c0
Subject: [PATCH 1/2] Correctly parse ELF for musllinux on Big Endian
99c1c0
99c1c0
---
99c1c0
 packaging/_musllinux.py | 8 +++++---
99c1c0
 1 file changed, 5 insertions(+), 3 deletions(-)
99c1c0
99c1c0
diff --git a/packaging/_musllinux.py b/packaging/_musllinux.py
99c1c0
index 8ac3059b..d5d3e044 100644
99c1c0
--- a/packaging/_musllinux.py
99c1c0
+++ b/packaging/_musllinux.py
99c1c0
@@ -39,9 +39,11 @@ def _parse_ld_musl_from_elf(f: IO[bytes]) -> Optional[str]:
99c1c0
         # p_fmt: Format for section header.
99c1c0
         # p_idx: Indexes to find p_type, p_offset, and p_filesz.
99c1c0
         e_fmt, p_fmt, p_idx = {
99c1c0
-            1: ("IIIIHHH", "IIIIIIII", (0, 1, 4)),  # 32-bit.
99c1c0
-            2: ("QQQIHHH", "IIQQQQQQ", (0, 2, 5)),  # 64-bit.
99c1c0
-        }[ident[4]]
99c1c0
+            (1, 1): ("
99c1c0
+            (1, 2): (">IIIIHHH", ">IIIIIIII", (0, 1, 4)),  # 32-bit MSB.
99c1c0
+            (2, 1): ("
99c1c0
+            (2, 2): (">QQQIHHH", ">IIQQQQQQ", (0, 2, 5)),  # 64-bit MSB.
99c1c0
+        }[(ident[4], ident[5])]
99c1c0
     except KeyError:
99c1c0
         return None
99c1c0
     else:
99c1c0
99c1c0
From a339dd3374b334a1a999481f3014f68a7389dacc Mon Sep 17 00:00:00 2001
99c1c0
From: Tzu-ping Chung <uranusjr@gmail.com>
99c1c0
Date: Sun, 29 May 2022 11:55:30 +0800
99c1c0
Subject: [PATCH 2/2] Always use LSB to parse binary in tests
99c1c0
99c1c0
---
99c1c0
 tests/test_musllinux.py | 9 +++++----
99c1c0
 1 file changed, 5 insertions(+), 4 deletions(-)
99c1c0
99c1c0
diff --git a/tests/test_musllinux.py b/tests/test_musllinux.py
99c1c0
index d2c87ca1..2623bdbc 100644
99c1c0
--- a/tests/test_musllinux.py
99c1c0
+++ b/tests/test_musllinux.py
99c1c0
@@ -101,14 +101,15 @@ def test_parse_ld_musl_from_elf_no_interpreter_section():
99c1c0
     with BIN_MUSL_X86_64.open("rb") as f:
99c1c0
         data = f.read()
99c1c0
 
99c1c0
-    # Change all sections to *not* PT_INTERP.
99c1c0
-    unpacked = struct.unpack("16BHHIQQQIHHH", data[:58])
99c1c0
+    # Change all sections to *not* PT_INTERP. We are explicitly using LSB rules
99c1c0
+    # because the binaries are in LSB.
99c1c0
+    unpacked = struct.unpack("<16BHHIQQQIHHH", data[:58])
99c1c0
     *_, e_phoff, _, _, _, e_phentsize, e_phnum = unpacked
99c1c0
     for i in range(e_phnum + 1):
99c1c0
         sb = e_phoff + e_phentsize * i
99c1c0
         se = sb + 56
99c1c0
-        section = struct.unpack("IIQQQQQQ", data[sb:se])
99c1c0
-        data = data[:sb] + struct.pack("IIQQQQQQ", 0, *section[1:]) + data[se:]
99c1c0
+        section = struct.unpack("
99c1c0
+        data = data[:sb] + struct.pack("
99c1c0
 
99c1c0
     assert _parse_ld_musl_from_elf(io.BytesIO(data)) is None
99c1c0