Hello!

> "-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.

-    fprintf (file, "1:\tnopl 0x00(%%eax,%%eax,1)\n"); /* 5 byte nop.  */
+    fprintf (file, "1:\tnopl 0x01(%%eax,%%eax,1)\n"); /* 5 byte nop.  */

Even the above change is not correct, since it will be assembled in a
different way on 32 bit and 64 bit targets (size prefix will be added
on 64 bit targets). Attached patch fixes this issue by emitting a
stream of bytes.

2017-11-15  Uros Bizjak  <ubiz...@gmail.com>

    * config/i386/i386.c (x86_print_call_or_nop): Emit 5 byte nop
    explicitly as a stream of bytes.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline, will be committed to release branches.

Uros.
Index: i386.c
===================================================================
--- i386.c      (revision 254773)
+++ i386.c      (working copy)
@@ -40473,7 +40473,8 @@ 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.  */
+    /* 5 byte nop: nopl 0(%[re]ax,%[re]ax,1) */
+    fprintf (file, "1:" ASM_BYTE "0x0f, 0x1f, 0x44, 0x00, 0x00\n");
   else
     fprintf (file, "1:\tcall\t%s\n", target);
 }

Reply via email to