Pager Mapsize updated in cinfo template only instead of cinfo.c

This commit is contained in:
Amit Mahajan
2009-11-03 01:34:51 +05:30
parent a41a8e0d93
commit 2b1adb059d
7 changed files with 66 additions and 64 deletions

23
tools/pyelf/elfsize.py Normal file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env python
import elf
# Calculate the size of loadable sections of elf binary
def elf_binary_size(img):
elffile = elf.ElfFile.from_file(img)
paddr_first = 0
paddr_start = 0
paddr_end = 0
for pheader in elffile.pheaders:
x = pheader.ai
if str(x.p_type) != "LOAD":
continue
if paddr_first == 0:
paddr_first = 1
paddr_start = x.p_paddr.value
if paddr_start > x.p_paddr.value:
paddr_start = x.p_paddr.value
if paddr_end < x.p_paddr + x.p_memsz:
paddr_end = x.p_paddr + x.p_memsz
return paddr_end - paddr_start