"-mnop-mcount" needs to make 5byte size "nop" instruction. however recently gcc make only 4byte "nop" in 32bit. I have test in gcc 5.4, 7.2.
======================================================= bug result ======================================================= 080485c5 <main>: 80485c5: 0f 1f 04 00 nopl (%eax,%eax,1) 80485c9: 8d 4c 24 04 lea 0x4(%esp),%ecx 80485cd: 83 e4 f0 and $0xfffffff0,%esp ======================================================= fixed result ======================================================= 08048598 <main>: 8048598: 0f 1f 44 00 01 nopl 0x1(%eax,%eax,1) 804859d: 8d 4c 24 04 lea 0x4(%esp),%ecx 80485a1: 83 e4 f0 and $0xfffffff0,%esp is it OK? ======================================================= Index : gcc/config/i386/i386.c ======================================================= diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index c6ca071..e574de3 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -40474,7 +40474,7 @@ static void x86_print_call_or_nop (FILE *file, const char *target) { if (flag_nop_mcount) - fprintf (file, "1:\tnopl 0x00(%%eax,%%eax,1)\n"); /* 5 byte nop. */ + fprintf (file, "1:\tnopl 0x01(%%eax,%%eax,1)\n"); /* 5 byte nop. */ else fprintf (file, "1:\tcall\t%s\n", target); }