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
 
(2 intermediate revisions by the same user not shown)
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
 
   
 
   
Line 18: Line 25:
 
     8500: eb000035 bl 85dc <call_gmon_start>
 
     8500: eb000035 bl 85dc <call_gmon_start>
 
     8504: e28dd004 add sp, sp, #4 ; 0x4
 
     8504: e28dd004 add sp, sp, #4 ; 0x4
 +
 +
= See also =
 +
* [[gdb]]
 +
* [[run vlc as root]] - an example for using objdump to disassemble an executable file
 +
 +
[[Category:Geeky]]
 +
[[Category:Command]]

Latest revision as of 17:07, 3 November 2013

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

See also