Port of printsizes to python3. #131

This commit is contained in:
Travis Goodspeed 2019-11-01 19:30:31 -04:00
parent b5d7a6a979
commit d2406c2635

View File

@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
## Quick little pyelftools script to test the size of a CC430F6137
## firmware image, warning the user if it looks too big.
@ -24,7 +24,9 @@ def printsizes(stream):
text=elffile.get_section_by_name('.text');
textlen=len(text.data());
rodata=elffile.get_section_by_name('.rodata');
rodatalen=len(rodata.data());
rodatalen=0;
try: rodatalen=len(rodata.data());
except: pass;
codeperc=(textlen+rodatalen)*100.0/32768;
print("\t%d bytes of .text, %d bytes of .rodata (%d%% Flash)" % (textlen,rodatalen,codeperc));
if codeperc>90: