[MC] Always emit relocations for same-section function references
authorReid Kleckner <rnk@google.com>
Wed, 14 Mar 2018 19:24:32 +0000 (19:24 +0000)
committerReid Kleckner <rnk@google.com>
Wed, 14 Mar 2018 19:24:32 +0000 (19:24 +0000)
commit5a5ac65768d124d98a10e8520363a0a4be3f4e38
treeb5f945d991dc5cb6fb170efb2f0c6bc00d2dddcb
parent59be4b434f5629443bf26e86d261ba618851b31b
[MC] Always emit relocations for same-section function references

Summary:
We already emit relocations in this case when the "incremental linker
compatible" flag is set, but it turns out these relocations are also
required for /guard:cf. Now that we have two use cases for this
behavior, let's make it unconditional to try to keep things simple.

We never hit this problem in Clang because it always sets the
"incremental linker compatible" flag when targeting MSVC. However, LLD
LTO doesn't set this flag, so we'd get CFG failures at runtime when
using ThinLTO and /guard:cf. We probably don't want LLD LTO to set the
"incremental linker compatible" assembler flag, since this has nothing
to do with incremental linking, and we don't need to timestamp LTO
temporary objects.

Fixes PR36624.

Reviewers: inglorion, espindola, majnemer

Subscribers: mehdi_amini, llvm-commits, hiraditya

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

llvm-svn: 327557
llvm/lib/MC/WinCOFFObjectWriter.cpp
llvm/test/MC/COFF/diff.s