From a339dd3374b334a1a999481f3014f68a7389dacc Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Sun, 29 May 2022 11:55:30 +0800 Subject: [PATCH] Always use LSB to parse binary in tests --- tests/test_musllinux.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_musllinux.py b/tests/test_musllinux.py index d2c87ca1..2623bdbc 100644 --- a/tests/test_musllinux.py +++ b/tests/test_musllinux.py @@ -101,14 +101,15 @@ def test_parse_ld_musl_from_elf_no_interpreter_section(): with BIN_MUSL_X86_64.open("rb") as f: data = f.read() - # Change all sections to *not* PT_INTERP. - unpacked = struct.unpack("16BHHIQQQIHHH", data[:58]) + # Change all sections to *not* PT_INTERP. We are explicitly using LSB rules + # because the binaries are in LSB. + unpacked = struct.unpack("<16BHHIQQQIHHH", data[:58]) *_, e_phoff, _, _, _, e_phentsize, e_phnum = unpacked for i in range(e_phnum + 1): sb = e_phoff + e_phentsize * i se = sb + 56 - section = struct.unpack("IIQQQQQQ", data[sb:se]) - data = data[:sb] + struct.pack("IIQQQQQQ", 0, *section[1:]) + data[se:] + section = struct.unpack("