summaryrefslogtreecommitdiffstats
path: root/lld/COFF/Writer.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2018-05-17 15:11:01 +0000
committerZachary Turner <zturner@google.com>2018-05-17 15:11:01 +0000
commitc8dd6ccc8a358273114ef7e6f19ad59f6258048c (patch)
treebc4d49450de5c3cc85f70afd762f6e22442aec53 /lld/COFF/Writer.cpp
parent07d4730ca4d671ebed4423595eeceebd9e2e523e (diff)
downloadbcm5719-llvm-c8dd6ccc8a358273114ef7e6f19ad59f6258048c.tar.gz
bcm5719-llvm-c8dd6ccc8a358273114ef7e6f19ad59f6258048c.zip
[COFF] Add /Brepro and /TIMESTAMP options.
Previously we would always write a hash of the binary into the PE file, for reproducible builds. This breaks AppCompat, which is a feature of Windows that relies on the timestamp in the PE header being set to a real value (or at the very least, a value that satisfies certain properties). To address this, we put the old behavior of writing the hash behind the /Brepro flag, which mimics MSVC linker behavior. We also match MSVC default behavior, which is to write an actual timestamp to the PE header. Finally, we add the /TIMESTAMP option (an lld extension) so that the user can specify the exact value to be used in case he/she manually constructs a value which is both reproducible and satisfies AppCompat. Differential Revision: https://reviews.llvm.org/D46966 llvm-svn: 332613
Diffstat (limited to 'lld/COFF/Writer.cpp')
-rw-r--r--lld/COFF/Writer.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index b14cbb47dc7..b38bef80ef6 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -1192,16 +1192,18 @@ void Writer::writeBuildId() {
reinterpret_cast<const char *>(Buffer->getBufferStart()),
Buffer->getBufferSize());
- uint32_t Hash = static_cast<uint32_t>(xxHash64(OutputFileData));
+ uint32_t Timestamp = Config->Timestamp;
+ if (Config->Repro)
+ Timestamp = static_cast<uint32_t>(xxHash64(OutputFileData));
if (DebugDirectory)
- DebugDirectory->setTimeDateStamp(Hash);
+ DebugDirectory->setTimeDateStamp(Timestamp);
uint8_t *Buf = Buffer->getBufferStart();
Buf += DOSStubSize + sizeof(PEMagic);
object::coff_file_header *CoffHeader =
reinterpret_cast<coff_file_header *>(Buf);
- CoffHeader->TimeDateStamp = Hash;
+ CoffHeader->TimeDateStamp = Timestamp;
}
// Sort .pdata section contents according to PE/COFF spec 5.5.
OpenPOWER on IntegriCloud