+#ifdef TARGET_WIN32_MSVC
+#define DLL_ENTRY_POINT "DllMain"
+
+static void
+emit_library_info (MonoAotCompile *acfg)
+{
+ // Only include for shared libraries linked directly from generated object.
+ if (link_shared_library (acfg)) {
+ char *name = NULL;
+ char symbol [MAX_SYMBOL_SIZE];
+
+ // Ask linker to export all global symbols.
+ emit_section_change (acfg, ".drectve", 0);
+ for (guint i = 0; i < acfg->globals->len; ++i) {
+ name = (char *)g_ptr_array_index (acfg->globals, i);
+ g_assert (name != NULL);
+ sprintf_s (symbol, MAX_SYMBOL_SIZE, " /EXPORT:%s", name);
+ emit_string (acfg, symbol);
+ }
+
+ // Emit DLLMain function, needed by MSVC linker for DLL's.
+ // NOTE, DllMain should not go into exports above.
+ emit_section_change (acfg, ".text", 0);
+ emit_global (acfg, DLL_ENTRY_POINT, TRUE);
+ emit_label (acfg, DLL_ENTRY_POINT);
+
+ // Simple implementation of DLLMain, just returning TRUE.
+ // For more information about DLLMain: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682583(v=vs.85).aspx
+ fprintf (acfg->fp, "movl $1, %%eax\n");
+ fprintf (acfg->fp, "ret\n");
+
+ // Inform linker about our dll entry function.
+ emit_section_change (acfg, ".drectve", 0);
+ emit_string (acfg, "/ENTRY:" DLL_ENTRY_POINT);
+ return;
+ }
+}
+
+#else
+
+static inline void
+emit_library_info (MonoAotCompile *acfg)
+{
+ return;
+}
+#endif
+