bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/29226] gcc -fcf-protection option causes GCC 12 gccgo build to f


From: jason.vas.dias at gmail dot com
Subject: [Bug ld/29226] gcc -fcf-protection option causes GCC 12 gccgo build to fail : "failed to match split-stack sequence"
Date: Sun, 05 Jun 2022 16:35:29 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=29226

--- Comment #8 from Jason Vas Dias <jason.vas.dias at gmail dot com> ---
So my best guess at a patch would currently be:

$ diff -U1  x86_64.cc~  x86_64.cc
--- x86_64.cc~  2022-01-22 12:14:09.000000000 +0000
+++ x86_64.cc   2022-06-05 17:34:26.400079527 +0100
@@ -6050,2 +6050,3 @@
 static const unsigned char lea_r11_insn_64[] = { 0x4c, 0x8d, 0x9c, 0x24 };
+static const unsigned char rdssp_insn_64[] =   { 0xf3, 0x0f, 0x1e, 0xfa };

@@ -6077,3 +6078,3 @@
   const size_t nop_len = (size == 32 ? 7 : 8);
-
+  const size_t rdssp_insn_len = 4;
   // The function starts with a comparison of the stack pointer and a
@@ -6111,7 +6112,28 @@
     {
-      if (!object->has_no_split_stack())
+      if ( (!object->has_no_split_stack())
+         &&(!this_match_view( view, view_size, fnoffset, rdssp_insn,
rdssp_insn_len))
+         )
+      {        unsigned char ib[16]={0};
+       if ( view )
+       { ib[0] = *(((unsigned char*)view) + fnoffset);
+         ib[1] = *(((unsigned char*)view) + fnoffset + 1);
+         ib[2] = *(((unsigned char*)view) + fnoffset + 2);
+         ib[3] = *(((unsigned char*)view) + fnoffset + 3);
+       }
        object->error(_("failed to match split-stack sequence at "
-                       "section %u offset %0zx"),
-                     shndx, static_cast<size_t>(fnoffset));
-      return;
+                       "section %u offset %0zx r10:%c r11:%c %u
%2.2hhx.%2.2hhx.%2.2hhx.%2.2hhx"),
+                     shndx, static_cast<size_t>(fnoffset)
+                     , (this->match_view(view, view_size, fnoffset,
+                                         lea_r10_insn, lea_r10_insn_len
+                                         ) ? '1' : '0'
+                        )
+                     , (this->match_view(view, view_size, fnoffset,
+                                         lea_r11_insn, lea_r11_insn_len
+                                         ) ? '1' : '0'
+                        )
+                      , static_cast<uint32_t>(fnsize)
+                      , ib[0], ib[1], ib[2], ib[3]
+                    );
+       return;
+      }
     }

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]