Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 70cf6d4

Browse files
authored
Cleanup DLL exports (#22500)
1 parent be1b5db commit 70cf6d4

File tree

16 files changed

+55
-105
lines changed

16 files changed

+55
-105
lines changed

src/debug/daccess/daccess.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ HINSTANCE g_thisModule;
4040

4141
extern VOID STDMETHODCALLTYPE TLS_FreeMasterSlotIndex();
4242

43-
DLLEXPORT
44-
EXTERN_C BOOL WINAPI
45-
DllMain(HANDLE instance, DWORD reason, LPVOID reserved)
43+
#if FEATURE_PAL
44+
DLLEXPORT // For Win32 PAL LoadLibrary emulation
45+
#endif
46+
EXTERN_C BOOL WINAPI DllMain(HANDLE instance, DWORD reason, LPVOID reserved)
4647
{
4748
static bool g_procInitialized = false;
4849

src/dlls/mscordbi/mscordbi.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ extern BOOL WINAPI DbgDllMain(HINSTANCE hInstance, DWORD dwReason,
1818
// The main dll entry point for this module. This routine is called by the
1919
// OS when the dll gets loaded. Control is simply deferred to the main code.
2020
//*****************************************************************************
21-
DLLEXPORT extern "C"
22-
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
21+
#ifdef FEATURE_PAL
22+
DLLEXPORT // For Win32 PAL LoadLibrary emulation
23+
#endif
24+
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
2325
{
2426
// Defer to the main debugging code.
2527
return DbgDllMain(hInstance, dwReason, lpReserved);

src/dlls/mscoree/mscoree.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,16 @@ extern "C" IExecutionEngine* IEE();
5656
extern "C" BOOL WINAPI _CRT_INIT(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved);
5757
#endif
5858

59-
extern "C" DLLEXPORT BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved);
59+
extern "C" BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved);
6060

6161
// For the CoreClr, this is the real DLL entrypoint. We make ourselves the first entrypoint as
6262
// we need to capture coreclr's hInstance before the C runtime initializes. This function
6363
// will capture hInstance, let the C runtime initialize and then invoke the "classic"
6464
// DllMain that initializes everything else.
65-
extern "C" DLLEXPORT BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
65+
#ifdef FEATURE_PAL
66+
DLLEXPORT // For Win32 PAL LoadLibrary emulation
67+
#endif
68+
extern "C" BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
6669
{
6770
STATIC_CONTRACT_NOTHROW;
6871

@@ -115,8 +118,10 @@ extern "C" DLLEXPORT BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, L
115118
return result;
116119
}
117120

118-
extern "C"
119-
DLLEXPORT BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
121+
#ifdef FEATURE_PAL
122+
DLLEXPORT // For Win32 PAL LoadLibrary emulation
123+
#endif
124+
extern "C" BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
120125
{
121126
STATIC_CONTRACT_NOTHROW;
122127

src/dlls/mscoree/mscorwks_unixexports.src

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ CoreDllMain
2020
DllMain
2121
GetCLRRuntimeHost
2222

23-
; Win32 API and other PAL functions used by the mscorlib
23+
; Win32 API and other PAL functions used by the System.Private.CoreLib
2424
CloseHandle
2525
CoTaskMemAlloc
2626
CoTaskMemRealloc
@@ -31,29 +31,23 @@ CreateMutexW
3131
CreateMutexExW
3232
CreateSemaphoreW
3333
CreateSemaphoreExW
34-
DuplicateHandle
3534
FormatMessageW
3635
FreeEnvironmentStringsW
37-
GetACP
3836
GetCurrentProcessId
3937
GetCurrentThreadId
4038
GetEnvironmentStringsW
4139
GetEnvironmentVariableW
42-
GetProcAddress
4340
GetStdHandle
4441
GetSystemInfo
4542
LocalAlloc
4643
LocalReAlloc
4744
LocalFree
48-
MetaDataGetDispenser
49-
MultiByteToWideChar
5045
OpenEventW
5146
OpenMutexW
5247
OpenSemaphoreW
5348
OutputDebugStringW
5449
QueryPerformanceCounter
5550
QueryPerformanceFrequency
56-
RaiseException
5751
ReleaseMutex
5852
ReleaseSemaphore
5953
ResetEvent
@@ -62,11 +56,5 @@ SetEvent
6256
SysAllocStringByteLen
6357
SysAllocStringLen
6458
SysFreeString
65-
SysStringByteLen
6659
SysStringLen
67-
VirtualAlloc
68-
VirtualFree
69-
GlobalMemoryStatusEx
70-
VirtualQuery
71-
WideCharToMultiByte
7260
WriteFile

src/inc/cortpoolhdr.h

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/inc/crtwrap.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
#include <wchar.h>
2222
#include <stdio.h>
2323

24-
#ifndef DLLEXPORT
25-
// DLLEXPORT is defined to influence method visibility for some compilers.
24+
#ifndef FEATURE_PAL
25+
// CoreCLR.dll uses linker .def files to control the exported symbols.
26+
// Define DLLEXPORT macro as empty on Windows.
2627
#define DLLEXPORT
27-
#endif // !DLLEXPORT
28+
#endif
2829

2930
#endif // __CrtWrap_h__

src/jit/ee_il_dll.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ void jitShutdown(bool processIsTerminating)
159159

160160
#ifndef FEATURE_MERGE_JIT_AND_ENGINE
161161

162-
extern "C" DLLEXPORT BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID pvReserved)
162+
#ifdef FEATURE_PAL
163+
DLLEXPORT // For Win32 PAL LoadLibrary emulation
164+
#endif
165+
extern "C" BOOL WINAPI
166+
DllMain(HANDLE hInstance, DWORD dwReason, LPVOID pvReserved)
163167
{
164168
if (dwReason == DLL_PROCESS_ATTACH)
165169
{

src/pal/inc/pal.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4314,6 +4314,7 @@ See MSDN doc for memcpy
43144314
--*/
43154315
EXTERN_C
43164316
PALIMPORT
4317+
DLLEXPORT
43174318
void *PAL_memcpy (void *dest, const void *src, size_t count);
43184319

43194320
PALIMPORT void * __cdecl memcpy(void *, const void *, size_t) THROW_DECL;
@@ -4600,13 +4601,14 @@ PALIMPORT char * __cdecl _strdup(const char *);
46004601
PALIMPORT PAL_NORETURN void __cdecl exit(int);
46014602
int __cdecl atexit(void (__cdecl *function)(void));
46024603

4603-
PALIMPORT DLLEXPORT void __cdecl qsort(void *, size_t, size_t, int (__cdecl *)(const void *, const void *));
4604-
PALIMPORT void * __cdecl bsearch(const void *, const void *, size_t, size_t,
4605-
int (__cdecl *)(const void *, const void *));
4606-
46074604
PALIMPORT char * __cdecl _fullpath(char *, const char *, size_t);
46084605

46094606
#ifndef PAL_STDCPP_COMPAT
4607+
4608+
PALIMPORT DLLEXPORT void __cdecl qsort(void *, size_t, size_t, int(__cdecl *)(const void *, const void *));
4609+
PALIMPORT DLLEXPORT void * __cdecl bsearch(const void *, const void *, size_t, size_t,
4610+
int(__cdecl *)(const void *, const void *));
4611+
46104612
PALIMPORT time_t __cdecl time(time_t *);
46114613

46124614
struct tm {
@@ -4725,8 +4727,8 @@ PALIMPORT DLLEXPORT int * __cdecl PAL_errno(int caller);
47254727
#define errno (*PAL_errno(PAL_get_caller))
47264728
#endif // PAL_STDCPP_COMPAT
47274729

4728-
PALIMPORT char * __cdecl getenv(const char *);
4729-
PALIMPORT int __cdecl _putenv(const char *);
4730+
PALIMPORT DLLEXPORT char * __cdecl getenv(const char *);
4731+
PALIMPORT DLLEXPORT int __cdecl _putenv(const char *);
47304732

47314733
#define ERANGE 34
47324734

src/pal/inc/rt/palrt.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ typedef union _ULARGE_INTEGER {
372372

373373
/******************* OLE, BSTR, VARIANT *************************/
374374

375-
STDAPI_(LPVOID) CoTaskMemAlloc(SIZE_T cb);
376-
STDAPI_(LPVOID) CoTaskMemRealloc(LPVOID pv, SIZE_T cb);
377-
STDAPI_(void) CoTaskMemFree(LPVOID pv);
375+
DLLEXPORT STDAPI_(LPVOID) CoTaskMemAlloc(SIZE_T cb);
376+
DLLEXPORT STDAPI_(LPVOID) CoTaskMemRealloc(LPVOID pv, SIZE_T cb);
377+
DLLEXPORT STDAPI_(void) CoTaskMemFree(LPVOID pv);
378378

379379
typedef SHORT VARIANT_BOOL;
380380
#define VARIANT_TRUE ((VARIANT_BOOL)-1)
@@ -386,11 +386,11 @@ typedef const OLECHAR* LPCOLESTR;
386386

387387
typedef WCHAR *BSTR;
388388

389-
STDAPI_(BSTR) SysAllocString(const OLECHAR*);
390-
STDAPI_(BSTR) SysAllocStringLen(const OLECHAR*, UINT);
389+
DLLEXPORT STDAPI_(BSTR) SysAllocString(const OLECHAR*);
390+
DLLEXPORT STDAPI_(BSTR) SysAllocStringLen(const OLECHAR*, UINT);
391391
DLLEXPORT STDAPI_(BSTR) SysAllocStringByteLen(const char *, UINT);
392-
STDAPI_(void) SysFreeString(BSTR);
393-
STDAPI_(UINT) SysStringLen(BSTR);
392+
DLLEXPORT STDAPI_(void) SysFreeString(BSTR);
393+
DLLEXPORT STDAPI_(UINT) SysStringLen(BSTR);
394394
DLLEXPORT STDAPI_(UINT) SysStringByteLen(BSTR);
395395

396396
typedef double DATE;

src/pal/src/cruntime/misc.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ PAL_qsort(void *base, size_t nmemb, size_t size,
243243
PERF_EXIT(qsort);
244244
}
245245

246-
DLLEXPORT
247246
PALIMPORT
248247
void * __cdecl
249248
PAL_bsearch(const void *key, const void *base, size_t nmemb, size_t size,
@@ -299,7 +298,6 @@ PAL_memcpy
299298
Overlapping buffer-safe version of memcpy.
300299
See MSDN doc for memcpy
301300
--*/
302-
DLLEXPORT
303301
EXTERN_C
304302
PALIMPORT
305303
void *PAL_memcpy (void *dest, const void *src, size_t count)

0 commit comments

Comments
 (0)