diff options
author | Jonathan Pryor <jonpryor@vt.edu> | 2012-12-05 08:08:44 +0400 |
---|---|---|
committer | Jonathan Pryor <jonpryor@vt.edu> | 2012-12-05 08:08:44 +0400 |
commit | 657bab25a98d2bea608630c31ac61d7fcefb55e7 (patch) | |
tree | ffe4e7697d72203ad22866f8111d6d84230845d2 | |
parent | d7280785f1a21ef0c1982a1d82dd1c765d023c67 (diff) |
Don't version shared libraries on Android.
Wanted: profiler support on Android. ;-)
...which seems sane enough: we have this nifty pluggable profiler
mechanism already, we have profilers built as separate shared libs
(e.g. libmono-profiler-log.so), let's just "somehow" load one, call
the init function, and we're off to the races, right?
void* h = dlopen ("path/to/libmono-profiler-log.so", RTLD_LAZY)
// h == null; dlerror() is:
// Cannot load library: soinfo_link_image(linker.cpp:1635): could not load library
// "libmonosgen-2.0.so.0" needed by "libmono-profiler-log.so"; caused by
// load_library(linker.cpp:745): library "libmonosgen-2.0.so.0" not found
Ouch. So the problem is that libmonosgen-2.0.so contains a versioned
SONAME ("libmonosgen-2.0.so.0"), and thus libmono-profiler-log.so
contains a versioned SONAME reference, which cannot be resolved.
(Android doesn't allow versioned .so's to be placed within .apks.)
Fix the first: make libmonosgen-2.0.so unversioned. That way,
libmono-profiler-log.so contains an unversioned library reference, and
Android is appeased!
(Unversion libmono-profiler-log.so for good measure.)
Fix the second: with the above fix in place, libmono-profiler-log.so
SITLL won't be loaded, with dlerror(3) reporting:
Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate
symbol "monoeg_g_log" referenced by "libmono-profiler-log.so"
The issue here is that libmonosgen-2.0.so contains unexported symbol
references from eglib, e.g. monoeg_g_log(), and dlopen() won't use
those unexported symbols. So just add the glib link references to
libmono-profiler-log.so, and everything is kosher. Yay.
-rw-r--r-- | mono/mini/Makefile.am | 4 | ||||
-rw-r--r-- | mono/profiler/Makefile.am | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/mono/mini/Makefile.am b/mono/mini/Makefile.am index 8ebf01aa0df..f4e6a71804e 100644 --- a/mono/mini/Makefile.am +++ b/mono/mini/Makefile.am @@ -547,6 +547,10 @@ libmonosgen_2_0_la_SOURCES = libmonosgen_2_0_la_CFLAGS = $(mono_sgen_CFLAGS) libmonosgen_2_0_la_LIBADD = libmini.la $(sgen_libs) $(LIBMONO_DTRACE_OBJECT) +if PLATFORM_ANDROID +libmonosgen_2_0_la_LDFLAGS = -avoid-version +endif + if MOONLIGHT libmono_moon_la_SOURCES = $(libmini_la_SOURCES) if MOONLIGHT_BOEHM diff --git a/mono/profiler/Makefile.am b/mono/profiler/Makefile.am index c69c8dbcae5..a6f029ab590 100644 --- a/mono/profiler/Makefile.am +++ b/mono/profiler/Makefile.am @@ -17,6 +17,9 @@ lib_LTLIBRARIES = libmono-profiler-cov.la libmono-profiler-aot.la libmono-profil if PLATFORM_DARWIN libmono_profiler_log_la_LDFLAGS = -Wl,-undefined -Wl,suppress -Wl,-flat_namespace endif +if PLATFORM_ANDROID +libmono_profiler_log_la_LDFLAGS = -avoid-version +endif endif endif endif @@ -57,6 +60,10 @@ libmono_profiler_iomap_la_LIBADD = $(LIBMONO) $(GLIB_LIBS) $(LIBICONV) libmono_profiler_log_la_SOURCES = proflog.c libmono_profiler_log_la_LIBADD = $(LIBMONO) $(Z_LIBS) +if PLATFORM_ANDROID +libmono_profiler_log_la_LIBADD += $(GLIB_LIBS) +endif + mprof_report_SOURCES = decode.c mprof_report_LDADD = $(Z_LIBS) |