summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-09-01 23:46:11 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-09-01 23:46:11 +0000
commit088ba020dd6fefb80829cc9837815a1222bee482 (patch)
treee976821f48564bbdfd1f2d94cdc1ef28c19ca165 /llvm/lib/MC
parentdcad05b4ebb47073f029b42062d489c08718e473 (diff)
downloadbcm5719-llvm-088ba020dd6fefb80829cc9837815a1222bee482.tar.gz
bcm5719-llvm-088ba020dd6fefb80829cc9837815a1222bee482.zip
[MC] Generate a timestamp for COFF object files
The MS incremental linker seems to inspect the timestamp written into the object file to determine whether or not it's contents need to be considered. Failing to set the timestamp to a date newer than the executable will result in the object file not participating in subsequent links. To ameliorate this, write the current time into the object file's TimeDateStamp field. llvm-svn: 246607
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r--llvm/lib/MC/WinCOFFObjectWriter.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index 9abd1a15906..c9dafb56908 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -35,6 +35,7 @@
#include "llvm/Support/JamCRC.h"
#include "llvm/Support/TimeValue.h"
#include <cstdio>
+#include <ctime>
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);
OpenPOWER on IntegriCloud