Skip to content

Commit

Permalink
Always use LSB to parse binary in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed May 29, 2022
1 parent c3476c3 commit 288a13e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/test_musllinux.py
Expand Up @@ -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("16B<HHIQQQIHHH", 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("<IIQQQQQQ", data[sb:se])
data = data[:sb] + struct.pack("<IIQQQQQQ", 0, *section[1:]) + data[se:]

assert _parse_ld_musl_from_elf(io.BytesIO(data)) is None

Expand Down

0 comments on commit 288a13e

Please sign in to comment.