[PATCH] D31524: Add a linker script to version LLVM symbols
Sylvestre Ledru via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 30 23:26:07 PDT 2017
sylvestre.ledru created this revision.
Herald added a subscriber: mgorny.
This patch adds a very simple linker script to version the lib's symbols
and thus trying to avoid crashes if an application loads two different
LLVM versions (as long as they do not share data between them).
Note that we deliberately *don't* make LLVM_5.0 depend on LLVM_5.0:
they're incompatible and the whole point of this patch is
to tell the linker that.
Avoid unexpected crashes when two LLVM versions are used in the same process.
Author: Rebecca N. Palmer <rebecca_palmer at zoho.com>
Author: Lisandro Damían Nicanor Pérez Meyer <lisandro at debian.org>
Author: Sylvestre Ledru <sylvestre at debian.org>
Bug-Debian: https://bugs.debian.org/848368
Repository:
rL LLVM
https://reviews.llvm.org/D31524
Files:
cmake/modules/AddLLVM.cmake
tools/llvm-shlib/CMakeLists.txt
tools/llvm-shlib/simple_version_script.map.in
Index: tools/llvm-shlib/simple_version_script.map.in
===================================================================
--- tools/llvm-shlib/simple_version_script.map.in
+++ tools/llvm-shlib/simple_version_script.map.in
@@ -0,0 +1 @@
+LLVM_ at LLVM_VERSION_MAJOR@. at LLVM_VERSION_MINOR@ { global: *; };
Index: tools/llvm-shlib/CMakeLists.txt
===================================================================
--- tools/llvm-shlib/CMakeLists.txt
+++ tools/llvm-shlib/CMakeLists.txt
@@ -38,8 +38,12 @@
list(REMOVE_DUPLICATES LIB_NAMES)
if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")) # FIXME: It should be "GNU ld for elf"
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in
+ ${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map)
+
# GNU ld doesn't resolve symbols in the version script.
- set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive)
+ set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
endif()
Index: cmake/modules/AddLLVM.cmake
===================================================================
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -82,7 +82,7 @@
set(native_export_file "${target_name}.exports")
# FIXME: Don't write the "local:" line on OpenBSD.
add_custom_command(OUTPUT ${native_export_file}
- COMMAND echo "{" > ${native_export_file}
+ COMMAND echo "LLVM_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR} {" > ${native_export_file}
COMMAND grep -q "[[:alnum:]]" ${export_file} && echo " global:" >> ${native_export_file} || :
COMMAND sed -e "s/$/;/" -e "s/^/ /" < ${export_file} >> ${native_export_file}
COMMAND echo " local: *;" >> ${native_export_file}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31524.93593.patch
Type: text/x-patch
Size: 2012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170331/a9b44646/attachment.bin>
More information about the llvm-commits
mailing list