gold: Add endbr64 to IBT TLSDESC PLT entry
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 29 Nov 2020 19:36:13 +0000 (11:36 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 29 Nov 2020 19:41:47 +0000 (11:41 -0800)
Gold generates:

 c10:   ff 35 da 23 00 00       push   0x23da(%rip)        # 2ff0 <_GLOBAL_OFFSET_TABLE_+0x8>
 c16:   f2 ff 25 c3 23 00 00    bnd jmp *0x23c3(%rip)        # 2fe0 <_DYNAMIC+0x260>
 c1d:   0f 1f 00                nopl   (%rax)

for IBT TLSDESC PLT entry which misses endbr64.  Add endbr64 to generate:

 c10:   f3 0f 1e fa             endbr64
 c14:   ff 35 d6 23 00 00       push   0x23d6(%rip)        # 2ff0 <_GLOBAL_OFFSET_TABLE_+0x8>
 c1a:   ff 25 c0 23 00 00       jmp    *0x23c0(%rip)        # 2fe0 <_DYNAMIC+0x260>

PR ld/26972
* x86_64.cc (Output_data_plt_x86_64_ibt::tlsdesc_plt_entry): Add
endbr64.
(Output_data_plt_x86_64_ibt::do_fill_tlsdesc_entry): Adjusted.

gold/ChangeLog
gold/x86_64.cc

index 53bb030821cd8c45ccdf60b340e712f17cc9ff22..a03163ebb8afc166a58f18e3f14c615c20a36eb5 100644 (file)
@@ -1,3 +1,10 @@
+2020-11-29  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/26972
+       * x86_64.cc (Output_data_plt_x86_64_ibt::tlsdesc_plt_entry): Add
+       endbr64.
+       (Output_data_plt_x86_64_ibt::do_fill_tlsdesc_entry): Adjusted.
+
 2020-11-29  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR gold/26939
index ddf4722160bcf942429aac3baa923e4bc9b25ce8..b570d6f439b69d3f18d220ee96785f8163fc9c90 100644 (file)
@@ -2480,11 +2480,11 @@ Output_data_plt_x86_64_ibt<size>::tlsdesc_plt_entry[plt_entry_size] =
 {
   // From Alexandre Oliva, "Thread-Local Storage Descriptors for IA32
   // and AMD64/EM64T", Version 0.9.4 (2005-10-10).
+  0xf3, 0x0f, 0x1e, 0xfa, // endbr64
   0xff, 0x35,          // pushq x(%rip)
   0, 0, 0, 0,          // replaced with address of linkmap GOT entry (at PLTGOT + 8)
-  0xf2, 0xff, 0x25,    // jmpq *y(%rip)
+  0xff, 0x25,          // jmpq *y(%rip)
   0, 0, 0, 0,          // replaced with offset of reserved TLSDESC_GOT entry
-  0x0f,        0x1f, 0         // nop
 };
 
 template<int size>
@@ -2498,15 +2498,15 @@ Output_data_plt_x86_64_ibt<size>::do_fill_tlsdesc_entry(
     unsigned int plt_offset)
 {
   memcpy(pov, tlsdesc_plt_entry, plt_entry_size);
-  elfcpp::Swap_unaligned<32, false>::writeval(pov + 2,
+  elfcpp::Swap_unaligned<32, false>::writeval(pov + 6,
                                              (got_address + 8
                                               - (plt_address + plt_offset
-                                                 + 6)));
-  elfcpp::Swap_unaligned<32, false>::writeval(pov + 9,
+                                                 + 10)));
+  elfcpp::Swap_unaligned<32, false>::writeval(pov + 12,
                                              (got_base
                                               + tlsdesc_got_offset
                                               - (plt_address + plt_offset
-                                                 + 13)));
+                                                 + 16)));
 }
 
 // The .eh_frame unwind information for the PLT.
This page took 0.032836 seconds and 4 git commands to generate.