Browse Source

Merge topic 'AutoExport-vftable'

f513781bc5 WINDOWS_EXPORT_ALL_SYMBOLS: Export vftable symbol

Acked-by: Kitware Robot <[email protected]>
Acked-by: buildbot <[email protected]>
Merge-request: !8201
Brad King 2 years ago
parent
commit
b297b63f17

+ 3 - 1
Source/bindexplib.cxx

@@ -281,6 +281,7 @@ public:
           // the symbol
           const char* scalarPrefix = "??_G";
           const char* vectorPrefix = "??_E";
+          const char* vftablePrefix = "??_7";
           // The original code had a check for
           //     symbol.find("real@") == std::string::npos)
           // but this disallows member functions with the name "real".
@@ -302,7 +303,8 @@ public:
                   this->DataSymbols.insert(symbol);
                 } else {
                   if (pSymbolTable->Type || !(SectChar & IMAGE_SCN_MEM_READ) ||
-                      (SectChar & IMAGE_SCN_MEM_EXECUTE)) {
+                      (SectChar & IMAGE_SCN_MEM_EXECUTE) ||
+                      (symbol.compare(0, 4, vftablePrefix) == 0)) {
                     this->Symbols.insert(symbol);
                   }
                 }

+ 9 - 0
Tests/RunCMake/AutoExportDll/hello.cxx

@@ -12,3 +12,12 @@ void hello()
 }
 void Hello::operator delete[](void*){};
 void Hello::operator delete(void*){};
+
+#ifdef HELLO_VFTABLE
+HelloVFTable::HelloVFTable()
+{
+}
+HelloVFTable::~HelloVFTable()
+{
+}
+#endif

+ 17 - 0
Tests/RunCMake/AutoExportDll/hello.h

@@ -16,3 +16,20 @@ public:
   static void operator delete[](void*);
   static void operator delete(void*);
 };
+
+// In the MSVC ABI, a delegating constructor references the vftable.
+#if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)
+#  define HELLO_VFTABLE
+#endif
+#ifdef HELLO_VFTABLE
+class HelloVFTable
+{
+public:
+  HelloVFTable();
+  HelloVFTable(int)
+    : HelloVFTable()
+  {
+  }
+  virtual ~HelloVFTable();
+};
+#endif

+ 3 - 0
Tests/RunCMake/AutoExportDll/say.cxx

@@ -52,6 +52,9 @@ int main()
   printf("\n");
 #ifdef HAS_JUSTNOP
   justnop();
+#endif
+#ifdef HELLO_VFTABLE
+  HelloVFTable helloVFTable(1);
 #endif
   return 0;
 }