[llvm] r246607 - [MC] Generate a timestamp for COFF object files
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 1 16:46:11 PDT 2015
Author: majnemer
Date: Tue Sep 1 18:46:11 2015
New Revision: 246607
URL: http://llvm.org/viewvc/llvm-project?rev=246607&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
llvm/trunk/test/MC/COFF/timestamp.s
Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=246607&r1=246606&r2=246607&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Tue Sep 1 18:46:11 2015
@@ -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(MC
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);
Modified: llvm/trunk/test/MC/COFF/timestamp.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/timestamp.s?rev=246607&r1=246606&r2=246607&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/timestamp.s (original)
+++ llvm/trunk/test/MC/COFF/timestamp.s Tue Sep 1 18:46:11 2015
@@ -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: {{.*}}
More information about the llvm-commits
mailing list