From e08cd678decc00bbb03300a7e1b3ddc64cb9c3e3 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 23 Oct 2015 22:44:39 +0000 Subject: [PATCH] ELF2: Simplify file magic setter. llvm-svn: 251159 --- lld/ELF/Writer.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 3187799f3e32..30e4079c9573 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -704,11 +704,9 @@ template int Writer::getPhdrsNum() const { template void Writer::writeHeader() { uint8_t *Buf = Buffer->getBufferStart(); + memcpy(Buf, "\177ELF", 4); + auto *EHdr = reinterpret_cast(Buf); - EHdr->e_ident[EI_MAG0] = 0x7F; - EHdr->e_ident[EI_MAG1] = 'E'; - EHdr->e_ident[EI_MAG2] = 'L'; - EHdr->e_ident[EI_MAG3] = 'F'; EHdr->e_ident[EI_CLASS] = ELFT::Is64Bits ? ELFCLASS64 : ELFCLASS32; EHdr->e_ident[EI_DATA] = ELFT::TargetEndianness == llvm::support::little ? ELFDATA2LSB