Injecting user defined opcode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

An empty main code results in the following opcode and assembly lines according to GDB.

$ gcc -masm=intel -g test.c -o test 
$ gdb ./test 
(gdb) set disassembly-flavor intel 
(gdb) list 
1       void main() 
2       { 
3       } 
(gdb) disass /r main 
Dump of assembler code for function main:    
  0x00000000004004ed <+0>:     55      push   rbp    
  0x00000000004004ee <+1>:     48 89 e5        mov    rbp,rsp    
  0x00000000004004f1 <+4>:     5d      pop    rbp    
  0x00000000004004f2 <+5>:     c3      ret 
End of assembler dump. (gdb) 




Now, when I put one assembly line with dummy opcode, it seems that gcc combines that with the subsequent line and doesn't create a machine code which I wrote.



(gdb) set disassembly-flavor intel 
(gdb) list 
1       void main() 
2       { 
3         __asm__(".byte 0x00"); 
4       } 
(gdb) disass /r main 
Dump of assembler code for function main:
    0x00000000004004ed <+0>:     55      push   rbp
    0x00000000004004ee <+1>:     48 89 e5        mov    rbp,rsp
    0x00000000004004f1 <+4>:     00 5d c3        add    BYTE PTR [rbp-0x3d],bl 
End of assembler dump. 


I expected to see something like this


  0x00000000004004ed <+0>:     55      push   rbp
  0x00000000004004ee <+1>:     48 89 e5        mov    rbp,rsp   
    ==========>                          00            INVALID
  0x00000000004004f1 <+4>:     5d      pop    rbp     
  0x00000000004004f2 <+5>:     c3      ret


Can I do that?

Regards,
Mahmood




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux