Get more --disable-dynamic-loading code out of shlib.cxx.

It's not terribly nice, but, hopefully, better.
The hope is that one day, lo_get_library_map will be no more.
In lo_get_implementation_map we can specify more precisely what to link
into the binary.

Change-Id: I99a1854fbae05be2f70302cc56bea88e522ec129
This commit is contained in:
Matúš Kukan 2013-12-16 17:26:34 +01:00
parent e20f27f0a0
commit d8bbae2fd6
7 changed files with 122 additions and 67 deletions

View File

@ -12,9 +12,10 @@
extern "C"
__attribute__ ((visibility("default")))
const lib_to_component_mapping *
lo_get_libmap(void)
lo_get_library_map(void)
{
static lib_to_component_mapping map[] = {
NON_APP_SPECIFIC_COMPONENT_MAP
{ "libanimcorelo.a", animcore_component_getFactory },
{ "libavmedialo.a", avmedia_component_getFactory },
{ "libdbalo.a", dba_component_getFactory },
@ -59,4 +60,17 @@ lo_get_libmap(void)
return map;
}
extern "C"
__attribute__ ((visibility("default")))
const lib_to_component_mapping *
lo_get_implementation_map(void)
{
static lib_to_component_mapping map[] = {
NON_APP_SPECIFIC_DIRECT_COMPONENT_MAP
{ NULL, NULL }
};
return map;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -12,9 +12,10 @@
extern "C"
__attribute__ ((visibility("default")))
const lib_to_component_mapping *
lo_get_libmap(void)
lo_get_library_map(void)
{
static lib_to_component_mapping map[] = {
NON_APP_SPECIFIC_COMPONENT_MAP
{ "libanimcorelo.a", animcore_component_getFactory },
{ "libavmedialo.a", avmedia_component_getFactory },
{ "libbasprov.uno.a", basprov_component_getFactory },
@ -77,4 +78,17 @@ lo_get_libmap(void)
return map;
}
extern "C"
__attribute__ ((visibility("default")))
const lib_to_component_mapping *
lo_get_implementation_map(void)
{
static lib_to_component_mapping map[] = {
NON_APP_SPECIFIC_DIRECT_COMPONENT_MAP
{ NULL, NULL }
};
return map;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -12,9 +12,10 @@
extern "C"
__attribute__ ((visibility("default")))
const lib_to_component_mapping *
lo_get_libmap(void)
lo_get_library_map(void)
{
static lib_to_component_mapping map[] = {
NON_APP_SPECIFIC_COMPONENT_MAP
{ "libanimcorelo.a", animcore_component_getFactory },
{ "libavmedialo.a", avmedia_component_getFactory },
{ "libbasprovlo.a", basprov_component_getFactory },
@ -89,4 +90,17 @@ lo_get_libmap(void)
return map;
}
extern "C"
__attribute__ ((visibility("default")))
const lib_to_component_mapping *
lo_get_implementation_map(void)
{
static lib_to_component_mapping map[] = {
NON_APP_SPECIFIC_DIRECT_COMPONENT_MAP
{ NULL, NULL }
};
return map;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -283,76 +283,27 @@ css::uno::Reference<css::uno::XInterface> loadSharedLibComponentFactory(
#ifdef DISABLE_DYNLOADING
// First test library names that aren't app-specific.
static lib_to_component_mapping components_mapping[] = {
{ "libintrospectionlo.a", introspection_component_getFactory },
{ "libreflectionlo.a", reflection_component_getFactory },
{ "libstocserviceslo.a", stocservices_component_getFactory },
{ "libcomphelper.a", comphelp_component_getFactory },
{ "libconfigmgrlo.a", configmgr_component_getFactory },
{ "libdeployment.a", deployment_component_getFactory },
{ "libfilterconfiglo.a", filterconfig1_component_getFactory },
{ "libfwklo.a", fwk_component_getFactory },
{ "libi18npoollo.a", i18npool_component_getFactory },
{ "liblocalebe1lo.a", localebe1_component_getFactory },
{ "libpackage2.a", package2_component_getFactory },
{ "libsfxlo.a", sfx_component_getFactory },
{ "libsvllo.a", svl_component_getFactory },
{ "libtklo.a", tk_component_getFactory },
{ "libucb1.a", ucb_component_getFactory },
{ "libucpexpand1lo.a", ucpexpand1_component_getFactory },
{ "libucpfile1.a", ucpfile_component_getFactory },
{ "libutllo.a", utl_component_getFactory },
{ "libvcllo.a", vcl_component_getFactory },
{ "libxstor.a", xstor_component_getFactory },
{ NULL, NULL }
};
static lib_to_component_mapping direct_components_mapping[] = {
{ "com.sun.star.comp.extensions.xml.sax.ParserExpat", com_sun_star_comp_extensions_xml_sax_ParserExpat_component_getFactory },
{ "com.sun.star.comp.extensions.xml.sax.FastParser", com_sun_star_comp_extensions_xml_sax_FastParser_component_getFactory },
{ "com.sun.star.comp.stoc.DLLComponentLoader.component.getFactory", com_sun_star_comp_stoc_DLLComponentLoader_component_getFactory },
{ "com.sun.star.comp.stoc.ImplementationRegistration.component.getFactory", com_sun_star_comp_stoc_ImplementationRegistration_component_getFactory },
{ "com.sun.star.comp.stoc.NestedRegistry.component.getFactory", com_sun_star_comp_stoc_NestedRegistry_component_getFactory },
{ "com.sun.star.comp.stoc.ORegistryServiceManager.component.getFactory", com_sun_star_comp_stoc_ORegistryServiceManager_component_getFactory },
{ "com.sun.star.comp.stoc.OServiceManager.component.getFactory", com_sun_star_comp_stoc_OServiceManager_component_getFactory },
{ "com.sun.star.comp.stoc.OServiceManagerWrapper.component.getFactory", com_sun_star_comp_stoc_OServiceManagerWrapper_component_getFactory },
{ "com.sun.star.comp.stoc.SimpleRegistry.component.getFactory", com_sun_star_comp_stoc_SimpleRegistry_component_getFactory },
{ "com.sun.star.extensions.xml.sax.Writer", com_sun_star_extensions_xml_sax_Writer_component_getFactory },
{ "com.sun.star.security.comp.stoc.AccessController.component.getFactory", com_sun_star_security_comp_stoc_AccessController_component_getFactory },
{ "com.sun.star.security.comp.stoc.FilePolicy.component.getFactory", com_sun_star_security_comp_stoc_FilePolicy_component_getFactory },
{ NULL, NULL }
};
lib_to_component_mapping *non_app_specific_map = components_mapping;
OString sName;
const lib_to_component_mapping *map = NULL;
if (rPrefix == "direct")
{
sName = OUStringToOString(rImplName, RTL_TEXTENCODING_ASCII_US);
non_app_specific_map = direct_components_mapping;
map = lo_get_implementation_map();
}
else
{
sName = OUStringToOString(uri, RTL_TEXTENCODING_ASCII_US);
map = lo_get_library_map();
}
for (int i = 0; pSym == NULL && non_app_specific_map[i].lib != NULL; ++i)
for (int i = 0; pSym == NULL && map[i].name != NULL; ++i)
{
if ( sName == non_app_specific_map[i].lib )
pSym = (oslGenericFunction) non_app_specific_map[i].component_getFactory_function;
if ( sName == map[i].name )
pSym = (oslGenericFunction) map[i].component_getFactory_function;
}
if ( pSym == NULL)
if ( pSym == NULL )
{
// The call the app-specific lo_get_libmap() to get a mapping for the rest
const lib_to_component_mapping *map = lo_get_libmap();
for (int i = 0; pSym == NULL && map[i].lib != NULL; ++i)
{
if ( uri.equalsAscii( map[i].lib ) )
pSym = (oslGenericFunction) map[i].component_getFactory_function;
}
if ( pSym == NULL )
{
fprintf( stderr, "attempting to load unknown library %s\n", OUStringToOString( uri, RTL_TEXTENCODING_ASCII_US ).getStr() );
assert( !"Attempt to load unknown library" );
}
fprintf( stderr, "attempting to load unknown library %s\n", OUStringToOString( uri, RTL_TEXTENCODING_ASCII_US ).getStr() );
assert( !"Attempt to load unknown library" );
}
#else

View File

@ -27,16 +27,53 @@ extern "C" {
*/
typedef struct {
const char *lib;
const char *name;
void * (*component_getFactory_function)(const char *, void *, void *);
} lib_to_component_mapping;
const lib_to_component_mapping *lo_get_libmap(void);
const lib_to_component_mapping *lo_get_library_map(void);
const lib_to_component_mapping *lo_get_implementation_map(void);
#ifdef __cplusplus
}
#endif
#define NON_APP_SPECIFIC_COMPONENT_MAP \
{ "libintrospectionlo.a", introspection_component_getFactory }, \
{ "libreflectionlo.a", reflection_component_getFactory }, \
{ "libstocserviceslo.a", stocservices_component_getFactory }, \
{ "libcomphelper.a", comphelp_component_getFactory }, \
{ "libconfigmgrlo.a", configmgr_component_getFactory }, \
{ "libdeployment.a", deployment_component_getFactory }, \
{ "libfilterconfiglo.a", filterconfig1_component_getFactory }, \
{ "libfwklo.a", fwk_component_getFactory }, \
{ "libi18npoollo.a", i18npool_component_getFactory }, \
{ "liblocalebe1lo.a", localebe1_component_getFactory }, \
{ "libpackage2.a", package2_component_getFactory }, \
{ "libsfxlo.a", sfx_component_getFactory }, \
{ "libsvllo.a", svl_component_getFactory }, \
{ "libtklo.a", tk_component_getFactory }, \
{ "libucb1.a", ucb_component_getFactory }, \
{ "libucpexpand1lo.a", ucpexpand1_component_getFactory }, \
{ "libucpfile1.a", ucpfile_component_getFactory }, \
{ "libutllo.a", utl_component_getFactory }, \
{ "libvcllo.a", vcl_component_getFactory }, \
{ "libxstor.a", xstor_component_getFactory }, \
#define NON_APP_SPECIFIC_DIRECT_COMPONENT_MAP \
{ "com.sun.star.comp.extensions.xml.sax.ParserExpat", com_sun_star_comp_extensions_xml_sax_ParserExpat_component_getFactory }, \
{ "com.sun.star.comp.extensions.xml.sax.FastParser", com_sun_star_comp_extensions_xml_sax_FastParser_component_getFactory }, \
{ "com.sun.star.comp.stoc.DLLComponentLoader.component.getFactory", com_sun_star_comp_stoc_DLLComponentLoader_component_getFactory }, \
{ "com.sun.star.comp.stoc.ImplementationRegistration.component.getFactory", com_sun_star_comp_stoc_ImplementationRegistration_component_getFactory }, \
{ "com.sun.star.comp.stoc.NestedRegistry.component.getFactory", com_sun_star_comp_stoc_NestedRegistry_component_getFactory }, \
{ "com.sun.star.comp.stoc.ORegistryServiceManager.component.getFactory", com_sun_star_comp_stoc_ORegistryServiceManager_component_getFactory }, \
{ "com.sun.star.comp.stoc.OServiceManager.component.getFactory", com_sun_star_comp_stoc_OServiceManager_component_getFactory }, \
{ "com.sun.star.comp.stoc.OServiceManagerWrapper.component.getFactory", com_sun_star_comp_stoc_OServiceManagerWrapper_component_getFactory }, \
{ "com.sun.star.comp.stoc.SimpleRegistry.component.getFactory", com_sun_star_comp_stoc_SimpleRegistry_component_getFactory }, \
{ "com.sun.star.extensions.xml.sax.Writer", com_sun_star_extensions_xml_sax_Writer_component_getFactory }, \
{ "com.sun.star.security.comp.stoc.AccessController.component.getFactory", com_sun_star_security_comp_stoc_AccessController_component_getFactory }, \
{ "com.sun.star.security.comp.stoc.FilePolicy.component.getFactory", com_sun_star_security_comp_stoc_FilePolicy_component_getFactory }, \
#endif /* DISABLE_DYNLOADING */
#endif // INCLUDED_OSL_DETAIL_COMPONENT_MAPPING_H

View File

@ -18,9 +18,10 @@
extern "C"
const lib_to_component_mapping *
lo_get_libmap(void)
lo_get_library_map(void)
{
static lib_to_component_mapping map[] = {
NON_APP_SPECIFIC_COMPONENT_MAP
{ "libanalysislo.a", analysis_component_getFactory },
{ "libanimcorelo.a", animcore_component_getFactory },
{ "libavmedialo.a", avmedia_component_getFactory },
@ -80,6 +81,18 @@ lo_get_libmap(void)
return map;
}
extern "C"
const lib_to_component_mapping *
lo_get_implementation_map(void)
{
static lib_to_component_mapping map[] = {
NON_APP_SPECIFIC_DIRECT_COMPONENT_MAP
{ NULL, NULL }
};
return map;
}
extern "C"
void
lo_initialize(void)

View File

@ -24,10 +24,11 @@
extern "C"
const lib_to_component_mapping *
lo_get_libmap(void)
lo_get_library_map(void)
{
static lib_to_component_mapping map[] = {
NON_APP_SPECIFIC_COMPONENT_MAP
//from IOS
//MAP_LIB_LO(analysis), //MAP_LIB_LO(animcore), //MAP_LIB_LO(sm),
@ -68,10 +69,21 @@ lo_get_libmap(void)
{ NULL, NULL }
};
return map;
}
extern "C"
const lib_to_component_mapping *
lo_get_implementation_map(void)
{
static lib_to_component_mapping map[] = {
NON_APP_SPECIFIC_DIRECT_COMPONENT_MAP
{ NULL, NULL }
};
return map;
}
NSString * createPaths(NSString * base,NSString * appRootEscaped,NSArray * fileNames){
NSString * prefix = @"file://";