10 Practical Examples using readelf Command

readelf command is used to analyze binaries based on Linux. This is most common tool used by security professionals to dig into binary files.

How to create ELF files

To create a ELF file, just write a small code of Hello World. I have used nano editor to write a code on test.c

nano test.c
#include <stdio.h>
int main() {
   printf("Hello, World!");
   return 0;
}

Use Ctrl + X to save the file test.c

Further, run the command by using the GCC compiler. You can check the format using Linux utility file.

#compile 
gcc test.c -o test
#run
./test
#check format
file test

10 Practical Examples using readelf Command

(1) To display the ELF file header of binary

readelf -h <binary-file>

(2) To display the program headers of binary

readelf -l <binary-file>

(3) To display the sections header of binary

readelf -S <binary-file>

(4) To display all information related to binary (equivalent to: -h -l -S -s -r -d -V -A -I)

readelf -a <binary-file>

(5) To display the symbol table of binary

readelf -s <binary-file>

(6) To display the histogram of bucket list lengths

readelf -I <binary-file>

(7) To display the version number of readelf

readelf -v

(8) To display notes of binary file

readelf -n <binary-file>

(9) To display the relocations of binary file

readelf -r <binary-file>

(10) To display the unwind information of binary file

readelf -u <binary-file>

Subscribe us to receive more such articles updates in your email.

If you have any questions, feel free to ask in the comments section below. Nothing gives me greater joy than helping my readers!

Disclaimer: This tutorial is for educational purpose only. Individual is solely responsible for any illegal act.

You may also like...

Leave a Reply

Your email address will not be published.