Re: Injecting user defined opcode

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

 



Hi!

On Sat, Jun 29, 2019 at 07:53:36PM +0000, Mahmood Naderan via gcc-help wrote:
> An empty main code results in the following opcode and assembly lines according to GDB.
> 
> $ gcc -masm=intel -g test.c -o test 

Use -S to see the actual assembler code generated:

$ gcc -masm=intel -S test.c

and look at the generated test.s file.

> 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

00 is not an invalid opcode.  It is the start of an "add" instruction,
as GDB showed you.

> Can I do that?

You could use 0xcc which is a single-byte instruction that breaks your
program (it's "int3").  It isn't clear what you actually want to do though?


Segher



[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