1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| mp$ cat - > a.cpp
#include <iostream>
using namespace std;
int main()
{
__asm volatile(".ascii \"\xEB\x01\xE8\"");
cout << "Hello world!" << endl;
return 0;
}
tmp$ g++ a.cpp
tmp$ gdb a.out
GNU gdb (GDB) 7.4
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/a.out...(no debugging symbols found)...done.
(gdb) disas main
Dump of assembler code for function main:
0x0000000000400690 <+0>: sub $0x8,%rsp
0x0000000000400694 <+4>: jmp 0x400697 <main+7>
0x0000000000400696 <+6>: callq 0x4048c359
0x000000000040069b <+11>: add %bh,0x600c40(%rdi)
0x00000000004006a1 <+17>: callq 0x400670 <_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@plt>
0x00000000004006a6 <+22>: mov %rax,%rdi
0x00000000004006a9 <+25>: callq 0x400680 <_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@plt>
0x00000000004006ae <+30>: xor %eax,%eax
0x00000000004006b0 <+32>: add $0x8,%rsp
0x00000000004006b4 <+36>: retq
End of assembler dump.
(gdb) disas main+7,main+37
Dump of assembler code from 0x400697 to 0x4006b4:
0x0000000000400697 <main+7>: mov $0x4008bc,%esi
0x000000000040069c <main+12>: mov $0x600c40,%edi
0x00000000004006a1 <main+17>: callq 0x400670 <_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@plt>
0x00000000004006a6 <main+22>: mov %rax,%rdi
0x00000000004006a9 <main+25>: callq 0x400680 <_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@plt>
0x00000000004006ae <main+30>: xor %eax,%eax
0x00000000004006b0 <main+32>: add $0x8,%rsp
0x00000000004006b4 <main+36>: retq
End of assembler dump. |
Partager