diff options
10 files changed, 23 insertions, 82 deletions
diff --git a/lld/include/lld/Core/Endian.h b/lld/include/lld/Core/Endian.h deleted file mode 100644 index 3994f70ca80..00000000000 --- a/lld/include/lld/Core/Endian.h +++ /dev/null @@ -1,67 +0,0 @@ -//===--- Endian.h - utility functions for endian-aware reads/writes -----*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLD_CORE_ENDIAN_H -#define LLD_CORE_ENDIAN_H - -#include "llvm/Support/Endian.h" - -namespace lld { - -inline uint16_t read16le(const void *p) { - return *reinterpret_cast<const llvm::support::ulittle16_t *>(p); -} - -inline uint32_t read32le(const void *p) { - return *reinterpret_cast<const llvm::support::ulittle32_t *>(p); -} - -inline uint64_t read64le(const void *p) { - return *reinterpret_cast<const llvm::support::ulittle64_t *>(p); -} - -inline void write16le(void *p, uint16_t v) { - *reinterpret_cast<llvm::support::ulittle16_t *>(p) = v; -} - -inline void write32le(void *p, uint32_t v) { - *reinterpret_cast<llvm::support::ulittle32_t *>(p) = v; -} - -inline void write64le(void *p, uint64_t v) { - *reinterpret_cast<llvm::support::ulittle64_t *>(p) = v; -} - -inline uint16_t read16be(const void *p) { - return *reinterpret_cast<const llvm::support::ubig16_t *>(p); -} - -inline uint32_t read32be(const void *p) { - return *reinterpret_cast<const llvm::support::ubig32_t *>(p); -} - -inline uint64_t read64be(const void *p) { - return *reinterpret_cast<const llvm::support::ubig64_t *>(p); -} - -inline void write16be(void *p, uint16_t v) { - *reinterpret_cast<llvm::support::ubig16_t *>(p) = v; -} - -inline void write32be(void *p, uint32_t v) { - *reinterpret_cast<llvm::support::ubig32_t *>(p) = v; -} - -inline void write64be(void *p, uint64_t v) { - *reinterpret_cast<llvm::support::ubig64_t *>(p) = v; -} - -} // namespace lld - -#endif diff --git a/lld/lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp index d809ec8ad10..d1ecc7fa884 100644 --- a/lld/lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp @@ -9,12 +9,13 @@ #include "AArch64TargetHandler.h" #include "AArch64LinkingContext.h" -#include "lld/Core/Endian.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Endian.h" #include "llvm/Support/MathExtras.h" using namespace lld; -using namespace elf; +using namespace lld::elf; +using namespace llvm::support::endian; #define PAGE(X) ((X) & ~0x0FFFL) diff --git a/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp index 5b1e159baf7..938210f8f49 100644 --- a/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp @@ -10,12 +10,13 @@ #include "ARMTargetHandler.h" #include "ARMLinkingContext.h" -#include "lld/Core/Endian.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Endian.h" #include "llvm/Support/MathExtras.h" using namespace lld; -using namespace elf; +using namespace lld::elf; +using namespace llvm::support::endian; static Reference::Addend readAddend_THM_MOV(const uint8_t *location) { const uint16_t halfHi = read16le(location); diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp index f5977685a8b..21967d356a3 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp @@ -11,12 +11,12 @@ #include "HexagonRelocationFunctions.h" #include "HexagonTargetHandler.h" #include "HexagonRelocationHandler.h" -#include "lld/Core/Endian.h" +#include "llvm/Support/Endian.h" using namespace lld; -using namespace elf; - +using namespace lld::elf; using namespace llvm::ELF; +using namespace llvm::support::endian; #define APPLY_RELOC(result) \ write32le(location, result | read32le(location)); diff --git a/lld/lib/ReaderWriter/ELF/X86/X86RelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/X86/X86RelocationHandler.cpp index 427036d5596..da5a24c6ec3 100644 --- a/lld/lib/ReaderWriter/ELF/X86/X86RelocationHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/X86/X86RelocationHandler.cpp @@ -9,10 +9,11 @@ #include "X86LinkingContext.h" #include "X86TargetHandler.h" -#include "lld/Core/Endian.h" +#include "llvm/Support/Endian.h" using namespace lld; -using namespace elf; +using namespace lld::elf; +using namespace llvm::support::endian; namespace { /// \brief R_386_32 - word32: S + A diff --git a/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp index b2038619470..9139aec0bf5 100644 --- a/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp @@ -9,10 +9,11 @@ #include "X86_64LinkingContext.h" #include "X86_64TargetHandler.h" -#include "lld/Core/Endian.h" +#include "llvm/Support/Endian.h" using namespace lld; -using namespace elf; +using namespace lld::elf; +using namespace llvm::support::endian; /// \brief R_X86_64_64 - word64: S + A static void reloc64(uint8_t *location, uint64_t P, uint64_t S, int64_t A) { diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h index ae47329034b..613c1b2f251 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h @@ -9,11 +9,11 @@ #include "MachONormalizedFile.h" -#include "lld/Core/Endian.h" #include "lld/Core/Error.h" #include "lld/Core/LLVM.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/Endian.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Host.h" #include "llvm/Support/MachO.h" @@ -26,6 +26,7 @@ namespace lld { namespace mach_o { namespace normalized { +using namespace llvm::support::endian; using llvm::sys::getSwappedBytes; template<typename T> diff --git a/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp b/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp index a7f76f35abb..d41ef581f7f 100644 --- a/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp +++ b/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp @@ -9,18 +9,19 @@ #include "IdataPass.h" #include "Pass.h" -#include "lld/Core/Endian.h" #include "lld/Core/File.h" #include "lld/Core/Pass.h" #include "lld/Core/Simple.h" #include "llvm/Support/COFF.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Endian.h" #include <algorithm> #include <cstddef> #include <cstring> #include <map> #include <vector> +using namespace llvm::support::endian; using llvm::object::delay_import_directory_table_entry; namespace lld { diff --git a/lld/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp b/lld/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp index dcf00dafe29..b2c9b965781 100644 --- a/lld/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp +++ b/lld/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp @@ -119,7 +119,6 @@ //===----------------------------------------------------------------------===// #include "Atoms.h" -#include "lld/Core/Endian.h" #include "lld/Core/Error.h" #include "lld/Core/File.h" #include "lld/Core/SharedLibraryAtom.h" @@ -130,6 +129,7 @@ #include "llvm/Support/COFF.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Endian.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Memory.h" #include "llvm/Support/MemoryBuffer.h" @@ -142,6 +142,7 @@ using namespace lld; using namespace lld::pecoff; using namespace llvm; +using namespace llvm::support::endian; #define DEBUG_TYPE "ReaderImportHeader" diff --git a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp index e11c672a222..886e1f952e1 100644 --- a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp +++ b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp @@ -22,7 +22,6 @@ #include "Atoms.h" #include "WriterImportLibrary.h" #include "lld/Core/DefinedAtom.h" -#include "lld/Core/Endian.h" #include "lld/Core/File.h" #include "lld/Core/Writer.h" #include "lld/ReaderWriter/AtomLayout.h" @@ -44,6 +43,8 @@ #define DEBUG_TYPE "WriterPECOFF" +using namespace llvm::support::endian; + using llvm::COFF::DataDirectoryIndex; using llvm::object::coff_runtime_function_x64; using llvm::support::ulittle16_t; |