From 7e779bb9523c71b358861a82da06f27cfda79fc7 Mon Sep 17 00:00:00 2001 From: oltolm Date: Sun, 16 Apr 2023 21:56:23 +0200 Subject: [PATCH] fix 32-bit definition file --- CMakeLists.txt | 2 + src/addr2line/CMakeLists.txt | 1 + src/catchsegv/CMakeLists.txt | 1 + src/drmingw/CMakeLists.txt | 1 + src/exchndl/CMakeLists.txt | 1 + src/mgwhelp/mgwhelp32.def | 190 +++++++++++++++++------------------ tests/CMakeLists.txt | 42 ++++---- tests/apps/CMakeLists.txt | 6 ++ tests/test_mgwhelp.cpp | 4 + 9 files changed, 136 insertions(+), 112 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c04421..b282be6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,8 @@ add_link_options( -static-libstdc++ ) +link_libraries(ssp) + find_package (WinDbg) include_directories ( diff --git a/src/addr2line/CMakeLists.txt b/src/addr2line/CMakeLists.txt index 3e51057..a656e07 100644 --- a/src/addr2line/CMakeLists.txt +++ b/src/addr2line/CMakeLists.txt @@ -5,6 +5,7 @@ add_executable (addr2line target_link_libraries (addr2line PRIVATE common mgwhelp_implib + dbghelp ) install (TARGETS addr2line RUNTIME DESTINATION bin) diff --git a/src/catchsegv/CMakeLists.txt b/src/catchsegv/CMakeLists.txt index 592ed5c..2453cca 100644 --- a/src/catchsegv/CMakeLists.txt +++ b/src/catchsegv/CMakeLists.txt @@ -13,6 +13,7 @@ target_link_libraries (catchsegv PRIVATE getoptW mgwhelp_implib winmm + dbghelp ) diff --git a/src/drmingw/CMakeLists.txt b/src/drmingw/CMakeLists.txt index 038bc84..3457ea5 100644 --- a/src/drmingw/CMakeLists.txt +++ b/src/drmingw/CMakeLists.txt @@ -13,6 +13,7 @@ target_compile_definitions(drmingw PRIVATE target_link_libraries (drmingw PRIVATE common mgwhelp_implib + dbghelp ) install (TARGETS drmingw RUNTIME DESTINATION bin) diff --git a/src/exchndl/CMakeLists.txt b/src/exchndl/CMakeLists.txt index ef60960..6095a6b 100644 --- a/src/exchndl/CMakeLists.txt +++ b/src/exchndl/CMakeLists.txt @@ -14,6 +14,7 @@ target_sources (exchndl PRIVATE target_link_libraries (exchndl PRIVATE common mgwhelp_implib + dbghelp ) set_target_properties (exchndl PROPERTIES diff --git a/src/mgwhelp/mgwhelp32.def b/src/mgwhelp/mgwhelp32.def index d44069b..dfdf576 100644 --- a/src/mgwhelp/mgwhelp32.def +++ b/src/mgwhelp/mgwhelp32.def @@ -11,98 +11,98 @@ EXPORTS SymLoadModuleExW@36 = MgwSymLoadModuleExW@36 == SymLoadModuleExW UnDecorateSymbolName@16 = MgwUnDecorateSymbolName@16 == UnDecorateSymbolName - EnumDirTree@24 == EnumDirTree - EnumDirTreeW@24 == EnumDirTreeW - EnumerateLoadedModules@12 == EnumerateLoadedModules - EnumerateLoadedModules64@12 == EnumerateLoadedModules64 - EnumerateLoadedModulesW64@12 == EnumerateLoadedModulesW64 - ExtensionApiVersion@0 == ExtensionApiVersion - FindDebugInfoFile@12 == FindDebugInfoFile - FindDebugInfoFileEx@20 == FindDebugInfoFileEx - FindExecutableImage@12 == FindExecutableImage - FindExecutableImageEx@20 == FindExecutableImageEx - FindExecutableImageExW@20 == FindExecutableImageExW - GetTimestampForLoadedLibrary@4 == GetTimestampForLoadedLibrary - ImageDirectoryEntryToData@16 == ImageDirectoryEntryToData - ImageDirectoryEntryToDataEx@20 == ImageDirectoryEntryToDataEx - ImageNtHeader@4 == ImageNtHeader - ImageRvaToSection@12 == ImageRvaToSection - ImageRvaToVa@16 == ImageRvaToVa - ImagehlpApiVersion@0 == ImagehlpApiVersion - ImagehlpApiVersionEx@4 == ImagehlpApiVersionEx - MakeSureDirectoryPathExists@4 == MakeSureDirectoryPathExists - MapDebugInformation@16 == MapDebugInformation - MiniDumpReadDumpStream@20 == MiniDumpReadDumpStream - MiniDumpWriteDump@28 == MiniDumpWriteDump - SearchTreeForFile@12 == SearchTreeForFile - SearchTreeForFileW@12 == SearchTreeForFileW - StackWalk@36 == StackWalk - StackWalk64@36 == StackWalk64 - SymAddSymbol@32 == SymAddSymbol - SymAddSymbolW@32 == SymAddSymbolW - SymEnumLines@28 == SymEnumLines - SymEnumSourceFiles@24 == SymEnumSourceFiles - SymEnumSymbols@24 == SymEnumSymbols - SymEnumSymbolsW@24 == SymEnumSymbolsW - SymEnumTypes@20 == SymEnumTypes - SymEnumTypesW@20 == SymEnumTypesW - SymEnumerateModules@12 == SymEnumerateModules - SymEnumerateModules64@12 == SymEnumerateModules64 - SymEnumerateModulesW64@12 == SymEnumerateModulesW64 - SymEnumerateSymbols@16 == SymEnumerateSymbols - SymEnumerateSymbols64@20 == SymEnumerateSymbols64 - SymFindFileInPath@40 == SymFindFileInPath - SymFindFileInPathW@40 == SymFindFileInPathW - SymFromName@12 == SymFromName - SymFunctionTableAccess@8 == SymFunctionTableAccess - SymFunctionTableAccess64@12 == SymFunctionTableAccess64 - SymGetLineFromAddr@16 == SymGetLineFromAddr - SymGetLineNext@8 == SymGetLineNext - SymGetLineNext64@8 == SymGetLineNext64 - SymGetLinePrev@8 == SymGetLinePrev - SymGetLinePrev64@8 == SymGetLinePrev64 - SymGetModuleBase@8 == SymGetModuleBase - SymGetModuleBase64@12 == SymGetModuleBase64 - SymGetModuleInfo@12 == SymGetModuleInfo - SymGetModuleInfo64@16 == SymGetModuleInfo64 - SymGetModuleInfoW@12 == SymGetModuleInfoW - SymGetModuleInfoW64@16 == SymGetModuleInfoW64 - SymGetOptions@0 == SymGetOptions - SymGetSearchPath@12 == SymGetSearchPath - SymGetSearchPathW@12 == SymGetSearchPathW - SymGetSourceFileToken@24 == SymGetSourceFileToken - SymGetSourceFileTokenW@24 == SymGetSourceFileTokenW - SymGetSymFromAddr@16 == SymGetSymFromAddr - SymGetSymFromAddr64@20 == SymGetSymFromAddr64 - SymGetSymFromName@12 == SymGetSymFromName - SymGetSymFromName64@12 == SymGetSymFromName64 - SymGetSymNext@8 == SymGetSymNext - SymGetSymNext64@8 == SymGetSymNext64 - SymGetSymPrev@8 == SymGetSymPrev - SymGetSymPrev64@8 == SymGetSymPrev64 - SymGetTypeFromName@20 == SymGetTypeFromName - SymGetTypeInfo@24 == SymGetTypeInfo - SymLoadModule@24 == SymLoadModule - SymLoadModule64@28 == SymLoadModule64 - SymMatchFileName@16 == SymMatchFileName - SymMatchFileNameW@16 == SymMatchFileNameW - SymMatchString@12 == SymMatchString - SymRefreshModuleList@4 == SymRefreshModuleList - SymRegisterCallback@12 == SymRegisterCallback - SymRegisterCallback64@16 == SymRegisterCallback64 - SymRegisterCallbackW64@16 == SymRegisterCallbackW64 - SymRegisterFunctionEntryCallback@12 == SymRegisterFunctionEntryCallback - SymRegisterFunctionEntryCallback64@16 == SymRegisterFunctionEntryCallback64 - SymSearch@44 == SymSearch - SymSearchW@44 == SymSearchW - SymSetContext@12 == SymSetContext - SymSetParentWindow@4 == SymSetParentWindow - SymSetScopeFromAddr@12 == SymSetScopeFromAddr - SymSetSearchPath@8 == SymSetSearchPath - SymSetSearchPathW@8 == SymSetSearchPathW - SymUnDName@12 == SymUnDName - SymUnDName64@12 == SymUnDName64 - SymUnloadModule@8 == SymUnloadModule - SymUnloadModule64@12 == SymUnloadModule64 - UnmapDebugInformation@4 == UnmapDebugInformation - WinDbgExtensionDllInit@12 == WinDbgExtensionDllInit + EnumDirTree = dbghelp.EnumDirTree + EnumDirTreeW = dbghelp.EnumDirTreeW + EnumerateLoadedModules = dbghelp.EnumerateLoadedModules + EnumerateLoadedModules64 = dbghelp.EnumerateLoadedModules64 + EnumerateLoadedModulesW64 = dbghelp.EnumerateLoadedModulesW64 + ExtensionApiVersion = dbghelp.ExtensionApiVersion + FindDebugInfoFile = dbghelp.FindDebugInfoFile + FindDebugInfoFileEx = dbghelp.FindDebugInfoFileEx + FindExecutableImage = dbghelp.FindExecutableImage + FindExecutableImageEx = dbghelp.FindExecutableImageEx + FindExecutableImageExW = dbghelp.FindExecutableImageExW + GetTimestampForLoadedLibrary = dbghelp.GetTimestampForLoadedLibrary + ImageDirectoryEntryToData = dbghelp.ImageDirectoryEntryToData + ImageDirectoryEntryToDataEx = dbghelp.ImageDirectoryEntryToDataEx + ImageNtHeader = dbghelp.ImageNtHeader + ImageRvaToSection = dbghelp.ImageRvaToSection + ImageRvaToVa = dbghelp.ImageRvaToVa + ImagehlpApiVersion = dbghelp.ImagehlpApiVersion + ImagehlpApiVersionEx = dbghelp.ImagehlpApiVersionEx + MakeSureDirectoryPathExists = dbghelp.MakeSureDirectoryPathExists + MapDebugInformation = dbghelp.MapDebugInformation + MiniDumpReadDumpStream = dbghelp.MiniDumpReadDumpStream + MiniDumpWriteDump = dbghelp.MiniDumpWriteDump + SearchTreeForFile = dbghelp.SearchTreeForFile + SearchTreeForFileW = dbghelp.SearchTreeForFileW + StackWalk = dbghelp.StackWalk + StackWalk64 = dbghelp.StackWalk64 + SymAddSymbol = dbghelp.SymAddSymbol + SymAddSymbolW = dbghelp.SymAddSymbolW + SymEnumLines = dbghelp.SymEnumLines + SymEnumSourceFiles = dbghelp.SymEnumSourceFiles + SymEnumSymbols = dbghelp.SymEnumSymbols + SymEnumSymbolsW = dbghelp.SymEnumSymbolsW + SymEnumTypes = dbghelp.SymEnumTypes + SymEnumTypesW = dbghelp.SymEnumTypesW + SymEnumerateModules = dbghelp.SymEnumerateModules + SymEnumerateModules64 = dbghelp.SymEnumerateModules64 + SymEnumerateModulesW64 = dbghelp.SymEnumerateModulesW64 + SymEnumerateSymbols = dbghelp.SymEnumerateSymbols + SymEnumerateSymbols64 = dbghelp.SymEnumerateSymbols64 + SymFindFileInPath = dbghelp.SymFindFileInPath + SymFindFileInPathW = dbghelp.SymFindFileInPathW + SymFromName = dbghelp.SymFromName + SymFunctionTableAccess = dbghelp.SymFunctionTableAccess + SymFunctionTableAccess64 = dbghelp.SymFunctionTableAccess64 + SymGetLineFromAddr = dbghelp.SymGetLineFromAddr + SymGetLineNext = dbghelp.SymGetLineNext + SymGetLineNext64 = dbghelp.SymGetLineNext64 + SymGetLinePrev = dbghelp.SymGetLinePrev + SymGetLinePrev64 = dbghelp.SymGetLinePrev64 + SymGetModuleBase = dbghelp.SymGetModuleBase + SymGetModuleBase64 = dbghelp.SymGetModuleBase64 + SymGetModuleInfo = dbghelp.SymGetModuleInfo + SymGetModuleInfo64 = dbghelp.SymGetModuleInfo64 + SymGetModuleInfoW = dbghelp.SymGetModuleInfoW + SymGetModuleInfoW64 = dbghelp.SymGetModuleInfoW64 + SymGetOptions = dbghelp.SymGetOptions + SymGetSearchPath = dbghelp.SymGetSearchPath + SymGetSearchPathW = dbghelp.SymGetSearchPathW + SymGetSourceFileToken = dbghelp.SymGetSourceFileToken + SymGetSourceFileTokenW = dbghelp.SymGetSourceFileTokenW + SymGetSymFromAddr = dbghelp.SymGetSymFromAddr + SymGetSymFromAddr64 = dbghelp.SymGetSymFromAddr64 + SymGetSymFromName = dbghelp.SymGetSymFromName + SymGetSymFromName64 = dbghelp.SymGetSymFromName64 + SymGetSymNext = dbghelp.SymGetSymNext + SymGetSymNext64 = dbghelp.SymGetSymNext64 + SymGetSymPrev = dbghelp.SymGetSymPrev + SymGetSymPrev64 = dbghelp.SymGetSymPrev64 + SymGetTypeFromName = dbghelp.SymGetTypeFromName + SymGetTypeInfo = dbghelp.SymGetTypeInfo + SymLoadModule = dbghelp.SymLoadModule + SymLoadModule64 = dbghelp.SymLoadModule64 + SymMatchFileName = dbghelp.SymMatchFileName + SymMatchFileNameW = dbghelp.SymMatchFileNameW + SymMatchString = dbghelp.SymMatchString + SymRefreshModuleList = dbghelp.SymRefreshModuleList + SymRegisterCallback = dbghelp.SymRegisterCallback + SymRegisterCallback64 = dbghelp.SymRegisterCallback64 + SymRegisterCallbackW64 = dbghelp.SymRegisterCallbackW64 + SymRegisterFunctionEntryCallback = dbghelp.SymRegisterFunctionEntryCallback + SymRegisterFunctionEntryCallback64 = dbghelp.SymRegisterFunctionEntryCallback64 + SymSearch = dbghelp.SymSearch + SymSearchW = dbghelp.SymSearchW + SymSetContext = dbghelp.SymSetContext + SymSetParentWindow = dbghelp.SymSetParentWindow + SymSetScopeFromAddr = dbghelp.SymSetScopeFromAddr + SymSetSearchPath = dbghelp.SymSetSearchPath + SymSetSearchPathW = dbghelp.SymSetSearchPathW + SymUnDName = dbghelp.SymUnDName + SymUnDName64 = dbghelp.SymUnDName64 + SymUnloadModule = dbghelp.SymUnloadModule + SymUnloadModule64 = dbghelp.SymUnloadModule64 + UnmapDebugInformation = dbghelp.UnmapDebugInformation + WinDbgExtensionDllInit = dbghelp.WinDbgExtensionDllInit diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 257a771..b393e68 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,12 +8,10 @@ force_debug () add_executable (test_mgwhelp test_mgwhelp.cpp ) -add_dependencies (test_mgwhelp mgwhelp_implib) target_link_libraries (test_mgwhelp mgwhelp_implib shlwapi ) -add_dependencies (check test_mgwhelp) add_test ( NAME test_mgwhelp COMMAND test_mgwhelp @@ -45,7 +43,6 @@ add_custom_target (test_mgwhelp_split ALL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_mgwhelp_split.exe ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_mgwhelp_split.debug ) -add_dependencies (check test_mgwhelp_split) add_test ( NAME test_mgwhelp_split COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_mgwhelp_split.exe @@ -81,7 +78,6 @@ add_custom_target (test_mgwhelp_split_subdir ALL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_mgwhelp_split_subdir.exe ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/.debug/test_mgwhelp_split_subdir.debug ) -add_dependencies (check test_mgwhelp_split_subdir) add_test ( NAME test_mgwhelp_split_subdir COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_mgwhelp_split_subdir.exe @@ -105,7 +101,6 @@ add_custom_target (test_mgwhelp_stripped ALL DEPENDS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_mgwhelp_stripped.exe ) -add_dependencies (check test_mgwhelp_stripped) add_test ( NAME test_mgwhelp_stripped COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_mgwhelp_stripped.exe @@ -185,8 +180,6 @@ if (NOT DEFINED OBJCOPY_VERSION) endif () if (OBJCOPY_VERSION STREQUAL "llvm-objcopy") set_target_properties (test_mgwhelp_zdebug PROPERTIES EXCLUDE_FROM_ALL ON) -else () - add_dependencies (check test_mgwhelp_zdebug) endif () if (OBJCOPY_VERSION STREQUAL "llvm-objcopy" OR NOT OBJCOPY_VERSION VERSION_GREATER_EQUAL "2.34") set_tests_properties (test_mgwhelp_zdebug PROPERTIES DISABLED ON) @@ -203,9 +196,7 @@ include_directories ( add_executable (test_exchndl_static_unicode test_exchndl_static_unicode.cpp ) -add_dependencies (test_exchndl_static_unicode exchndl_implib) target_link_libraries (test_exchndl_static_unicode exchndl_implib shlwapi) -add_dependencies (check test_exchndl_static_unicode) add_test ( NAME test_exchndl_static_unicode COMMAND test_exchndl_static_unicode @@ -223,9 +214,7 @@ include_directories ( add_executable (test_exchndl_static_ansi test_exchndl_static_ansi.cpp ) -add_dependencies (test_exchndl_static_ansi exchndl_implib) target_link_libraries (test_exchndl_static_ansi exchndl_implib shlwapi) -add_dependencies (check test_exchndl_static_ansi) add_test ( NAME test_exchndl_static_ansi COMMAND test_exchndl_static_ansi @@ -244,8 +233,6 @@ add_executable (test_exchndl_dynamic_unicode test_exchndl_dynamic_unicode.cpp ) target_link_libraries (test_exchndl_dynamic_unicode shlwapi) -add_dependencies (test_exchndl_dynamic_unicode exchndl) -add_dependencies (check test_exchndl_dynamic_unicode) add_test ( NAME test_exchndl_dynamic_unicode COMMAND test_exchndl_dynamic_unicode @@ -264,8 +251,6 @@ add_executable (test_exchndl_dynamic_ansi test_exchndl_dynamic_ansi.cpp ) target_link_libraries (test_exchndl_dynamic_ansi shlwapi) -add_dependencies (test_exchndl_dynamic_ansi exchndl) -add_dependencies (check test_exchndl_dynamic_ansi) add_test ( NAME test_exchndl_dynamic_ansi COMMAND test_exchndl_dynamic_ansi @@ -280,10 +265,33 @@ add_test ( add_executable (test_addr2line test_addr2line.cpp ) -add_dependencies (test_addr2line addr2line) -add_dependencies (check test_addr2line) add_test ( NAME test_addr2line COMMAND test_addr2line WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) + +set(test_targets + test_addr2line + test_exchndl_dynamic_ansi + test_exchndl_dynamic_unicode + test_exchndl_static_ansi + test_exchndl_static_unicode + test_mgwhelp + test_mgwhelp_split + test_mgwhelp_split_subdir + test_mgwhelp_stripped + test_mgwhelp_zdebug +) + +add_test(test_build + "${CMAKE_COMMAND}" + --build "${CMAKE_BINARY_DIR}" + --config "$" + --target ${test_targets} +) + +set_tests_properties(test_build PROPERTIES FIXTURES_SETUP test_fixture) +foreach(test_target ${test_targets}) + set_tests_properties(${test_target} PROPERTIES FIXTURES_REQUIRED test_fixture) +endforeach() diff --git a/tests/apps/CMakeLists.txt b/tests/apps/CMakeLists.txt index 84a9836..31a4afd 100644 --- a/tests/apps/CMakeLists.txt +++ b/tests/apps/CMakeLists.txt @@ -37,6 +37,12 @@ if (MINGW) set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer") set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer") set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer") + + add_link_options( + -static + -static-libgcc + -static-libstdc++ + ) endif () # https://github.com/jrfonseca/drmingw/issues/42 diff --git a/tests/test_mgwhelp.cpp b/tests/test_mgwhelp.cpp index e95cafc..d7056ae 100755 --- a/tests/test_mgwhelp.cpp +++ b/tests/test_mgwhelp.cpp @@ -190,6 +190,10 @@ main(int argc, char **argv) if (!hMgwHelpDll) { test_line(false, "GetModuleHandleA(\"mgwhelp.dll\")"); } else { + test_line(GetProcAddress(hMgwHelpDll, "SymInitialize") != NULL, "GetProcAddress(\"SymInitialize\")"); + test_line(GetProcAddress(hMgwHelpDll, "SymInitialize@12") == NULL, "!GetProcAddress(\"SymInitialize\")"); + test_line(GetProcAddress(hMgwHelpDll, "EnumDirTree") != NULL, "GetProcAddress(\"EnumDirTree\")"); + test_line(GetProcAddress(hMgwHelpDll, "EnumDirTree@24") == NULL, "!GetProcAddress(\"EnumDirTree\")"); test_line(GetProcAddress(hMgwHelpDll, "SymGetOptions") != NULL, "GetProcAddress(\"SymGetOptions\")"); test_line(GetProcAddress(hMgwHelpDll, "SymGetOptions@0") == NULL, "!GetProcAddress(\"SymGetOptions\")"); }