summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-08-07 18:21:08 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-08-07 18:21:19 +0200
commit9c9f0ea2c38929d133b0fe2faf616ecab17e07c9 (patch)
tree692821f2b387b637367ff2a2394eb1d84d6f0d04
parent525063f24d2a95bd0ae47780f7e7cb15333f0d33 (diff)
Include RTTI in generated vtables for ubsan's vptr-based checks
...though only on gcc3_linux_x86-64 for now. Change-Id: Id90554425e78b38a5a97149f2a7d3ac04cbe0c9b
-rw-r--r--bridges/Library_cpp_uno.mk2
-rw-r--r--bridges/inc/bridges/cpp_uno/shared/vtablefactory.hxx14
-rw-r--r--bridges/source/cpp_uno/gcc3_aix_powerpc/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-arm.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-arm64.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-i386.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_alpha/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_hppa/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_ia64/cpp2uno.cxx2
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_intel/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_m68k/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_powerpc/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_s390/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_s390x/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_sparc/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx11
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx130
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx1
-rw-r--r--bridges/source/cpp_uno/gcc3_macosx_intel/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_macosx_powerpc/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_macosx_x86-64/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_solaris_intel/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_solaris_sparc/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/mingw_intel/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/mingw_x86-64/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/shared/vtablefactory.cxx15
31 files changed, 83 insertions, 164 deletions
diff --git a/bridges/Library_cpp_uno.mk b/bridges/Library_cpp_uno.mk
index d929c868be4a..e9714426f8cf 100644
--- a/bridges/Library_cpp_uno.mk
+++ b/bridges/Library_cpp_uno.mk
@@ -125,7 +125,7 @@ ifneq ($(filter DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),)
bridges_SELECTED_BRIDGE := gcc3_linux_x86-64
bridge_asm_objects := call
bridge_noncallexception_noopt_objects := callvirtualmethod
-bridge_exception_objects := abi cpp2uno except uno2cpp
+bridge_exception_objects := abi cpp2uno except rtti uno2cpp
else ifeq ($(OS),MACOSX)
bridges_SELECTED_BRIDGE := gcc3_macosx_x86-64
bridge_exception_objects := abi call cpp2uno except uno2cpp
diff --git a/bridges/inc/bridges/cpp_uno/shared/vtablefactory.hxx b/bridges/inc/bridges/cpp_uno/shared/vtablefactory.hxx
index 613358dc84e0..5b4b06b4e03c 100644
--- a/bridges/inc/bridges/cpp_uno/shared/vtablefactory.hxx
+++ b/bridges/inc/bridges/cpp_uno/shared/vtablefactory.hxx
@@ -128,9 +128,11 @@ private:
void freeBlock(Block const & block) const;
- void createVtables(
+ sal_Int32 createVtables(
GuardedBlocks & blocks, BaseOffset const & baseOffset,
- typelib_InterfaceTypeDescription * type, bool includePrimary) const;
+ typelib_InterfaceTypeDescription * type, sal_Int32 vtableNumber,
+ typelib_InterfaceTypeDescription * mostDerived, bool includePrimary)
+ const;
// This function is not defined in the generic part, but instead has to be
// defined individually for each CPP--UNO bridge:
@@ -150,9 +152,15 @@ private:
@param block the start address of the raw vtable block
@param slotCount the number of slots
+ @param vtableNumber zero-based count across all the most derived type's
+ vtables (for vtable's "offset to top" slot)
+ @param type non-null most derived type (for vtable's "typeinfo pointer"
+ slot)
@return a pointer past the last vtable slot
*/
- static Slot * initializeBlock(void * block, sal_Int32 slotCount);
+ static Slot * initializeBlock(
+ void * block, sal_Int32 slotCount, sal_Int32 vtableNumber,
+ typelib_InterfaceTypeDescription * type);
// This function is not defined in the generic part, but instead has to be
// defined individually for each CPP--UNO bridge:
diff --git a/bridges/source/cpp_uno/gcc3_aix_powerpc/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_aix_powerpc/cpp2uno.cxx
index d98d32f53002..33bb5fafe19c 100644
--- a/bridges/source/cpp_uno/gcc3_aix_powerpc/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_aix_powerpc/cpp2uno.cxx
@@ -579,7 +579,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-arm.cxx b/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-arm.cxx
index 526ba8b4a279..2c02610dcad1 100644
--- a/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-arm.cxx
+++ b/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-arm.cxx
@@ -507,7 +507,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-arm64.cxx b/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-arm64.cxx
index bfea96955f4c..3a67648efa06 100644
--- a/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-arm64.cxx
+++ b/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-arm64.cxx
@@ -498,7 +498,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-i386.cxx b/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-i386.cxx
index 4d10b1c45105..0aa8f5be5626 100644
--- a/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-i386.cxx
+++ b/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno-i386.cxx
@@ -469,7 +469,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_linux_alpha/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_alpha/cpp2uno.cxx
index 799676279ed5..c784d01310de 100644
--- a/bridges/source/cpp_uno/gcc3_linux_alpha/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_alpha/cpp2uno.cxx
@@ -592,7 +592,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx
index 0c7666ac9b4d..b717a4ff8b42 100644
--- a/bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_arm/cpp2uno.cxx
@@ -497,7 +497,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_linux_hppa/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_hppa/cpp2uno.cxx
index bff59bff06f2..b04928f1af10 100644
--- a/bridges/source/cpp_uno/gcc3_linux_hppa/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_hppa/cpp2uno.cxx
@@ -642,7 +642,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_linux_ia64/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_ia64/cpp2uno.cxx
index b638d6c80544..e8ef62e3ba63 100644
--- a/bridges/source/cpp_uno/gcc3_linux_ia64/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_ia64/cpp2uno.cxx
@@ -598,7 +598,7 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
return (slotCount + 2) * sizeof (Slot) + slotCount * codeSnippetSize;
}
-bridges::cpp_uno::shared::VtableFactory::Slot* bridges::cpp_uno::shared::VtableFactory::initializeBlock(void * block, sal_Int32 slotCount)
+bridges::cpp_uno::shared::VtableFactory::Slot* bridges::cpp_uno::shared::VtableFactory::initializeBlock(void * block, sal_Int32 slotCount, sal_Int32, typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
Slot foo = {0,0};
diff --git a/bridges/source/cpp_uno/gcc3_linux_intel/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_intel/cpp2uno.cxx
index defe5aaedd22..d73d2c08dd2e 100644
--- a/bridges/source/cpp_uno/gcc3_linux_intel/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_intel/cpp2uno.cxx
@@ -443,7 +443,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_linux_m68k/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_m68k/cpp2uno.cxx
index aa78fce4d904..5e963eb848d0 100644
--- a/bridges/source/cpp_uno/gcc3_linux_m68k/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_m68k/cpp2uno.cxx
@@ -454,7 +454,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx
index f54ec5ed3ff5..96b7cbfc0813 100644
--- a/bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx
@@ -731,7 +731,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0; //null
diff --git a/bridges/source/cpp_uno/gcc3_linux_powerpc/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_powerpc/cpp2uno.cxx
index 889046c5f3ad..fed962244b02 100644
--- a/bridges/source/cpp_uno/gcc3_linux_powerpc/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_powerpc/cpp2uno.cxx
@@ -709,7 +709,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx
index 5d7d9d966dd9..a4a08c5bf303 100644
--- a/bridges/source/cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx
@@ -639,7 +639,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_linux_s390/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_s390/cpp2uno.cxx
index 7fcefedaa4cf..3ffe81b562ee 100644
--- a/bridges/source/cpp_uno/gcc3_linux_s390/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_s390/cpp2uno.cxx
@@ -609,7 +609,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_linux_s390x/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_s390x/cpp2uno.cxx
index 35b26d79388e..edcdd9c9b289 100644
--- a/bridges/source/cpp_uno/gcc3_linux_s390x/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_s390x/cpp2uno.cxx
@@ -572,7 +572,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_linux_sparc/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_sparc/cpp2uno.cxx
index b4fddaa28dbc..52eb13f74fb6 100644
--- a/bridges/source/cpp_uno/gcc3_linux_sparc/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_sparc/cpp2uno.cxx
@@ -487,7 +487,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0; //null
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx
index 9bb5149a507c..dd6537d749e7 100644
--- a/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/uno/genfunc.hxx>
#include "com/sun/star/uno/RuntimeException.hpp"
+#include <config_options.h>
#include <uno/data.h>
#include <typelib/typedescription.hxx>
@@ -37,6 +38,7 @@
#include "abi.hxx"
#include "call.hxx"
+#include "rtti.hxx"
#include "share.hxx"
using namespace ::osl;
@@ -448,11 +450,16 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32 vtableNumber,
+ typelib_InterfaceTypeDescription * type)
{
Slot * slots = mapBlockToVtable(block);
- slots[-2].fn = 0;
+ slots[-2].fn = reinterpret_cast<void *>(-(vtableNumber * sizeof (void *)));
+#if ENABLE_RUNTIME_OPTIMIZATIONS
slots[-1].fn = 0;
+#else
+ slots[-1].fn = x86_64::getRtti(type->aBase);
+#endif
return slots + slotCount;
}
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx
index 64386b391d53..ad3ce268e0bd 100644
--- a/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx
@@ -20,15 +20,9 @@
#include <stdio.h>
#include <string.h>
-#include <dlfcn.h>
-#include <boost/unordered_map.hpp>
-
-#include <rtl/strbuf.hxx>
#include <rtl/ustrbuf.hxx>
-#include <rtl/instance.hxx>
#include <osl/diagnose.h>
-#include <osl/mutex.hxx>
#include <sal/log.hxx>
#include <com/sun/star/uno/genfunc.hxx>
@@ -36,6 +30,7 @@
#include <typelib/typedescription.hxx>
#include <uno/any2.h>
+#include "rtti.hxx"
#include "share.hxx"
@@ -86,121 +81,6 @@ static OUString toUNOname( char const * p )
#endif
}
-class RTTI
-{
- typedef boost::unordered_map< OUString, type_info *, OUStringHash > t_rtti_map;
-
- Mutex m_mutex;
- t_rtti_map m_rttis;
- t_rtti_map m_generatedRttis;
-
- void * m_hApp;
-
-public:
- RTTI();
- ~RTTI();
-
- type_info * getRTTI( typelib_CompoundTypeDescription * );
-};
-
-RTTI::RTTI()
-#if defined(FREEBSD) && __FreeBSD_version < 702104
- : m_hApp( dlopen( 0, RTLD_NOW | RTLD_GLOBAL ) )
-#else
- : m_hApp( dlopen( 0, RTLD_LAZY ) )
-#endif
-{
-}
-
-RTTI::~RTTI()
-{
- dlclose( m_hApp );
-}
-
-
-type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr )
-{
- type_info * rtti;
-
- OUString const & unoName = *(OUString const *)&pTypeDescr->aBase.pTypeName;
-
- MutexGuard guard( m_mutex );
- t_rtti_map::const_iterator iFind( m_rttis.find( unoName ) );
- if (iFind == m_rttis.end())
- {
- // RTTI symbol
- OStringBuffer buf( 64 );
- buf.append( "_ZTIN" );
- sal_Int32 index = 0;
- do
- {
- OUString token( unoName.getToken( 0, '.', index ) );
- buf.append( token.getLength() );
- OString c_token( OUStringToOString( token, RTL_TEXTENCODING_ASCII_US ) );
- buf.append( c_token );
- }
- while (index >= 0);
- buf.append( 'E' );
-
- OString symName( buf.makeStringAndClear() );
-#if defined(FREEBSD) && __FreeBSD_version < 702104 /* #i22253# */
- rtti = (type_info *)dlsym( RTLD_DEFAULT, symName.getStr() );
-#else
- rtti = (type_info *)dlsym( m_hApp, symName.getStr() );
-#endif
-
- if (rtti)
- {
- pair< t_rtti_map::iterator, bool > insertion (
- m_rttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
- SAL_WARN_IF( !insertion.second, "bridges", "key " << unoName << " already in rtti map" );
- }
- else
- {
- // try to lookup the symbol in the generated rtti map
- t_rtti_map::const_iterator iFind2( m_generatedRttis.find( unoName ) );
- if (iFind2 == m_generatedRttis.end())
- {
- // we must generate it !
- // symbol and rtti-name is nearly identical,
- // the symbol is prefixed with _ZTI
- char const * rttiName = symName.getStr() +4;
-#if OSL_DEBUG_LEVEL > 1
- fprintf( stderr,"generated rtti for %s\n", rttiName );
-#endif
- if (pTypeDescr->pBaseTypeDescription)
- {
- // ensure availability of base
- type_info * base_rtti = getRTTI(
- (typelib_CompoundTypeDescription *)pTypeDescr->pBaseTypeDescription );
- rtti = new __si_class_type_info(
- strdup( rttiName ), (__class_type_info *)base_rtti );
- }
- else
- {
- // this class has no base class
- rtti = new __class_type_info( strdup( rttiName ) );
- }
-
- pair< t_rtti_map::iterator, bool > insertion (
- m_generatedRttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
- SAL_WARN_IF( !insertion.second, "bridges", "key " << unoName << " already in generated rtti map" );
- }
- else // taking already generated rtti
- {
- rtti = iFind2->second;
- }
- }
- }
- else
- {
- rtti = iFind->second;
- }
-
- return rtti;
-}
-
-
extern "C" {
static void _GLIBCXX_CDTOR_CALLABI deleteException( void * pExc )
{
@@ -217,11 +97,6 @@ static void _GLIBCXX_CDTOR_CALLABI deleteException( void * pExc )
}
}
-namespace
-{
- struct theRTTI : public rtl::Static<RTTI, theRTTI> {};
-}
-
void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
{
#if OSL_DEBUG_LEVEL > 1
@@ -252,8 +127,7 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
// destruct uno exception
::uno_any_destruct( pUnoExc, 0 );
// avoiding locked counts
- static RTTI &rRTTI = theRTTI::get();
- rtti = rRTTI.getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr );
+ rtti = x86_64::getRtti(*pTypeDescr);
TYPELIB_DANGER_RELEASE( pTypeDescr );
OSL_ENSURE( rtti, "### no rtti for throwing exception!" );
if (! rtti)
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx
index 732fe5bd1a1e..96ddfc0be0b3 100644
--- a/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx
+++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx
@@ -29,6 +29,7 @@
#endif
#include "config_gcc.h"
+#include "uno/any2.h"
#include "uno/mapping.h"
#ifdef _LIBCPP_VERSION
diff --git a/bridges/source/cpp_uno/gcc3_macosx_intel/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_macosx_intel/cpp2uno.cxx
index 2ab17ef71b14..47a21f101e9c 100644
--- a/bridges/source/cpp_uno/gcc3_macosx_intel/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_macosx_intel/cpp2uno.cxx
@@ -450,7 +450,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_macosx_powerpc/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_macosx_powerpc/cpp2uno.cxx
index f9e1cdeb9f17..0cba20d5b260 100644
--- a/bridges/source/cpp_uno/gcc3_macosx_powerpc/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_macosx_powerpc/cpp2uno.cxx
@@ -665,7 +665,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_macosx_x86-64/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_macosx_x86-64/cpp2uno.cxx
index 99259373a0a6..d6d23f92ef74 100644
--- a/bridges/source/cpp_uno/gcc3_macosx_x86-64/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_macosx_x86-64/cpp2uno.cxx
@@ -441,7 +441,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_solaris_intel/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_solaris_intel/cpp2uno.cxx
index 2b3576b15bf2..5957a0db7c9d 100644
--- a/bridges/source/cpp_uno/gcc3_solaris_intel/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_solaris_intel/cpp2uno.cxx
@@ -438,7 +438,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/gcc3_solaris_sparc/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_solaris_sparc/cpp2uno.cxx
index f42a45586eb5..a1c65efeb6fc 100644
--- a/bridges/source/cpp_uno/gcc3_solaris_sparc/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_solaris_sparc/cpp2uno.cxx
@@ -485,7 +485,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0; //null
diff --git a/bridges/source/cpp_uno/mingw_intel/cpp2uno.cxx b/bridges/source/cpp_uno/mingw_intel/cpp2uno.cxx
index 184c4681fd85..3cbff636882b 100644
--- a/bridges/source/cpp_uno/mingw_intel/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/mingw_intel/cpp2uno.cxx
@@ -434,7 +434,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/mingw_x86-64/cpp2uno.cxx b/bridges/source/cpp_uno/mingw_x86-64/cpp2uno.cxx
index 25d94971c3fa..39eb28b59331 100644
--- a/bridges/source/cpp_uno/mingw_x86-64/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/mingw_x86-64/cpp2uno.cxx
@@ -441,7 +441,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
Slot * slots = mapBlockToVtable(block);
slots[-2].fn = 0;
diff --git a/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx b/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx
index 58e3fbc96ac2..371254722073 100644
--- a/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx
@@ -432,7 +432,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
- void * block, sal_Int32 slotCount)
+ void * block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription *)
{
struct Rtti {
sal_Int32 n0, n1, n2;
diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx
index 43cdf94c970c..555bee10481d 100644
--- a/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx
@@ -447,7 +447,8 @@ sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
void * block,
- sal_Int32 slotCount )
+ sal_Int32 slotCount,
+ sal_Int32, typelib_InterfaceTypeDescription * )
{
struct Rtti {
sal_Int32 n0, n1, n2;
diff --git a/bridges/source/cpp_uno/shared/vtablefactory.cxx b/bridges/source/cpp_uno/shared/vtablefactory.cxx
index 2589f64d40f6..325f9e326f11 100644
--- a/bridges/source/cpp_uno/shared/vtablefactory.cxx
+++ b/bridges/source/cpp_uno/shared/vtablefactory.cxx
@@ -207,7 +207,7 @@ VtableFactory::Vtables VtableFactory::getVtables(
Map::iterator i(m_map.find(name));
if (i == m_map.end()) {
GuardedBlocks blocks(*this);
- createVtables(blocks, BaseOffset(type), type, true);
+ createVtables(blocks, BaseOffset(type), type, 0, type, true);
Vtables vtables;
OSL_ASSERT(blocks.size() <= SAL_MAX_INT32);
vtables.count = static_cast< sal_Int32 >(blocks.size());
@@ -323,9 +323,10 @@ void VtableFactory::freeBlock(Block const & block) const {
}
#endif
-void VtableFactory::createVtables(
+sal_Int32 VtableFactory::createVtables(
GuardedBlocks & blocks, BaseOffset const & baseOffset,
- typelib_InterfaceTypeDescription * type, bool includePrimary) const
+ typelib_InterfaceTypeDescription * type, sal_Int32 vtableNumber,
+ typelib_InterfaceTypeDescription * mostDerived, bool includePrimary) const
{
if (includePrimary) {
sal_Int32 slotCount
@@ -335,7 +336,8 @@ void VtableFactory::createVtables(
throw std::bad_alloc();
}
try {
- Slot * slots = initializeBlock(block.start, slotCount);
+ Slot * slots = initializeBlock(
+ block.start, slotCount, vtableNumber, mostDerived);
unsigned char * codeBegin =
reinterpret_cast< unsigned char * >(slots);
unsigned char * code = codeBegin;
@@ -366,8 +368,11 @@ void VtableFactory::createVtables(
}
}
for (sal_Int32 i = 0; i < type->nBaseTypes; ++i) {
- createVtables(blocks, baseOffset, type->ppBaseTypes[i], i != 0);
+ vtableNumber = createVtables(
+ blocks, baseOffset, type->ppBaseTypes[i],
+ vtableNumber + (i == 0 ? 0 : 1), mostDerived, i != 0);
}
+ return vtableNumber;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */