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]) *_, 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:] assert _parse_ld_musl_from_elf(io.BytesIO(data)) is None
def test_parse_ld_musl_from_elf_invalid(data): assert _parse_ld_musl_from_elf(io.BytesIO(data)) is None
def test_parse_ld_musl_from_elf_invalid_section(head): data = BIN_MUSL_X86_64.read_bytes()[:head] assert _parse_ld_musl_from_elf(io.BytesIO(data)) is None
def test_parse_ld_musl_from_elf(executable, location): with executable.open("rb") as f: assert _parse_ld_musl_from_elf(f) == location