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
111 stars 38 forks source link

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

Closed bessman closed 1 year ago

bessman commented 1 year 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 1 year 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 1 year ago

Done.