I have a firmware binary with an AIS that uses Section Load commands. In some places, blocks of repeating bytes occur.
I am trying to reduce the flash memory used for AIS by inserting Section Fill commands, where possible.
For example, a 256 byte block of 0x00 could be swapped for a Section Fill command filling 256 bytes with pattern 0x00, followed by a Section Load command for the remaining data.
The same is true for patterns of length 2 and 4 bytes. If the sequence length is >32 bytes, space can be saved.
I wish to process the entire AIS, identifying repeating patterns and inserting Section Fill commands where appropriate.
Is there already a tool to do this?
(I do not have access to the source code, I am modifying the binary using Python.)