What is objdump?
5 objdump examples
Syntax and Options
Related Commands
What is objdump?
Mar 14, 2013 objDump, a small Java framework that dumps any Java object to a string.
The Linux objdump command is used to display various types of information stored in object files. This command is mostly used while debugging or by the developers who are working on compilation tools.
- Download PE objdump for free. Tool to find symbols in windows Library or Executable. It reads windows Portable Executable file format.
- Objdump displays information about one or more object files. The options control what particular information to display. This information is mostly useful to programmers who are working on the compilation tools, as opposed to programmers who just want their program to compile and work.
- Objdump displays information about one or more object files. The options control what particular information to display. This information is mostly useful to programmers who are working on the compilation tools, as opposed to programmers who just want their program to compile and work. Are the object files to be examined.
- Apr 13, 2021 objdump - Displays information from object files. Ranlib - Generates an index to the contents of an archive. Readelf - Displays information from any ELF format object file. Size - Lists the section sizes of an object or archive file. Strings - Lists printable strings from files. Strip - Discards symbols.
5 objdump Examples
1. Display file header using -f option
Output consisting of only the file header (ELF header) can be displayed using -f option with this command.
Consider the following example :
So we see that the file header was produced in the output.
2. Display information related to all the sections using -s option
An object file may consist of various sections. To retrieve information related to all the sections, supply the -s option along with this command.
Consider the following example :
So we see that information related to all the sections was produced in the output.
3. Display a particular section using -j option
If we want that the output should consist only of a particular section. Then this can be done using the -j option along with this command.
Amazon prime photos login. Consider the following example :
So we see that details related to the section .interp was produced in the output.
4. Accept the options from file by using @ option
Rather than supplying options through command line, a file can be used to supply options to the objdump command.
Consider the following example :
So we see that objdump command successfully accepted the options from a file and produced a relevant output.
5. Display all the header information using -x option
Information related to all the headers can be retrieved using -x option along with this command.
Consider the following example :
Jitsi meet google chrome. So we see that a detailed information was produced in the output.
Syntax and Options
Short Option | Long Option | Option Description |
---|---|---|
-a | –archive-header | If any of the objfile files are archives, display the archive header information (in a format similar to ls -l). Besides the information you could list with ar tv, objdump -a shows the object file format of each archive member. |
–adjust-vma=offset | When dumping information, first add offset to all the section addresses. This is useful if the section addresses do not correspond to the symbol table, which can happen when putting sections at particular addresses when using a format which can not represent section addresses, such as a.out. | |
-C | –demangle[=style] | Decode (demangle) low-level symbol names into user-level names. Besides removing any initial underscore perpended by the system, this makes C++ function names readable. Different compilers have different mangling styles. The optional demangling style argument can be used to choose an appropriate demangling style for your compiler. |
-e | –debugging-tags | Like -g, but the information is generated in a format compatible with ctags tool. |
-D | –disassemble-all | Like -d, but disassemble the contents of all sections, not just those expected to contain instructions. If the target is an ARM architecture this switch also has the effect of forcing the disassembler to decode pieces of data found in code sections as if they were instructions. |
-EB, -EL | –endian={big|little} | Specify the endianness of the object files. This only affects disassembly. This can be useful when disassembling a file format which does not describe endianness information, such as S-records. |
-F | –file-offsets | When disassembling sections, whenever a symbol is displayed, also display the file offset of the region of data that is about to be dumped. If zeros are being skipped, then when disassembly resumes, tell the user how many zeros were skipped and the file offset of the location from where the disassembly resumes. When dumping sections, display the file offset of the location from where the dump starts. |
-j name | –section=name | Display information only for section name. |
Related Commands
nm
readelf
Objdump command in Linux is used to provide thorough information on object files. This command is mainly used by the programmers who work on compilers, but still its a very handy tool for normal programmers also when it comes to debugging. In this article, we will understand how to use objdump command through some examples.
Basic syntax of objdump is :
There is a wide range of options available for this command. We will try to cover a good amount of them in this tutorial.
Examples
The ELF binary file of the following C program is used in all the examples mentioned in this article.
Note: The above is just a test code that was being used for some other purpose, but I found it simple enough to use for this article.
1. Display the contents of the overall file header using -f option
Consider the following example :
So we see that the information related to the overall file header was shown in the output.
NOTE: The executable format used in the examples is ELF. To know more about it, refer to our article on ELF file format.
2.Display object format specific file header contents using -p option
The following example prints the object file format specific information.
3. Display the contents of the section headers using -h option
There can be various sections in an object file. Information related to them can be printed using -h option.
The following examples shows various sections. As you see there are total of 26 (only partial output is shown here).
So we see that the information related to all the section headers was printed in the output. In the output above, Size is the size of the loaded section, VMA represents the virtual memory address, LMA represents the logical memory address, File off is this section's offset from the beginning of the file, Algn represents alignment, CONTENTS, ALLOC, LOAD, READONLY, DATA are flags that represent that a particular section is to be LOADED or is READONLY etc.
4. Display the contents of all headers using -x option
Information related to all the headers in the object file can be retrieved using the -x option.
The following example displays all the sections (only partial output is shown here):
5. Display assembler contents of executable sections using -d option
Consider the following example. The assembler contents of executable sections (in the object file) are displayed in this output (partial output shown below):
6. Display assembler contents of all sections using -D option
In case the assembler contents of all the sections is required in output, the option -D can be used.
Consider the following output :
So we see that the relevant output was displayed. Since the output was very long, so I clipped it. Note that I used the pager command for controlling the output.
7. Display the full contents of all sections using -s option
Consider the following example :
So we see that the complete contents for all the sections were displayed in the output.
8. Display debug information using -g option
Consider the following example:
So we see that all the available debug information was printed in output.
9. Display the contents of symbol table (or tables) using the -t option
Consider the following example :
Objdump -b
So we see that the contents of symbol table were displayed in the output.
10. Display the contents of dynamic symbol table using -T option
Dynamic symbols are those which are resolved during run time. The information related to these symbols can be retrieved using the -D option.
Consider the following example :
So we see that information related to dynamic symbols was displayed in output.
11. Display the dynamic relocation entries in the file using -R option
Consider the following example:
So we see that all the dynamic relocation entries were displayed in the output.
12. Display section of interest using -j option
This is extremely useful when you know the section related to which the information is required. The option -j is used in this case.
Consider the following example :
So we see that information related to rodata section was displayed above.
Objdump Intel Syntax
13. Use the older disassembly format using –prefix-addresses option
The older format prints the complete address on each line.
The time in gmt. Consider the following example :
So we see that complete address were printed in the output.
14. Accept input options from a file using @ option
Objdump Linux
If you want, the options to objdump can be read from a file. This can be done using ‘@' option.
Consider the following example :
Objdump For Windows
Consider the following example :
So we see that objdump command successfully accepted the options from a file and produced a relevant output.
5. Display all the header information using -x option
Information related to all the headers can be retrieved using -x option along with this command.
Consider the following example :
Jitsi meet google chrome. So we see that a detailed information was produced in the output.
Syntax and Options
Short Option | Long Option | Option Description |
---|---|---|
-a | –archive-header | If any of the objfile files are archives, display the archive header information (in a format similar to ls -l). Besides the information you could list with ar tv, objdump -a shows the object file format of each archive member. |
–adjust-vma=offset | When dumping information, first add offset to all the section addresses. This is useful if the section addresses do not correspond to the symbol table, which can happen when putting sections at particular addresses when using a format which can not represent section addresses, such as a.out. | |
-C | –demangle[=style] | Decode (demangle) low-level symbol names into user-level names. Besides removing any initial underscore perpended by the system, this makes C++ function names readable. Different compilers have different mangling styles. The optional demangling style argument can be used to choose an appropriate demangling style for your compiler. |
-e | –debugging-tags | Like -g, but the information is generated in a format compatible with ctags tool. |
-D | –disassemble-all | Like -d, but disassemble the contents of all sections, not just those expected to contain instructions. If the target is an ARM architecture this switch also has the effect of forcing the disassembler to decode pieces of data found in code sections as if they were instructions. |
-EB, -EL | –endian={big|little} | Specify the endianness of the object files. This only affects disassembly. This can be useful when disassembling a file format which does not describe endianness information, such as S-records. |
-F | –file-offsets | When disassembling sections, whenever a symbol is displayed, also display the file offset of the region of data that is about to be dumped. If zeros are being skipped, then when disassembly resumes, tell the user how many zeros were skipped and the file offset of the location from where the disassembly resumes. When dumping sections, display the file offset of the location from where the dump starts. |
-j name | –section=name | Display information only for section name. |
Related Commands
nm
readelf
Objdump command in Linux is used to provide thorough information on object files. This command is mainly used by the programmers who work on compilers, but still its a very handy tool for normal programmers also when it comes to debugging. In this article, we will understand how to use objdump command through some examples.
Basic syntax of objdump is :
There is a wide range of options available for this command. We will try to cover a good amount of them in this tutorial.
Examples
The ELF binary file of the following C program is used in all the examples mentioned in this article.
Note: The above is just a test code that was being used for some other purpose, but I found it simple enough to use for this article.
1. Display the contents of the overall file header using -f option
Consider the following example :
So we see that the information related to the overall file header was shown in the output.
NOTE: The executable format used in the examples is ELF. To know more about it, refer to our article on ELF file format.
2.Display object format specific file header contents using -p option
The following example prints the object file format specific information.
3. Display the contents of the section headers using -h option
There can be various sections in an object file. Information related to them can be printed using -h option.
The following examples shows various sections. As you see there are total of 26 (only partial output is shown here).
So we see that the information related to all the section headers was printed in the output. In the output above, Size is the size of the loaded section, VMA represents the virtual memory address, LMA represents the logical memory address, File off is this section's offset from the beginning of the file, Algn represents alignment, CONTENTS, ALLOC, LOAD, READONLY, DATA are flags that represent that a particular section is to be LOADED or is READONLY etc.
4. Display the contents of all headers using -x option
Information related to all the headers in the object file can be retrieved using the -x option.
The following example displays all the sections (only partial output is shown here):
5. Display assembler contents of executable sections using -d option
Consider the following example. The assembler contents of executable sections (in the object file) are displayed in this output (partial output shown below):
6. Display assembler contents of all sections using -D option
In case the assembler contents of all the sections is required in output, the option -D can be used.
Consider the following output :
So we see that the relevant output was displayed. Since the output was very long, so I clipped it. Note that I used the pager command for controlling the output.
7. Display the full contents of all sections using -s option
Consider the following example :
So we see that the complete contents for all the sections were displayed in the output.
8. Display debug information using -g option
Consider the following example:
So we see that all the available debug information was printed in output.
9. Display the contents of symbol table (or tables) using the -t option
Consider the following example :
Objdump -b
So we see that the contents of symbol table were displayed in the output.
10. Display the contents of dynamic symbol table using -T option
Dynamic symbols are those which are resolved during run time. The information related to these symbols can be retrieved using the -D option.
Consider the following example :
So we see that information related to dynamic symbols was displayed in output.
11. Display the dynamic relocation entries in the file using -R option
Consider the following example:
So we see that all the dynamic relocation entries were displayed in the output.
12. Display section of interest using -j option
This is extremely useful when you know the section related to which the information is required. The option -j is used in this case.
Consider the following example :
So we see that information related to rodata section was displayed above.
Objdump Intel Syntax
13. Use the older disassembly format using –prefix-addresses option
The older format prints the complete address on each line.
The time in gmt. Consider the following example :
So we see that complete address were printed in the output.
14. Accept input options from a file using @ option
Objdump Linux
If you want, the options to objdump can be read from a file. This can be done using ‘@' option.
Consider the following example :
Objdump For Windows
In this example above, I have used the -v and -i options. While -v is used to print the version information, -i is used to provide supported object formats and architectures.
Now I created a file and add these two options there.
Objdump Options
Execute the objdump by calling the options.txt file as shown below. This displays the same output as above, as it is reading the options from the options.txt file.