core: restrict liboakcore exports to the C ABI via version script

Even statically linked runtime libraries must not leak symbols: the
linker version script now whitelists oakcore_* only. nm reports 188
oakcore_* exports and zero anything else.
This commit is contained in:
2026-07-19 23:51:15 +08:00
parent 4fc8b80d7e
commit 1128694257
2 changed files with 13 additions and 0 deletions
+7
View File
@@ -74,6 +74,13 @@ set_target_properties(olivecore PROPERTIES
# OAKCORE_BUILD marks the library side of the export macros (dllexport) # OAKCORE_BUILD marks the library side of the export macros (dllexport)
target_compile_definitions(olivecore PRIVATE OAKCORE_BUILD) target_compile_definitions(olivecore PRIVATE OAKCORE_BUILD)
# Export only the C ABI (oakcore_*), nothing else — not even symbols from
# statically linked runtime libraries
if (UNIX AND NOT APPLE)
target_link_options(olivecore PRIVATE
"LINKER:--version-script,${CMAKE_CURRENT_SOURCE_DIR}/oakcore.map")
endif ()
# The library builds against its internal implementation headers # The library builds against its internal implementation headers
# (src/oliveimpl); consumers only ever see the public C API and wrapper # (src/oliveimpl); consumers only ever see the public C API and wrapper
# headers (include/olive/core). oliveimpl must come first so that internal # headers (include/olive/core). oliveimpl must come first so that internal
+6
View File
@@ -0,0 +1,6 @@
{
global:
oakcore_*;
local:
*;
};