Skip to content

Commit

Permalink
Fix alignement issue identified by @AvenGeeker
Browse files Browse the repository at this point in the history
Resolve #993
  • Loading branch information
romainthomas committed Nov 7, 2023
1 parent 6a98c63 commit 6b73798
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/MachO/Builder.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ ok_error_t Builder::build(SymbolCommand& symbol_command) {
++isym;
}
}
nlist_table.align(8);
nlist_table.align(binary_->is64_ ? 8 : 4);

raw_nlist_table = nlist_table.raw();
symtab.symoff = linkedit_offset_ + linkedit_.size();
Expand Down
10 changes: 10 additions & 0 deletions tests/macho/test_issues.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import lief
from utils import get_sample
from pathlib import Path

def test_945():
target = lief.MachO.parse(get_sample("MachO/python3_issue_476.bin")).at(0)
Expand All @@ -12,3 +13,12 @@ def test_945():
for load_command in target.commands:
if load_command.command in (lief.MachO.LOAD_COMMAND_TYPES.SEGMENT, lief.MachO.LOAD_COMMAND_TYPES.SEGMENT_64):
assert isinstance(load_command, lief.MachO.SegmentCommand)

def test_993(tmp_path):
target = lief.MachO.parse(get_sample("MachO/alivcffmpeg_armv7.dylib"))
out = Path(tmp_path) / "issue_993.dylib"
target.write(out.as_posix())

new = lief.MachO.parse(out)
not_err, msg = lief.MachO.check_layout(new)
assert not_err, msg

0 comments on commit 6b73798

Please sign in to comment.