mirror of
https://github.com/drasko/codezero.git
synced 2026-02-27 17:23:13 +01:00
Pager Mapsize updated in cinfo template only instead of cinfo.c
This commit is contained in:
23
tools/pyelf/elfsize.py
Normal file
23
tools/pyelf/elfsize.py
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user