ELF: Only add libcall symbols to the link if defined in bitcode.
authorPeter Collingbourne <peter@pcc.me.uk>
Wed, 8 Aug 2018 23:48:12 +0000 (23:48 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Wed, 8 Aug 2018 23:48:12 +0000 (23:48 +0000)
commit98930115ea666ed457e45dbdda4530675688d7cb
treed6727c2be4193b624bd69926dee4e053d444b844
parentf9a80fe87a7992c7a65e66bcb414dc34bdd339b9
ELF: Only add libcall symbols to the link if defined in bitcode.

Adding all libcall symbols to the link can have undesired consequences.
For example, the libgcc implementation of __sync_val_compare_and_swap_8
on 32-bit ARM pulls in an .init_array entry that aborts the program if
the Linux kernel does not support 64-bit atomics, which would prevent
the program from running even if it does not use 64-bit atomics.

This change makes it so that we only add libcall symbols to the
link before LTO if we have to, i.e. if the symbol's definition is in
bitcode. Any other required libcall symbols will be added to the link
after LTO when we add the LTO object file to the link.

Differential Revision: https://reviews.llvm.org/D50475

llvm-svn: 339301
lld/ELF/Driver.cpp
lld/ELF/Symbols.cpp
lld/ELF/Symbols.h
lld/test/ELF/lto/Inputs/libcall-archive.s [new file with mode: 0644]
lld/test/ELF/lto/libcall-archive.ll