Difference between revisions of "Objdump"

From Linuxintro
imported>ThorstenStaerk
(New page: Nokia-N810-43-7:~# cat main.cpp #include <iostream> int main() { std::cout << "hello world" << std::endl; } Nokia-N810-43-7:~# g\+\+-3.4 main.cpp Now we look at a fixed-length-c...)
 
imported>ThorstenStaerk
Line 1: Line 1:
  Nokia-N810-43-7:~# cat main.cpp  
+
Objdump displays information from object files. That means you can for example disassemble an executable file with it.
 +
 
 +
= Disassembly =
 +
Let's look at an example:
 +
  # cat main.cpp  
 
  #include <iostream>
 
  #include <iostream>
 
  int main()
 
  int main()
Line 5: Line 9:
 
   std::cout << "hello world" << std::endl;
 
   std::cout << "hello world" << std::endl;
 
  }
 
  }
 +
You can now compile this file and look at the executable file using objdump.
 +
 +
== ARM ==
 +
Here is the disassembly on the ARM architecture, a fixed-length-command-set-architecture:
 
  Nokia-N810-43-7:~# g\+\+-3.4 main.cpp  
 
  Nokia-N810-43-7:~# g\+\+-3.4 main.cpp  
Now we look at a fixed-length-command-set-architecture at the machine code.
 
 
  Nokia-N810-43-7:~# objdump -d a.out | head
 
  Nokia-N810-43-7:~# objdump -d a.out | head
 
   
 
   

Revision as of 09:10, 2 January 2010

Objdump displays information from object files. That means you can for example disassemble an executable file with it.

Disassembly

Let's look at an example:

# cat main.cpp 
#include <iostream>
int main()
{
  std::cout << "hello world" << std::endl;
}

You can now compile this file and look at the executable file using objdump.

ARM

Here is the disassembly on the ARM architecture, a fixed-length-command-set-architecture:

Nokia-N810-43-7:~# g\+\+-3.4 main.cpp 
Nokia-N810-43-7:~# objdump -d a.out | head

a.out:     file format elf32-littlearm

Disassembly of section .init:

000084f8 <_init>:
    84f8:	e52de004 	str	lr, [sp, #-4]!
    84fc:	e24dd004 	sub	sp, sp, #4	; 0x4
    8500:	eb000035 	bl	85dc <call_gmon_start>
    8504:	e28dd004 	add	sp, sp, #4	; 0x4