LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-15-2010, 03:16 PM   #1
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Rep: Reputation: 39
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.
 
Old 08-15-2010, 04:10 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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

Last edited by paulsm4; 08-15-2010 at 04:12 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Can't properly configure lirc, hexdump shows other bits changing brubizu Linux - Software 2 07-20-2010 05:36 AM
[SOLVED] Hexdump: inaccurate output? mattseanbachman Linux - Newbie 1 04-21-2010 06:19 PM
How can I use hexdump to display ASCII control codes? Akabaka Linux - Software 2 09-19-2009 06:52 PM
hexdump vs od sulekha Linux - General 1 01-12-2009 03:35 PM
readelf and objdump andyzn Programming 1 12-06-2007 05:08 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration