diff --git a/lib/MC/WinCOFFObjectWriter.cpp b/lib/MC/WinCOFFObjectWriter.cpp index 9abd1a15906..c9dafb56908 100644 --- a/lib/MC/WinCOFFObjectWriter.cpp +++ b/lib/MC/WinCOFFObjectWriter.cpp @@ -35,6 +35,7 @@ #include "llvm/Support/JamCRC.h" #include "llvm/Support/TimeValue.h" #include +#include using namespace llvm; @@ -1012,8 +1013,12 @@ void WinCOFFObjectWriter::writeObject(MCAssembler &Asm, Header.PointerToSymbolTable = offset; - // We want a deterministic output. It looks like GNU as also writes 0 in here. - Header.TimeDateStamp = 0; + // MS LINK expects to be able to use this timestamp to implement their + // /INCREMENTAL feature. + std::time_t Now = time(nullptr); + if (Now < 0 || Now > UINT32_MAX) + Now = UINT32_MAX; + Header.TimeDateStamp = Now; // Write it all to disk... WriteFileHeader(Header); diff --git a/test/MC/COFF/timestamp.s b/test/MC/COFF/timestamp.s index 18736a2b2d6..917e1e717a8 100644 --- a/test/MC/COFF/timestamp.s +++ b/test/MC/COFF/timestamp.s @@ -1,4 +1,4 @@ // RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s -o - | llvm-readobj -h | FileCheck %s // CHECK: ImageFileHeader { -// CHECK: TimeDateStamp: {{.*}} (0x0) +// CHECK: TimeDateStamp: {{.*}}