When we compile source code, an object file is generated of the program and with the help of linker, this object files gets converted to a binary file which, only the machine can understand. This kind of file follows some structures one of which is ELF(Executable and Linkable Format). And to get the information of these ELF files readelf command is used.
Working with readelf command and ELF files
1. To display help of readelf command.
$readelf

This displays the help section of the command containing all its parameters and their uses.
2. To check wheather a file is ELF file.
$file elf_file

If it prints ELF in the output then the file is an ELF file.
Note: In our case, file name is elf_file.
3. To generate a elf file using gcc compiler.
$gcc filename.c -o elf_file

The above command will generate an executable elffile.
Note: In our case, the name of file is filename.c and the name of elf file is elf_file.
4. To display file headers of a elf file.
$readelf -h elf_file

This will display the top-level headers of the elf file.
Note: In our case, the name of elf file is elf_file.
5. To display information about the different sections of the process’ address space.
$readelf -S elf_file


This will display the different sections of the process’ address space.
Note: In our case, the name of elf file is elf_file.
6. To display symbols table.
$readelf -s elf_file


This will display the symbols table of the file.
Note: In our case, the name of elf file is elf_file.
7. To display core notes.
$readelf -n elf_files

This will display the core notes related to the file.
Note: In our case, the name of elf file is elf_file.
8. To display relocation section.
$readelf -r elf_file

This will displaythe relocks(if present).
Note: In our case, the name of elf file is elf_file.
9. To display the dynamic section.
$readelf -d elf_file

This will display the dynamic section of the file.
Note: In our case, the name of elf file is elf_file.
10. To get the version of the readelf command.
$readelf -v

This will display the version information of the readelf command.
Recommended Posts:
- 'IPCS' command in Linux with examples
- select command in Linux with examples
- Sed Command in Linux/Unix with examples
- ZIP command in Linux with examples
- SORT command in Linux/Unix with examples
- Cat command in Linux with examples
- Head command in Linux with examples
- Tail command in Linux with examples
- wc command in Linux with examples
- tar command in Linux with examples
- atrm command in Linux with examples
- bc command in Linux with examples
- AWK command in Unix/Linux with examples
- tr command in Unix/Linux with examples
- mv command in Linux with examples
- Paste command in Linux with examples
- comm command in Linux with examples
- cmp Command in Linux with examples
- cut command in Linux with examples
- cp command in Linux with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

