[lld] r249959 - ELF2: Use memcpy to vector contents.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 10 17:10:36 PDT 2015


Author: ruiu
Date: Sat Oct 10 19:10:36 2015
New Revision: 249959

URL: http://llvm.org/viewvc/llvm-project?rev=249959&view=rev
Log:
ELF2: Use memcpy to vector contents.

Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=249959&r1=249958&r2=249959&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sat Oct 10 19:10:36 2015
@@ -591,10 +591,7 @@ template <class ELFT> void Writer<ELFT>:
   EHdr->e_shentsize = sizeof(Elf_Shdr);
   EHdr->e_shnum = getNumSections();
   EHdr->e_shstrndx = Out<ELFT>::StrTab->getSectionIndex();
-
-  auto PHdrs = reinterpret_cast<Elf_Phdr *>(Buf + EHdr->e_phoff);
-  for (Elf_Phdr &PH : Phdrs)
-    *PHdrs++ = PH;
+  memcpy(Buf + EHdr->e_phoff, &Phdrs[0], Phdrs.size() * sizeof(Phdrs[0]));
 
   auto SHdrs = reinterpret_cast<Elf_Shdr *>(Buf + EHdr->e_shoff);
   // First entry is null.




More information about the llvm-commits mailing list