Blame SOURCES/538.patch

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