Blame SOURCES/538.patch

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