在 2019-07-09二的 09:38 +0000,Mahmood Naderan via gcc-help写道: > BTW, as I run the instruction, I get permission denied error. You can not run the output of the assembler (as). It's a relocatable object file, not executable. You should link it. > > On Tuesday, July 9, 2019, 1:23:58 PM GMT+4:30, Mahmood Naderan via gcc- > help <gcc-help@xxxxxxxxxxx> wrote: > > >You mean x86-64, instead of x86. On x86 "c5 00" means "lds (%eax),%eax". > > "c5" itself is not illegal. For example, "c5 00 58 00" means an AVX > > instruction > > "vaddps (%rax),%xmm15,%xmm8". The disassembler can only determine that it's > > an > > illegal instruction after it has seen "c5 00 00". > > Xi,The code looks like > $ cat machine3.c > void main() { > __asm__(".byte 0xc5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > 0x00, 0x00, 0x00, 0x00, 0x00"); > } > $ gcc -masm=intel -g -c machine3.c > $ objdump -d -M intel -S -z machine3.o > > machine3.o: file format elf64-x86-64 > > > Disassembly of section .text: > > 0000000000000000 <main>: > void main() { > 0: 55 push rbp > 1: 48 89 e5 mov rbp,rsp > 4: c5 00 00 (bad) > 7: 00 00 add BYTE PTR [rax],al > 9: 00 00 add BYTE PTR [rax],al > b: 00 00 add BYTE PTR [rax],al > d: 00 00 add BYTE PTR [rax],al > f: 00 00 add BYTE PTR [rax],al > 11: 00 00 add BYTE PTR [rax],al > __asm__(".byte 0xc5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > 0x00, 0x00, 0x00, 0x00, 0x00"); > } > 13: 5d pop rbp > 14: c3 ret > > > > Why gcc considers that as a three byte instructions and then tag it as a bad > instruction? It's not GCC. Objdump is a part of Binutils. "c5" may be a prefix of a legal instruction so objdump can't say it's illegal. "c5 00" may be a prefix of a legal instruction so objdump can't say it's illegal. (An example: "c5 00 58 00" is "vaddsubps %xmm0,%xmm1,%xmm2".) But "c5 00 00" is not a prefix of any known legal instruction so objdump can say it's definitely illegal. > Regards, > Mahmood -- Xi Ruoyao <xry111@xxxxxxxxxxxxxxxx> School of Aerospace Science and Technology, Xidian University