[llvm-commits] [lld] r171575 - in /lld/trunk/lib/ReaderWriter/ELF: ReferenceKinds.cpp ReferenceKinds.h X86Reference.cpp

Michael J. Spencer bigcheesegs at gmail.com
Fri Jan 4 16:46:11 PST 2013


Author: mspencer
Date: Fri Jan  4 18:46:10 2013
New Revision: 171575

URL: http://llvm.org/viewvc/llvm-project?rev=171575&view=rev
Log:
Style

Modified:
    lld/trunk/lib/ReaderWriter/ELF/ReferenceKinds.cpp
    lld/trunk/lib/ReaderWriter/ELF/ReferenceKinds.h
    lld/trunk/lib/ReaderWriter/ELF/X86Reference.cpp

Modified: lld/trunk/lib/ReaderWriter/ELF/ReferenceKinds.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ReferenceKinds.cpp?rev=171575&r1=171574&r2=171575&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ReferenceKinds.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ReferenceKinds.cpp Fri Jan  4 18:46:10 2013
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-
 #include "ReferenceKinds.h"
 
 #include "llvm/ADT/StringRef.h"
@@ -15,21 +14,17 @@
 
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ELF.h"
+
 namespace lld {
 namespace elf {
-
-//===----------------------------------------------------------------------===//
-//  KindHandler
-//===----------------------------------------------------------------------===//
-
 KindHandler::KindHandler() {
 }
 
 KindHandler::~KindHandler() {
 }
 
-std::unique_ptr<KindHandler> KindHandler::makeHandler(uint16_t arch,
-                                          llvm::support::endianness endian) {
+std::unique_ptr<KindHandler>
+KindHandler::makeHandler(uint16_t arch, llvm::support::endianness endian) {
   switch(arch) {
   case llvm::ELF::EM_HEXAGON:
     return std::unique_ptr<KindHandler>(new HexagonKindHandler());
@@ -41,9 +36,5 @@
     llvm_unreachable("arch not supported");
   }
 }
-
 } // namespace elf
 } // namespace lld
-
-
-

Modified: lld/trunk/lib/ReaderWriter/ELF/ReferenceKinds.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ReferenceKinds.h?rev=171575&r1=171574&r2=171575&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ReferenceKinds.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ReferenceKinds.h Fri Jan  4 18:46:10 2013
@@ -7,63 +7,58 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/ADT/DenseMap.h"
-
 #include "lld/Core/LLVM.h"
 #include "lld/Core/Reference.h"
 #include "lld/ReaderWriter/WriterELF.h"
 
+#include "llvm/ADT/DenseMap.h"
+
 #include <functional>
 #include <map>
 #include <memory>
 
-#ifndef LLD_READER_WRITER_ELF_REFERENCE_KINDS_H_
-#define LLD_READER_WRITER_ELF_REFERENCE_KINDS_H_
+#ifndef LLD_READER_WRITER_ELF_REFERENCE_KINDS_H
+#define LLD_READER_WRITER_ELF_REFERENCE_KINDS_H
 
 namespace lld {
 namespace elf {
-
-
+/// \brief the abstract interface to Reference::Kind values for ELF files.
 ///
-/// The KindHandler class is the abstract interface to Reference::Kind
-/// values for ELF files.  Particular Kind values (e.g. 3) has a different
-/// meaning for each architecture.
-/// TODO: Needs to be updated for ELF, stubs for now.
+/// Particular Kind values (e.g. 3) has a different meaning for each
+/// architecture.
 ///
+/// TODO: Needs to be updated for ELF, stubs for now.
 class KindHandler {
 public:
   typedef Reference::Kind Kind;
-  
+
   static std::unique_ptr<KindHandler> makeHandler(uint16_t arch,
                                       llvm::support::endianness endian);
   virtual             ~KindHandler();
   virtual Kind        stringToKind(StringRef str) = 0;
   virtual StringRef   kindToString(Kind) = 0;
   virtual bool        isCallSite(Kind) = 0;
-  virtual bool        isPointer(Kind) = 0; 
-  virtual bool        isLazyImmediate(Kind) = 0; 
-  virtual bool        isLazyTarget(Kind) = 0; 
+  virtual bool        isPointer(Kind) = 0;
+  virtual bool        isLazyImmediate(Kind) = 0;
+  virtual bool        isLazyTarget(Kind) = 0;
   virtual void        applyFixup(int32_t reloc, uint64_t addend,
                                  uint8_t *location,
                                  uint64_t fixupAddress,
                                  uint64_t targetAddress) = 0;
-  
+
 protected:
   KindHandler();
 };
 
-
 class HexagonKindHandler : public KindHandler {
 public:
-
-// Note: Reference::Kinds are a another representation of
-// relocation types, using negative values to represent architecture
-// independent reference type.
-// The positive values are the same ones defined in ELF.h and that
-// is what we are using.
+  // Note: Reference::Kinds are a another representation of relocation types,
+  // using negative values to represent architecture independent reference type.
+  // The positive values are the same ones defined in ELF.h and that is what we
+  // are using.
   enum Kinds {
-    none            = llvm::ELF::R_HEX_NONE,
-    invalid=255,         // used to denote an error creating a Reference
+    none    = llvm::ELF::R_HEX_NONE,
+    invalid = 255 // used to denote an error creating a Reference
   };
 
   enum RelocationError {
@@ -76,27 +71,26 @@
   virtual Kind stringToKind(StringRef str);
   virtual StringRef kindToString(Kind);
   virtual bool isCallSite(Kind);
-  virtual bool isPointer(Kind); 
-  virtual bool isLazyImmediate(Kind); 
-  virtual bool isLazyTarget(Kind); 
+  virtual bool isPointer(Kind);
+  virtual bool isLazyImmediate(Kind);
+  virtual bool isLazyTarget(Kind);
   virtual void applyFixup(int32_t reloc, uint64_t addend,
                           uint8_t *location,
                           uint64_t fixupAddress, uint64_t targetAddress);
 
-// A map is used here and in the other handlers but if performace overhead
-// becomes an issue this could be implemented as an array of function pointers.
 private:
+  // A map is used here and in the other handlers but if performace overhead
+  // becomes an issue this could be implemented as an array of function
+  // pointers.
   llvm::DenseMap<int32_t,
-           std::function <int (uint8_t *location, uint64_t fixupAddress,
+           std::function<int (uint8_t *location, uint64_t fixupAddress,
                       uint64_t targetAddress, uint64_t addend)> > _fixupHandler;
-
 };
 
-
 class X86KindHandler : public KindHandler {
 public:
   enum Kinds {
-    invalid,         // used to denote an error creating a Reference
+    invalid, // used to denote an error creating a Reference
     none,
   };
 
@@ -109,29 +103,23 @@
   virtual Kind stringToKind(StringRef str);
   virtual StringRef kindToString(Kind);
   virtual bool isCallSite(Kind);
-  virtual bool isPointer(Kind); 
-  virtual bool isLazyImmediate(Kind); 
-  virtual bool isLazyTarget(Kind); 
+  virtual bool isPointer(Kind);
+  virtual bool isLazyImmediate(Kind);
+  virtual bool isLazyTarget(Kind);
   virtual void applyFixup(int32_t reloc, uint64_t addend, uint8_t *location,
                           uint64_t fixupAddress, uint64_t targetAddress);
 
 private:
   llvm::DenseMap<int32_t,
-           std::function <int (uint8_t *location, uint64_t fixupAddress,
+           std::function<int (uint8_t *location, uint64_t fixupAddress,
                       uint64_t targetAddress, uint64_t addend)> > _fixupHandler;
 };
 
 class PPCKindHandler : public KindHandler {
 public:
-
-// Note: Reference::Kinds are a another representation of
-// relocation types, using negative values to represent architecture
-// independent reference type.
-// The positive values are the same ones defined in ELF.h and that
-// is what we are using.
   enum Kinds {
-    none            = llvm::ELF::R_PPC_NONE,
-    invalid=255,         // used to denote an error creating a Reference
+    none    = llvm::ELF::R_PPC_NONE,
+    invalid = 255, // used to denote an error creating a Reference
   };
 
   enum RelocationError {
@@ -144,24 +132,19 @@
   virtual Kind stringToKind(StringRef str);
   virtual StringRef kindToString(Kind);
   virtual bool isCallSite(Kind);
-  virtual bool isPointer(Kind); 
-  virtual bool isLazyImmediate(Kind); 
-  virtual bool isLazyTarget(Kind); 
+  virtual bool isPointer(Kind);
+  virtual bool isLazyImmediate(Kind);
+  virtual bool isLazyTarget(Kind);
   virtual void applyFixup(int32_t reloc, uint64_t addend,
                           uint8_t *location,
                           uint64_t fixupAddress, uint64_t targetAddress);
 
 private:
   llvm::DenseMap<int32_t,
-           std::function <int (uint8_t *location, uint64_t fixupAddress,
+           std::function<int (uint8_t *location, uint64_t fixupAddress,
                       uint64_t targetAddress, uint64_t addend)> > _fixupHandler;
-
 };
+} // end namespace elf
+} // end namespace lld
 
-} // namespace elf
-} // namespace lld
-
-
-
-#endif // LLD_READER_WRITER_ELF_REFERENCE_KINDS_H_
-
+#endif

Modified: lld/trunk/lib/ReaderWriter/ELF/X86Reference.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86Reference.cpp?rev=171575&r1=171574&r2=171575&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86Reference.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86Reference.cpp Fri Jan  4 18:46:10 2013
@@ -6,41 +6,33 @@
 // License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
-
+///
+/// \file
+/// The following relocation routines are derived from the
+/// SYSTEM V APPLICATION BINARY INTERFACE: Intel386 Architecture Processor
+/// Supplement (Fourth Edition)
+/// Symbols used:
+///   P: Place, address of the field being relocated, r_offset
+///   S: Value of the symbol whose index resides in the relocation entry.
+///   A: Addend used to compute the value, r_addend
+///
+//===----------------------------------------------------------------------===//
 
 #include "ReferenceKinds.h"
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 
+#include "llvm/Support/ELF.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/ELF.h"
 
 namespace lld {
 namespace elf {
-
-//===----------------------------------------------------------------------===//
-//  X86KindHandler
-//  TODO: more to do here
-//===----------------------------------------------------------------------===//
-
 X86KindHandler::~X86KindHandler() {
 }
 
-/// \brief The following relocation routines are derived from the
-///  SYSTEM V APPLICATION BINARY INTERFACE: Intel386 Architecture Processor
-///  Supplement (Fourth Edition)
-/// Symbols used:
-///  P: Place, address of the field being relocated, r_offset
-///  S: Value of the symbol whose index resides in the relocation entry.
-///  A: Addend used to compute the value, r_addend
-
-namespace x86 {
-int relocNone(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) {
-  return X86KindHandler::NoError;
-}
-
+namespace {
 /// \brief R_386_32 - word32:  S + A
 int reloc32(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) {
   int32_t result = (uint32_t)(S + A);
@@ -48,6 +40,7 @@
             (uint32_t)*reinterpret_cast<llvm::support::ulittle32_t *>(location);
   return X86KindHandler::NoError;
 }
+
 /// \brief R_386_PC32 - word32: S + A - P
 int relocPC32(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) {
   uint32_t result = (uint32_t)((S + A) - P);
@@ -55,12 +48,11 @@
             (uint32_t)*reinterpret_cast<llvm::support::ulittle32_t *>(location);
   return X86KindHandler::NoError;
 }
-
-} // namespace x86
+} // end anon namespace
 
 X86KindHandler::X86KindHandler(){
-  _fixupHandler[llvm::ELF::R_386_32] = x86::reloc32;
-  _fixupHandler[llvm::ELF::R_386_PC32] = x86::relocPC32;
+  _fixupHandler[llvm::ELF::R_386_32] = reloc32;
+  _fixupHandler[llvm::ELF::R_386_PC32] = relocPC32;
 }
 
 Reference::Kind X86KindHandler::stringToKind(StringRef str) {
@@ -116,6 +108,5 @@
     }
   }
 }
-
-} // namespace elf
-} // namespace lld
+} // end namespace elf
+} // end namespace lld





More information about the llvm-commits mailing list