LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   difference between hexdump and objdump. (https://www.linuxquestions.org/questions/programming-9/difference-between-hexdump-and-objdump-826387/)

tkmsr 08-15-2010 03:16 PM

difference between hexdump and objdump.
 
I am not clear with difference between hexdump and objdump and coredump.
I wrote a small program
Code:

main (){
int a=2;
int b=4;
int k=b/a;
int m=9;
}

and tried to compare its hexdump and objdump.
Here is a link to the hexdump
and objdump.

I tried to search the instructions found in objdump with the numbers in hexdump I was expecting a line in objdump such as
Code:

8048398:    83 e4 f0                and    $0xfffffff0,%esp
 804839b:    ff 71 fc                pushl  -0x4(%ecx)
 804839e:    55                      push  %ebp
 804839f:    89 e5                    mov    %esp,%ebp
 80483a1:    51                      push  %ecx
 80483a2:    83 ec 1c                sub    $0x1c,%esp
 80483a5:    c7 45 f8 02 00 00 00    movl  $0x2,-0x8(%ebp)
 80483ac:    c7 45 f4 04 00 00 00    movl  $0x4,-0xc(%ebp)
 80483b3:    8b 45 f4                mov    -0xc(%ebp),%eax
 80483b6:    89 45 e0                mov    %eax,-0x20(%ebp)
 80483b9:    8b 55 e0                mov    -0x20(%ebp),%edx
 80483bc:    89 d0                    mov    %edx,%eax
 80483be:    c1 fa 1f                sar    $0x1f,%edx
 80483c1:    f7 7d f8                idivl  -0x8(%ebp)
 80483c4:    89 45 f0                mov    %eax,-0x10(%ebp)
 80483c7:    c7 45 ec 09 00 00 00    movl  $0x9,-0x14(%ebp)

Some of the above instructions such as 89 d0 should be present in hexdump.
What exactly is the hexdump ,objdump and coredump and what is their importance?
Why do scripting languages not have these or if I am wrong then correct me.

paulsm4 08-15-2010 04:10 PM

Hi -

Quote:

Q: Why do scripting languages not have these?

A: There are basically two kinds of "programs":

1) "Compiled programs" (like C, C++ and FORTRAN) parse source
code and turn it into machine instructions (binary, executable programs).

2) "Interpreted programs" (aka "scripting languages", like bash and Perl) interpret and execute the source code on-the-fly. The program (e.g. "/usr/bin/perl") parses and executes the script directly - there's never a "binary .exe of the program" in the middle.
Quote:

Q: I tried to search the instructions found in objdump with the numbers in hexdump I was expecting a line in objdump...

A: A binary executable (e.g. "myprog.exe") is more than just "a bunch of assembly instructions". It has a structure: a header, executable code sections, pre-initialized data sections, dynamic references (to be "filled in" from shared libraries), etc etc.

Examples of binary object file formats include ELF, COFF, PE and OMF.

The purpose of "objdump" is to show the elements in (the "structure of") a binary object file.

The purpose of "hexdump" is to show the contents of a binary file.
'Hope that helps .. PSM


All times are GMT -5. The time now is 07:40 AM.