mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-01 04:51:30 +08:00
Add a simple tool to analyze elf files
This commit is contained in:
parent
fdada47325
commit
01e6db5c2e
2 changed files with 32 additions and 0 deletions
|
@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
|
|||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Add a simple python tool to check the elf sizes (@slurdge)
|
||||
- Change: new keys for Vigik badges in default_keys.dict (@luminouw)
|
||||
- Add 'hw standalone' to jump to standalone mode from command line or script (@doegox)
|
||||
- Add to 'hf 14a apdu' print apdu and compose apdu (@merlokk)
|
||||
|
|
31
tools/analyzesize.py
Executable file
31
tools/analyzesize.py
Executable file
|
@ -0,0 +1,31 @@
|
|||
#! /usr/bin/python3
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
def print_increase(x, y, name):
|
||||
if x > y:
|
||||
print("{} increase by: {} (0x{:08X}) bytes ({}%)".format(name, x-y, x-y, (x-y)*100/y))
|
||||
else:
|
||||
print("{} decrease by: {} (0x{:08X}) bytes ({}%)".format(name, y-x, y-x, (y-x)*100/x))
|
||||
dbname = "tools/data.json"
|
||||
db = json.load(open(dbname,"r"))
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
print("Usage: analazysize.py <info|add|diff> <datasetname>")
|
||||
exit(-1)
|
||||
action, name = sys.argv[1:3]
|
||||
currentdata = subprocess.run(["arm-none-eabi-size","armsrc/obj/fullimage.stage1.elf"], stdout=subprocess.PIPE).stdout
|
||||
currentdata = currentdata.split(b"\n")[1].strip()
|
||||
text,data,bss = [int(x) for x in currentdata.split(b"\t")[:3]]
|
||||
if action.lower() == "add":
|
||||
db[name] = [text, data, bss]
|
||||
json.dump(db, open(dbname, "w"))
|
||||
elif action.lower() == "diff":
|
||||
text_ref, data_ref, bss_ref = db[name]
|
||||
flash_ref = text_ref+data_ref
|
||||
flash = text+data
|
||||
print_increase(flash, flash_ref, "Flash")
|
||||
print_increase(bss, bss_ref, "RAM")
|
||||
|
Loading…
Reference in a new issue