Build with -Bsymbolic to prevent symbol preemption
The CMake build was already using -fvisibility=protected, which has the
same effect but uses duplicate symbol entries for internal/external use.
Bug: b/148240133
Change-Id: I8069a1b293a6ec0604be32179ed591ffaa645ed7
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/41648
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1c3a63a..538d360 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -293,8 +293,9 @@
set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--version-script=${DIR}/${TARGET}.lds")
set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_DEPENDS "${DIR}/${TARGET}.lds;")
- # Don't allow symbols to be overridden by another module.
- set_property(TARGET ${TARGET} APPEND_STRING PROPERTY COMPILE_FLAGS " -fvisibility=protected")
+ # -Bsymbolic binds symbol references to their global definitions within
+ # a shared object, thereby preventing symbol preemption.
+ set_property(TARGET ${TARGET} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wl,-Bsymbolic")
if(ARCH STREQUAL "mipsel" OR ARCH STREQUAL "mips64el")
# MIPS supports sysv hash-style only.