Module: xenomai-3 Branch: master Commit: 8c82454cd6bed496a8c4d6e1d059b0b5c87bb6c7 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8c82454cd6bed496a8c4d6e1d059b0b5c87bb6c7
Author: Philippe Gerum <[email protected]> Date: Tue Mar 14 19:01:20 2017 +0100 lib/cobalt: modechk: switch to shared object, drop cxa wrappers Dynamically linked code from shared libraries which may reference mode checking wrappers cannot depend on symbols which are only visible from the static link phase, such as those defined by the libmodechk.a library. Otherwise, unresolved references to symbols from libmodechk.a may exist in shared objects such as libcopperplate.so. Unfortunately, we can't interpose on the cxa* API from a dynamic library, since the latter would create references to "real" __cxa_acquire/release/abort() routines, which are not available from plain C builds since only libstdc++ defines them. Providing placeholders for the cxa* API calls in a dynamic object is not an option either, since that would create a dependency on the link order between libmodechk and libstdc++ for pulling the actual symbols instead of the dummy ones, which is not acceptable. Besides, relying on LD_DYNAMIC_WEAK is fragile, unpractical, and won't work in secured execution mode. To work around this chicken-and-egg issue, make libmodechk a shared object, and drop mode checking for the cxa* API for now. We'll revisit the issue of enabling back the cxa* API later. --- configure.ac | 2 +- lib/cobalt/Makefile.am | 16 +++----------- lib/cobalt/cxaguard.c | 54 ------------------------------------------------ 3 files changed, 4 insertions(+), 68 deletions(-) diff --git a/configure.ac b/configure.ac index d5c5aaa..37b15a0 100644 --- a/configure.ac +++ b/configure.ac @@ -820,7 +820,7 @@ AC_SUBST(XENO_AUTOINIT_LDFLAGS) XENO_CORE_LDADD="\$(top_builddir)/lib/$rtcore_type/lib${rtcore_type}.la" if test $rtcore_type = cobalt; then - XENO_CORE_LDADD="$XENO_CORE_LDADD \$(top_builddir)/lib/cobalt/libmodechk.a" + XENO_CORE_LDADD="$XENO_CORE_LDADD \$(top_builddir)/lib/cobalt/libmodechk.la" fi AC_SUBST(XENO_CORE_LDADD) diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am index c2d5956..5230a38 100644 --- a/lib/cobalt/Makefile.am +++ b/lib/cobalt/Makefile.am @@ -5,7 +5,7 @@ noinst_HEADERS = \ umm.h \ internal.h -lib_LTLIBRARIES = libcobalt.la +lib_LTLIBRARIES = libcobalt.la libmodechk.la libcobalt_la_LDFLAGS = @XENO_LIB_LDFLAGS@ -version-info 2:0:0 -lpthread -lrt @@ -42,21 +42,11 @@ libcobalt_la_CPPFLAGS = \ -I$(top_srcdir)/include/cobalt \ -I$(top_srcdir)/include -# The mode checking wrappers must reside in a static archive, so that -# the linker will pull them on demand, dropping the requirement for -# providing potentially conflicting placeholders for wrapped symbols -# which may not be present in both C and C++ support libraries -# (e.g. __cxa_guard_acquire/release/abort from the one-time C++ -# constructor API). - -lib_LIBRARIES = libmodechk.a - -libmodechk_a_SOURCES = \ - cxaguard.c \ +libmodechk_la_SOURCES = \ malloc.c \ malloc-nowrap.c -libmodechk_a_CPPFLAGS = \ +libmodechk_la_CPPFLAGS = \ @XENO_COBALT_CFLAGS@ \ -I$(top_srcdir)/include/cobalt \ -I$(top_srcdir)/include diff --git a/lib/cobalt/cxaguard.c b/lib/cobalt/cxaguard.c deleted file mode 100644 index 6df471a..0000000 --- a/lib/cobalt/cxaguard.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2017 Henning Schild <[email protected]> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#include <stdint.h> -#include <cobalt/sys/cobalt.h> -#include <cobalt/wrappers.h> - -#ifdef __ARM_EABI__ -typedef uint32_t __cxa_guard_type; -#else -typedef uint64_t __cxa_guard_type; -#endif - -COBALT_DECL(int, __cxa_guard_acquire(__cxa_guard_type *g)); -int __real_cxa_guard_acquire(__cxa_guard_type *g); - -/* CXXABI 3.3.2 One-time Construction API */ -COBALT_IMPL(int, __cxa_guard_acquire, (__cxa_guard_type *g)) -{ - cobalt_assert_nrt(); - return __STD(__cxa_guard_acquire(g)); -} - -COBALT_DECL(void, __cxa_guard_release(__cxa_guard_type *g)); -void __real_cxa_guard_release(__cxa_guard_type *g); - -COBALT_IMPL(void, __cxa_guard_release, (__cxa_guard_type *g)) -{ - cobalt_assert_nrt(); - __STD(__cxa_guard_release(g)); -} - -COBALT_DECL(void, __cxa_guard_abort(__cxa_guard_type *g)); -void __real_cxa_guard_abort(__cxa_guard_type *g); - -COBALT_IMPL(void, __cxa_guard_abort, (__cxa_guard_type *g)) -{ - cobalt_assert_nrt(); - __STD(__cxa_guard_abort(g)); -} _______________________________________________ Xenomai-git mailing list [email protected] https://xenomai.org/mailman/listinfo/xenomai-git
