Feature #2859
openExplicitly export public symbols
0%
Description
Updated by Junxiao Shi over 9 years ago
- Blocked by Task #2243: Allow building of shared library added
Updated by Davide Pesavento over 9 years ago
- Subject changed from Explicitly export public types to Explicitly export public symbols
- Start date deleted (
06/07/2015)
This should be done in 3 steps:
- Define a macro, e.g.
#define NDN_CXX_EXPORT __attribute__((visibility("default")))
- Apply the above macro to every library symbol that we want to export (and that will define our public ABI)
- Add
-fvisibility=hidden
to the default CXXFLAGS for the library
Updated by Davide Pesavento over 9 years ago
Also note that -fvisibility=hidden
makes -fvisibility-inlines-hidden
redundant.
Further reading: https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html
Updated by Davide Pesavento about 3 years ago
Ad interim, we could consider adding flags such as -Bsymbolic-functions
, -fvisibility-inlines-hidden
, -fno-semantic-interposition
, and -fno-plt
.
Two very relevant articles (though pretty technical and not easy to read) are:
https://maskray.me/blog/2021-05-09-fno-semantic-interposition
https://maskray.me/blog/2021-05-16-elf-interposition-and-bsymbolic
Moreover, we should build all executables (including nfd, etc.) with -fPIE which has a number of benefits including performance. While on some linux distros gcc is configured to build PIE binaries by default, it's not necessarily the case on every distro or every ELF platform, so we should pass -fPIE explicitly to be safe.