Blame SOURCES/538.patch

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