summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/Object.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-objcopy/Object.cpp')
-rw-r--r--llvm/tools/llvm-objcopy/Object.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/tools/llvm-objcopy/Object.cpp b/llvm/tools/llvm-objcopy/Object.cpp
index d8e90fdc34a..e7ffb1eae11 100644
--- a/llvm/tools/llvm-objcopy/Object.cpp
+++ b/llvm/tools/llvm-objcopy/Object.cpp
@@ -153,9 +153,10 @@ void ELFSectionWriter<ELFT>::visit(const CompressedSection &Sec) {
ArrayRef<uint8_t> Magic = {'Z', 'L', 'I', 'B'};
std::copy(Magic.begin(), Magic.end(), Buf);
Buf += Magic.size();
- uint64_t *DecompressedSizePtr = reinterpret_cast<uint64_t *>(Buf);
- *DecompressedSizePtr = support::endian::read64be(&Sec.DecompressedSize);
- Buf += sizeof(Sec.DecompressedSize);
+ const uint64_t DecompressedSize =
+ support::endian::read64be(&Sec.DecompressedSize);
+ memcpy(Buf, &DecompressedSize, sizeof(DecompressedSize));
+ Buf += sizeof(DecompressedSize);
} else {
auto Chdr = reinterpret_cast<Elf_Chdr_Impl<ELFT> *>(Buf);
Chdr->ch_type = ELF::ELFCOMPRESS_ZLIB;
OpenPOWER on IntegriCloud