diff options
Diffstat (limited to 'ELF/Bits.h')
-rw-r--r-- | ELF/Bits.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ELF/Bits.h b/ELF/Bits.h new file mode 100644 index 000000000000..13d40322265e --- /dev/null +++ b/ELF/Bits.h @@ -0,0 +1,35 @@ +//===- Bits.h ---------------------------------------------------*- C++ -*-===// +// +// The LLVM Linker +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLD_ELF_BITS_H +#define LLD_ELF_BITS_H + +#include "Config.h" +#include "llvm/Support/Endian.h" + +namespace lld { +namespace elf { + +inline uint64_t readUint(uint8_t *Buf) { + if (Config->Is64) + return llvm::support::endian::read64(Buf, Config->Endianness); + return llvm::support::endian::read32(Buf, Config->Endianness); +} + +inline void writeUint(uint8_t *Buf, uint64_t Val) { + if (Config->Is64) + llvm::support::endian::write64(Buf, Val, Config->Endianness); + else + llvm::support::endian::write32(Buf, Val, Config->Endianness); +} + +} // namespace elf +} // namespace lld + +#endif |