Injecting user defined opcode

Xi Ruoyao xry111@mengyan1223.wang
Sun Jun 30 06:10:00 GMT 2019


On 2019-06-30 05:42 +0000, Mahmood Naderan via gcc-help wrote:
> As I looked to the assembly code generated by -S, I see
> 
>         .file   "test.c"
>         .intel_syntax noprefix
>         .text
>         .globl  main
>         .type   main, @function
> main:
> .LFB0:
>         .cfi_startproc
>         push    rbp
>         .cfi_def_cfa_offset 16
>         .cfi_offset 6, -16
>         mov     rbp, rsp
>         .cfi_def_cfa_register 6
> #APP
> # 3 "test.c" 1
>         .byte 0x00
> # 0 "" 2
> #NO_APP
>         pop     rbp
>         .cfi_def_cfa 7, 8
>         ret
>         .cfi_endproc
> .LFE0:
>         .size   main, .-main
>         .ident  "GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-16)"
>         .section        .note.GNU-stack,"",@progbits
> 
> 
> 
> It seems that in the machine code generation, gcc combines 00 with the next
> instruction.
> Any thought?

No.  That's not done by GCC or GNU as.

It's how Intel/AMD CPU parses the machine code.  There are no "delimeters" in
machine code so the CPU regards "00 5d c3" as an instruction.  objdump (from
Binutils) just emulates the behavior of CPU.
-- 
Xi Ruoyao <xry111@mengyan1223.wang>
School of Aerospace Science and Technology, Xidian University



More information about the Gcc-help mailing list