MC, COFF: Use relocations for function references inside the section
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 11 Nov 2014 08:43:57 +0000 (08:43 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 11 Nov 2014 08:43:57 +0000 (08:43 +0000)
commit16d8031f94a4ac7ebe6bf666cd821239cbee32d3
tree1a14d4526f4d361165c9aa370998b9309685cf44
parentfdf59619d258f89c0e79b160095c292c9ce27214
MC, COFF: Use relocations for function references inside the section

Referencing one symbol from another in the same section does not
generally require a relocation.  However, the MS linker has a feature
called /INCREMENTAL which enables incremental links.  It achieves this
by creating thunks to the actual function and redirecting all
relocations to point to the thunk.

This breaks down with the old scheme if you have a function which
references, say, itself.  On x86_64, we would use %rip relative
addressing to reference the start of the function from out current
position.  This would lead to miscompiles because other references might
reference the thunk instead, breaking function pointer equality.

This fixes PR21520.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221678 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Object/COFF.h
lib/MC/WinCOFFObjectWriter.cpp
lib/MC/WinCOFFStreamer.cpp
test/MC/COFF/simple-fixups.s