OSDN Git Service

Add missing vtable anchors
authorWeiming Zhao <wmzhao.code@gmail.com>
Wed, 11 Apr 2018 23:09:20 +0000 (23:09 +0000)
committerWeiming Zhao <wmzhao.code@gmail.com>
Wed, 11 Apr 2018 23:09:20 +0000 (23:09 +0000)
Summary: This patch adds anchor() for MemoryBuffer, raw_fd_ostream, RTDyldMemoryManager, SectionMemoryManager, etc.

Reviewers: jlebar, eli.friedman, dblaikie

Reviewed By: dblaikie

Subscribers: mehdi_amini, mgorny, dblaikie, weimingz, llvm-commits

Differential Revision: https://reviews.llvm.org/D45244

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329861 91177308-0d34-0410-b5e6-96231b3b80d8

12 files changed:
include/llvm/ExecutionEngine/ObjectMemoryBuffer.h
include/llvm/ExecutionEngine/RTDyldMemoryManager.h
include/llvm/ExecutionEngine/SectionMemoryManager.h
include/llvm/Support/MemoryBuffer.h
include/llvm/Support/raw_ostream.h
lib/ExecutionEngine/MCJIT/MCJIT.cpp
lib/ExecutionEngine/MCJIT/MCJIT.h
lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
lib/ExecutionEngine/SectionMemoryManager.cpp
lib/LTO/LLVMBuild.txt
lib/Support/MemoryBuffer.cpp
lib/Support/raw_ostream.cpp

index 0f00ad0..0356753 100644 (file)
@@ -56,6 +56,7 @@ public:
 private:
   SmallVector<char, 0> SV;
   std::string BufferName;
+  void anchor() override;
 };
 
 } // namespace llvm
index ee75202..23d651f 100644 (file)
@@ -47,6 +47,9 @@ public:
   /// newly loaded object.
   virtual void notifyObjectLoaded(ExecutionEngine *EE,
                                   const object::ObjectFile &) {}
+
+private:
+  void anchor() override;
 };
 
 // RuntimeDyld clients often want to handle the memory management of
@@ -142,6 +145,9 @@ protected:
   };
   typedef std::vector<EHFrame> EHFrameInfos;
   EHFrameInfos EHFrames;
+
+private:
+  void anchor() override;
 };
 
 // Create wrappers for C Binding types (see CBindingWrapping.h).
index d76e371..ee7978c 100644 (file)
@@ -182,6 +182,8 @@ private:
   std::error_code applyMemoryGroupPermissions(MemoryGroup &MemGroup,
                                               unsigned Permissions);
 
+  void anchor() override;
+
   MemoryGroup CodeMem;
   MemoryGroup RWDataMem;
   MemoryGroup RODataMem;
index 2997ae4..535579e 100644 (file)
@@ -148,6 +148,9 @@ public:
   virtual BufferKind getBufferKind() const = 0;
 
   MemoryBufferRef getMemBufferRef() const;
+
+private:
+  virtual void anchor();
 };
 
 /// This class is an extension of MemoryBuffer, which allows copy-on-write
index d11f5a8..1421201 100644 (file)
@@ -329,6 +329,8 @@ private:
   /// Copy data into the buffer. Size must not be greater than the number of
   /// unused bytes in the buffer.
   void copy_to_buffer(const char *Ptr, size_t Size);
+
+  virtual void anchor();
 };
 
 /// An abstract base class for streams implementations that also support a
@@ -336,6 +338,7 @@ private:
 /// but needs to patch in a header that needs to know the output size.
 class raw_pwrite_stream : public raw_ostream {
   virtual void pwrite_impl(const char *Ptr, size_t Size, uint64_t Offset) = 0;
+  void anchor() override;
 
 public:
   explicit raw_pwrite_stream(bool Unbuffered = false)
@@ -383,6 +386,8 @@ class raw_fd_ostream : public raw_pwrite_stream {
   /// Set the flag indicating that an output error has been encountered.
   void error_detected(std::error_code EC) { this->EC = EC; }
 
+  void anchor() override;
+
 public:
   /// Open the specified file for writing. If an error occurs, information
   /// about the error is put into EC, and the stream should be immediately
index 438e656..eb99312 100644 (file)
@@ -28,6 +28,8 @@
 
 using namespace llvm;
 
+void llvm::ObjectMemoryBuffer::anchor() {}
+
 namespace {
 
 static struct RegisterJIT {
@@ -665,3 +667,5 @@ LinkingSymbolResolver::findSymbol(const std::string &Name) {
     return nullptr;
   return ClientResolver->findSymbol(Name);
 }
+
+void LinkingSymbolResolver::anchor() {}
index 110cfa6..7ac7924 100644 (file)
@@ -42,6 +42,7 @@ public:
 private:
   MCJIT &ParentEngine;
   std::shared_ptr<LegacyJITSymbolResolver> ClientResolver;
+  void anchor() override;
 };
 
 // About Module states: added->loaded->finalized.
index 99e84b7..e774af0 100644 (file)
@@ -298,4 +298,6 @@ void *RTDyldMemoryManager::getPointerToNamedFunction(const std::string &Name,
   return (void*)Addr;
 }
 
+void RTDyldMemoryManager::anchor() {}
+void MCJITMemoryManager::anchor() {}
 } // namespace llvm
index 2dc66a1..05ab4a0 100644 (file)
@@ -232,6 +232,8 @@ SectionMemoryManager::~SectionMemoryManager() {
 
 SectionMemoryManager::MemoryMapper::~MemoryMapper() {}
 
+void SectionMemoryManager::anchor() {}
+
 namespace {
 // Trivial implementation of SectionMemoryManager::MemoryMapper that just calls
 // into sys::Memory.
index a199331..b74e9a7 100644 (file)
@@ -37,3 +37,4 @@ required_libraries =
  Support
  Target
  TransformUtils
+ MCJIT
index a906465..86dd559 100644 (file)
@@ -531,3 +531,5 @@ MemoryBufferRef MemoryBuffer::getMemBufferRef() const {
   StringRef Identifier = getBufferIdentifier();
   return MemoryBufferRef(Data, Identifier);
 }
+
+void MemoryBuffer::anchor() {}
index 5ecb18f..c0e210b 100644 (file)
@@ -474,6 +474,8 @@ raw_ostream &raw_ostream::indent(unsigned NumSpaces) {
   return *this;
 }
 
+void raw_ostream::anchor() {}
+
 //===----------------------------------------------------------------------===//
 //  Formatted Output
 //===----------------------------------------------------------------------===//
@@ -727,6 +729,8 @@ bool raw_fd_ostream::has_colors() const {
   return sys::Process::FileDescriptorHasColors(FD);
 }
 
+void raw_fd_ostream::anchor() {}
+
 //===----------------------------------------------------------------------===//
 //  outs(), errs(), nulls()
 //===----------------------------------------------------------------------===//
@@ -804,3 +808,5 @@ uint64_t raw_null_ostream::current_pos() const {
 
 void raw_null_ostream::pwrite_impl(const char *Ptr, size_t Size,
                                    uint64_t Offset) {}
+
+void raw_pwrite_stream::anchor() {}