Skip to content

Commit

Permalink
Fix DBI loading problem on Linux
Browse files Browse the repository at this point in the history
Part of PR dotnet#81573 needed to be undone to build libmscordbi.so without
any undefined symbols from the DAC. The DAC_PAL_RegisterModule, etc. stubs I recommended didn't work and DBI
could not be loaded by SOS because of missing exports.

The double pass at the libraries from the `target_link_libraries(mscordbi ${COREDBI_LIBRARIES} ${COREDBI_LIBRARIES})`
cmake file needed to be restored. The stubs were not needed after that.
  • Loading branch information
mikem8361 committed Feb 22, 2023
1 parent 1a321fd commit a9a730c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
5 changes: 4 additions & 1 deletion src/coreclr/dlls/mscordbi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ elseif(CLR_CMAKE_HOST_UNIX)
mscordaccore
)

target_link_libraries(mscordbi ${COREDBI_LIBRARIES})
# COREDBI_LIBRARIES is mentioned twice because ld is one pass linker and will not find symbols
# if they are defined after they are used. Having all libs twice makes sure that ld will actually
# find all symbols.
target_link_libraries(mscordbi ${COREDBI_LIBRARIES} ${COREDBI_LIBRARIES})

add_dependencies(mscordbi mscordaccore)

Expand Down
15 changes: 0 additions & 15 deletions src/coreclr/dlls/mscordbi/mscordbi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,3 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
// Defer to the main debugging code.
return DbgDllMain(hInstance, dwReason, lpReserved);
}

#if defined(TARGET_LINUX) && !defined(HOST_WINDOWS)
PALIMPORT HINSTANCE PALAPI DAC_PAL_RegisterModule(IN LPCSTR lpLibFileName);
PALIMPORT VOID PALAPI DAC_PAL_UnregisterModule(IN HINSTANCE hInstance);

HINSTANCE PALAPI PAL_RegisterModule(IN LPCSTR lpLibFileName)
{
return DAC_PAL_RegisterModule(lpLibFileName);
}

VOID PALAPI PAL_UnregisterModule(IN HINSTANCE hInstance)
{
DAC_PAL_UnregisterModule(hInstance);
}
#endif

0 comments on commit a9a730c

Please sign in to comment.