LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 12-28-2010, 02:01 PM   #1
Kitt3n
LQ Newbie
 
Registered: Dec 2010
Posts: 3

Rep: Reputation: 0
objdump


I just started learning C from a book and it told me to use objdump to look at the code in assembly. However I run into the problem that the output objdump gives me is not the same as is in the book. That other addresses are used I understand. But why is the program not executed the exact same way even know I use the same processor (x86) as is used in the book.

Sins I have not found out yet how I can copy text from the command line in my virtual box in windows I can only give you the example from the book. What I am reffering to is the 3th and 4th column the left.

Example:
Code:
reader:~/booksrc $ objdump -M intel -D a.out | grep -A20 main.:
08048374 <main>:
 8048374:       55                      push   ebp
 8048375:       89 e5                   mov    ebp,esp
 8048377:       83 ec 08                sub    esp,0x8
 804837a:       83 e4 f0                and    esp,0xfffffff0
 804837d:       b8 00 00 00 00          mov    eax,0x0
 8048382:       29 c4                   sub    esp,eax
 8048384:       c7 45 fc 00 00 00 00    mov    DWORD PTR [ebp-4],0x0
 804838b:       83 7d fc 09             cmp    DWORD PTR [ebp-4],0x9
 804838f:       7e 02                   jle    8048393 <main+0x1f>
 8048391:       eb 13                   jmp    80483a6 <main+0x32>
 8048393:       c7 04 24 84 84 04 08    mov    DWORD PTR [esp],0x8048484
 804839a:       e8 01 ff ff ff          call   80482a0 <printf@plt>
 804839f:       8d 45 fc                lea    eax,[ebp-4]
 80483a2:       ff 00                   inc    DWORD PTR [eax]
 80483a4:       eb e5                   jmp    804838b <main+0x17>
 80483a6:       c9                      leave
 80483a7:       c3                      ret
 80483a8:       90                      nop
 80483a9:       90                      nop
 80483aa:       90                      nop
reader:~/booksrc $
 
Old 12-28-2010, 06:18 PM   #2
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Quote:
Originally Posted by Kitt3n View Post
I just started learning C from a book and it told me to use objdump to look at the code in assembly.
Yes, you could use objdump(1) or a debugger (which should be capable to disassemble).


Quote:
Originally Posted by Kitt3n View Post
However I run into the problem that the output objdump gives me is not the same as is in the book. But why is the program not executed the exact same way even know I use the same processor (x86) as is used in the book.
That's hard to tell from just the original assembly code. If my internal de-compiler worked correctly ;-), the original C code seems to be a for (i = 0; i<10; i++) while each iteration prints the same string. Though, what do you mean by "not executed the exact same way"? Do you get a different number of iterations? Don't you get ANY output? Does it run forever? Does your program crash?

Quote:
Originally Posted by Kitt3n View Post
Sins I have not found out yet how I can copy text from the command line in my virtual box in windows I can only give you the example from the book. What I am reffering to is the 3th and 4th column the left.
Your disassembly (and possibly our C-code) would be really helpful ...

Andi
 
  


Reply



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
objdump doubt!!!!! webquinty Linux - Newbie 6 09-30-2008 08:03 AM
readelf and objdump andyzn Programming 1 12-06-2007 05:08 AM
when objdump is applied on vmlinux topworld Linux - Software 0 03-31-2006 01:05 AM
objdump usage cranium2004 Linux - Newbie 0 01-20-2005 01:00 AM
Using objdump for decompiling JIV Programming 0 06-13-2004 08:33 AM

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

All times are GMT -5. The time now is 09:58 AM.

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