[AsmParser] Provide target direct access to mnemonic token. Allow assignment parsing...
[oota-llvm.git] / lib / MC / WinCOFFObjectWriter.cpp
index 81facc01eed4160fe731693d43b979dbd20c56ab..8d4d3df21ab48b959b2b4e0562a9a502046851ed 100644 (file)
@@ -127,7 +127,7 @@ public:
   COFF::header Header;
   sections Sections;
   symbols Symbols;
-  StringTableBuilder Strings;
+  StringTableBuilder Strings{StringTableBuilder::WinCOFF};
 
   // Maps used during object file creation.
   section_map SectionMap;
@@ -710,6 +710,11 @@ void WinCOFFObjectWriter::recordRelocation(
     Asm.getContext().reportFatalError(Fixup.getLoc(),
                                       Twine("symbol '") + A.getName() +
                                           "' can not be undefined");
+  if (A.isTemporary() && A.isUndefined()) {
+    Asm.getContext().reportFatalError(Fixup.getLoc(),
+                                      Twine("assembler label '") + A.getName() +
+                                          "' can not be undefined");
+  }
 
   MCSection *Section = Fragment->getParent();
 
@@ -903,7 +908,7 @@ void WinCOFFObjectWriter::writeObject(MCAssembler &Asm,
   for (const auto &S : Symbols)
     if (S->should_keep() && S->Name.size() > COFF::NameSize)
       Strings.add(S->Name);
-  Strings.finalize(StringTableBuilder::WinCOFF);
+  Strings.finalize();
 
   // Set names.
   for (const auto &S : Sections)
@@ -1013,12 +1018,17 @@ void WinCOFFObjectWriter::writeObject(MCAssembler &Asm,
 
   Header.PointerToSymbolTable = offset;
 
+#if (ENABLE_TIMESTAMPS == 1)
   // MS LINK expects to be able to use this timestamp to implement their
   // /INCREMENTAL feature.
   std::time_t Now = time(nullptr);
-  if (Now < 0 || (unsigned long)Now > UINT32_MAX)
+  if (Now < 0 || !isUInt<32>(Now))
     Now = UINT32_MAX;
   Header.TimeDateStamp = Now;
+#else
+  // We want a deterministic output. It looks like GNU as also writes 0 in here.
+  Header.TimeDateStamp = 0;
+#endif
 
   // Write it all to disk...
   WriteFileHeader(Header);