[lld] r316707 - Move bit operations to a new file, ELF/Bits.h.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 26 14:37:18 PDT 2017


Author: ruiu
Date: Thu Oct 26 14:37:17 2017
New Revision: 316707

URL: http://llvm.org/viewvc/llvm-project?rev=316707&view=rev
Log:
Move bit operations to a new file, ELF/Bits.h.

Added:
    lld/trunk/ELF/Bits.h
Modified:
    lld/trunk/ELF/SyntheticSections.cpp

Added: lld/trunk/ELF/Bits.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Bits.h?rev=316707&view=auto
==============================================================================
--- lld/trunk/ELF/Bits.h (added)
+++ lld/trunk/ELF/Bits.h Thu Oct 26 14:37:17 2017
@@ -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

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=316707&r1=316706&r2=316707&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Thu Oct 26 14:37:17 2017
@@ -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.




More information about the llvm-commits mailing list