Skip to content

Instantly share code, notes, and snippets.

@RobinDavid
Created August 8, 2019 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobinDavid/efc0f7bdf67831adfae806398c886745 to your computer and use it in GitHub Desktop.
Save RobinDavid/efc0f7bdf67831adfae806398c886745 to your computer and use it in GitHub Desktop.
Sum the size of all the shared libraries for a given dynamic ELF
#!/usr/bin/env python3
import sys
from pathlib import Path
import lddwrap
from hurry.filesize import size
def get_shared_size(filepath):
deps = lddwrap.list_dependencies(Path(filepath))
tot_size = 0
for d in deps:
if d.path.exists():
tot_size += d.path.stat().st_size
return tot_size
sz = get_shared_size(sys.argv[1])
print(size(sz))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment