objdump

This is a discussion on objdump within the Linux Programming forums, part of the Platform Specific Boards category; I just started learning C from a book in Linux and it told me to use objdump to look at ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    62

    objdump

    I just started learning C from a book in Linux 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 $
    Last edited by Kitt3n; 12-28-2010 at 01:07 PM.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    Don't worry about it. Unless you compiled with the *exact* same version of compiler, compilation flags, etc, you should expect some differences...
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    62
    Thanks. I was getting worried I overlooked something and that I could trow the book in the trashcan.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assertion Fail error
    By TheEngineer in forum C Programming
    Replies: 14
    Last Post: 05-13-2010, 10:22 AM
  2. objdump for dos or windows
    By DavidP in forum Tech Board
    Replies: 3
    Last Post: 02-25-2010, 07:26 AM
  3. Using objdump to see a called function
    By Angus in forum C Programming
    Replies: 3
    Last Post: 03-17-2009, 01:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21