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

as_binary() raises a MemoryError #30

Closed E-genin closed 1 year ago

E-genin commented 1 year ago

Hi there,

I am running the following script :

import bincopy 

f = bincopy.BinFile("Test_2.hex")
print(f.as_binary())

I get the following error : image

I noticed that when I reduce the size of the binary file, it works. (the original binary is around 26 KB)

Thanks in advance

eerimoq commented 1 year ago

There are probably huge sections of empty space in your binary. The maximum address is a lot higher than the minimum address.

E-genin commented 1 year ago

Thanks @eerimoq for the reply,

Do you know why should this be a problem ? Do you suggest some kind of workaround ?

eerimoq commented 1 year ago

It all depends on what you are trying to do. Maybe there are some segments you can remove?

E-genin commented 1 year ago

I need to sign the binary, so I don't think I can modify the content or remove blocks.

jrast commented 1 year ago

Depending on how you need to sign the binary it might be enough to loop over the individual segments instead of the whole binary. Without any additional information (example file, inforamtion about how to sign, ...) it's hard to guess the correct way.