This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gold patch committed: Fix x86_64 nops


PR 10419 points out that the nops used for the x86_64 target are
completely wrong; they are, in fact, simply copied from the i386
target.  That was a dumb oversight.  Fortunately, the problem is only
detectable when coding in assembly language, relying on sections being
appended together to form a single body of code, and using section
alignment.  I committed this patch to fix the problem.

Ian


2009-07-20  Ian Lance Taylor  <ian@airs.com>

	PR 10419
	* x86_64.cc (Target_x86_64::do_code_fill): Correct nop sequences.


Index: x86_64.cc
===================================================================
RCS file: /cvs/src/src/gold/x86_64.cc,v
retrieving revision 1.83
diff -p -u -r1.83 x86_64.cc
--- x86_64.cc	22 Jun 2009 06:51:53 -0000	1.83
+++ x86_64.cc	21 Jul 2009 05:22:22 -0000
@@ -2620,40 +2620,40 @@ Target_x86_64::do_code_fill(section_size
   // Nop sequences of various lengths.
   const char nop1[1] = { 0x90 };                   // nop
   const char nop2[2] = { 0x66, 0x90 };             // xchg %ax %ax
-  const char nop3[3] = { 0x8d, 0x76, 0x00 };       // leal 0(%esi),%esi
-  const char nop4[4] = { 0x8d, 0x74, 0x26, 0x00};  // leal 0(%esi,1),%esi
-  const char nop5[5] = { 0x90, 0x8d, 0x74, 0x26,   // nop
-                         0x00 };                   // leal 0(%esi,1),%esi
-  const char nop6[6] = { 0x8d, 0xb6, 0x00, 0x00,   // leal 0L(%esi),%esi
+  const char nop3[3] = { 0x0f, 0x1f, 0x00 };       // nop (%rax)
+  const char nop4[4] = { 0x0f, 0x1f, 0x40, 0x00};  // nop 0(%rax)
+  const char nop5[5] = { 0x0f, 0x1f, 0x44, 0x00,   // nop 0(%rax,%rax,1)
+                         0x00 };
+  const char nop6[6] = { 0x66, 0x0f, 0x1f, 0x44,   // nopw 0(%rax,%rax,1)
                          0x00, 0x00 };
-  const char nop7[7] = { 0x8d, 0xb4, 0x26, 0x00,   // leal 0L(%esi,1),%esi
+  const char nop7[7] = { 0x0f, 0x1f, 0x80, 0x00,   // nopl 0L(%rax)
                          0x00, 0x00, 0x00 };
-  const char nop8[8] = { 0x90, 0x8d, 0xb4, 0x26,   // nop
-                         0x00, 0x00, 0x00, 0x00 }; // leal 0L(%esi,1),%esi
-  const char nop9[9] = { 0x89, 0xf6, 0x8d, 0xbc,   // movl %esi,%esi
-                         0x27, 0x00, 0x00, 0x00,   // leal 0L(%edi,1),%edi
+  const char nop8[8] = { 0x0f, 0x1f, 0x84, 0x00,   // nopl 0L(%rax,%rax,1)
+                         0x00, 0x00, 0x00, 0x00 };
+  const char nop9[9] = { 0x66, 0x0f, 0x1f, 0x84,   // nopw 0L(%rax,%rax,1)
+                         0x00, 0x00, 0x00, 0x00,
                          0x00 };
-  const char nop10[10] = { 0x8d, 0x76, 0x00, 0x8d, // leal 0(%esi),%esi
-                           0xbc, 0x27, 0x00, 0x00, // leal 0L(%edi,1),%edi
+  const char nop10[10] = { 0x66, 0x2e, 0x0f, 0x1f, // nopw %cs:0L(%rax,%rax,1)
+                           0x84, 0x00, 0x00, 0x00,
                            0x00, 0x00 };
-  const char nop11[11] = { 0x8d, 0x74, 0x26, 0x00, // leal 0(%esi,1),%esi
-                           0x8d, 0xbc, 0x27, 0x00, // leal 0L(%edi,1),%edi
+  const char nop11[11] = { 0x66, 0x66, 0x2e, 0x0f, // data16
+                           0x1f, 0x84, 0x00, 0x00, // nopw %cs:0L(%rax,%rax,1)
                            0x00, 0x00, 0x00 };
-  const char nop12[12] = { 0x8d, 0xb6, 0x00, 0x00, // leal 0L(%esi),%esi
-                           0x00, 0x00, 0x8d, 0xbf, // leal 0L(%edi),%edi
+  const char nop12[12] = { 0x66, 0x66, 0x66, 0x2e, // data16; data16
+                           0x0f, 0x1f, 0x84, 0x00, // nopw %cs:0L(%rax,%rax,1)
                            0x00, 0x00, 0x00, 0x00 };
-  const char nop13[13] = { 0x8d, 0xb6, 0x00, 0x00, // leal 0L(%esi),%esi
-                           0x00, 0x00, 0x8d, 0xbc, // leal 0L(%edi,1),%edi
-                           0x27, 0x00, 0x00, 0x00,
+  const char nop13[13] = { 0x66, 0x66, 0x66, 0x66, // data16; data16; data16
+                           0x2e, 0x0f, 0x1f, 0x84, // nopw %cs:0L(%rax,%rax,1)
+                           0x00, 0x00, 0x00, 0x00,
                            0x00 };
-  const char nop14[14] = { 0x8d, 0xb4, 0x26, 0x00, // leal 0L(%esi,1),%esi
-                           0x00, 0x00, 0x00, 0x8d, // leal 0L(%edi,1),%edi
-                           0xbc, 0x27, 0x00, 0x00,
+  const char nop14[14] = { 0x66, 0x66, 0x66, 0x66, // data16; data16; data16
+                           0x66, 0x2e, 0x0f, 0x1f, // data16
+                           0x84, 0x00, 0x00, 0x00, // nopw %cs:0L(%rax,%rax,1)
                            0x00, 0x00 };
-  const char nop15[15] = { 0xeb, 0x0d, 0x90, 0x90, // jmp .+15
-                           0x90, 0x90, 0x90, 0x90, // nop,nop,nop,...
-                           0x90, 0x90, 0x90, 0x90,
-                           0x90, 0x90, 0x90 };
+  const char nop15[15] = { 0x66, 0x66, 0x66, 0x66, // data16; data16; data16
+                           0x66, 0x66, 0x2e, 0x0f, // data16; data16
+                           0x1f, 0x84, 0x00, 0x00, // nopw %cs:0L(%rax,%rax,1)
+                           0x00, 0x00, 0x00 };
 
   const char* nops[16] = {
     NULL,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]