diff options
| author | Rui Ueyama <ruiu@google.com> | 2017-10-26 21:37:17 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2017-10-26 21:37:17 +0000 |
| commit | 6e5fda9db80787039edfec0fa1d84c353f60d451 (patch) | |
| tree | 8e99fb60d2db448007c44639f9b2d6ef516f2219 | |
| parent | 1f13b3c24384332736b74853b3618aa1f5adc6b4 (diff) | |
| download | bcm5719-llvm-6e5fda9db80787039edfec0fa1d84c353f60d451.tar.gz bcm5719-llvm-6e5fda9db80787039edfec0fa1d84c353f60d451.zip | |
Move bit operations to a new file, ELF/Bits.h.
llvm-svn: 316707
| -rw-r--r-- | lld/ELF/Bits.h | 35 | ||||
| -rw-r--r-- | lld/ELF/SyntheticSections.cpp | 14 |
2 files changed, 36 insertions, 13 deletions
diff --git a/lld/ELF/Bits.h b/lld/ELF/Bits.h new file mode 100644 index 00000000000..13d40322265 --- /dev/null +++ b/lld/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 diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index a6bf9f9b498..74b40858882 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -15,6 +15,7 @@ //===----------------------------------------------------------------------===// #include "SyntheticSections.h" +#include "Bits.h" #include "Config.h" #include "InputFiles.h" #include "LinkerScript.h" @@ -854,19 +855,6 @@ bool MipsGotSection::empty() const { uint64_t MipsGotSection::getGp() const { return ElfSym::MipsGp->getVA(0); } -static uint64_t readUint(uint8_t *Buf) { - if (Config->Is64) - return read64(Buf, Config->Endianness); - return read32(Buf, Config->Endianness); -} - -static void writeUint(uint8_t *Buf, uint64_t Val) { - if (Config->Is64) - write64(Buf, Val, Config->Endianness); - else - write32(Buf, Val, Config->Endianness); -} - void MipsGotSection::writeTo(uint8_t *Buf) { // Set the MSB of the second GOT slot. This is not required by any // MIPS ABI documentation, though. |

