llvm.org GIT mirror llvm / cd789d8
Add a linker script to version LLVM symbols Summary: 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_4.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@zoho.com> Author: Lisandro Damían Nicanor Pérez Meyer <lisandro@debian.org> Author: Sylvestre Ledru <sylvestre@debian.org> Bug-Debian: https://bugs.debian.org/848368 Reviewers: beanz, rnk Reviewed By: rnk Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D31524 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300496 91177308-0d34-0410-b5e6-96231b3b80d8 Sylvestre Ledru 3 years ago
3 changed file(s) with 8 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
8080 # Gold and BFD ld require a version script rather than a plain list.
8181 set(native_export_file "${target_name}.exports")
8282 # FIXME: Don't write the "local:" line on OpenBSD.
83 # in the export file, also add a linker script to version LLVM symbols (form: LLVM_N.M)
8384 add_custom_command(OUTPUT ${native_export_file}
84 COMMAND echo "{" > ${native_export_file}
85 COMMAND echo "LLVM_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR} {" > ${native_export_file}
8586 COMMAND grep -q "[[:alnum:]]" ${export_file} && echo " global:" >> ${native_export_file} || :
8687 COMMAND sed -e "s/$/;/" -e "s/^/ /" < ${export_file} >> ${native_export_file}
8788 COMMAND echo " local: *;" >> ${native_export_file}
3737
3838 list(REMOVE_DUPLICATES LIB_NAMES)
3939 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"
40 configure_file(
41 ${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in
42 ${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map)
43
4044 # GNU ld doesn't resolve symbols in the version script.
41 set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive)
45 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)
4246 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
4347 set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
4448 endif()
0 LLVM_@LLVM_VERSION_MAJOR@.@LLVM_VERSION_MINOR@ { global: *; };