Set visibility option to hidden (#21924)
authorAdeel Mujahid <adeelbm@outlook.com>
Sat, 9 Feb 2019 01:24:59 +0000 (03:24 +0200)
committerJan Vorlicek <janvorli@microsoft.com>
Sat, 9 Feb 2019 01:24:59 +0000 (02:24 +0100)
51 files changed:
CMakeLists.txt
build.sh
configurecompiler.cmake
src/ToolBox/SOS/Strike/exts.h
src/ToolBox/SOS/Strike/sos_stacktrace.h
src/ToolBox/SOS/Strike/strike.cpp
src/ToolBox/SOS/lldbplugin/sosplugin.cpp
src/corefx/System.Globalization.Native/CMakeLists.txt
src/debug/daccess/daccess.cpp
src/debug/daccess/dacdbiimpl.h
src/debug/daccess/nidump.cpp
src/debug/di/cordb.cpp
src/debug/di/process.cpp
src/dlls/dbgshim/dbgshim.cpp
src/dlls/dbgshim/dbgshim.h
src/dlls/mscordbi/mscordbi.cpp
src/dlls/mscoree/coreclr/CMakeLists.txt
src/dlls/mscoree/mscoree.cpp
src/dlls/mscoree/unixinterface.cpp
src/gc/gcload.cpp
src/inc/crtwrap.h
src/jit/ee_il_dll.cpp
src/nativeresources/rctocpp.awk
src/pal/inc/pal.h
src/pal/inc/pal_mstypes.h
src/pal/inc/rt/guiddef.h
src/pal/inc/rt/palrt.h
src/pal/src/CMakeLists.txt
src/pal/src/cruntime/misc.cpp
src/pal/src/include/pal/module.h
src/pal/src/locale/unicode_data.cpp
src/pal/src/misc/environ.cpp
src/pal/src/safecrt/mbusafecrt_internal.h
src/pal/src/safecrt/memcpy_s.cpp
src/pal/src/safecrt/sprintf_s.cpp
src/pal/src/safecrt/sscanf_s.cpp
src/pal/src/safecrt/swprintf.cpp
src/pal/src/safecrt/vsprintf.cpp
src/pal/src/safecrt/vswprint.cpp
src/pal/src/safecrt/xtoa_s.cpp
src/pal/src/safecrt/xtox_s.inl
src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest1.cpp
src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest2.cpp
src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test1/test1.cpp
src/palrt/bstr.cpp
src/palrt/comem.cpp
src/utilcode/ccomprc.cpp
src/vm/appdomain.hpp
src/vm/corhost.cpp
src/vm/crst.h
src/vm/listlock.h

index a9649e6..5ac693b 100644 (file)
@@ -37,7 +37,7 @@ OPTION(CLR_CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF)
 OPTION(CLR_CMAKE_WARNINGS_ARE_ERRORS "Warnings are errors" ON)
 
 # Ensure that python is present
-find_program(PYTHON NAMES python3 python2 python)
+find_program(PYTHON NAMES python3 python2 python py)
 if (PYTHON STREQUAL "PYTHON-NOTFOUND")
     message(FATAL_ERROR "PYTHON not found: Please install Python 2.7.9 or later from https://www.python.org/downloads/")
 endif()
index 45ac18a..5793981 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -7,7 +7,7 @@ export ghprbCommentBody=
 
 # resolve python-version to use
 if [ "$PYTHON" == "" ] ; then
-    if ! PYTHON=$(command -v python3 || command -v python2 || command -v python)
+    if ! PYTHON=$(command -v python3 || command -v python2 || command -v python || command -v py)
     then
        echo "Unable to locate build-dependency python!" 1>&2
        exit 1
index 5afca2d..d291595 100644 (file)
@@ -482,6 +482,9 @@ if (CLR_CMAKE_PLATFORM_UNIX)
   # as x64 does. It has been causing issues in ARM (https://github.com/dotnet/coreclr/issues/4746)
   add_compile_options(-fsigned-char)
 
+  # We mark the function which needs exporting with DLLEXPORT
+  add_compile_options(-fvisibility=hidden)
+
   # Specify the minimum supported version of macOS
   if(CLR_CMAKE_PLATFORM_DARWIN)
     set(MACOS_VERSION_MIN_FLAGS "-mmacosx-version-min=10.12")
index 36b5230..c66ba7f 100644 (file)
@@ -182,8 +182,16 @@ inline BOOL IsInterrupt()
 //
 #undef DECLARE_API
 
+#ifndef DLLEXPORT
+#ifdef _MSC_VER
+#define DLLEXPORT __declspec(dllexport)
+#else
+#define DLLEXPORT __attribute__ ((visibility ("default")))
+#endif // _MSC_VER
+#endif // DLLEXPORT
+
 #define DECLARE_API(extension)     \
-CPPMOD HRESULT CALLBACK extension(PDEBUG_CLIENT client, PCSTR args)
+CPPMOD DLLEXPORT HRESULT CALLBACK extension(PDEBUG_CLIENT client, PCSTR args)
 
 class __ExtensionCleanUp
 {
index 0af241c..ed2b81b 100644 (file)
@@ -95,7 +95,7 @@ struct StackTrace_SimpleContext
 extern "C" {
 #endif // __cplusplus
 
-HRESULT CALLBACK _EFN_StackTrace(
+DLLEXPORT HRESULT CALLBACK _EFN_StackTrace(
     PDEBUG_CLIENT client,
     __out_ecount(*puiTextLength) WCHAR wszTextOut[],
     size_t *puiTextLength,
@@ -119,7 +119,7 @@ HRESULT CALLBACK _EFN_StackTrace(
 // cbString - number of characters available in the string buffer. 
 // 
 // The output will be truncated of cbString is not long enough for the full stack trace.
-HRESULT CALLBACK _EFN_GetManagedExcepStack(
+DLLEXPORT HRESULT CALLBACK _EFN_GetManagedExcepStack(
     PDEBUG_CLIENT client,
     ULONG64 StackObjAddr,
     __out_ecount(cbString) PSTR szStackString,
@@ -128,7 +128,7 @@ HRESULT CALLBACK _EFN_GetManagedExcepStack(
 
 // _EFN_GetManagedExcepStackW - same as _EFN_GetManagedExcepStack, but returns 
 //                              the stack as a wide string.
-HRESULT CALLBACK _EFN_GetManagedExcepStackW(
+DLLEXPORT HRESULT CALLBACK _EFN_GetManagedExcepStackW(
     PDEBUG_CLIENT client,
     ULONG64 StackObjAddr,
     __out_ecount(cchString) PWSTR wszStackString,
@@ -141,7 +141,7 @@ HRESULT CALLBACK _EFN_GetManagedExcepStackW(
 // szName - a buffer to be filled with the full type name
 // cbName - the number of characters available in the buffer
 //
-HRESULT CALLBACK _EFN_GetManagedObjectName(
+DLLEXPORT HRESULT CALLBACK _EFN_GetManagedObjectName(
     PDEBUG_CLIENT client,
     ULONG64 objAddr,
     __out_ecount(cbName) PSTR szName,
@@ -158,7 +158,7 @@ HRESULT CALLBACK _EFN_GetManagedObjectName(
 // pOffset - the offset from objAddr to the field. This parameter can be NULL.
 //
 // At least one of pValue and pOffset must be non-NULL.
-HRESULT CALLBACK _EFN_GetManagedObjectFieldInfo(
+DLLEXPORT HRESULT CALLBACK _EFN_GetManagedObjectFieldInfo(
     PDEBUG_CLIENT client,
     ULONG64 objAddr,
     __out_ecount (mdNameLen) PSTR szFieldName,
index 2a24245..82af32e 100644 (file)
@@ -15149,7 +15149,7 @@ DECLARE_API(ExposeDML)
 // According to kksharma the Windows debuggers always sign-extend
 // arguments when calling externally, therefore StackObjAddr 
 // conforms to CLRDATA_ADDRESS contract.
-HRESULT CALLBACK 
+HRESULT CALLBACK
 _EFN_GetManagedExcepStack(
     PDEBUG_CLIENT client,
     ULONG64 StackObjAddr,
@@ -15196,7 +15196,7 @@ _EFN_GetManagedExcepStackW(
 // According to kksharma the Windows debuggers always sign-extend
 // arguments when calling externally, therefore objAddr 
 // conforms to CLRDATA_ADDRESS contract.
-HRESULT CALLBACK 
+HRESULT CALLBACK
 _EFN_GetManagedObjectName(
     PDEBUG_CLIENT client,
     ULONG64 objAddr,
@@ -15224,7 +15224,7 @@ _EFN_GetManagedObjectName(
 // According to kksharma the Windows debuggers always sign-extend
 // arguments when calling externally, therefore objAddr 
 // conforms to CLRDATA_ADDRESS contract.
-HRESULT CALLBACK 
+HRESULT CALLBACK
 _EFN_GetManagedObjectFieldInfo(
     PDEBUG_CLIENT client,
     ULONG64 objAddr,
index 1aba481..f575d0d 100644 (file)
@@ -5,7 +5,7 @@
 #include "sosplugin.h"
 
 namespace lldb {
-    bool PluginInitialize (lldb::SBDebugger debugger);
+    DLLEXPORT bool PluginInitialize (lldb::SBDebugger debugger);
 }
 
 bool
index 026e5bb..5e38c6b 100644 (file)
@@ -7,9 +7,6 @@ add_definitions(-DBIT64=1)
 
 set(ICU_HOMEBREW_INC_PATH "/usr/local/opt/icu4c/include")
 
-# We mark the function which needs exporting with DLLEXPORT
-add_compile_options(-fvisibility=hidden)
-
 find_path(UTYPES_H "unicode/utypes.h" PATHS ${ICU_HOMEBREW_INC_PATH})
 if(UTYPES_H STREQUAL UTYPES_H-NOTFOUND)
     message(FATAL_ERROR "Cannot find utypes.h, try installing libicu-dev (or the appropriate package for your platform)")
index 9501376..f70a562 100644 (file)
@@ -40,6 +40,7 @@ HINSTANCE g_thisModule;
 
 extern VOID STDMETHODCALLTYPE TLS_FreeMasterSlotIndex();
 
+DLLEXPORT
 EXTERN_C BOOL WINAPI
 DllMain(HANDLE instance, DWORD reason, LPVOID reserved)
 {
index 403fa7f..cd1b7ad 100644 (file)
@@ -14,6 +14,7 @@
 
 // Prototype for creation function
 STDAPI
+DLLEXPORT
 DacDbiInterfaceInstance(
     ICorDebugDataTarget * pTarget,
     CORDB_ADDRESS baseAddress,
index 9886aad..e61c61d 100644 (file)
@@ -447,7 +447,7 @@ static OptionDependencies g_dependencies[] =
 // 
 
 // This function gets the Dispenser interface given the CLSID and REFIID.
-STDAPI MetaDataGetDispenser(
+DLLEXPORT STDAPI MetaDataGetDispenser(
     REFCLSID     rclsid,    // The class to desired.
     REFIID       riid,      // Interface wanted on class factory.
     LPVOID FAR * ppv)       // Return interface pointer here.
index 4febb51..ed4e4a8 100644 (file)
@@ -130,7 +130,7 @@ STDAPI CreateCordbObject(int iDebuggerVersion, IUnknown ** ppCordb)
 // Notes:
 //    It's inconsistent that this takes a (handle, pid) but hands back an ICorDebug instead of an ICorDebugProcess.
 //    Callers will need to call *ppCordb->DebugActiveProcess(pid).
-STDAPI CoreCLRCreateCordbObjectEx(int iDebuggerVersion, DWORD pid, LPCWSTR lpApplicationGroupId, HMODULE hmodTargetCLR, IUnknown ** ppCordb)
+STDAPI DLLEXPORT CoreCLRCreateCordbObjectEx(int iDebuggerVersion, DWORD pid, LPCWSTR lpApplicationGroupId, HMODULE hmodTargetCLR, IUnknown ** ppCordb)
 {
     if (ppCordb == NULL)
     {
@@ -180,7 +180,7 @@ STDAPI CoreCLRCreateCordbObjectEx(int iDebuggerVersion, DWORD pid, LPCWSTR lpApp
 // Notes:
 //    It's inconsistent that this takes a (handle, pid) but hands back an ICorDebug instead of an ICorDebugProcess.
 //    Callers will need to call *ppCordb->DebugActiveProcess(pid).
-STDAPI CoreCLRCreateCordbObject(int iDebuggerVersion, DWORD pid, HMODULE hmodTargetCLR, IUnknown ** ppCordb)
+STDAPI DLLEXPORT CoreCLRCreateCordbObject(int iDebuggerVersion, DWORD pid, HMODULE hmodTargetCLR, IUnknown ** ppCordb)
 {
     return CoreCLRCreateCordbObjectEx(iDebuggerVersion, pid, NULL, hmodTargetCLR, ppCordb);
 }
@@ -309,7 +309,7 @@ const GUID IID_IDebugRemoteCorDebug = {0x83C91210, 0xA34F, 0x427c, {0xB3, 0x5F,
 // Called by COM to get a class factory for a given CLSID.  If it is one we
 // support, instantiate a class factory object and prepare for create instance.
 //*****************************************************************************
-STDAPI DllGetClassObjectInternal(               // Return code.
+STDAPI DLLEXPORT DllGetClassObjectInternal(               // Return code.
     REFCLSID    rclsid,                 // The class to desired.
     REFIID      riid,                   // Interface wanted on class factory.
     LPVOID FAR  *ppv)                   // Return interface pointer here.
@@ -369,7 +369,7 @@ STDAPI DllGetClassObjectInternal(               // Return code.
 // (we went through the shim). CoreCLR doesn't have a shim and we go back to the COM model so we re-expose
 // DllGetClassObject to make that work.
 
-STDAPI DllGetClassObject(               // Return code.
+STDAPI DLLEXPORT DllGetClassObject(               // Return code.
     REFCLSID    rclsid,                 // The class to desired.
     REFIID      riid,                   // Interface wanted on class factory.
     LPVOID FAR  *ppv)                   // Return interface pointer here.
index 2343122..150d0e3 100644 (file)
@@ -61,7 +61,7 @@ extern RSDebuggingInfo * g_pRSDebuggingInfo;
 //    @dbgtodo attach-bit: need to determine fate of attach bit.
 //
 //---------------------------------------------------------------------------------------
-STDAPI OpenVirtualProcessImpl(
+STDAPI DLLEXPORT OpenVirtualProcessImpl(
     ULONG64 clrInstanceId,
     IUnknown * pDataTarget,
     HMODULE hDacModule,
@@ -172,7 +172,7 @@ STDAPI OpenVirtualProcessImpl(
 // Return Value:
 //    S_OK on success. Else failure
 //---------------------------------------------------------------------------------------
-STDAPI OpenVirtualProcessImpl2(
+STDAPI DLLEXPORT OpenVirtualProcessImpl2(
     ULONG64 clrInstanceId,
     IUnknown * pDataTarget,
     LPCWSTR pDacModulePath,
@@ -195,7 +195,7 @@ STDAPI OpenVirtualProcessImpl2(
 // We'd like a beta1 shim/VS to still be able to open dumps using a CLR v4 Beta2+ mscordbi.dll,
 // so we'll leave this in place (at least until after Beta2 is in wide use).
 //---------------------------------------------------------------------------------------
-STDAPI OpenVirtualProcess2(
+STDAPI DLLEXPORT OpenVirtualProcess2(
     ULONG64 clrInstanceId,
     IUnknown * pDataTarget,
     HMODULE hDacModule,
@@ -213,7 +213,7 @@ STDAPI OpenVirtualProcess2(
 // Public OpenVirtualProcess method to get an ICorDebugProcess4 instance
 // Used directly in CLR v4 pre Beta1 - can probably be safely removed now
 //---------------------------------------------------------------------------------------
-STDAPI OpenVirtualProcess(
+STDAPI DLLEXPORT OpenVirtualProcess(
     ULONG64 clrInstanceId,
     IUnknown * pDataTarget,
     REFIID riid,
index 020dbdc..c3f321a 100644 (file)
@@ -77,6 +77,7 @@ Notes:
 // that can be supported cross-platform.
 //
 //-----------------------------------------------------------------------------
+DLLEXPORT
 HRESULT
 CreateProcessForLaunch(
     __in LPWSTR lpCommandLine,
@@ -137,6 +138,7 @@ CreateProcessForLaunch(
 // ResumeProcess - to be used with the CreateProcessForLaunch resume handle
 //
 //-----------------------------------------------------------------------------
+DLLEXPORT
 HRESULT
 ResumeProcess(
     __in HANDLE hResumeHandle)
@@ -155,6 +157,7 @@ ResumeProcess(
 // CloseResumeHandle - to be used with the CreateProcessForLaunch resume handle
 //
 //-----------------------------------------------------------------------------
+DLLEXPORT
 HRESULT
 CloseResumeHandle(
     __in HANDLE hResumeHandle)
@@ -692,6 +695,7 @@ StartupHelperThread(LPVOID p)
 // ppUnregisterToken -- pointer to put the UnregisterForRuntimeStartup token.
 //
 //-----------------------------------------------------------------------------
+DLLEXPORT
 HRESULT
 RegisterForRuntimeStartup(
     __in DWORD dwProcessId,
@@ -732,6 +736,7 @@ RegisterForRuntimeStartup(
 // ppUnregisterToken -- pointer to put the UnregisterForRuntimeStartup token.
 //
 //-----------------------------------------------------------------------------
+DLLEXPORT
 HRESULT
 RegisterForRuntimeStartupEx(
     __in DWORD dwProcessId,
@@ -780,6 +785,7 @@ RegisterForRuntimeStartupEx(
 //
 // pUnregisterToken -- unregister token from RegisterForRuntimeStartup or NULL.
 //-----------------------------------------------------------------------------
+DLLEXPORT
 HRESULT
 UnregisterForRuntimeStartup(
     __in PVOID pUnregisterToken)
@@ -815,8 +821,9 @@ const int cchEventNameBufferSize = (sizeof(StartupNotifyEventNamePrefix) + sizeo
                                     + 8  // + hex process id DWORD 
                                     + 10 // + decimal session id DWORD 
                                     + 1;  // '\' after session id
-                                        
-HRESULT 
+
+DLLEXPORT
+HRESULT
 GetStartupNotificationEvent(
     __in DWORD debuggeePID,
     __out HANDLE* phStartupEvent)
@@ -1210,6 +1217,7 @@ EnumProcessModulesInternal(
 // Notes:
 //   Callers use  code:CloseCLREnumeration to free the returned arrays.
 //-----------------------------------------------------------------------------
+DLLEXPORT
 HRESULT 
 EnumerateCLRs(
     DWORD debuggeePID, 
@@ -1347,6 +1355,7 @@ EnumerateCLRs(
 // dwArrayLength -- array length originally returned by EnumerateCLRs
 //
 //-----------------------------------------------------------------------------
+DLLEXPORT
 HRESULT 
 CloseCLREnumeration(
     __in HANDLE* pHandleArray,
@@ -1473,6 +1482,7 @@ const WCHAR *c_versionStrFormat = W("%08x;%08x;%p");
 //   The version string is an opaque string that can only be passed back to other 
 //   DbgShim APIs.
 //-----------------------------------------------------------------------------
+DLLEXPORT
 HRESULT 
 CreateVersionStringFromModule(
     __in DWORD pidDebuggee,
@@ -1707,6 +1717,7 @@ CheckDbiAndRuntimeVersion(
 //    the right debug pack is not installed.
 //  else Error. (*ppCordb will be null)
 //-----------------------------------------------------------------------------
+DLLEXPORT
 HRESULT 
 CreateDebuggingInterfaceFromVersionEx(
     __in int iDebuggerVersion,
@@ -1735,7 +1746,8 @@ CreateDebuggingInterfaceFromVersionEx(
 //    the right debug pack is not installed.
 //  else Error. (*ppCordb will be null)
 //-----------------------------------------------------------------------------
-HRESULT 
+DLLEXPORT
+HRESULT
 CreateDebuggingInterfaceFromVersion2(
     __in int iDebuggerVersion,
     __in LPCWSTR szDebuggeeVersion,
@@ -1867,6 +1879,7 @@ Exit:
 //    the right debug pack is not installed.
 //  else Error. (*ppCordb will be null)
 //-----------------------------------------------------------------------------
+DLLEXPORT
 HRESULT 
 CreateDebuggingInterfaceFromVersion(
     __in LPCWSTR szDebuggeeVersion, 
@@ -1960,6 +1973,7 @@ GetContinueStartupEvent(
 // Return:
 //  S_OK on success.
 //-----------------------------------------------------------------------------
+DLLEXPORT
 HRESULT 
 CLRCreateInstance(
     REFCLSID clsid,
index 018058b..e3e7186 100644 (file)
@@ -46,24 +46,24 @@ EXTERN_C HRESULT
 UnregisterForRuntimeStartup(
     __in PVOID pUnregisterToken);
 
-EXTERN_C HRESULT 
+EXTERN_C HRESULT
 GetStartupNotificationEvent(
     __in DWORD debuggeePID,
     __out HANDLE* phStartupEvent);
 
-EXTERN_C HRESULT 
+EXTERN_C HRESULT
 EnumerateCLRs(DWORD debuggeePID, 
     __out HANDLE** ppHandleArrayOut,
     __out LPWSTR** ppStringArrayOut,
     __out DWORD* pdwArrayLengthOut);
 
-EXTERN_C HRESULT 
+EXTERN_C HRESULT
 CloseCLREnumeration(
     __in HANDLE* pHandleArray,
     __in LPWSTR* pStringArray,
     __in DWORD dwArrayLength);
 
-EXTERN_C HRESULT 
+EXTERN_C HRESULT
 CreateVersionStringFromModule(
     __in DWORD pidDebuggee,
     __in LPCWSTR szModuleName,
@@ -71,20 +71,22 @@ CreateVersionStringFromModule(
     __in DWORD cchBuffer,
     __out DWORD* pdwLength);
 
-EXTERN_C HRESULT 
+EXTERN_C HRESULT
 CreateDebuggingInterfaceFromVersionEx(
     __in int iDebuggerVersion,
     __in LPCWSTR szDebuggeeVersion,
     __out IUnknown ** ppCordb);
 
-EXTERN_C HRESULT 
+EXTERN_C
+DLLEXPORT
+HRESULT
 CreateDebuggingInterfaceFromVersion2(
     __in int iDebuggerVersion,
     __in LPCWSTR szDebuggeeVersion,
     __in LPCWSTR szApplicationGroupId,
     __out IUnknown ** ppCordb);
 
-EXTERN_C HRESULT 
+EXTERN_C HRESULT
 CreateDebuggingInterfaceFromVersion(
     __in LPCWSTR szDebuggeeVersion, 
     __out IUnknown ** ppCordb);
index 94b4dc4..cb50b9c 100644 (file)
@@ -18,7 +18,7 @@ extern BOOL WINAPI DbgDllMain(HINSTANCE hInstance, DWORD dwReason,
 // The main dll entry point for this module.  This routine is called by the
 // OS when the dll gets loaded.  Control is simply deferred to the main code.
 //*****************************************************************************
-extern "C"
+DLLEXPORT extern "C"
 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
 {
        // Defer to the main debugging code.
index 2619cba..0729652 100644 (file)
@@ -120,13 +120,18 @@ else()
     list(APPEND CORECLR_LIBRARIES
         ${START_WHOLE_ARCHIVE} # force all PAL objects to be included so all exports are available
         coreclrpal
-        tracepointprovider
         ${END_WHOLE_ARCHIVE}
         mscorrc_debug
         palrt
     )
 endif(WIN32)
 
+if(CMAKE_SYSTEM_NAME STREQUAL Linux)
+    list(APPEND CORECLR_LIBRARIES
+        tracepointprovider
+    )
+endif(CMAKE_SYSTEM_NAME STREQUAL Linux)
+
 if(FEATURE_PERFTRACING)
     list(APPEND CORECLR_LIBRARIES
         eventpipe
index 40cc04f..7701035 100644 (file)
@@ -56,13 +56,13 @@ extern "C" IExecutionEngine* IEE();
 extern "C" BOOL WINAPI _CRT_INIT(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved);
 #endif
 
-extern "C" BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved);
+extern "C" DLLEXPORT BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved);
 
 // For the CoreClr, this is the real DLL entrypoint. We make ourselves the first entrypoint as
 // we need to capture coreclr's hInstance before the C runtime initializes. This function
 // will capture hInstance, let the C runtime initialize and then invoke the "classic"
 // DllMain that initializes everything else.
-extern "C" BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
+extern "C" DLLEXPORT BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
 {
     STATIC_CONTRACT_NOTHROW;
 
@@ -116,7 +116,7 @@ extern "C" BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpRe
 }
 
 extern "C"
-BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
+DLLEXPORT BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
 {
     STATIC_CONTRACT_NOTHROW;
 
@@ -221,7 +221,7 @@ HINSTANCE GetModuleInst()
 // %%Function: MetaDataGetDispenser
 // This function gets the Dispenser interface given the CLSID and REFIID.
 // ---------------------------------------------------------------------------
-STDAPI MetaDataGetDispenser(            // Return HRESULT
+DLLEXPORT STDAPI MetaDataGetDispenser(            // Return HRESULT
     REFCLSID    rclsid,                 // The class to desired.
     REFIID      riid,                   // Interface wanted on class factory.
     LPVOID FAR  *ppv)                   // Return interface pointer here.
@@ -251,7 +251,7 @@ ErrExit:
 // %%Function: GetMetaDataInternalInterface
 // This function gets the IMDInternalImport given the metadata on memory.
 // ---------------------------------------------------------------------------
-STDAPI  GetMetaDataInternalInterface(
+DLLEXPORT STDAPI  GetMetaDataInternalInterface(
     LPVOID      pData,                  // [IN] in memory metadata section
     ULONG       cbData,                 // [IN] size of the metadata section
     DWORD       flags,                  // [IN] MDInternal_OpenForRead or MDInternal_OpenForENC
@@ -280,7 +280,7 @@ STDAPI  GetMetaDataInternalInterface(
 // This function gets the internal scopeless interface given the public
 // scopeless interface.
 // ---------------------------------------------------------------------------
-STDAPI  GetMetaDataInternalInterfaceFromPublic(
+DLLEXPORT STDAPI  GetMetaDataInternalInterfaceFromPublic(
     IUnknown    *pv,                    // [IN] Given interface.
     REFIID      riid,                   // [IN] desired interface
     void        **ppv)                  // [OUT] returned interface
@@ -307,7 +307,7 @@ STDAPI  GetMetaDataInternalInterfaceFromPublic(
 // This function gets the public scopeless interface given the internal
 // scopeless interface.
 // ---------------------------------------------------------------------------
-STDAPI  GetMetaDataPublicInterfaceFromInternal(
+DLLEXPORT STDAPI  GetMetaDataPublicInterfaceFromInternal(
     void        *pv,                    // [IN] Given interface.
     REFIID      riid,                   // [IN] desired interface.
     void        **ppv)                  // [OUT] returned interface
index cf9bbc5..0769ea4 100644 (file)
@@ -161,6 +161,7 @@ extern "C" int coreclr_create_delegate(void*, unsigned int, const char*, const c
 //  HRESULT indicating status of the operation. S_OK if the assembly was successfully executed
 //
 extern "C"
+DLLEXPORT
 int coreclr_initialize(
             const char* exePath,
             const char* appDomainFriendlyName,
@@ -280,6 +281,7 @@ int coreclr_initialize(
 //  HRESULT indicating status of the operation. S_OK if the assembly was successfully executed
 //
 extern "C"
+DLLEXPORT
 int coreclr_shutdown(
             void* hostHandle,
             unsigned int domainId)
@@ -310,6 +312,7 @@ int coreclr_shutdown(
 //  HRESULT indicating status of the operation. S_OK if the assembly was successfully executed
 //
 extern "C"
+DLLEXPORT
 int coreclr_shutdown_2(
             void* hostHandle,
             unsigned int domainId,
@@ -344,6 +347,7 @@ int coreclr_shutdown_2(
 //  HRESULT indicating status of the operation. S_OK if the assembly was successfully executed
 //
 extern "C"
+DLLEXPORT
 int coreclr_create_delegate(
             void* hostHandle,
             unsigned int domainId,
@@ -383,6 +387,7 @@ int coreclr_create_delegate(
 //  HRESULT indicating status of the operation. S_OK if the assembly was successfully executed
 //
 extern "C"
+DLLEXPORT
 int coreclr_execute_assembly(
             void* hostHandle,
             unsigned int domainId,
index 2d157c8..f6977ca 100644 (file)
 #include "gcenv.h"
 #include "gc.h"
 
+#ifndef DLLEXPORT
 #ifdef _MSC_VER
 #define DLLEXPORT __declspec(dllexport)
 #else
 #define DLLEXPORT __attribute__ ((visibility ("default")))
 #endif // _MSC_VER
+#endif // DLLEXPORT
 
 #define GC_EXPORT extern "C" DLLEXPORT
 
index 56f63cb..c6f0525 100644 (file)
 #include <wchar.h>
 #include <stdio.h>
 
-#ifndef PUB
-// PUB is defined to influence method visibility for some compilers.
-#define PUB
-#endif // !PUB
+#ifndef DLLEXPORT
+// DLLEXPORT is defined to influence method visibility for some compilers.
+#define DLLEXPORT
+#endif // !DLLEXPORT
 
 #endif // __CrtWrap_h__
-
index 2dae497..31904cf 100644 (file)
@@ -54,7 +54,7 @@ JitOptions jitOpts = {
 
 /*****************************************************************************/
 
-extern "C" void __stdcall jitStartup(ICorJitHost* jitHost)
+extern "C" DLLEXPORT void __stdcall jitStartup(ICorJitHost* jitHost)
 {
     if (g_jitInitialized)
     {
@@ -159,7 +159,7 @@ void jitShutdown(bool processIsTerminating)
 
 #ifndef FEATURE_MERGE_JIT_AND_ENGINE
 
-extern "C" BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID pvReserved)
+extern "C" DLLEXPORT BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID pvReserved)
 {
     if (dwReason == DLL_PROCESS_ATTACH)
     {
@@ -182,7 +182,7 @@ HINSTANCE GetModuleInst()
     return (g_hInst);
 }
 
-extern "C" void __stdcall sxsJitStartup(CoreClrCallbacks const& cccallbacks)
+extern "C" DLLEXPORT void __stdcall sxsJitStartup(CoreClrCallbacks const& cccallbacks)
 {
 #ifndef SELF_NO_HOST
     InitUtilcode(cccallbacks);
@@ -207,7 +207,7 @@ void* __cdecl operator new(size_t, const CILJitSingletonAllocator&)
 
 ICorJitCompiler* g_realJitCompiler = nullptr;
 
-ICorJitCompiler* __stdcall getJit()
+DLLEXPORT ICorJitCompiler* __stdcall getJit()
 {
     if (ILJitter == nullptr)
     {
index e631021..6f8d597 100644 (file)
@@ -78,7 +78,7 @@ function writefooter(arrayName, tableName)
     print "};";
     print "";
 
-    print "const NativeStringResourceTable " tableName " = {";
+    print "const NativeStringResourceTable " tableName " __attribute__((visibility(\"default\"))) = {";
     print numEntries ",";
     print arrayName "};";
 }
index 67e39ae..3552dea 100644 (file)
@@ -208,8 +208,6 @@ typedef __builtin_va_list va_list;
 
 #define VOID void
 
-#define PUB __attribute__((visibility("default")))
-
 #else // __GNUC__
 
 typedef char * va_list;
@@ -359,7 +357,7 @@ typedef long time_t;
                                         PAL_INITIALIZE_ENSURE_STACK_SIZE | \
                                         PAL_INITIALIZE_REGISTER_SIGNALS)
 
-typedef DWORD (PALAPI *PTHREAD_START_ROUTINE)(LPVOID lpThreadParameter);
+typedef DWORD (PALAPI_NOEXPORT *PTHREAD_START_ROUTINE)(LPVOID lpThreadParameter);
 typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
 
 /******************* PAL-Specific Entrypoints *****************************/
@@ -1577,7 +1575,7 @@ PALAPI
 ResumeThread(
          IN HANDLE hThread);
 
-typedef VOID (PALAPI *PAPCFUNC)(ULONG_PTR dwParam);
+typedef VOID (PALAPI_NOEXPORT *PAPCFUNC)(ULONG_PTR dwParam);
 
 PALIMPORT
 DWORD
@@ -2578,7 +2576,7 @@ OpenFileMappingW(
 #define OpenFileMapping OpenFileMappingA
 #endif
 
-typedef INT_PTR (PALAPI *FARPROC)();
+typedef INT_PTR (PALAPI_NOEXPORT *FARPROC)();
 
 PALIMPORT
 LPVOID
@@ -2679,7 +2677,7 @@ Return value:
     TRUE - success
     FALSE - failure (incorrect ptr, etc.)
 --*/
-BOOL 
+BOOL
 PALAPI
 PAL_LOADUnloadPEFile(void * ptr);
 
@@ -2746,7 +2744,7 @@ GetModuleFileNameExW(
 #define GetModuleFileNameEx GetModuleFileNameExW
 #endif
 
-// Get base address of the module containing a given symbol 
+// Get base address of the module containing a given symbol
 PALAPI
 LPCVOID
 PAL_GetSymbolModuleBase(void *symbol);
@@ -2802,7 +2800,7 @@ typedef struct _MEMORYSTATUSEX {
   DWORDLONG ullAvailExtendedVirtual;
 } MEMORYSTATUSEX, *LPMEMORYSTATUSEX;
 
-PALIMPORT 
+PALIMPORT
 BOOL
 PALAPI
 GlobalMemoryStatusEx(
@@ -3268,7 +3266,7 @@ PAL_nanosleep(
 
 #ifndef FEATURE_PAL_SXS
 
-typedef LONG (PALAPI *PTOP_LEVEL_EXCEPTION_FILTER)(
+typedef LONG (PALAPI_NOEXPORT *PTOP_LEVEL_EXCEPTION_FILTER)(
                            struct _EXCEPTION_POINTERS *ExceptionInfo);
 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
 
@@ -3280,7 +3278,7 @@ SetUnhandledExceptionFilter(
 
 #else // FEATURE_PAL_SXS
 
-typedef EXCEPTION_DISPOSITION (PALAPI *PVECTORED_EXCEPTION_HANDLER)(
+typedef EXCEPTION_DISPOSITION (PALAPI_NOEXPORT *PVECTORED_EXCEPTION_HANDLER)(
                            struct _EXCEPTION_POINTERS *ExceptionPointers);
 
 #endif // FEATURE_PAL_SXS
@@ -4370,62 +4368,62 @@ PALIMPORT int __cdecl toupper(int);
 #define _TRUNCATE ((size_t)-1)
 #endif
 
-PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t) THROW_DECL;
+PALIMPORT DLLEXPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t) THROW_DECL;
 PALIMPORT errno_t __cdecl memmove_s(void *, size_t, const void *, size_t);
 PALIMPORT char * __cdecl _strlwr(char *);
-PALIMPORT int __cdecl _stricmp(const char *, const char *);
-PALIMPORT int __cdecl vsprintf_s(char *, size_t, const char *, va_list);
+PALIMPORT DLLEXPORT int __cdecl _stricmp(const char *, const char *);
+PALIMPORT DLLEXPORT int __cdecl vsprintf_s(char *, size_t, const char *, va_list);
 PALIMPORT char * __cdecl _gcvt_s(char *, int, double, int);
 PALIMPORT int __cdecl __iscsym(int);
 PALIMPORT unsigned char * __cdecl _mbsinc(const unsigned char *);
 PALIMPORT unsigned char * __cdecl _mbsninc(const unsigned char *, size_t);
 PALIMPORT unsigned char * __cdecl _mbsdec(const unsigned char *, const unsigned char *);
-PALIMPORT int __cdecl _wcsicmp(const WCHAR *, const WCHAR*);
+PALIMPORT DLLEXPORT int __cdecl _wcsicmp(const WCHAR *, const WCHAR*);
 PALIMPORT int __cdecl _wcsnicmp(const WCHAR *, const WCHAR *, size_t);
 PALIMPORT int __cdecl _vsnprintf(char *, size_t, const char *, va_list);
-PALIMPORT int __cdecl _vsnprintf_s(char *, size_t, size_t, const char *, va_list);
-PALIMPORT int __cdecl _vsnwprintf_s(WCHAR *, size_t, size_t, const WCHAR *, va_list);
-PALIMPORT int __cdecl _snwprintf_s(WCHAR *, size_t, size_t, const WCHAR *, ...);
-PALIMPORT int __cdecl _snprintf_s(char *, size_t, size_t, const char *, ...);
-PALIMPORT int __cdecl sprintf_s(char *, size_t, const char *, ... );
-PALIMPORT int __cdecl swprintf_s(WCHAR *, size_t, const WCHAR *, ... );
+PALIMPORT DLLEXPORT int __cdecl _vsnprintf_s(char *, size_t, size_t, const char *, va_list);
+PALIMPORT DLLEXPORT int __cdecl _vsnwprintf_s(WCHAR *, size_t, size_t, const WCHAR *, va_list);
+PALIMPORT DLLEXPORT int __cdecl _snwprintf_s(WCHAR *, size_t, size_t, const WCHAR *, ...);
+PALIMPORT DLLEXPORT int __cdecl _snprintf_s(char *, size_t, size_t, const char *, ...);
+PALIMPORT DLLEXPORT int __cdecl sprintf_s(char *, size_t, const char *, ... );
+PALIMPORT DLLEXPORT int __cdecl swprintf_s(WCHAR *, size_t, const WCHAR *, ... );
 PALIMPORT int __cdecl _snwprintf_s(WCHAR *, size_t, size_t, const WCHAR *, ...);
 PALIMPORT int __cdecl vswprintf_s( WCHAR *, size_t, const WCHAR *, va_list);
-PALIMPORT int __cdecl sscanf_s(const char *, const char *, ...);
-PALIMPORT errno_t __cdecl _itow_s(int, WCHAR *, size_t, int);
+PALIMPORT DLLEXPORT int __cdecl sscanf_s(const char *, const char *, ...);
+PALIMPORT DLLEXPORT errno_t __cdecl _itow_s(int, WCHAR *, size_t, int);
 
-PALIMPORT size_t __cdecl PAL_wcslen(const WCHAR *);
-PALIMPORT int __cdecl PAL_wcscmp(const WCHAR*, const WCHAR*);
-PALIMPORT int __cdecl PAL_wcsncmp(const WCHAR *, const WCHAR *, size_t);
-PALIMPORT WCHAR * __cdecl PAL_wcscat(WCHAR *, const WCHAR *);
+PALIMPORT DLLEXPORT size_t __cdecl PAL_wcslen(const WCHAR *);
+PALIMPORT DLLEXPORT int __cdecl PAL_wcscmp(const WCHAR*, const WCHAR*);
+PALIMPORT DLLEXPORT int __cdecl PAL_wcsncmp(const WCHAR *, const WCHAR *, size_t);
+PALIMPORT DLLEXPORT WCHAR * __cdecl PAL_wcscat(WCHAR *, const WCHAR *);
 PALIMPORT WCHAR * __cdecl PAL_wcsncat(WCHAR *, const WCHAR *, size_t);
 PALIMPORT WCHAR * __cdecl PAL_wcscpy(WCHAR *, const WCHAR *);
 PALIMPORT WCHAR * __cdecl PAL_wcsncpy(WCHAR *, const WCHAR *, size_t);
-PALIMPORT const WCHAR * __cdecl PAL_wcschr(const WCHAR *, WCHAR);
-PALIMPORT const WCHAR * __cdecl PAL_wcsrchr(const WCHAR *, WCHAR);
+PALIMPORT DLLEXPORT const WCHAR * __cdecl PAL_wcschr(const WCHAR *, WCHAR);
+PALIMPORT DLLEXPORT const WCHAR * __cdecl PAL_wcsrchr(const WCHAR *, WCHAR);
 PALIMPORT WCHAR _WConst_return * __cdecl PAL_wcspbrk(const WCHAR *, const WCHAR *);
-PALIMPORT WCHAR _WConst_return * __cdecl PAL_wcsstr(const WCHAR *, const WCHAR *);
+PALIMPORT DLLEXPORT WCHAR _WConst_return * __cdecl PAL_wcsstr(const WCHAR *, const WCHAR *);
 PALIMPORT WCHAR * __cdecl PAL_wcstok(WCHAR *, const WCHAR *);
-PALIMPORT size_t __cdecl PAL_wcscspn(const WCHAR *, const WCHAR *);
+PALIMPORT DLLEXPORT size_t __cdecl PAL_wcscspn(const WCHAR *, const WCHAR *);
 PALIMPORT int __cdecl PAL_swprintf(WCHAR *, const WCHAR *, ...);
 PALIMPORT int __cdecl PAL_vswprintf(WCHAR *, const WCHAR *, va_list);
 PALIMPORT int __cdecl PAL_swscanf(const WCHAR *, const WCHAR *, ...);
 PALIMPORT LONG __cdecl PAL_wcstol(const WCHAR *, WCHAR **, int);
-PALIMPORT ULONG __cdecl PAL_wcstoul(const WCHAR *, WCHAR **, int);
+PALIMPORT DLLEXPORT ULONG __cdecl PAL_wcstoul(const WCHAR *, WCHAR **, int);
 PALIMPORT size_t __cdecl PAL_wcsspn (const WCHAR *, const WCHAR *);
 PALIMPORT double __cdecl PAL_wcstod(const WCHAR *, WCHAR **);
 PALIMPORT int __cdecl PAL_iswalpha(WCHAR);
-PALIMPORT int __cdecl PAL_iswprint(WCHAR);
+PALIMPORT DLLEXPORT int __cdecl PAL_iswprint(WCHAR);
 PALIMPORT int __cdecl PAL_iswupper(WCHAR);
-PALIMPORT int __cdecl PAL_iswspace(WCHAR);
+PALIMPORT DLLEXPORT int __cdecl PAL_iswspace(WCHAR);
 PALIMPORT int __cdecl PAL_iswdigit(WCHAR);
 PALIMPORT int __cdecl PAL_iswxdigit(WCHAR);
 PALIMPORT WCHAR __cdecl PAL_towlower(WCHAR);
 PALIMPORT WCHAR __cdecl PAL_towupper(WCHAR);
 
 PALIMPORT WCHAR * __cdecl _wcslwr(WCHAR *);
-PALIMPORT ULONGLONG _wcstoui64(const WCHAR *, WCHAR **, int);
-PALIMPORT errno_t __cdecl _i64tow_s(long long, WCHAR *, size_t, int);
+PALIMPORT DLLEXPORT ULONGLONG _wcstoui64(const WCHAR *, WCHAR **, int);
+PALIMPORT DLLEXPORT errno_t __cdecl _i64tow_s(long long, WCHAR *, size_t, int);
 PALIMPORT int __cdecl _wtoi(const WCHAR *);
 
 #ifdef __cplusplus
@@ -4581,9 +4579,9 @@ inline __int64 abs(__int64 _X) {
 }
 #endif
 
-PALIMPORT void * __cdecl malloc(size_t);
-PALIMPORT void   __cdecl free(void *);
-PALIMPORT void * __cdecl realloc(void *, size_t);
+PALIMPORT DLLEXPORT void * __cdecl malloc(size_t);
+PALIMPORT DLLEXPORT void   __cdecl free(void *);
+PALIMPORT DLLEXPORT void * __cdecl realloc(void *, size_t);
 PALIMPORT char * __cdecl _strdup(const char *);
 
 #if defined(_MSC_VER)
@@ -4602,7 +4600,7 @@ PALIMPORT char * __cdecl _strdup(const char *);
 PALIMPORT PAL_NORETURN void __cdecl exit(int);
 int __cdecl atexit(void (__cdecl *function)(void));
 
-PALIMPORT void __cdecl qsort(void *, size_t, size_t, int (__cdecl *)(const void *, const void *));
+PALIMPORT DLLEXPORT void __cdecl qsort(void *, size_t, size_t, int (__cdecl *)(const void *, const void *));
 PALIMPORT void * __cdecl bsearch(const void *, const void *, size_t, size_t,
 int (__cdecl *)(const void *, const void *));
 
@@ -4630,7 +4628,7 @@ PALIMPORT char * __cdecl ctime(const time_t *);
 
 PALIMPORT int __cdecl _open_osfhandle(INT_PTR, int);
 PALIMPORT int __cdecl _close(int);
-PALIMPORT int __cdecl _flushall();
+PALIMPORT DLLEXPORT int __cdecl _flushall();
 
 #ifdef PAL_STDCPP_COMPAT
 
@@ -4663,14 +4661,14 @@ typedef struct _FILE PAL_FILE;
 
 PALIMPORT int __cdecl PAL_fclose(PAL_FILE *);
 PALIMPORT void __cdecl PAL_setbuf(PAL_FILE *, char*);
-PALIMPORT int __cdecl PAL_fflush(PAL_FILE *);
+PALIMPORT DLLEXPORT int __cdecl PAL_fflush(PAL_FILE *);
 PALIMPORT size_t __cdecl PAL_fwrite(const void *, size_t, size_t, PAL_FILE *);
 PALIMPORT size_t __cdecl PAL_fread(void *, size_t, size_t, PAL_FILE *);
 PALIMPORT char * __cdecl PAL_fgets(char *, int, PAL_FILE *);
 PALIMPORT int __cdecl PAL_fputs(const char *, PAL_FILE *);
 PALIMPORT int __cdecl PAL_fputc(int c, PAL_FILE *stream);
 PALIMPORT int __cdecl PAL_putchar(int c);
-PALIMPORT int __cdecl PAL_fprintf(PAL_FILE *, const char *, ...);
+PALIMPORT DLLEXPORT int __cdecl PAL_fprintf(PAL_FILE *, const char *, ...);
 PALIMPORT int __cdecl PAL_vfprintf(PAL_FILE *, const char *, va_list);
 PALIMPORT int __cdecl PAL_fseek(PAL_FILE *, LONG, int);
 PALIMPORT LONG __cdecl PAL_ftell(PAL_FILE *);
@@ -4682,7 +4680,7 @@ PALIMPORT int __cdecl PAL_fgetc(PAL_FILE *stream);
 PALIMPORT int __cdecl PAL_ungetc(int c, PAL_FILE *stream);
 PALIMPORT int __cdecl PAL_setvbuf(PAL_FILE *stream, char *, int, size_t);
 PALIMPORT WCHAR * __cdecl PAL_fgetws(WCHAR *, int, PAL_FILE *);
-PALIMPORT int __cdecl PAL_fwprintf(PAL_FILE *, const WCHAR *, ...);
+PALIMPORT DLLEXPORT int __cdecl PAL_fwprintf(PAL_FILE *, const WCHAR *, ...);
 PALIMPORT int __cdecl PAL_vfwprintf(PAL_FILE *, const WCHAR *, va_list);
 PALIMPORT int __cdecl PAL_wprintf(const WCHAR*, ...);
 
@@ -4701,7 +4699,7 @@ PALIMPORT PAL_FILE * __cdecl _wfsopen(const WCHAR *, const WCHAR *, int);
 PALIMPORT int __cdecl rand(void);
 PALIMPORT void __cdecl srand(unsigned int);
 
-PALIMPORT int __cdecl printf(const char *, ...);
+PALIMPORT DLLEXPORT int __cdecl printf(const char *, ...);
 PALIMPORT int __cdecl vprintf(const char *, va_list);
 
 #ifdef _MSC_VER
@@ -4710,10 +4708,10 @@ PALIMPORT int __cdecl vprintf(const char *, va_list);
 #define PAL_get_caller 0
 #endif
 
-PALIMPORT PAL_FILE * __cdecl PAL_get_stdout(int caller);
+PALIMPORT DLLEXPORT PAL_FILE * __cdecl PAL_get_stdout(int caller);
 PALIMPORT PAL_FILE * __cdecl PAL_get_stdin(int caller);
-PALIMPORT PAL_FILE * __cdecl PAL_get_stderr(int caller);
-PALIMPORT int * __cdecl PAL_errno(int caller);
+PALIMPORT DLLEXPORT PAL_FILE * __cdecl PAL_get_stderr(int caller);
+PALIMPORT DLLEXPORT int * __cdecl PAL_errno(int caller);
 
 #ifdef PAL_STDCPP_COMPAT
 #define PAL_stdout (PAL_get_stdout(PAL_get_caller))
index 9f305c6..78c6b04 100644 (file)
@@ -96,17 +96,20 @@ extern "C" {
 #else
 #define PALIMPORT   __declspec(dllimport)
 #endif
+#define DLLEXPORT __declspec(dllexport)
 #define PAL_NORETURN __declspec(noreturn)
 
 #else
 
 #define PALIMPORT
+#define DLLEXPORT __attribute__((visibility("default")))
 #define PAL_NORETURN    __attribute__((noreturn))
 
 #endif
 
-#define PALAPI      __cdecl
-#define PALAPIV     __cdecl
+#define PALAPI             DLLEXPORT __cdecl
+#define PALAPI_NOEXPORT    __cdecl
+#define PALAPIV            __cdecl
 
 ////////////////////////////////////////////////////////////////////////
 // Type attribute stuff
index 12e51c8..392df60 100644 (file)
@@ -18,7 +18,7 @@
 
 #ifdef INITGUID
 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
-        EXTERN_C const GUID DECLSPEC_SELECTANY name \
+        EXTERN_C DLLEXPORT const GUID DECLSPEC_SELECTANY name \
                 = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
 #else
 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
index 9ff6ea5..78190fc 100644 (file)
@@ -388,10 +388,10 @@ typedef WCHAR *BSTR;
 
 STDAPI_(BSTR) SysAllocString(const OLECHAR*);
 STDAPI_(BSTR) SysAllocStringLen(const OLECHAR*, UINT);
-STDAPI_(BSTR) SysAllocStringByteLen(const char *, UINT);
+DLLEXPORT STDAPI_(BSTR) SysAllocStringByteLen(const char *, UINT);
 STDAPI_(void) SysFreeString(BSTR);
 STDAPI_(UINT) SysStringLen(BSTR);
-STDAPI_(UINT) SysStringByteLen(BSTR);
+DLLEXPORT STDAPI_(UINT) SysStringByteLen(BSTR);
 
 typedef double DATE;
 
index be5b5bd..829638b 100644 (file)
@@ -295,10 +295,18 @@ add_library(coreclrpal
   ${LIBUNWIND_OBJECTS}
 )
 
-add_library(tracepointprovider
-  STATIC
-  misc/tracepointprovider.cpp
-)
+# There is only one function exported in 'tracepointprovider.cpp' namely 'PAL_InitializeTracing',
+# which is guarded with '#if defined(__linux__)'. On macOS, Xcode issues the following warning:
+#
+# > warning: /Applications/Xcode-9.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib:
+# > warning for library: libtracepointprovider.a the table of contents is empty (no object file members in the library define global symbols)
+#
+if(CMAKE_SYSTEM_NAME STREQUAL Linux)
+  add_library(tracepointprovider
+    STATIC
+    misc/tracepointprovider.cpp
+  )
+endif(CMAKE_SYSTEM_NAME STREQUAL Linux)
 
 if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
   find_library(COREFOUNDATION CoreFoundation)
index 9e5acf6..68427f5 100644 (file)
@@ -138,7 +138,6 @@ Function:
 
 See MSDN for more details.
 --*/
-
 PAL_time_t 
 __cdecl
 PAL_mktime(struct PAL_tm *tm)
@@ -215,7 +214,6 @@ PAL_time(PAL_time_t *tloc)
     return result;
 }
 
-
 PALIMPORT 
 void __cdecl 
 PAL_qsort(void *base, size_t nmemb, size_t size, 
@@ -245,6 +243,7 @@ PAL_qsort(void *base, size_t nmemb, size_t size,
     PERF_EXIT(qsort);
 }
 
+DLLEXPORT
 PALIMPORT 
 void * __cdecl 
 PAL_bsearch(const void *key, const void *base, size_t nmemb, size_t size,
@@ -300,6 +299,7 @@ PAL_memcpy
 Overlapping buffer-safe version of memcpy.
 See MSDN doc for memcpy
 --*/
+DLLEXPORT
 EXTERN_C
 PALIMPORT
 void *PAL_memcpy (void *dest, const void *src, size_t count)
index aacc326..66ac238 100644 (file)
@@ -25,9 +25,9 @@ extern "C"
 {
 #endif // __cplusplus
 
-typedef BOOL (PALAPI *PDLLMAIN)(HINSTANCE, DWORD, LPVOID);   /* entry point of module */
-typedef HINSTANCE (PALAPI *PREGISTER_MODULE)(LPCSTR);           /* used to create the HINSTANCE for above DLLMain entry point */
-typedef VOID (PALAPI *PUNREGISTER_MODULE)(HINSTANCE);           /* used to cleanup the HINSTANCE for above DLLMain entry point */
+typedef BOOL (PALAPI_NOEXPORT *PDLLMAIN)(HINSTANCE, DWORD, LPVOID);   /* entry point of module */
+typedef HINSTANCE (PALAPI_NOEXPORT *PREGISTER_MODULE)(LPCSTR);           /* used to create the HINSTANCE for above DLLMain entry point */
+typedef VOID (PALAPI_NOEXPORT *PUNREGISTER_MODULE)(HINSTANCE);           /* used to cleanup the HINSTANCE for above DLLMain entry point */
 
 typedef struct _MODSTRUCT
 {
index f9ba166..4f7a51f 100644 (file)
@@ -22,7 +22,7 @@ Abstract:
 
 #if !HAVE_COREFOUNDATION
 
-CONST UnicodeDataRec UnicodeData[] = {
+CONST UnicodeDataRec UnicodeData[] DLLEXPORT = {
 
 
 { 0x0000,      0x0020, 0x0000, 0 },
@@ -1846,7 +1846,7 @@ CONST UnicodeDataRec UnicodeData[] = {
 { 0xffe0,      0x0010, 0x0000, 13 },
 };
 
-CONST UINT UNICODE_DATA_SIZE = sizeof(UnicodeData)/sizeof(UnicodeDataRec);
-CONST UINT UNICODE_DATA_DIRECT_ACCESS = 256;
+CONST UINT UNICODE_DATA_SIZE DLLEXPORT = sizeof(UnicodeData)/sizeof(UnicodeDataRec);
+CONST UINT UNICODE_DATA_DIRECT_ACCESS DLLEXPORT = 256;
 
 #endif // !HAVE_COREFOUNDATION
index 9fc1346..f73d7ec 100644 (file)
@@ -1050,6 +1050,7 @@ See MSDN for more details.
 Note:   The BSD implementation can cause
         memory leaks. See man pages for more details.
 --*/
+DLLEXPORT
 int
 __cdecl 
 _putenv( const char * envstring )
@@ -1079,7 +1080,7 @@ Function : PAL_getenv
     
 See MSDN for more details.
 --*/
-char * __cdecl PAL_getenv(const char *varname)
+DLLEXPORT char * __cdecl PAL_getenv(const char *varname)
 {
     char *retval;
 
index 9a3aa1c..973c869 100644 (file)
 #include "pal_char16.h"
 #include "pal_mstypes.h"
 
+#ifndef DLLEXPORT
+#ifdef _MSC_VER
+#define DLLEXPORT __declspec(dllexport)
+#else
+#define DLLEXPORT __attribute__ ((visibility ("default")))
+#endif // _MSC_VER
+#endif // !DLLEXPORT
+
 typedef __builtin_va_list va_list;
 
 // The ifdef below are to accommodate Unix build
index a75ec41..db3bb5f 100644 (file)
@@ -49,7 +49,7 @@
 *
 *******************************************************************************/
 
-errno_t __cdecl memcpy_s(
+DLLEXPORT errno_t __cdecl memcpy_s(
     void * dst,
     size_t sizeInBytes,
     const void * src,
index edfb768..79a4e43 100644 (file)
@@ -65,8 +65,7 @@
 *Exceptions:
 *
 *******************************************************************************/
-
-int sprintf_s (
+DLLEXPORT int sprintf_s (
         char *string,
         size_t sizeInBytes,
         const char *format,
@@ -81,7 +80,7 @@ int sprintf_s (
         return ret;
 }
 
-int _snprintf_s (
+DLLEXPORT int _snprintf_s (
         char *string,
         size_t sizeInBytes,
         size_t count,
index 7a481b5..686513d 100644 (file)
@@ -189,7 +189,7 @@ static int __cdecl vnwscan_fn (
 *
 *******************************************************************************/
 
-int __cdecl sscanf_s (
+DLLEXPORT int __cdecl sscanf_s (
         const char *string,
         const char *format,
         ...
index 2fbfcfa..1d8cf42 100644 (file)
@@ -80,7 +80,7 @@
 *
 *******************************************************************************/
 
-int __cdecl swprintf_s (
+DLLEXPORT int __cdecl swprintf_s (
         wchar_t *string,
         size_t sizeInWords,
         const wchar_t *format,
@@ -99,7 +99,7 @@ int __cdecl swprintf_s (
     return ret;
 }
 
-int __cdecl _snwprintf_s (
+DLLEXPORT int __cdecl _snwprintf_s (
         wchar_t *string,
         size_t sizeInWords,
         size_t count,
index e1a94d0..6d4b786 100644 (file)
@@ -119,7 +119,7 @@ int __cdecl _vsnprintf_helper (
         return -1;
 }
 
-int __cdecl vsprintf_s (
+DLLEXPORT int __cdecl vsprintf_s (
         char *string,
         size_t sizeInBytes,
         const char *format,
@@ -150,7 +150,7 @@ int __cdecl vsprintf_s (
     return retvalue;
 }
 
-int __cdecl _vsnprintf_s (
+DLLEXPORT int __cdecl _vsnprintf_s (
         char *string,
         size_t sizeInBytes,
         size_t count,
index b9940a6..3f81412 100644 (file)
@@ -112,7 +112,7 @@ int __cdecl _vswprintf_helper (
         return -1;
 }
 
-int __cdecl vswprintf_s (
+DLLEXPORT int __cdecl vswprintf_s (
         wchar_t *string,
         size_t sizeInWords,
         const wchar_t *format,
@@ -143,7 +143,7 @@ int __cdecl vswprintf_s (
     return retvalue;
 }
 
-int __cdecl _vsnwprintf_s (
+DLLEXPORT int __cdecl _vsnwprintf_s (
         wchar_t *string,
         size_t sizeInWords,
         size_t count,
index 42cc578..2857bea 100644 (file)
@@ -12,7 +12,7 @@
 *   via repeated calls.
 *
 *******************************************************************************/
-
+#include "pal/palinternal.h"
 #include <string.h>
 #include <errno.h>
 #include <limits.h>
index 7c8b2f2..2ad59e5 100644 (file)
@@ -154,7 +154,7 @@ static void __stdcall xtox
    and return pointer to buffer. */
 
 #ifdef _SECURE_ITOA
-errno_t __cdecl _itox_s (
+DLLEXPORT errno_t __cdecl _itox_s (
         int val,
         TCHAR *buf,
         size_t sizeInTChars,
@@ -359,7 +359,7 @@ static void __fastcall x64tox
 /* Actual functions just call conversion helper with neg flag set correctly,
    and return pointer to buffer. */
 
-errno_t __cdecl _i64tox_s (
+DLLEXPORT errno_t __cdecl _i64tox_s (
         long long val,
         TCHAR *buf,
         size_t sizeInTChars,
index 22602bf..bbcb664 100644 (file)
@@ -15,7 +15,9 @@
 #include <palsuite.h>
 
 extern "C"
-int InitializeDllTest1()
+int
+PALAPI
+InitializeDllTest1()
 {
     PAL_SetInitializeDLLFlags(PAL_INITIALIZE_DLL | PAL_INITIALIZE_REGISTER_SIGNALS);
     return PAL_InitializeDLL();
@@ -36,7 +38,9 @@ BOOL bTry    = FALSE;
 BOOL bExcept = FALSE;
 
 extern "C"
-int DllTest1()
+int
+PALAPI
+DllTest1()
 {
     Trace("Starting pal_sxs test1 DllTest1\n");
 
index 222898f..084d990 100644 (file)
@@ -15,7 +15,9 @@
 #include <palsuite.h>
 
 extern "C"
-int InitializeDllTest2()
+int
+PALAPI
+InitializeDllTest2()
 {
     PAL_SetInitializeDLLFlags(PAL_INITIALIZE_DLL | PAL_INITIALIZE_REGISTER_SIGNALS);
     return PAL_InitializeDLL();
@@ -36,7 +38,9 @@ BOOL bTry    = FALSE;
 BOOL bExcept = FALSE;
 
 extern "C"
-int DllTest2()
+int
+PALAPI
+DllTest2()
 {
     Trace("Starting pal_sxs test1 DllTest2\n");
 
index 5515ae4..7b89dfe 100644 (file)
@@ -15,7 +15,7 @@
 **===========================================================================*/
 #include <palsuite.h>
 
-typedef int (PALAPI *SIMPLEFUNCTION)(int);
+typedef int (PALAPI_NOEXPORT *SIMPLEFUNCTION)(int);
 
 /* SHLEXT is defined only for Unix variants */
 #if defined(SHLEXT)
index ae22b15..8b3cc36 100644 (file)
@@ -71,7 +71,7 @@ inline HRESULT CbSysStringSize(ULONG cchSize, BOOL isByteLen, ULONG *result)
 *  return value = BSTR, NULL if the allocation failed.
 *
 ***********************************************************************/
-STDAPI_(BSTR) SysAllocStringLen(const OLECHAR *psz, UINT len)
+DLLEXPORT STDAPI_(BSTR) SysAllocStringLen(const OLECHAR *psz, UINT len)
 {
     
     BSTR bstr;
@@ -168,7 +168,7 @@ SysAllocStringByteLen(const char FAR* psz, unsigned int len)
 *  None
 *
 ***********************************************************************/
-STDAPI_(void) SysFreeString(BSTR bstr)
+DLLEXPORT STDAPI_(void) SysFreeString(BSTR bstr)
 {
     if(bstr == NULL)
       return;
@@ -187,7 +187,7 @@ STDAPI_(void) SysFreeString(BSTR bstr)
 *  return value = unsigned int, length in characters.
 *
 ***********************************************************************/
-STDAPI_(unsigned int)
+DLLEXPORT STDAPI_(unsigned int)
 SysStringLen(BSTR bstr)
 {
     if(bstr == NULL)
index e44550d..e0069d2 100644 (file)
 
 #include "common.h" 
 
-STDAPI_(LPVOID) CoTaskMemAlloc(SIZE_T cb)
+DLLEXPORT STDAPI_(LPVOID) CoTaskMemAlloc(SIZE_T cb)
 {
     return LocalAlloc(LMEM_FIXED, cb);
 }
 
-STDAPI_(LPVOID) CoTaskMemRealloc(LPVOID pv, SIZE_T cb)
+DLLEXPORT STDAPI_(LPVOID) CoTaskMemRealloc(LPVOID pv, SIZE_T cb)
 {
     return LocalReAlloc(pv, cb, LMEM_MOVEABLE);
 }
 
-STDAPI_(void) CoTaskMemFree(LPVOID pv)
+DLLEXPORT STDAPI_(void) CoTaskMemFree(LPVOID pv)
 {
     LocalFree(pv);
 }
index 6071a56..26308e5 100644 (file)
@@ -11,7 +11,7 @@
 #ifdef FEATURE_PAL
 #include "resourcestring.h"
 #define NATIVE_STRING_RESOURCE_NAME mscorrc_debug
-DECLARE_NATIVE_STRING_RESOURCE_TABLE(NATIVE_STRING_RESOURCE_NAME);
+__attribute__((visibility("default"))) DECLARE_NATIVE_STRING_RESOURCE_TABLE(NATIVE_STRING_RESOURCE_NAME);
 #endif
 #include "sstring.h"
 #include "stringarraylist.h"
index e949af2..051a003 100644 (file)
@@ -838,7 +838,7 @@ public:
     }
 #endif // DACCESS_COMPILE
 
-    DEBUG_NOINLINE static void HolderEnter(PEFileListLock *pThis) PUB
+    DEBUG_NOINLINE static void HolderEnter(PEFileListLock *pThis)
     {
         WRAPPER_NO_CONTRACT;
         ANNOTATION_SPECIAL_HOLDER_CALLER_NEEDS_DYNAMIC_CONTRACT;
@@ -846,7 +846,7 @@ public:
         pThis->Enter();
     }
 
-    DEBUG_NOINLINE static void HolderLeave(PEFileListLock *pThis) PUB
+    DLLEXPORT DEBUG_NOINLINE static void HolderLeave(PEFileListLock *pThis)
     {
         WRAPPER_NO_CONTRACT;
         ANNOTATION_SPECIAL_HOLDER_CALLER_NEEDS_DYNAMIC_CONTRACT;
index 82bf0e4..9f8aeb7 100644 (file)
@@ -1171,6 +1171,7 @@ HRESULT CorRuntimeHostBase::EnumDomains(HDOMAINENUM *hEnum)
 #endif // FEATURE_COMINTEROP
 
 extern "C"
+DLLEXPORT
 HRESULT  GetCLRRuntimeHost(REFIID riid, IUnknown **ppUnk)
 {
     WRAPPER_NO_CONTRACT;
index 5289dfa..33c0b84 100644 (file)
@@ -183,13 +183,13 @@ private:
     void SpinEnter();
 
 #ifndef DACCESS_COMPILE
-    DEBUG_NOINLINE static void AcquireLock(CrstBase *c) PUB {
+    DEBUG_NOINLINE static void AcquireLock(CrstBase *c) {
         WRAPPER_NO_CONTRACT;
         ANNOTATION_SPECIAL_HOLDER_CALLER_NEEDS_DYNAMIC_CONTRACT;
         c->Enter(); 
     }
 
-    DEBUG_NOINLINE static void ReleaseLock(CrstBase *c) PUB { 
+    DLLEXPORT DEBUG_NOINLINE static void ReleaseLock(CrstBase *c) {
         WRAPPER_NO_CONTRACT;
         ANNOTATION_SPECIAL_HOLDER_CALLER_NEEDS_DYNAMIC_CONTRACT;
         c->Leave(); 
@@ -202,8 +202,8 @@ private:
     // Argument: 
     //     input: c - the lock to be checked. 
     // Note: Throws
-    static void AcquireLock(CrstBase * c) PUB
-    { 
+    DLLEXPORT static void AcquireLock(CrstBase * c)
+    {
         SUPPORTS_DAC;
         if (c->GetEnterCount() != 0) 
         {
@@ -211,8 +211,8 @@ private:
         }
     };
 
-    static void ReleaseLock(CrstBase *c) PUB
-    { 
+    DLLEXPORT static void ReleaseLock(CrstBase *c)
+    {
         SUPPORTS_DAC;
     };
 #endif // DACCESS_COMPILE
@@ -537,5 +537,3 @@ __inline BOOL IsOwnerOfCrst(LPVOID lock)
 void DebugTryCrst(CrstBase * pLock);
 #endif
 #endif // __crst_h__
-
-
index 8b35670..25c7f49 100644 (file)
@@ -196,14 +196,14 @@ public:
 
     // LockHolder holds the lock of the element, not the element itself
 
-    DEBUG_NOINLINE static void LockHolderEnter(Entry_t *pThis) PUB
+    DLLEXPORT DEBUG_NOINLINE static void LockHolderEnter(Entry_t *pThis)
     {
         WRAPPER_NO_CONTRACT;
         ANNOTATION_SPECIAL_HOLDER_CALLER_NEEDS_DYNAMIC_CONTRACT;
         pThis->Enter();
     }
 
-    DEBUG_NOINLINE static void LockHolderLeave(Entry_t *pThis) PUB
+    DLLEXPORT DEBUG_NOINLINE static void LockHolderLeave(Entry_t *pThis)
     {
         WRAPPER_NO_CONTRACT;
         ANNOTATION_SPECIAL_HOLDER_CALLER_NEEDS_DYNAMIC_CONTRACT;