[MC] Add support for generating COFF CRCs
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 1 Sep 2015 21:23:58 +0000 (21:23 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 1 Sep 2015 21:23:58 +0000 (21:23 +0000)
commit3d58bd6369de960bcd144318b6209ccdea200c3f
tree97e5714edf138ebbc00d6a86e4f924fe364cc940
parentbb93db26e41de1324339755c13223ea2cf2be8e4
[MC] Add support for generating COFF CRCs

COFF sections are accompanied with an auxiliary symbol which includes a
checksum.  This checksum used to be filled with just zero but this seems
to upset LINK.exe when it is processing a /INCREMENTAL link job.
Instead, fill the CheckSum field with the JamCRC of the section
contents.  This matches MSVC's behavior.

This fixes PR19666.

N.B.  A rather simple implementation of JamCRC is given.  It implements
a byte-wise calculation using the method given by Sarwate.  There are
implementations with higher throughput like slice-by-eight and making
use of PCLMULQDQ.  We can switch to one of those techniques if it turns
out to be a significant use of time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246590 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/JamCRC.h [new file with mode: 0644]
lib/MC/WinCOFFObjectWriter.cpp
lib/Support/CMakeLists.txt
lib/Support/JamCRC.cpp [new file with mode: 0644]
test/MC/COFF/basic-coff-64.s
test/MC/COFF/basic-coff.s
test/MC/COFF/symbol-fragment-offset-64.s
test/MC/COFF/symbol-fragment-offset.s