From 8ad2b6f9d8169b46a71b82198ff1f73482a602e8 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 9 Dec 2014 16:10:17 +0100 Subject: Fix base+offset pointer calculations when synthesizing exception data ...but the code does not yet work: Care must be taken to allocate the various data structures close enough together so that the offset calculations at the four places now marked with assert(...); //TODO actually succeed. Change-Id: I1fedf7d2d3cdde5035842b4ad5eca9ad9ccf2d44 --- .../source/cpp_uno/msvc_win32_x86-64/except.cxx | 45 ++++++++++++++++------ 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'bridges') diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx index 70a6637772cd..5ea44f2bb57d 100644 --- a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx +++ b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx @@ -466,9 +466,20 @@ struct ExceptionType // As _n0 is always initialized to zero, that means the // hasvirtbase flag (see the ONTL catchabletype struct) is // off, and thus the copyctor is of the ctor_ptr kind. - _pTypeInfo = (sal_uInt32) ((sal_uInt64) mscx_getRTTI( pTD->pTypeName ) - pCodeBase); + type_info * ti = mscx_getRTTI(pTD->pTypeName); + assert( + pCodeBase <= reinterpret_cast(ti) + && reinterpret_cast(ti) - pCodeBase < 0x100000000); + //TODO + _pTypeInfo = static_cast( + reinterpret_cast(ti) - pCodeBase); GenerateConstructorTrampoline( pCode, pTD ); - _pCopyCtor = (sal_uInt32) ((sal_uInt64) pCode - pCodeBase); + assert( + pCodeBase <= reinterpret_cast(pCode) + && (reinterpret_cast(pCode) - pCodeBase + < 0x100000000)); //TODO + _pCopyCtor = static_cast( + reinterpret_cast(pCode) - pCodeBase); } inline ~ExceptionType() throw () { @@ -533,7 +544,8 @@ RaiseInfo::RaiseInfo( typelib_TypeDescription * pTD )throw () unsigned char * pCode = _code = (unsigned char *)::rtl_allocateMemory( codeSize ); - _codeBase = (sal_uInt64)pCode & ~(ExceptionInfos::allocationGranularity-1); + _codeBase = reinterpret_cast(pCode) + & ~static_cast(ExceptionInfos::allocationGranularity - 1); DWORD old_protect; #if OSL_DEBUG_LEVEL > 0 @@ -549,19 +561,28 @@ RaiseInfo::RaiseInfo( typelib_TypeDescription * pTD )throw () pCode += codeSnippetSize; // Info count accompanied by type info ptrs: type, base type, base base type, ... - _types = (sal_Int32)((sal_uInt64)::rtl_allocateMemory( 4 + 4* nLen) - _codeBase); - *(sal_Int32 *)_types = nLen; - - ExceptionType ** ppTypes = (ExceptionType **)((sal_Int32 *)_types + 1); - - int nPos = 0; + DWORD * types = static_cast(rtl_allocateMemory(4 + 4 * nLen)); + assert( + _codeBase <= reinterpret_cast(types) + && reinterpret_cast(types) - _codeBase < 0x100000000); + //TODO + _types = static_cast( + reinterpret_cast(types) - _codeBase); + types[0] = nLen; + + int nPos = 1; for ( pCompTD = (typelib_CompoundTypeDescription*)pTD; pCompTD; pCompTD = pCompTD->pBaseTypeDescription ) { - ppTypes[nPos++] = - new ExceptionType( pCode, _codeBase, - (typelib_TypeDescription *)pCompTD ); + ExceptionType * et = new ExceptionType( + pCode, _codeBase, (typelib_TypeDescription *)pCompTD); pCode += codeSnippetSize; + assert( + _codeBase <= reinterpret_cast(et) + && reinterpret_cast(et) - _codeBase < 0x100000000); + //TODO + types[nPos++] + = static_cast(reinterpret_cast(et) - _codeBase); } } -- cgit