<p dir="ltr">Thanks! </p>
<div class="gmail_quote">On Sep 29, 2015 7:02 PM, "Rui Ueyama via llvm-commits" <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Tue Sep 29 18:00:47 2015<br>
New Revision: 248844<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=248844&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=248844&view=rev</a><br>
Log:<br>
ELF2: Do not create ArrayRefs and use const arrays instead. NFC.<br>
<br>
Modified:<br>
    lld/trunk/ELF/Target.cpp<br>
<br>
Modified: lld/trunk/ELF/Target.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=248844&r1=248843&r2=248844&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=248844&r1=248843&r2=248844&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Target.cpp (original)<br>
+++ lld/trunk/ELF/Target.cpp Tue Sep 29 18:00:47 2015<br>
@@ -37,16 +37,11 @@ X86TargetInfo::X86TargetInfo() {<br>
<br>
 void X86TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
                                   uint64_t PltEntryAddr) const {<br>
-  ArrayRef<uint8_t> Jmp = {0xff, 0x25}; // jmpl *val<br>
-  memcpy(Buf, Jmp.data(), Jmp.size());<br>
-  Buf += Jmp.size();<br>
-<br>
+  // jmpl *val; nop; nop<br>
+  const uint8_t Inst[] = {0xff, 0x25, 0, 0, 0, 0, 0x90, 0x90};<br>
+  memcpy(Buf, Inst, sizeof(Inst));<br>
   assert(isUInt<32>(GotEntryAddr));<br>
-  write32le(Buf, GotEntryAddr);<br>
-  Buf += 4;<br>
-<br>
-  ArrayRef<uint8_t> Nops = {0x90, 0x90};<br>
-  memcpy(Buf, Nops.data(), Nops.size());<br>
+  write32le(Buf + 2, GotEntryAddr);<br>
 }<br>
<br>
 bool X86TargetInfo::relocNeedsGot(uint32_t Type) const {<br>
@@ -107,18 +102,14 @@ X86_64TargetInfo::X86_64TargetInfo() {<br>
<br>
 void X86_64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
                                      uint64_t PltEntryAddr) const {<br>
-  ArrayRef<uint8_t> Jmp = {0xff, 0x25}; // jmpq *val(%rip)<br>
-  memcpy(Buf, Jmp.data(), Jmp.size());<br>
-  Buf += Jmp.size();<br>
+  // jmpq *val(%rip); nop; nop<br>
+  const uint8_t Inst[] = {0xff, 0x25, 0, 0, 0, 0, 0x90, 0x90};<br>
+  memcpy(Buf, Inst, sizeof(Inst));<br>
<br>
   uintptr_t NextPC = PltEntryAddr + 6;<br>
   intptr_t Delta = GotEntryAddr - NextPC;<br>
   assert(isInt<32>(Delta));<br>
-  write32le(Buf, Delta);<br>
-  Buf += 4;<br>
-<br>
-  ArrayRef<uint8_t> Nops = {0x90, 0x90};<br>
-  memcpy(Buf, Nops.data(), Nops.size());<br>
+  write32le(Buf + 2, Delta);<br>
 }<br>
<br>
 bool X86_64TargetInfo::relocNeedsGot(uint32_t Type) const {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>