[MIPS] Don't emit R_(MICRO)MIPS_JALR relocations against data symbols
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Mon, 13 Jan 2020 13:52:48 +0000 (13:52 +0000)
committerAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Mon, 13 Jan 2020 14:14:03 +0000 (14:14 +0000)
commit8e8ccf4712cf58562a91c197da3efd4f9963ce0d
tree444388591ad6c533d6565e323c2f438d31114f75
parent894f742acb977a09285dcab024e50c2cf6bce578
[MIPS] Don't emit R_(MICRO)MIPS_JALR relocations against data symbols

The R_(MICRO)MIPS_JALR optimization only works when used against functions.
Using the relocation against a data symbol (e.g. function pointer) will
cause some linkers that don't ignore the hint in this case (e.g. LLD prior
to commit 5bab291b7b) to generate a relative branch to the data symbol
which crashes at run time. Before this patch, LLVM was erroneously emitting
these relocations against local-dynamic TLS function pointers and global
function pointers with internal visibility.

Reviewers: atanasyan, jrtc27, vstefanovic
Reviewed By: atanasyan
Differential Revision: https://reviews.llvm.org/D72571
llvm/lib/Target/Mips/MipsISelLowering.cpp
llvm/test/CodeGen/Mips/reloc-jalr.ll