Created
May 25, 2024 00:16
-
-
Save iTrooz/740f00f0935e365534f5a76dab0e7738 to your computer and use it in GitHub Desktop.
Print the size of sections in a ELF object file/binary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Print the size of sections in a ELF object file/binary. Thx ChatGPT | |
size -A -d $1 | awk 'NR > 2 {print $2, $1}' | sort -n | awk '{ | |
size=$1; | |
if (size >= 1024*1024*1024) { | |
printf "%7.2f GB %-20s\n", size / (1024*1024*1024), $2; | |
} else if (size >= 1024*1024) { | |
printf "%7.2f MB %-20s\n", size / (1024*1024), $2; | |
} else if (size >= 1024) { | |
printf "%7.2f KB %-20s\n", size / 1024, $2; | |
} else { | |
printf "%7d B %-20s\n", size, $2; | |
}}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment