From d2406c26358221430b7637b0a117e13bb749b51b Mon Sep 17 00:00:00 2001 From: Travis Goodspeed Date: Fri, 1 Nov 2019 19:30:31 -0400 Subject: [PATCH] Port of printsizes to python3. #131 --- bin/printsizes.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/printsizes.py b/bin/printsizes.py index a07adeb..d808729 100755 --- a/bin/printsizes.py +++ b/bin/printsizes.py @@ -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: