Hello,
I'm developing a C++11 shared library that uses Boost.Asio (with Boost
version 1.72) as a header-only library. Exceptions are disabled as the
library is intended to be used on embedded devices that do not support
exceptions and, to ensure this is the case, all interfaces in my library
have the noexcept operator and I have BOOST_EXCEPTION_DISABLE and
BOOST_NO_EXCEPTIONS defined. Additionally, all public interfaces in the
library do not expose any Boost / Boost.Asio types.
When attempting to hide private symbols in my shared library with the GCC
visibility flags and annotations (i.e. -fvisibility=hidden), I learned that
I needed to define BOOST_ASIO_DISABLE_VISIBILITY to disable the visibility
pragmas in Boost.Asio so the boost::asio symbols will also be hidden.
Although I was able to hide the boost::asio symbols with this strategy,
this still results in a subset of boost::system symbols being visible.
I do have some internal helper free functions that accept a
boost::system::error_code. I suspect that they may have something to do
with these visible symbols, but they are completely internal to the library
and the symbols for those helper functions are not visible when I inspect
the library's symbols with nm -DC.
I will note that I was able to hide the boost::system symbols by using a
linker version script, but I do not wish to maintain an unwieldy list of
symbols to export if I can help it.
Is there a supported way to hide the boost::system symbols aside from using
a linker version script? I have attached nm -DC output along with gcc / g++
invocations for reference.
Thank you,
-Angela
# Compiling the source file with the helper functions:
# Note that the "someboostinstalldir" include directory is marked as system
headers to squelch the
# warnings from asio when the -Woverloaded-virtual flag is used.
# see https://github.com/chriskohlhoff/asio/issues/526
g++ -fno-strict-aliasing -Woverloaded-virtual -Wno-literal-suffix -g -O2
-DBOOST_EXCEPTION_DISABLE -DBOOST_NO_EXCEPTIONS -DBOOST_ASIO_DISABLE_VISIBILITY
-isystem../../someboostinstalldir/include -I../../mylib/include
-fmessage-length=0 -W -Wall -Wshadow -Wwrite-strings -Wformat-security -Werror
-Wmissing-format-attribute -Wno-unused-but-set-variable -mcpu=cortex-a53
-march=armv8-a -funwind-tables -Wa,--noexecstack -Wno-unused-but-set-variable
-Wno-literal-suffix -std=c++11 -fvisibility=hidden -fvisibility-inlines-hidden
-fPIC -MMD -MP -MF .deps.bin/asio_converters.cxx.d -c
src/asio/asio_converters.cxx -o bin/src/asio/asio_converters.o
# Compiling my shared library:
gcc -shared -g -O2 -z noexecstack -Wl,--build-id=sha1 -Wl,--hash-style=gnu
-Wl,-soname,libmylib.so.1 -o bin/libmylib.so.1.0 bin/src/asio/asio_converters.o
<other internal object files included here>
$ nm -DC libmylib.so | grep boost
00000000000273d0 u guard variable for
boost::system::system_category()::system_category_instance
00000000000273b8 u guard variable for
boost::system::generic_category()::generic_category_instance
00000000000273a0 u guard variable for
boost::system::detail::to_std_category(boost::system::error_category
const&)::system_instance
0000000000027388 u guard variable for
boost::system::detail::to_std_category(boost::system::error_category
const&)::generic_instance
0000000000027350 u guard variable for
boost::system::detail::to_std_category(boost::system::error_category
const&)::map_
000000000000e940 W boost::system::system_category()
0000000000008a60 W boost::system::system_error::what() const
00000000000067b8 W boost::system::error_category::equivalent(int,
boost::system::error_condition const&) const
0000000000006828 W
boost::system::error_category::equivalent(boost::system::error_code const&,
int) const
0000000000006a68 W boost::system::error_category::default_error_condition(int)
const
0000000000006860 W boost::system::error_category::failed(int) const
00000000000069d8 W boost::system::error_category::message(int, char*, unsigned
long) const
0000000000007cc0 W boost::system::detail::std_category::equivalent(int,
std::error_condition const&) const
0000000000008520 W
boost::system::detail::std_category::equivalent(std::error_code const&, int)
const
0000000000006da0 W
boost::system::detail::system_error_category::default_error_condition(int) const
0000000000006ee0 W
boost::system::detail::system_error_category::message[abi:cxx11](int) const
0000000000006908 W boost::system::detail::system_error_category::message(int,
char*, unsigned long) const
0000000000006fe0 W
boost::system::detail::generic_error_category::message[abi:cxx11](int) const
0000000000006918 W boost::system::detail::generic_error_category::message(int,
char*, unsigned long) const
00000000000266c0 V typeinfo for boost::system::system_error
0000000000026668 V typeinfo for boost::system::error_category
00000000000266a8 V typeinfo for boost::system::detail::std_category
0000000000026690 V typeinfo for boost::system::detail::system_error_category
0000000000026678 V typeinfo for boost::system::detail::generic_error_category
0000000000012af8 V typeinfo name for boost::system::system_error
0000000000012a50 V typeinfo name for boost::system::error_category
0000000000012ad0 V typeinfo name for boost::system::detail::std_category
0000000000012aa0 V typeinfo name for
boost::system::detail::system_error_category
0000000000012a70 V typeinfo name for
boost::system::detail::generic_error_category
0000000000026848 V vtable for boost::system::system_error
0000000000026720 V vtable for boost::system::error_category
00000000000267f8 V vtable for boost::system::detail::std_category
00000000000267b0 V vtable for boost::system::detail::system_error_category
0000000000026768 V vtable for boost::system::detail::generic_error_category
00000000000273d8 u boost::system::system_category()::system_category_instance
00000000000273c0 u boost::system::generic_category()::generic_category_instance
00000000000273a8 u
boost::system::detail::to_std_category(boost::system::error_category
const&)::system_instance
0000000000027390 u
boost::system::detail::to_std_category(boost::system::error_category
const&)::generic_instance
0000000000027358 u
boost::system::detail::to_std_category(boost::system::error_category
const&)::map_
0000000000027320 u
boost::system::detail::to_std_category(boost::system::error_category
const&)::map_mx_
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost-users