eerimoq / bincopy

Mangling of various file formats that conveys binary information (Motorola S-Record, Intel HEX, TI-TXT, Verilog VMEM, ELF and binary files).
MIT License
109 stars 38 forks source link

First chunk is misaligned if segment has non-aligned start address #40

Closed bessman closed 10 months ago

bessman commented 11 months ago
records = """
    :02000004000AF0
    :10B8440000000000000000009630000007770000B0
"""
hexfile = bincopy.BinFile()
hexfile.add_ihex(records)
align = 8
chunks = hexfile.segments.chunks(size=16, alignment=align)
assert not any(c.address % align for c in chunks)

IMO, the first chunk should be padded such that it is also aligned.

eerimoq commented 11 months ago

I haven't given it much thought, but I noticed that the length of the padding parameter to as_binary() depends on word size. If possible, padding parameters across the library should be consistent. Is it possible to make the new padding parameter word size dependent?

bessman commented 11 months ago

Done.