Blame SOURCES/538.patch

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