You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider the following tests/macho/test_builder.py test:
deftest_extend_section_2(tmp_path):
""" This test makes multiple calls to add_section, and then it makes calls to extend_section. """bin_path=pathlib.Path(get_sample("MachO/MachO64_x86-64_binary_id.bin"))
original=lief.MachO.parse(bin_path.as_posix()).at(0)
output=f"{tmp_path}/test_extend_section.bin"text_segment=original.get_segment("__TEXT")
sections= []
foriinrange(3):
section=lief.MachO.Section(f"__lief_{i}")
section.alignment=2# 2^2 == 4 bytessections.append(original.add_section(text_segment, section))
forsectioninsections:
assertoriginal.extend_section(section, 1000)
checked, err=lief.MachO.check_layout(original)
assertchecked, err# <------------------------ THIS CHECK FAILSoriginal.write(output)
new=lief.MachO.parse(output).at(0)
checked, err=lief.MachO.check_layout(new)
assertchecked, err# <------------------------ THIS CHECK SUCCEEDS
I think that the problem is caused by not updated original_size field of a Binary:
True. Actually the binary instance after a write operation can't be considered as consistent.
This is why most of the tests are done on a reloaded instance.
I agree it's not ideal but it simplifies some parts of the write process
Consider the following
tests/macho/test_builder.py
test:I think that the problem is caused by not updated
original_size
field of a Binary:LIEF/src/MachO/layout_check.cpp
Lines 850 to 852 in 2c0bf31
The text was updated successfully, but these errors were encountered: