summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike McLaughlin <mikem@microsoft.com>2015-06-22 17:47:46 -0700
committerMike McLaughlin <mikem@microsoft.com>2015-07-01 17:21:13 -0700
commite2010fd083f4c4cb85a2b43c5b7d3c543cb32a20 (patch)
tree4dc56ac9e4282c405a3ea3b51e89d48691d3d500
parent2219d103cc1a881f154a657dc522b496a4e3b6d1 (diff)
downloadcoreclr-e2010fd083f4c4cb85a2b43c5b7d3c543cb32a20.tar.gz
coreclr-e2010fd083f4c4cb85a2b43c5b7d3c543cb32a20.tar.bz2
coreclr-e2010fd083f4c4cb85a2b43c5b7d3c543cb32a20.zip
Generate the dac table RVA using nm at build time.
Remove the temporary PAL dac table file at runtime. Replaced it with dactablerva.h file generated at build time from the libcoreclr module. nm works across Linux, OSx and FreeBSD.
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/debug/daccess/CMakeLists.txt5
-rw-r--r--src/debug/daccess/daccess.cpp19
-rw-r--r--src/debug/ee/dactable.cpp1
-rw-r--r--src/dlls/mscoree/coreclr/CMakeLists.txt9
-rw-r--r--src/pal/inc/pal.h26
-rw-r--r--src/pal/src/CMakeLists.txt1
-rw-r--r--src/pal/src/misc/dactableaddress.cpp161
-rw-r--r--src/pal/tools/gen-dactable-rva.sh1
9 files changed, 22 insertions, 202 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 149ae1b17a..f7872e00ee 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,6 +13,7 @@ endif()
set(CLR_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(VM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/vm)
+set(GENERATED_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/inc)
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
set(CLR_CMAKE_PLATFORM_UNIX 1)
diff --git a/src/debug/daccess/CMakeLists.txt b/src/debug/daccess/CMakeLists.txt
index ba5ae14712..65365d18aa 100644
--- a/src/debug/daccess/CMakeLists.txt
+++ b/src/debug/daccess/CMakeLists.txt
@@ -16,7 +16,8 @@ include_directories(${CLR_DIR}/src/gc)
include_directories(${CLR_DIR}/src/gcdump)
if(CLR_CMAKE_PLATFORM_UNIX)
- add_compile_options(-fPIC)
+ include_directories(${GENERATED_INCLUDE_DIR})
+ add_compile_options(-fPIC)
endif(CLR_CMAKE_PLATFORM_UNIX)
set(DACCESS_SOURCES
@@ -54,3 +55,5 @@ convert_to_absolute_path(DACCESS_SOURCES ${DACCESS_SOURCES})
add_precompiled_header(stdafx.h stdafx.cpp DACCESS_SOURCES)
add_library(daccess ${DACCESS_SOURCES})
+
+add_dependencies(daccess coreclr)
diff --git a/src/debug/daccess/daccess.cpp b/src/debug/daccess/daccess.cpp
index ded8ff9272..9d21dcad2c 100644
--- a/src/debug/daccess/daccess.cpp
+++ b/src/debug/daccess/daccess.cpp
@@ -25,6 +25,9 @@
#include "dwreport.h"
#include "primitives.h"
#include "dbgutil.h"
+#ifdef FEATURE_PAL
+#include <dactablerva.h>
+#endif
#include "dwbucketmanager.hpp"
@@ -7196,20 +7199,14 @@ HRESULT
ClrDataAccess::GetDacGlobals()
{
#ifdef FEATURE_PAL
- PVOID dacTableAddress = nullptr;
- ULONG dacTableSize = 0;
- DWORD err = PAL_GetDacTableAddress((PVOID)m_globalBase, &dacTableAddress, &dacTableSize);
- if (err != ERROR_SUCCESS)
- {
- return CORDBG_E_MISSING_DEBUGGER_EXPORTS;
- }
-
- if (dacTableSize != sizeof(g_dacGlobals))
+#ifdef DAC_TABLE_SIZE
+ if (DAC_TABLE_SIZE != sizeof(g_dacGlobals))
{
return E_INVALIDARG;
}
-
- if (FAILED(ReadFromDataTarget(m_pTarget, (ULONG64)dacTableAddress, (BYTE*)&g_dacGlobals, dacTableSize)))
+#endif
+ ULONG64 dacTableAddress = m_globalBase + DAC_TABLE_RVA;
+ if (FAILED(ReadFromDataTarget(m_pTarget, dacTableAddress, (BYTE*)&g_dacGlobals, sizeof(g_dacGlobals))))
{
return CORDBG_E_MISSING_DEBUGGER_EXPORTS;
}
diff --git a/src/debug/ee/dactable.cpp b/src/debug/ee/dactable.cpp
index c7cf64e186..b1925830b6 100644
--- a/src/debug/ee/dactable.cpp
+++ b/src/debug/ee/dactable.cpp
@@ -58,7 +58,6 @@ void DacGlobals::Initialize()
#ifdef FEATURE_SVR_GC
g_dacTable.InitializeSVREntries(baseAddress);
#endif
- PAL_PublishDacTableAddress((PVOID)baseAddress, &g_dacTable, sizeof(g_dacTable));
}
// Initializes the non-SVR table entries
diff --git a/src/dlls/mscoree/coreclr/CMakeLists.txt b/src/dlls/mscoree/coreclr/CMakeLists.txt
index 9337fc54b4..d6653a03e3 100644
--- a/src/dlls/mscoree/coreclr/CMakeLists.txt
+++ b/src/dlls/mscoree/coreclr/CMakeLists.txt
@@ -117,7 +117,6 @@ endif(WIN32)
target_link_libraries(coreclr ${CORECLR_LIBRARIES})
if(WIN32)
-
add_dependencies(coreclr dactablegen)
# Add dac table & debug resource to coreclr
@@ -134,6 +133,14 @@ if(WIN32)
COMMAND $<TARGET_FILE:InjectResource> /bin:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin /dll:$<TARGET_FILE:coreclr> /name:CLRDEBUGINFO
COMMENT Add dactable & debug resources to coreclr
)
+else()
+ add_custom_command(
+ TARGET coreclr
+ POST_BUILD
+ VERBATIM
+ COMMAND sh ${CLR_DIR}/src/pal/tools/gen-dactable-rva.sh $<TARGET_FILE:coreclr> ${GENERATED_INCLUDE_DIR}/dactablerva.h
+ COMMENT Generating ${GENERATED_INCLUDE_DIR}/dactablerva.h
+ )
endif(WIN32)
# add the install targets
diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h
index b9d537f654..2148b119a3 100644
--- a/src/pal/inc/pal.h
+++ b/src/pal/inc/pal.h
@@ -599,32 +599,6 @@ PAL_DeleteExecWatchpoint(
#endif
-PALIMPORT
-DWORD
-PALAPI
-PAL_PublishDacTableAddress(
- IN PVOID baseAddress,
- IN PVOID tableAddress,
- IN ULONG tableSize
- );
-
-PALIMPORT
-DWORD
-PALAPI
-PAL_GetDacTableAddress(
- IN PVOID baseAddress,
- OUT PVOID *tableAddress,
- OUT PULONG tableSize
- );
-
-PALIMPORT
-VOID
-PALAPI
-PAL_CleanupDacTableAddress(
- IN PVOID baseAddress
- );
-
-
/******************* winuser.h Entrypoints *******************************/
PALIMPORT
diff --git a/src/pal/src/CMakeLists.txt b/src/pal/src/CMakeLists.txt
index bc966c1ce5..890fc4c46c 100644
--- a/src/pal/src/CMakeLists.txt
+++ b/src/pal/src/CMakeLists.txt
@@ -104,7 +104,6 @@ set(SOURCES
misc/interlock.cpp
misc/miscpalapi.cpp
misc/msgbox.cpp
- misc/dactableaddress.cpp
misc/strutil.cpp
misc/sysinfo.cpp
misc/time.cpp
diff --git a/src/pal/src/misc/dactableaddress.cpp b/src/pal/src/misc/dactableaddress.cpp
deleted file mode 100644
index ba635a0226..0000000000
--- a/src/pal/src/misc/dactableaddress.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-/*++
-
-
-
-Module Name:
-
- dactableaddress.cpp
-
-Abstract:
-
- Functions to write and read DAC global pointer table address between the coreclr
- and DAC/debugger processes.
-
-NOTE:
-
- These functions are temporary until a better way to plumb the DAC table
- address from the debuggee to debugger processes is implemented.
-
-Revision History:
-
-
---*/
-
-#include "pal/palinternal.h"
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdio.h>
-
-/*++
-Function
- PAL_PublishDacTableAddress
-
-Parameters
-
- baseAddress
- [in] base address of CLR module
- tableAddress
- [in] address of dac table
- tableSize
- [in] size of dac table
-
-Return Values
- pal errors
-
---*/
-PALIMPORT
-DWORD
-PALAPI
-PAL_PublishDacTableAddress(
- IN PVOID baseAddress,
- IN PVOID tableAddress,
- IN ULONG tableSize)
-{
- DWORD ret = NO_ERROR;
-
- char fileName[100];
- snprintf(fileName, sizeof(fileName), "/tmp/%p_dacTable", baseAddress);
-
- FILE *file = fopen(fileName, "w+");
- if (file != nullptr)
- {
- char dacTableInfo[100];
- snprintf(dacTableInfo, sizeof(dacTableInfo), "%p %d\n", tableAddress, tableSize);
-
- if (fputs(dacTableInfo, file) < 0)
- {
- ret = ERROR_INVALID_DATA;
- }
-
- fclose(file);
- }
- else
- {
- ret = ERROR_FILE_NOT_FOUND;
- }
-
- return ret;
-}
-
-
-/*++
-Function
- PAL_GetDacTableAddress
-
-Parameters
-
- baseAddress
- [in] base address of CLR module
- tableAddress
- [out] pointer to put DAC table address
- tableSize
- [out] pointer to put DAC table size
-
-Return Values
- pal errors
-
---*/
-PALIMPORT
-DWORD
-PALAPI
-PAL_GetDacTableAddress(
- IN PVOID baseAddress,
- OUT PVOID *tableAddress,
- OUT PULONG tableSize)
-{
- DWORD ret = NO_ERROR;
-
- char fileName[100];
- snprintf(fileName, sizeof(fileName), "/tmp/%p_dacTable", baseAddress);
-
- FILE *file = fopen(fileName, "r");
- if (file != nullptr)
- {
- char data[100];
- if (fgets(data, sizeof(data), file) != nullptr)
- {
- if (sscanf(data, "%p %d\n", tableAddress, tableSize) != 2)
- {
- ret = ERROR_INVALID_DATA;
- }
- }
- else
- {
- ret = ERROR_INVALID_DATA;
- }
-
- fclose(file);
- }
- else
- {
- ret = ERROR_FILE_NOT_FOUND;
- }
- return ret;
-}
-
-/*++
-Function
- PAL_CleanupDacTableAddress
-
-Parameters
- None
-
-Return Values
- None
-
---*/
-PALIMPORT
-VOID
-PALAPI
-PAL_CleanupDacTableAddress(
- IN PVOID baseAddress)
-{
- char fileName[100];
- snprintf(fileName, sizeof(fileName), "/tmp/%p_dacTable", baseAddress);
- remove(fileName);
-}
diff --git a/src/pal/tools/gen-dactable-rva.sh b/src/pal/tools/gen-dactable-rva.sh
new file mode 100644
index 0000000000..dd200068e5
--- /dev/null
+++ b/src/pal/tools/gen-dactable-rva.sh
@@ -0,0 +1 @@
+nm $1 | grep g_dacTable | cut -f 1 -d' ' | head -n 1 | awk '{ print "#define DAC_TABLE_RVA 0x" $1}' > $2